📄 server.java
字号:
package za.co.halo.SecureCommunications.gui.server;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.WindowConstants;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import org.netbeans.lib.awtextra.AbsoluteConstraints;
import org.netbeans.lib.awtextra.AbsoluteLayout;
import za.co.halo.SecureCommunications.DownloadRuleManager;
import za.co.halo.SecureCommunications.Email;
import za.co.halo.SecureCommunications.Rule;
import za.co.halo.SecureCommunications.ServerAdmin;
import za.co.halo.SecureCommunications.ServerGroupManager;
import za.co.halo.SecureCommunications.ServerManager;
import za.co.halo.SecureCommunications.gui.client2.DownloadRuleGui;
import za.co.halo.SecureCommunications.gui.client2.ServerGeneralPanel;
import za.co.halo.SecureCommunications.gui.client2.SplashScreen;
import za.co.halo.SecureCommunications.languageFilter.FilterGui;
import za.co.halo.SecureCommunications.languageFilter.LanguageManagerFilter;
import za.co.halo.SecureCommunications.network.ServerSettings;
/**
* This code was generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* *************************************
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED
* for this machine, so Jigloo or this code cannot be used legally
* for any corporate or commercial purpose.
* *************************************
*/
/**
* @author
* Server Class
* This class presents the GUI for iCat's server
* It acts as a container that incorporates other classes with GUI components
* This class also contains the code to start the servers: POP3, SMTP, Web Server, RMI Server
*/
public class Server extends JFrame implements ActionListener, MouseListener
{
private static final long serialVersionUID = 1L;
private JPanel welcomePanel;
private JPanel leftPanel;
private JPanel rightPanel;
private JPanel infoPanel;
private JPanel serversTabPanel;
private JPanel accountTabPanel;
private JPanel groupsTabPanel;
private JPanel logTabPanel;
private JPanel domainTabPanel;
private JPanel downloadTabPanel;
private JPanel languageFilterTabPanel;
private JPanel optionsTabPanel;
private JSplitPane splitPane;
private JButton accountButton;
private JButton groupButton;
private JButton downloadButton;
private JButton optionsButton;
private JButton logButton;
private JButton languageFilterButton;
private JButton closeButton;
private JButton domainButton;
private JLabel infoLabel;
private JLabel imageLabel;
private JTabbedPane tabbedPane;
private SplashScreen splashscreen;
private LogFilePanel logFilePanel;
private ServerAccountsPanel serverAccountsPanel;
private GroupsPanel groupsPanel;
private DomainPanel domainPanel;
private ServerPanel2 serverPanel;
private OptionsPanel optionsPanel;
private ServerGeneralPanel generalPanel, downloadgeneralPanel;
private FilterGui languageFiltergui;
private DownloadRuleGui rulegui;
private Border whiteLine = BorderFactory.createLineBorder(Color.white,1);
private Font customFont = new Font("Helvetica", Font.PLAIN, 14);
private Font customFont2 = new Font("Helvetica", Font.PLAIN, 12);
private ImageIcon iCatImage;
private ServerManager accounts;
private ServerGroupManager groups;
private ServerSettings serverSettings;
private Vector<Rule> theRules;
private DownloadRuleManager ruleManager;
private LocalServerManager localServerManager;
private LanguageManagerFilter languageFilter;
/**
* getTestEmails method
* Use to:
* initialise a test email list
* @param void
* @return Vector<Email>
*/
private Vector<Email> getTestEmails() {
Vector<String> receivers = new Vector<String>(3);
receivers.addElement("s23152835@tuks.co.za");
receivers.addElement("s21152835@tuks.co.za");
receivers.addElement("rusty@tuks.co.za");
Vector<String> message = new Vector<String>(1);
message .addElement("If you can read this , ICAT V0.03 is up and running."
+ "Thank You for your patience");
message.addElement("The next updated version of ICAT v0.03 will be released the 14Okt");
Vector<Email> e = new Vector<Email>(10);
e.addElement(new Email("Something Special", "Isabel Bostha", receivers,
receivers, receivers, "John McGee", message, "1:03",
"Anliend de Lange"));
e.addElement(new Email("Read it...", "Jeanri Pellissier", receivers,
receivers, receivers, "John McGee", message, "1:03",
"Anliend de Lange"));
e.addElement(new Email("How's the shot going ?", "Pieter Toute",
receivers, receivers, receivers, "John McGee", message,
"1:03", "Anliend de Lange"));
e.addElement(new Email("me - you", "Lizel van Rensburg", receivers,
receivers, receivers, "John McGee", message, "1:03",
"Anliend de Lange"));
e.addElement(new Email("This is the life", "Jaco Pieterse", receivers,
receivers, receivers, "John McGee", message, "1:03",
"Anliend de Lange"));
return e;
}
/**
* main method
* Use to:
* display the JFrame.
*/
public static void main(String[] args)
{
SplashScreen splash = new SplashScreen("splash.png");
splash.start();
Server serverGUI = new Server();
serverGUI.pack();
serverGUI.setVisible(true);
splash.stop();
}
/**
* Server constructor
* Use to:
* initialize member variables
* initialize the build of graphical components
* call the function startServers of the localServerManager class to start the appropriate servers
* @param void
* @return void
*/
public Server()
{
serverSettings = getServerSettings();
accounts = new ServerManager();
accounts.load();
languageFilter = new LanguageManagerFilter();
languageFilter.load();
groups = new ServerGroupManager();
groups.load();
localServerManager = new LocalServerManager(accounts, groups,serverSettings);
ruleManager = new DownloadRuleManager();
ruleManager.load();
theRules = ruleManager.getRules();
//clusterServer = new ClusterServer(accounts,groups);
accounts.setDomain(serverSettings.getDomain());
initGUI();
localServerManager.startServers();
}
/**
* getServerSettings method
* Use to:
* reload the previous server settings
* @param void
* @return ServerSettings
*/
public ServerSettings getServerSettings()
{
try {
ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File(ServerAdmin.SERVER_SETTINGS_SAVE_FILE)));
ServerSettings s = (ServerSettings)in.readObject();
in.close();
return s;
} catch (Exception e) {
e.printStackTrace();
return new ServerSettings();
}
}
/**
* getTestEmails method
* Use to:
* save all the previous server settings
* @param void
* @return void
*/
private void saveServerSettings() {
try {
ObjectOutputStream in = new ObjectOutputStream(new FileOutputStream(new File(ServerAdmin.SERVER_SETTINGS_SAVE_FILE)));
in.writeObject(serverSettings);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* initGUI method
* Use to:
* initialize graphics
* @param void
* @return void
*/
private void initGUI() {
try {
{
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setPreferredSize(new Dimension(930,700));
this.setLocation(50,5);
this.setTitle("iCat Server");
this.setIconImage(new ImageIcon("Banners/iconLogo.png").getImage());
welcomePanel = new JPanel();
welcomePanel.setSize(new Dimension(800,100));
welcomePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(whiteLine,"Welcome: iCat Administrator",TitledBorder.TOP,TitledBorder.LEADING,customFont,Color.white),BorderFactory.createEmptyBorder(0,0,0,0)));
welcomePanel.setBackground(new Color(21,118,146));
this.add(welcomePanel,BorderLayout.NORTH);
leftPanel = new JPanel();
leftPanel.setMinimumSize(new Dimension(250,600));
leftPanel.setLayout(null);
leftPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(whiteLine,"Options",TitledBorder.LEADING,TitledBorder.TOP,customFont2,Color.white),BorderFactory.createEmptyBorder(5,5,5,5)));
leftPanel.setBackground(new Color(15,65,108));
rightPanel = new JPanel();
rightPanel.setMinimumSize(new Dimension(700,800));
rightPanel.setLayout(null);
rightPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(whiteLine,"Information",TitledBorder.LEADING,TitledBorder.TOP,customFont2,Color.white),BorderFactory.createEmptyBorder(5,5,5,5)));
rightPanel.setBackground(new Color(15,65,108));
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(251);
this.add(splitPane,"Center");
accountButton = new JButton("Manage Accounts");
accountButton.setBounds(25,60,200,30);
accountButton.setActionCommand("accounts");
accountButton.addActionListener(this);
accountButton.addMouseListener(this);
leftPanel.add(accountButton);
groupButton = new JButton("Manage Groups");
groupButton.setBounds(25,95,200,30);
groupButton.setActionCommand("groups");
groupButton.addActionListener(this);
groupButton.addMouseListener(this);
leftPanel.add(groupButton);
domainButton = new JButton("Change Domain Settings");
domainButton.setBounds(25,130,200,30);
domainButton.setActionCommand("domain");
domainButton.addActionListener(this);
domainButton.addMouseListener(this);
leftPanel.add(domainButton);
downloadButton = new JButton("Change Download Policies");
downloadButton.setBounds(25,165,200,30);
downloadButton.setActionCommand("download");
downloadButton.addActionListener(this);
downloadButton.addMouseListener(this);
leftPanel.add(downloadButton);
optionsButton = new JButton("Options");
optionsButton.setBounds(25,200,200,30);
optionsButton.setActionCommand("options");
optionsButton.addActionListener(this);
optionsButton.addMouseListener(this);
leftPanel.add(optionsButton);
logButton = new JButton("View Log File");
logButton.setBounds(25,235,200,30);
logButton.setActionCommand("log");
logButton.addActionListener(this);
logButton.addMouseListener(this);
leftPanel.add(logButton);
languageFilterButton = new JButton("Open Language Filter");
languageFilterButton.setBounds(25,270,200,30);
languageFilterButton.setActionCommand("languageFilter");
languageFilterButton.addActionListener(this);
languageFilterButton.addMouseListener(this);
leftPanel.add(languageFilterButton);
infoPanel = new JPanel();
infoPanel.setBounds(20, 358, 205, 97);
infoPanel.setLayout(null);
infoPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(whiteLine,"Button Description",TitledBorder.LEADING,TitledBorder.TOP,customFont2,Color.white),BorderFactory.createEmptyBorder(5,5,5,5)));
infoPanel.setBackground(new Color(15,65,108));
leftPanel.add(infoPanel);
infoLabel = new JLabel();
infoLabel.setBounds(9, 16, 185, 70);
infoLabel.setText("<html><font Color=white>Move mouse over buttons for a <br> discription of their functionality</font></html>");
infoPanel.add(infoLabel);
iCatImage = createImageIcon("images/toets.png","iCat");
imageLabel = new JLabel(iCatImage);
imageLabel.setBounds(20,465,205,150);
leftPanel.add(imageLabel);
tabbedPane = new JTabbedPane();
tabbedPane.setBounds(10, 20, 640, 584);
rightPanel.add(tabbedPane);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -