summaryrefslogtreecommitdiff
path: root/java/src/IceGrid/Model.java
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2005-10-18 23:11:29 +0000
committerBernard Normier <bernard@zeroc.com>2005-10-18 23:11:29 +0000
commit765c3fec852a05c957116145220719d1c0e40797 (patch)
treed1178fc923be909fc13f53288c8a82bf38908393 /java/src/IceGrid/Model.java
parentx86 is now the default machine on Windows (diff)
downloadice-765c3fec852a05c957116145220719d1c0e40797.tar.bz2
ice-765c3fec852a05c957116145220719d1c0e40797.tar.xz
ice-765c3fec852a05c957116145220719d1c0e40797.zip
New current status window
Diffstat (limited to 'java/src/IceGrid/Model.java')
-rwxr-xr-xjava/src/IceGrid/Model.java216
1 files changed, 168 insertions, 48 deletions
diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java
index 71874c40952..62db008e1e3 100755
--- a/java/src/IceGrid/Model.java
+++ b/java/src/IceGrid/Model.java
@@ -13,6 +13,7 @@ import java.util.prefs.BackingStoreException;
import java.awt.BorderLayout;
import java.awt.Cursor;
+import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.Container;
@@ -27,6 +28,7 @@ import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
+import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
@@ -48,6 +50,7 @@ import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import IceGrid.TreeNode.Application;
import IceGrid.TreeNode.CommonBase;
+import IceGrid.TreeNode.Editor;
import IceGrid.TreeNode.Root;
//
@@ -186,6 +189,7 @@ public class Model
JMenu viewMenu = new JMenu("View");
viewMenu.setMnemonic(java.awt.event.KeyEvent.VK_V);
add(viewMenu);
+ viewMenu.add(_showVarsMenuItem);
viewMenu.add(_substituteMenuItem);
//
@@ -264,16 +268,11 @@ public class Model
addSeparator();
add(_actions[CommonBase.DELETE]);
addSeparator();
- add(_substituteTool );
+ add(_showVarsTool);
+ add(_substituteTool);
}
}
-
-
-
-
-
-
-
+
//
// All Model's methods run in the UI thread
//
@@ -403,13 +402,10 @@ public class Model
public void refreshDisplay()
{
- if(_displayEnabled)
+ CommonBase currentNode = getSelectedNode();
+ if(currentNode != null)
{
- CommonBase currentNode = getSelectedNode();
- if(currentNode != null)
- {
- currentNode.displayProperties();
- }
+ show(currentNode);
}
}
@@ -434,12 +430,9 @@ public class Model
{
CommonBase newNode = findNewNode(path);
_tree.setSelectionPath(newNode.getPath());
- newNode.displayProperties();
}
}
-
-
public boolean canUpdate()
{
if(isUpdateInProgress())
@@ -673,21 +666,29 @@ public class Model
void nodeUp(NodeDynamicInfo updatedInfo)
{
_root.nodeUp(updatedInfo);
+ showActions();
+ refreshCurrentStatus();
}
void nodeDown(String node)
{
_root.nodeDown(node);
+ showActions();
+ refreshCurrentStatus();
}
void updateServer(String node, ServerDynamicInfo updatedInfo)
{
_root.updateServer(node, updatedInfo);
+ showActions();
+ refreshCurrentStatus();
}
void updateAdapter(String node, AdapterDynamicInfo updatedInfo)
{
_root.updateAdapter(node, updatedInfo);
+ showActions();
+ refreshCurrentStatus();
}
@@ -791,31 +792,36 @@ public class Model
return true;
}
- public void toggleSubstitute()
+ private void showVars()
{
- _substitute = !_substitute;
+ substitute(false);
+ }
- //
- // Synchronize the other button
- //
- if(_substituteMenuItem.isSelected() != _substitute)
- {
- _substituteMenuItem.setSelected(_substitute);
- }
- if(_substituteTool.isSelected() != _substitute)
- {
- _substituteTool.setSelected(_substitute);
- }
-
- CommonBase node = (CommonBase)_tree.getLastSelectedPathComponent();
- if(node != null)
+ private void substituteVars()
+ {
+ substitute(true);
+ }
+
+ private void substitute(boolean newValue)
+ {
+ if(_substitute != newValue)
{
- node.displayProperties();
+ _substitute = newValue;
+
+ if(_substitute)
+ {
+ _substituteMenuItem.setSelected(true);
+ _substituteTool.setSelected(true);
+ }
+ else
+ {
+ _showVarsMenuItem.setSelected(true);
+ _showVarsTool.setSelected(true);
+ }
+ refreshDisplay();
}
}
-
-
public boolean substitute()
{
return _substitute;
@@ -848,14 +854,14 @@ public class Model
return _tree;
}
- public void setPropertiesFrame(SimpleInternalFrame frame)
+ public SimpleInternalFrame getPropertiesFrame()
{
- _propertiesFrame = frame;
+ return _propertiesFrame;
}
- public SimpleInternalFrame getPropertiesFrame()
+ public SimpleInternalFrame getCurrentStatusFrame()
{
- return _propertiesFrame;
+ return _currentStatusFrame;
}
public JFrame getMainFrame()
@@ -874,6 +880,17 @@ public class Model
_root = new Root(this);
_treeModel = new TreeModelI(_root);
+ //
+ // Fixed height for current status frame
+ //
+ Dimension prefSize = new Dimension(0, 160);
+ Dimension maxSize = new Dimension(Short.MAX_VALUE, 160);
+ _currentStatusFrame.setMinimumSize(prefSize);
+ _currentStatusFrame.setPreferredSize(prefSize);
+ _currentStatusFrame.setMaximumSize(maxSize);
+ _currentStatusFrame.getTitleLabel().setEnabled(false);
+ _propertiesFrame.getTitleLabel().setEnabled(false);
+
final int MENU_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
//
@@ -1085,23 +1102,53 @@ public class Model
_actions[CommonBase.DELETE].putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("DELETE"));
_actions[CommonBase.DELETE].putValue(Action.SHORT_DESCRIPTION, "Delete");
- _actions[CommonBase.SUBSTITUTE_VARS] = new
+ _actions[CommonBase.SHOW_VARS] = new
AbstractAction("${}")
{
public void actionPerformed(ActionEvent e)
{
- _actionsTarget.substituteVars();
- putValue(Action.NAME, _substitute ? "abc" : "${}");
+ showVars();
}
};
+ _actions[CommonBase.SHOW_VARS].putValue(
+ Action.SHORT_DESCRIPTION,
+ "Show variables and parameters in the Properties pane");
+
+
+ _actions[CommonBase.SUBSTITUTE_VARS] = new
+ AbstractAction("abc")
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ substituteVars();
+ }
+ };
+
_actions[CommonBase.SUBSTITUTE_VARS].putValue(
Action.SHORT_DESCRIPTION,
"Substitute variables and parameters with their values in the Properties pane");
+
+
+ _showVarsMenuItem = new
+ JCheckBoxMenuItem(_actions[CommonBase.SHOW_VARS]);
+ _showVarsTool = new
+ JToggleButton(_actions[CommonBase.SHOW_VARS]);
+
_substituteMenuItem = new
JCheckBoxMenuItem(_actions[CommonBase.SUBSTITUTE_VARS]);
_substituteTool = new
JToggleButton(_actions[CommonBase.SUBSTITUTE_VARS]);
-
+
+ ButtonGroup group = new ButtonGroup();
+ group.add(_showVarsMenuItem);
+ group.add(_substituteMenuItem);
+ group = new ButtonGroup();
+ group.add(_showVarsTool);
+ group.add(_substituteTool);
+
+ _showVarsMenuItem.setSelected(true);
+ _showVarsTool.setSelected(true);
+
_actions[CommonBase.MOVE_UP] = new AbstractAction("Move up")
{
public void actionPerformed(ActionEvent e)
@@ -1157,7 +1204,7 @@ public class Model
}
};
_actions[CommonBase.APPLICATION_INSTALL_DISTRIBUTION] =
- new AbstractAction("Install or refresh distribution")
+ new AbstractAction("Patch")
{
public void actionPerformed(ActionEvent e)
{
@@ -1165,7 +1212,7 @@ public class Model
}
};
_actions[CommonBase.SERVER_INSTALL_DISTRIBUTION] =
- new AbstractAction("Install or refresh distribution")
+ new AbstractAction("Patch")
{
public void actionPerformed(ActionEvent e)
{
@@ -1174,6 +1221,71 @@ public class Model
};
}
+ void show(CommonBase node)
+ {
+ if(_displayEnabled)
+ {
+ showActions(node);
+
+ _currentEditor = node.getEditor();
+
+ Ice.StringHolder title = new Ice.StringHolder();
+ Component currentStatus = _currentEditor.getCurrentStatus(title);
+ if(title.value == null)
+ {
+ title.value = "Current status";
+ }
+ _currentStatusFrame.setTitle(title.value);
+
+ if(currentStatus == null)
+ {
+ _currentStatusFrame.setToolBar(null);
+ Component oldContent = _currentStatusFrame.getContent();
+ if(oldContent != null)
+ {
+ _currentStatusFrame.remove(oldContent);
+ }
+ _currentStatusFrame.getTitleLabel().setEnabled(false);
+ }
+ else
+ {
+ _currentStatusFrame.setToolBar(
+ _currentEditor.getCurrentStatusToolBar());
+ _currentStatusFrame.setContent(currentStatus);
+ _currentStatusFrame.getTitleLabel().setEnabled(true);
+ }
+ _currentStatusFrame.validate();
+ _currentStatusFrame.repaint();
+
+ Component currentProperties = _currentEditor.getProperties();
+
+ if(currentProperties == null)
+ {
+ Component oldContent = _propertiesFrame.getContent();
+ if(oldContent != null)
+ {
+ _propertiesFrame.remove(oldContent);
+ }
+ _propertiesFrame.getTitleLabel().setEnabled(false);
+ }
+ else
+ {
+ _propertiesFrame.setContent(currentProperties);
+ _propertiesFrame.getTitleLabel().setEnabled(true);
+ }
+ _propertiesFrame.validate();
+ _propertiesFrame.repaint();
+ }
+ }
+
+ void refreshCurrentStatus()
+ {
+ if(_currentEditor != null)
+ {
+ _currentEditor.refreshCurrentStatus();
+ }
+ }
+
//
// New application action
//
@@ -1422,11 +1534,16 @@ public class Model
private boolean _displayEnabled = true;
- private SimpleInternalFrame _propertiesFrame;
-
+ private SimpleInternalFrame _currentStatusFrame
+ = new SimpleInternalFrame("Current status");
+ private SimpleInternalFrame _propertiesFrame
+ = new SimpleInternalFrame("Properties");
+
private JFrame _mainFrame;
private SessionKeeper _sessionKeeper;
+ private Editor _currentEditor;
+
private Object _clipboard;
//
@@ -1441,8 +1558,11 @@ public class Model
private Action _about;
private Action[] _actions;
+
+ private JToggleButton _showVarsTool;
private JToggleButton _substituteTool;
private JCheckBoxMenuItem _substituteMenuItem;
+ private JCheckBoxMenuItem _showVarsMenuItem;
private CommonBase _actionsTarget;