01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui.access;
19:
20: import javax.swing.JDialog;
21: import javax.swing.JLabel;
22: import javax.swing.JOptionPane;
23:
24: import de.finix.contelligent.client.ContelligentClient;
25: import de.finix.contelligent.client.security.ComponentAccess;
26: import de.finix.contelligent.client.util.list.NameValueComboBox;
27:
28: public class PermissionOptionPane extends JOptionPane {
29:
30: private NameValueComboBox permissionChooser;
31:
32: boolean allowExecute = true;
33:
34: public PermissionOptionPane() {
35: }
36:
37: public PermissionOptionPane(boolean allowExecute) {
38: this .allowExecute = allowExecute;
39: }
40:
41: public String getPermission() {
42: return (String) permissionChooser.getSelectedItemValue();
43: }
44:
45: public int showPermissionDialog(String title, String label) {
46: JLabel stringLabel = new JLabel(label);
47:
48: if (allowExecute) {
49: permissionChooser = ComponentAccess
50: .getDescriptionComboBox(ComponentAccess.PERMISSIONS);
51: } else {
52: permissionChooser = ComponentAccess
53: .getDescriptionComboBox(ComponentAccess.PERMISSIONS_NOEXECUTE);
54: }
55: permissionChooser.setSelectedIndex(0);
56:
57: Object[] array = { stringLabel, permissionChooser };
58:
59: setMessage(array);
60: setMessageType(QUESTION_MESSAGE);
61: setOptionType(JOptionPane.OK_CANCEL_OPTION);
62:
63: JDialog dialog = createDialog(ContelligentClient
64: .getActiveFrame(), title);
65: dialog.setVisible(true);
66: if (getValue() instanceof Integer) {
67: return ((Integer) getValue()).intValue();
68: }
69: return CANCEL_OPTION;
70: }
71: }
|