📄 adminmgr.java
字号:
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact info@exolab.org.
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2000 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: AdminMgr.java,v 1.6 2003/08/07 13:32:59 tanderson Exp $
*
* Date Author Changes
* $Date jimm Created
*/
package org.exolab.jms.jndiadministration;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.PrintStream;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeExpansionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import org.exolab.jms.config.Configuration;
import org.exolab.jms.config.ConfigurationManager;
import org.exolab.jms.util.CommandLine;
/**
* This class is the Gui controller for the JMS JNDI administration. It
* displays data as a hierarchical set of tree nodes.
*
* <P>The Root is all the contactable JMS servers, idealy there can be several
* of these all on different ports, with one common admin port they all listen
* to. A user selects a JMSServer then connects via the menu item. This
* allows the admin GUI to connect to the server via the main port and begin
* displaying all its JndiContexts
*
* <P>For the moment this is not truly dynamic, that is a refresh needs to be
* activated on the Gui to cause an update (other than changes made
* through the Gui istelf).
*
* @version $Revision: 1.6 $ $Date: 2003/08/07 13:32:59 $
* @author <a href="mailto:mourikis@exolab.org">Jim Mourikis</a>
*
**/
public class AdminMgr extends JFrame {
// Gui Declarations
private JMenuBar menuBar_;
private JMenu file_;
private JMenuItem exit_;
private JMenu actions_;
private JMenu connections_;
private JMenuItem refresh_;
private JMenuItem online_;
private JMenuItem offline_;
private JMenuItem disconnect_;
private JScrollPane jMSServers_;
private JTree serverProperties_;
private JTextField messageArea_;
private JComboBox jMSCombo_;
// If this Admin object is connected to any OpenJMS
private boolean connected_ = false;
/**
* The default constructor performs all gui creations.
*
*/
public AdminMgr() {
initComponents();
pack();
}
/** This method is called from within the constructor to
* initialize the form. All the GUI objects are created, and callbacks
* registered.
*/
private void initComponents() {
menuBar_ = new JMenuBar();
file_ = new JMenu();
exit_ = new JMenuItem();
actions_ = new JMenu();
connections_ = new JMenu();
refresh_ = new JMenuItem();
online_ = new JMenuItem();
offline_ = new JMenuItem();
disconnect_ = new JMenuItem();
jMSServers_ = new JScrollPane();
jMSCombo_ = new JComboBox();
serverProperties_ = new JTree();
setTitle("OpenJMS JNDI Admin");
DefaultTreeModel serverModel =
OpenJMSServer.createServerList(serverProperties_);
serverProperties_.setModel(serverModel);
messageArea_ = new JTextField();
file_.setText("File");
exit_.setToolTipText("Exit administration");
exit_.setText("Exit");
exit_.setMnemonic('x');
serverProperties_.setRootVisible(false);
serverProperties_.setShowsRootHandles(true);
serverProperties_.putClientProperty("JTree.lineStyle", "Angled");
// serverProperties_.setCellEditor(new OpenJMSEditor(serverProperties_,
// jMSCombo_));
serverProperties_.setEditable(false);
setupCallbacks();
file_.add(exit_);
file_.setMnemonic('F');
menuBar_.add(file_);
actions_.setText("Actions");
actions_.setMnemonic('A');
connections_.setText("Connections");
connections_.setMnemonic('C');
refresh_.setToolTipText("Refresh the display");
online_.setToolTipText("Connect to a running OpenJMS JNDI Server");
offline_.setToolTipText("Connect directly to a JNDI database");
refresh_.setText("Refresh");
refresh_.setMnemonic('R');
actions_.add(refresh_);
online_.setText("Online");
online_.setMnemonic('O');
offline_.setText("Offline");
offline_.setMnemonic('f');
connections_.add(online_);
connections_.add(offline_);
actions_.add(connections_);
disconnect_.setToolTipText
("Disconnect from any connected OpenJMS JNDI Servers");
disconnect_.setText("Disconnect");
disconnect_.setMnemonic('D');
actions_.add(disconnect_);
menuBar_.add(actions_);
jMSServers_.setViewportView(serverProperties_);
getContentPane().add(jMSServers_, BorderLayout.CENTER);
messageArea_.setToolTipText("Message Area");
messageArea_.setEditable(false);
messageArea_.setForeground(java.awt.Color.red);
messageArea_.setText("Not Connected");
messageArea_.setHorizontalAlignment(SwingConstants.CENTER);
getContentPane().add(messageArea_, BorderLayout.SOUTH);
setJMenuBar(menuBar_);
refresh_.setEnabled(false);
disconnect_.setEnabled(false);
}
/**
* The exit method for the application, when the user shutdowns the form.
*
* @param evt The event that triggered this action.
*
*/
private void exitAdmin(ActionEvent evt) {
System.exit(0);
}
/**
* Exit the Application when a user selects File->Exit from the menu
*
* @param evt The window event that triggered this call.
*
*/
private void exitForm(WindowEvent evt) {
System.exit(0);
}
/**
* Refresh the display, and repaint all items.
*
* @param evt The event that triggered this operation.
*
*/
private void refresh(ActionEvent evt) {
if (AdminConnection.instance() instanceof OnlineConnection) {
setConnected(false, null);
setConnected(true, "Connected - Online Mode");
} else {
((OpenJMSServer) (serverProperties_.getModel().getRoot()
)).refresh();
}
}
/**
* When a user wishes to connect to all known OpenJMSServers.
* Attempt to create an RMI connection to the OpenJMSServer. If the server
* is not running, this will fail. The user can start the server through
* the start server command, and attempt to re-connect, or use the offline
* method below.
*
* @param evt The event that triggered this operation.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -