diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-09-15 19:42:39 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-09-15 19:42:39 +0000 |
commit | 926a34c0cde3bb59a64c6906442246015290c310 (patch) | |
tree | 247d19ba42bd29fb7b60d96ac936ca91d497357b /java/src/IceGridGUI/Application/Editor.java | |
parent | Merged fixes from 3.1 branch (diff) | |
download | ice-926a34c0cde3bb59a64c6906442246015290c310.tar.bz2 ice-926a34c0cde3bb59a64c6906442246015290c310.tar.xz ice-926a34c0cde3bb59a64c6906442246015290c310.zip |
dos2unix
Diffstat (limited to 'java/src/IceGridGUI/Application/Editor.java')
-rwxr-xr-x | java/src/IceGridGUI/Application/Editor.java | 480 |
1 files changed, 240 insertions, 240 deletions
diff --git a/java/src/IceGridGUI/Application/Editor.java b/java/src/IceGridGUI/Application/Editor.java index abd137b2669..62298aa0f04 100755 --- a/java/src/IceGridGUI/Application/Editor.java +++ b/java/src/IceGridGUI/Application/Editor.java @@ -1,240 +1,240 @@ -// **********************************************************************
-//
-// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-package IceGridGUI.Application;
-
-import java.awt.BorderLayout;
-import java.awt.event.ActionEvent;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JToolBar;
-
-import javax.swing.tree.TreePath;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import com.jgoodies.forms.factories.Borders;
-import com.jgoodies.forms.factories.ButtonBarFactory;
-import com.jgoodies.forms.factories.DefaultComponentFactory;
-import com.jgoodies.forms.layout.FormLayout;
-import com.jgoodies.forms.util.LayoutStyle;
-
-import IceGrid.*;
-import IceGridGUI.*;
-
-public class Editor extends EditorBase
-{
- static public java.util.Map makeParameterValues(
- java.util.Map oldParameterValues,
- java.util.List newParameters)
- {
- java.util.Map result = new java.util.HashMap();
-
- java.util.Iterator p = newParameters.iterator();
- while(p.hasNext())
- {
- Object name = p.next();
- Object value = oldParameterValues.get(name);
- if(value != null)
- {
- result.put(name, value);
- }
- }
- return result;
- }
-
- public boolean save()
- {
- if(_applyButton.isEnabled())
- {
- return validate() && applyUpdate();
- }
- else
- {
- return true;
- }
- }
-
- protected boolean validate()
- {
- return true;
- }
-
- protected boolean applyUpdate()
- {
- assert false;
- return false;
- }
-
- protected void detectUpdates(boolean val)
- {
- _detectUpdates = val;
- }
-
- protected void discardUpdate()
- {
- if(_target.isEphemeral())
- {
- _target.delete();
- }
- else
- {
- _target.getCoordinator().getCurrentTab().showNode(_target);
- }
- }
-
- protected void appendProperties(DefaultFormBuilder builder)
- {}
-
- protected void buildPropertiesPanel()
- {
- super.buildPropertiesPanel();
- JComponent buttonBar =
- ButtonBarFactory.buildRightAlignedBar(_applyButton,
- _discardButton);
- buttonBar.setBorder(Borders.DIALOG_BORDER);
- _propertiesPanel.add(buttonBar, BorderLayout.SOUTH);
- }
-
-
- Editor()
- {
- //
- // _applyButton
- //
- AbstractAction apply = new AbstractAction("Apply")
- {
- public void actionPerformed(ActionEvent e)
- {
- if(validate())
- {
- applyUpdate();
- }
- }
- };
- _applyButton = new JButton(apply);
- _applyButton.setEnabled(false);
-
- //
- // _discardButton
- //
- AbstractAction discard = new AbstractAction("Discard")
- {
- public void actionPerformed(ActionEvent e)
- {
- discardUpdate();
- }
- };
- _discardButton = new JButton(discard);
- _discardButton.setEnabled(false);
-
- _updateListener = new DocumentListener()
- {
- public void changedUpdate(DocumentEvent e)
- {
- updated();
- }
-
- public void insertUpdate(DocumentEvent e)
- {
- updated();
- }
-
- public void removeUpdate(DocumentEvent e)
- {
- updated();
- }
- };
- }
-
- //
- // Used by the sub-editor (when there is one)
- //
- Object getSubDescriptor()
- {
- return null;
- }
-
- Utils.Resolver getDetailResolver()
- {
- return null;
- }
-
- TreeNode getTarget()
- {
- return _target;
- }
-
- void updated()
- {
- if(_detectUpdates)
- {
- _target.getRoot().disableRegistryUpdates();
- _applyButton.setEnabled(true);
- _discardButton.setEnabled(true);
- }
- }
-
- DocumentListener getUpdateListener()
- {
- return _updateListener;
- }
-
- //
- // Check that these 'val' are filled in
- //
- boolean check(String[] nameValArray)
- {
- String emptyFields = "";
- int errorCount = 0;
-
- for(int i = 1; i < nameValArray.length; i += 2)
- {
- if(nameValArray[i] == null || nameValArray[i].length() == 0)
- {
- errorCount++;
- if(emptyFields.length() > 0)
- {
- emptyFields += "\n";
- }
- emptyFields += "'" + nameValArray[i - 1] + "'";
- }
- }
-
- if(errorCount > 0)
- {
- String message = errorCount == 1 ?
- emptyFields + " cannot be empty" :
- "The following fields cannot be empty:\n" + emptyFields;
-
- JOptionPane.showMessageDialog(
- _target.getCoordinator().getMainFrame(),
- message,
- "Validation failed",
- JOptionPane.ERROR_MESSAGE);
- }
-
- return errorCount == 0;
- }
-
- protected JButton _applyButton;
- protected JButton _discardButton;
- protected DocumentListener _updateListener;
-
- protected TreeNode _target;
- private boolean _detectUpdates = true;
-}
+// ********************************************************************** +// +// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** +package IceGridGUI.Application; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JToolBar; + +import javax.swing.tree.TreePath; + +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; + +import com.jgoodies.forms.builder.DefaultFormBuilder; +import com.jgoodies.forms.factories.Borders; +import com.jgoodies.forms.factories.ButtonBarFactory; +import com.jgoodies.forms.factories.DefaultComponentFactory; +import com.jgoodies.forms.layout.FormLayout; +import com.jgoodies.forms.util.LayoutStyle; + +import IceGrid.*; +import IceGridGUI.*; + +public class Editor extends EditorBase +{ + static public java.util.Map makeParameterValues( + java.util.Map oldParameterValues, + java.util.List newParameters) + { + java.util.Map result = new java.util.HashMap(); + + java.util.Iterator p = newParameters.iterator(); + while(p.hasNext()) + { + Object name = p.next(); + Object value = oldParameterValues.get(name); + if(value != null) + { + result.put(name, value); + } + } + return result; + } + + public boolean save() + { + if(_applyButton.isEnabled()) + { + return validate() && applyUpdate(); + } + else + { + return true; + } + } + + protected boolean validate() + { + return true; + } + + protected boolean applyUpdate() + { + assert false; + return false; + } + + protected void detectUpdates(boolean val) + { + _detectUpdates = val; + } + + protected void discardUpdate() + { + if(_target.isEphemeral()) + { + _target.delete(); + } + else + { + _target.getCoordinator().getCurrentTab().showNode(_target); + } + } + + protected void appendProperties(DefaultFormBuilder builder) + {} + + protected void buildPropertiesPanel() + { + super.buildPropertiesPanel(); + JComponent buttonBar = + ButtonBarFactory.buildRightAlignedBar(_applyButton, + _discardButton); + buttonBar.setBorder(Borders.DIALOG_BORDER); + _propertiesPanel.add(buttonBar, BorderLayout.SOUTH); + } + + + Editor() + { + // + // _applyButton + // + AbstractAction apply = new AbstractAction("Apply") + { + public void actionPerformed(ActionEvent e) + { + if(validate()) + { + applyUpdate(); + } + } + }; + _applyButton = new JButton(apply); + _applyButton.setEnabled(false); + + // + // _discardButton + // + AbstractAction discard = new AbstractAction("Discard") + { + public void actionPerformed(ActionEvent e) + { + discardUpdate(); + } + }; + _discardButton = new JButton(discard); + _discardButton.setEnabled(false); + + _updateListener = new DocumentListener() + { + public void changedUpdate(DocumentEvent e) + { + updated(); + } + + public void insertUpdate(DocumentEvent e) + { + updated(); + } + + public void removeUpdate(DocumentEvent e) + { + updated(); + } + }; + } + + // + // Used by the sub-editor (when there is one) + // + Object getSubDescriptor() + { + return null; + } + + Utils.Resolver getDetailResolver() + { + return null; + } + + TreeNode getTarget() + { + return _target; + } + + void updated() + { + if(_detectUpdates) + { + _target.getRoot().disableRegistryUpdates(); + _applyButton.setEnabled(true); + _discardButton.setEnabled(true); + } + } + + DocumentListener getUpdateListener() + { + return _updateListener; + } + + // + // Check that these 'val' are filled in + // + boolean check(String[] nameValArray) + { + String emptyFields = ""; + int errorCount = 0; + + for(int i = 1; i < nameValArray.length; i += 2) + { + if(nameValArray[i] == null || nameValArray[i].length() == 0) + { + errorCount++; + if(emptyFields.length() > 0) + { + emptyFields += "\n"; + } + emptyFields += "'" + nameValArray[i - 1] + "'"; + } + } + + if(errorCount > 0) + { + String message = errorCount == 1 ? + emptyFields + " cannot be empty" : + "The following fields cannot be empty:\n" + emptyFields; + + JOptionPane.showMessageDialog( + _target.getCoordinator().getMainFrame(), + message, + "Validation failed", + JOptionPane.ERROR_MESSAGE); + } + + return errorCount == 0; + } + + protected JButton _applyButton; + protected JButton _discardButton; + protected DocumentListener _updateListener; + + protected TreeNode _target; + private boolean _detectUpdates = true; +} |