📄 serveraddresssetup.java
字号:
/*
* Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books.
* Copyright (C) 2001-2002 WOTLAS Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package wotlas.server.setup;
import wotlas.server.*;
import wotlas.common.*;
import wotlas.libs.wizard.*;
import wotlas.libs.graphics2D.FontFactory;
import wotlas.utils.*;
import wotlas.utils.Debug;
import wotlas.libs.aswing.*;
import wotlas.libs.log.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Properties;
import java.io.*;
/** This a utility to update the server address.
*
* @author Aldiss
*/
public class ServerAddressSetup extends JWizard {
/*------------------------------------------------------------------------------------*/
/** Our serverID
*/
private static int serverID;
/** Server Config Address file path.
*/
private static String serverAddressFile;
/** User Password
*/
private static String password="";
/*------------------------------------------------------------------------------------*/
/** Constructor.
*/
public ServerAddressSetup() {
super("Server Address Setup",
ServerDirector.getResourceManager(),
FontFactory.getDefaultFontFactory().getFont("Lucida Blackletter").deriveFont(18f),
470,550);
setLocation(200,100);
serverID = ServerDirector.getServerID();
serverAddressFile = ServerDirector.getResourceManager().getExternalServerConfigsDir()
+ServerConfigManager.SERVERS_PREFIX
+serverID+ServerConfigManager.SERVERS_SUFFIX
+ServerConfigManager.SERVERS_ADDRESS_SUFFIX;
if(serverID==0)
JOptionPane.showMessageDialog( null, "Your server ID is 0 ('localhost'). This setup program is only"
+"\nfor servers that need to publish their IP on the Internet.",
"Warning", JOptionPane.WARNING_MESSAGE);
// We display first step
try{
init( AddressWizardStep.getStaticParameters() );
}
catch( WizardException we ) {
we.printStackTrace();
dispose(); // init failed !
ServerAdminGUI.setAdminGUI();
}
}
/*------------------------------------------------------------------------------------*/
/** Called when wizard is finished (after last step's end).
*/
protected void onFinished(Object context) {
dispose();
ServerAdminGUI.setAdminGUI();
}
/*------------------------------------------------------------------------------------*/
/** Called when wizard is canceled ('cancel' button pressed).
*/
protected void onCanceled(Object context) {
dispose();
ServerAdminGUI.setAdminGUI();
}
/*------------------------------------------------------------------------------------*/
/**
* First Step of our JWizard. Address config.
*/
public static class AddressWizardStep extends JWizardStep {
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Swing Fields
*/
private JTextField t_ipAddress;
private JTextField t_login;
private JPasswordField t_passw;
private JComboBox c_prog, c_options, c_workdir;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** This is a static JWizardStep, to build it more simply this method
* returns the JWizardStepParameters needed for the JWizard.
*/
public static JWizardStepParameters getStaticParameters() {
JWizardStepParameters param = new JWizardStepParameters(
"wotlas.server.setup.ServerAddressSetup$AddressWizardStep",
"Server Address Setup" );
param.setIsPrevButtonEnabled(false);
param.setIsDynamic(true); // we don't want the step to be buffered, we want its data
return param; // to be updated each time the step is displayed
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/** Constructor.
*/
public AddressWizardStep() {
super();
// JPanel inits
JPanel stepPanel = new JPanel( new GridLayout(8,1,5,5) );
stepPanel.setAlignmentX(LEFT_ALIGNMENT);
stepPanel.setBackground(Color.white);
stepPanel.setPreferredSize( new Dimension(430,630) );
setAlignmentX(LEFT_ALIGNMENT);
JScrollPane scroll = new JScrollPane( stepPanel );
scroll.setAlignmentX(LEFT_ALIGNMENT);
scroll.setPreferredSize( new Dimension(450,430) );
add( scroll );
// Info on this Step
JPanel group0 = new JPanel(new GridLayout(1,1,0,0));
group0.setAlignmentX(LEFT_ALIGNMENT);
group0.setBackground(Color.white);
JTextArea text0 = new JTextArea("\n Welcome to your Server Address Setup."
+" This is where you declare and export your server's"
+" IP address (or DNS name). Make sure the information below is correct"
+" and move on to the next step. Your server ID is "+serverID+".");
text0.setLineWrap(true);
text0.setWrapStyleWord(true);
text0.setEditable(false);
text0.setAlignmentX(LEFT_ALIGNMENT);
group0.add( text0 );
stepPanel.add(group0);
// IP Address Combo Box
JPanel group1 = new JPanel(new GridLayout(3,1,0,0));
group1.setAlignmentX(LEFT_ALIGNMENT);
group1.setBackground(Color.white);
JLabel label1 = new JLabel("Select/Enter your Internet address or DNS name (do not enter both) :");
label1.setAlignmentX(LEFT_ALIGNMENT);
String lastIP = ServerDirector.getResourceManager().loadText( serverAddressFile );
if(lastIP==null) lastIP="0.0.0.0";
t_ipAddress = new JTextField( lastIP );
t_ipAddress.setAlignmentX(LEFT_ALIGNMENT);
JLabel label1bis = new JLabel(" ");
label1bis.setAlignmentX(LEFT_ALIGNMENT);
group1.add( label1 );
group1.add( t_ipAddress );
group1.add( label1bis );
stepPanel.add(group1);
// File Transfer Info
JTextArea text2 = new JTextArea("\n We need to know how to transfer your server's IP"
+" address to the wotlas central web server : "
+ServerDirector.getRemoteServersProperties().getProperty("info.remoteServerHomeURL") );
text2.setAlignmentX(LEFT_ALIGNMENT);
text2.setLineWrap(true);
text2.setWrapStyleWord(true);
text2.setEditable(false);
stepPanel.add(text2);
// Login
JPanel group2 = new JPanel(new GridLayout(2,1,0,0));
group2.setAlignmentX(LEFT_ALIGNMENT);
group2.setBackground(Color.white);
JLabel label2 = new JLabel("Enter your login :");
label2.setAlignmentX(LEFT_ALIGNMENT);
t_login = new JTextField(ServerDirector.getRemoteServersProperties().getProperty("transfer.serverHomeLogin",""));
t_login.setAlignmentX(LEFT_ALIGNMENT);
group2.add( label2 );
group2.add( t_login );
stepPanel.add(group2);
// Password
JPanel group3 = new JPanel(new GridLayout(2,1,0,0));
group3.setAlignmentX(LEFT_ALIGNMENT);
group3.setBackground(Color.white);
JLabel label3 = new JLabel("Enter your password :");
label3.setAlignmentX(LEFT_ALIGNMENT);
t_passw = new JPasswordField(password);
t_passw.setAlignmentX(LEFT_ALIGNMENT);
group3.add( label3 );
group3.add( t_passw );
stepPanel.add(group3);
// File Tranfer Program
JPanel group4 = new JPanel(new GridLayout(2,1,0,0));
group4.setAlignmentX(LEFT_ALIGNMENT);
group4.setBackground(Color.white);
JLabel label4 = new JLabel("Enter the program to use for file transfer :");
label4.setAlignmentX(LEFT_ALIGNMENT);
String cmdProgList[] = {
ServerDirector.getRemoteServersProperties().getProperty("transfer.fileTransferProgram",""),
"../bin/win32/pscp.exe",
"\"../bin/win32/pscp.exe\" (for win2000 & XP, don't remove the \" \" )",
"scp",
"ftp",
};
c_prog = new JComboBox(cmdProgList);
c_prog.setEditable(true);
c_prog.setAlignmentX(LEFT_ALIGNMENT);
group4.add( label4 );
group4.add( c_prog );
stepPanel.add(group4);
// File Tranfer Options
JPanel group5 = new JPanel(new GridLayout(2,1,0,0));
group5.setAlignmentX(LEFT_ALIGNMENT);
group5.setBackground(Color.white);
JTextArea text5 = new JTextArea("Enter the program's command line options. "
+"It should contain $FILE$, $LOGIN$ and $PASSW$ tags "
+"that we'll replace by their value.");
text5.setAlignmentX(LEFT_ALIGNMENT);
text5.setLineWrap(true);
text5.setWrapStyleWord(true);
text5.setEditable(false);
String cmdOptList[] = {
ServerDirector.getRemoteServersProperties().getProperty("tranfer.fileTransferOptions",""),
"-pw $PASSW$ $FILE$ $LOGIN$@shell.sf.net:/home/groups/w/wo/wotlas/htdocs/game",
};
c_options = new JComboBox(cmdOptList);
c_options.setEditable(true);
c_options.setAlignmentX(LEFT_ALIGNMENT);
group5.add( text5 );
group5.add( c_options );
stepPanel.add(group5);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -