📄 admintoolframe.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: AdminToolFrame.java,v 1.11 2000/10/28 16:55:20 daniela Exp $package org.ozoneDB.tools;import org.ozoneDB.DxLib.DxSet;import org.ozoneDB.DxLib.DxIterator;import java.awt.*;import java.awt.event.*;import java.util.*;/** */public class AdminToolFrame extends Frame implements IODevice { TextArea messages; TextArea comment; CommandLine commandLine; CommandChoice commands; CommandExecute exec; /** */ class CloseButton extends Button implements ActionListener { public CloseButton() { super( "QUIT" ); addActionListener( this ); } public void actionPerformed( ActionEvent e ) { String[] com = {"quit"}; ((AdminToolFrame)getParent()).exec.execute( com ); System.exit( 0 ); } } /** */ class ShutdownButton extends Button implements ActionListener { public ShutdownButton() { super( "SHUTDOWN & QUIT" ); addActionListener( this ); } public void actionPerformed( ActionEvent e ) { String[] com = {"shutdown"}; ((AdminToolFrame)getParent()).exec.execute( com ); System.exit( 0 ); } } /** */ class CommandLine extends TextField implements ActionListener { public CommandLine() { super(); addActionListener( this ); } public void actionPerformed( ActionEvent e ) { StringTokenizer st = new StringTokenizer( getText() ); String[] com = new String[st.countTokens()]; int i = 0; while (st.hasMoreTokens()) { com[i++] = st.nextToken(); } ((AdminToolFrame)getParent()).exec.execute( com ); setText( ((AdminToolFrame)getParent()).commands.getSelectedItem() + " " ); } } /** */ class CommandChoice extends Choice implements ItemListener { public CommandChoice( DxSet choices ) { DxIterator it = choices.iterator(); while (it.next() != null) { add( it.object().toString() ); } addItemListener( this ); } public void itemStateChanged( ItemEvent e ) { ((AdminToolFrame)getParent()).commandLine.setText( e.getItem().toString() + " " ); } } /** */ public AdminToolFrame() { super( "Ozone Administrator" ); exec = new CommandExecute( this ); setFont( new Font( "Helvetica", Font.PLAIN, 12 ) ); setLayout( new GridBagLayout() ); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1.0; c.weighty = 0.0; c.fill = GridBagConstraints.BOTH; c.gridwidth = GridBagConstraints.REMAINDER; add( new Label( "Server messages:" ), c ); c.weighty = 1.0; messages = new TextArea( "", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY ); messages.setEditable( false ); add( messages, c ); c.weighty = 0.0; add( new Label( "Command:" ), c ); c.gridwidth = GridBagConstraints.RELATIVE; commandLine = new CommandLine(); add( commandLine, c ); c.gridwidth = GridBagConstraints.REMAINDER; commands = new CommandChoice( exec.commands() ); add( commands, c ); c.weighty = 1.0; comment = new TextArea( "", 10, 10, TextArea.SCROLLBARS_VERTICAL_ONLY ); comment.setEditable( false ); add( comment, c ); c.weighty = 0.1; c.gridwidth = GridBagConstraints.RELATIVE; add( new ShutdownButton(), c ); add( new CloseButton(), c ); setSize( 500, 400 ); setLocation( 100, 100 ); show(); } /** */ public void connect( String host, int port ) { try { exec.open( host, port ); asyncMessage( "Connected to " + host + " at port " + port ); } catch (Exception e) { MessageBox.ConfirmBox( this, "Unable to open connection to" + host + " at port " + port + " ! Closing ..." ); System.exit( 0 ); } } /** */ public void close() { try { exec.close(); } catch (Exception e) { } System.exit( 0 ); } /** */ public void message( String mess ) { comment.append( mess + "\n" ); } /** */ public void asyncMessage( String mess ) { messages.append( mess + "\n" ); } /** */ public boolean request( String req ) { return MessageBox.YesNoBox( this, req ) == MessageBox.YES; } /** */ public static void main( String[] args ) { String hostname = "localhost"; int port = 3000; System.out.println( "ozone administration tool" ); AdminToolFrame adf = new AdminToolFrame(); boolean help = false; for (int i = 0; i < args.length; i++) { if (args[i].startsWith( "-host" )) { hostname = args[i].substring( 5 ); } else if (args[i].startsWith( "-port" )) { port = Integer.parseInt( args[i].substring( 5 ) ); } else if (args[i].startsWith( "-h" )) { help = true; } else { System.out.println( "unknown option:" + args[i] ); help = true; } } if (help) { System.out.println( "\nusage: ozoneAdminFrame [-host<host>] [-port<number>] [-h]\n" ); System.out.println( "-host<host> the host to connect to" ); System.out.println( "-port<number> the port number to connect to the Ozone DB" ); System.out.println( "-h shows this help" ); System.exit( 0 ); } adf.connect( hostname, port ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -