diff options
Diffstat (limited to 'java/src')
-rwxr-xr-x | java/src/IceGridGUI/Coordinator.java | 3 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveActions.java | 10 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/ObjectDialog.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Server.java | 18 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/TreeNode.java | 15 | ||||
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java | 197 |
6 files changed, 237 insertions, 8 deletions
diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index d14580f14e5..6ab0f7f18b7 100755 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -444,6 +444,9 @@ public class Coordinator _serverMenu.add(_liveActionsForMenu.get( IceGridGUI.LiveDeployment.TreeNode.PATCH_SERVER)); _serverMenu.addSeparator(); + _serverMenu.add(_liveActionsForMenu.get( + IceGridGUI.LiveDeployment.TreeNode.WRITE_MESSAGE)); + _serverMenu.addSeparator(); _signalMenu = new JMenu("Send signal"); _serverMenu.add(_signalMenu); _signalMenu.add(_liveActionsForMenu.get(IceGridGUI.LiveDeployment.TreeNode.SIGHUP)); diff --git a/java/src/IceGridGUI/LiveActions.java b/java/src/IceGridGUI/LiveActions.java index 3eadaa79fed..abc460c8af7 100755 --- a/java/src/IceGridGUI/LiveActions.java +++ b/java/src/IceGridGUI/LiveActions.java @@ -120,6 +120,16 @@ public class LiveActions _array[TreeNode.SIGUSR2] = new SendSignal("SIGUSR2"); _array[TreeNode.SIGTERM] = new SendSignal("SIGTERM"); + _array[TreeNode.WRITE_MESSAGE] = new AbstractAction("Write message") + { + public void actionPerformed(ActionEvent e) + { + _target.writeMessage(); + } + }; + _array[TreeNode.WRITE_MESSAGE].putValue(Action.SHORT_DESCRIPTION, + "Write message to stdout or stderr"); + _array[TreeNode.SHUTDOWN_NODE] = new AbstractAction("Shutdown") { diff --git a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java index d1379d8f6cc..d66773e18f7 100755 --- a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java @@ -54,7 +54,7 @@ class ObjectDialog extends JDialog type = _type.getSelectedItem().toString(); } - if(root.addObject(_proxy.getText(),type)) + if(root.addObject(_proxy.getText(), type)) { setVisible(false); } diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index 84e1c616940..864e124bf9c 100755 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -41,10 +41,12 @@ class Server extends ListArrayTreeNode actions[STOP] = _state != ServerState.Inactive; actions[ENABLE] = !_enabled; actions[DISABLE] = _enabled; + actions[WRITE_MESSAGE] = _state != ServerState.Inactive; + actions[PATCH_SERVER] = !_serverDescriptor.distrib.icepatch.equals(""); - if(_state != ServerState.Inactive && _enabled) + if(_state != ServerState.Inactive) { Node node = (Node)_parent; if(!node.isRunningWindows()) @@ -156,6 +158,15 @@ class Server extends ListArrayTreeNode enableServer(false); } + public void writeMessage() + { + if(_writeMessageDialog == null) + { + _writeMessageDialog = new WriteMessageDialog(getRoot()); + } + _writeMessageDialog.showDialog(_id); + } + public void signal(final String s) { final String prefix = "Sending '" + s + "' to server '" + _id + "'..."; @@ -320,7 +331,9 @@ class Server extends ListArrayTreeNode _popup.addSeparator(); _popup.add(la.get(PATCH_SERVER)); _popup.addSeparator(); - + _popup.add(la.get(WRITE_MESSAGE)); + _popup.addSeparator(); + JMenu signalMenu = new JMenu("Send signal"); _popup.add(signalMenu); @@ -807,4 +820,5 @@ class Server extends ListArrayTreeNode static private ServerEditor _editor; static private JPopupMenu _popup; + static private WriteMessageDialog _writeMessageDialog; } diff --git a/java/src/IceGridGUI/LiveDeployment/TreeNode.java b/java/src/IceGridGUI/LiveDeployment/TreeNode.java index 065ce0cff55..bf1a865eb59 100755 --- a/java/src/IceGridGUI/LiveDeployment/TreeNode.java +++ b/java/src/IceGridGUI/LiveDeployment/TreeNode.java @@ -45,15 +45,16 @@ public abstract class TreeNode extends TreeNodeBase public static final int SIGUSR2 = 9; public static final int SIGTERM = 10; + public static final int WRITE_MESSAGE = 11; - public static final int SHUTDOWN_NODE = 11; - public static final int SHUTDOWN_REGISTRY = 12; + public static final int SHUTDOWN_NODE = 12; + public static final int SHUTDOWN_REGISTRY = 13; - public static final int PATCH_SERVER = 13; + public static final int PATCH_SERVER = 14; - public static final int ADD_OBJECT = 14; + public static final int ADD_OBJECT = 15; - static public final int ACTION_COUNT = 15; + static public final int ACTION_COUNT = 16; public boolean[] getAvailableActions() { @@ -76,6 +77,10 @@ public abstract class TreeNode extends TreeNodeBase { assert false; } + public void writeMessage() + { + assert false; + } public void signal(String s) { assert false; diff --git a/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java b/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java new file mode 100644 index 00000000000..fab14442a9d --- /dev/null +++ b/java/src/IceGridGUI/LiveDeployment/WriteMessageDialog.java @@ -0,0 +1,197 @@ +// ********************************************************************** +// +// 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.LiveDeployment; + +import java.awt.Cursor; +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ButtonGroup; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +import com.jgoodies.forms.builder.DefaultFormBuilder; +import com.jgoodies.forms.factories.Borders; +import com.jgoodies.forms.factories.ButtonBarFactory; +import com.jgoodies.forms.layout.CellConstraints; +import com.jgoodies.forms.layout.FormLayout; +import com.jgoodies.forms.util.LayoutStyle; + +import IceGrid.*; +import IceGridGUI.*; + +class WriteMessageDialog extends JDialog +{ + WriteMessageDialog(final Root root) + { + super(root.getCoordinator().getMainFrame(), + "Write Message - IceGrid Admin", true); + setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); + _mainFrame = root.getCoordinator().getMainFrame(); + + _stdOut = new JRadioButton("Write to stdout"); + _stdOut.setSelected(true); + JRadioButton stdErr = new JRadioButton("Write to stderr"); + ButtonGroup bg = new ButtonGroup(); + bg.add(_stdOut); + bg.add(stdErr); + + JButton okButton = new JButton("OK"); + ActionListener okListener = new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + final Coordinator c = root.getCoordinator(); + final String target = _target; + final String prefix = "Writing message to server '" + target + "'..."; + + + AMI_Admin_writeMessage cb = new AMI_Admin_writeMessage() + { + public void ice_response() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + c.getStatusBar().setText(prefix + "done."); + } + }); + } + + public void ice_exception(final Ice.UserException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure("IceGrid exception: " + e.toString()); + } + + }); + } + + public void ice_exception(final Ice.LocalException e) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + handleFailure("Communication exception: " + e.toString()); + } + }); + } + + private void handleFailure(String message) + { + c.getStatusBar().setText(prefix + "failed!"); + + JOptionPane.showMessageDialog( + _mainFrame, + message, + "Writing message to server '" + target + "' failed", + JOptionPane.ERROR_MESSAGE); + } + }; + + try + { + c.getStatusBar().setText(prefix); + _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + + c.getAdmin().writeMessage_async( + cb, _target, _message.getText(), _stdOut.isSelected() ? 1 : 2); + } + catch(Ice.LocalException ex) + { + c.getStatusBar().setText(prefix + "failed."); + JOptionPane.showMessageDialog( + _mainFrame, + "Communication exception: " + ex.toString(), + "Writing message to server '" + target + "' failed", + JOptionPane.ERROR_MESSAGE); + + return; + } + finally + { + _mainFrame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + + setVisible(false); + } + }; + okButton.addActionListener(okListener); + getRootPane().setDefaultButton(okButton); + + JButton cancelButton = new JButton("Cancel"); + ActionListener cancelListener = new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + setVisible(false); + } + }; + cancelButton.addActionListener(cancelListener); + + FormLayout layout = new FormLayout("left:pref, 3dlu, fill:pref:grow", ""); + DefaultFormBuilder builder = new DefaultFormBuilder(layout); + builder.setDefaultDialogBorder(); + builder.setRowGroupingEnabled(true); + builder.setLineGapSize(LayoutStyle.getCurrent().getLinePad()); + + JScrollPane scrollPane = new JScrollPane(_message, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); + builder.append(scrollPane, 3); + builder.nextLine(); + builder.append(_stdOut); + builder.append(stdErr); + builder.nextLine(); + JComponent buttonBar = + ButtonBarFactory.buildOKCancelBar(okButton, cancelButton); + buttonBar.setBorder(Borders.DIALOG_BORDER); + + Container contentPane = getContentPane(); + contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); + contentPane.add(builder.getPanel()); + contentPane.add(buttonBar); + + pack(); + setResizable(false); + } + + void showDialog(String serverId) + { + _target = serverId; + _message.setText(""); + setLocationRelativeTo(_mainFrame); + setVisible(true); + } + + private JRadioButton _stdOut; + private JTextArea _message = new JTextArea(3, 40); + private String _target; + private JFrame _mainFrame; +} |