001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.gui;
019:
020: import java.awt.BorderLayout;
021: import java.awt.Dimension;
022:
023: import javax.swing.JDialog;
024: import javax.swing.JOptionPane;
025: import javax.swing.JPanel;
026: import javax.swing.border.TitledBorder;
027:
028: import de.finix.contelligent.client.ContelligentClient;
029: import de.finix.contelligent.client.base.ContelligentComponent;
030: import de.finix.contelligent.client.gui.access.AccessEditor;
031: import de.finix.contelligent.client.i18n.Resources;
032: import de.finix.contelligent.client.util.RestrictedTextField;
033: import de.finix.contelligent.client.util.TableLayout;
034: import de.finix.contelligent.client.wizard.AbstractWizard;
035:
036: public class CreateContextOptionPane extends AbstractWizard {
037:
038: private RestrictedTextField textField;
039:
040: private ContelligentComponent component;
041:
042: private AccessEditor accessEditor;
043:
044: private boolean createContext;
045:
046: public CreateContextOptionPane(ContelligentComponent component,
047: boolean createContext) {
048: this .component = component;
049: this .createContext = createContext;
050: }
051:
052: public CreateContextOptionPane(ContelligentComponent component) {
053: this (component, true);
054: }
055:
056: public String getContextName() {
057: if (textField != null) {
058: return textField.getText();
059: } else {
060: return null;
061: }
062: }
063:
064: public int showDialog(String text) {
065: JPanel panel;
066: if (createContext) {
067: panel = new JPanel(new TableLayout(new double[][] {
068: { TableLayout.FILL },
069: { TableLayout.PREFERRED, TableLayout.FILL } }));
070: JPanel textFieldPane = new JPanel(new BorderLayout());
071: textFieldPane.setBorder(new TitledBorder(Resources
072: .getLocalString("create_context_name")));
073: textField = new RestrictedTextField(text);
074: textField
075: .setAllowString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_");
076: textFieldPane.add(textField, BorderLayout.CENTER);
077: panel.add(textFieldPane, "0,0");
078: } else {
079: panel = new JPanel(new TableLayout(new double[][] {
080: { TableLayout.FILL }, { 0, TableLayout.FILL } }));
081: }
082: accessEditor = new AccessEditor(false, false);
083: accessEditor.setComponent(component);
084: accessEditor.setProtocolVisible(false);
085: accessEditor.setExecuteModifiable(false);
086: accessEditor.init();
087: panel.add(accessEditor, "0,1");
088: panel.setPreferredSize(new Dimension(600, 400));
089: setMessage(panel);
090: setOptionType(JOptionPane.OK_CANCEL_OPTION);
091:
092: JDialog dialog;
093:
094: if (createContext) {
095: dialog = createDialog(ContelligentClient.getActiveFrame(),
096: Resources.getLocalString("create_context_title"));
097: } else {
098: dialog = createDialog(ContelligentClient.getActiveFrame(),
099: Resources.getLocalString("edit_context_acl_title"));
100: }
101: dialog.setVisible(true);
102: if (getValue() instanceof Integer) {
103: return ((Integer) getValue()).intValue();
104: }
105: return CANCEL_OPTION;
106: }
107: }
|