📄 managecontrol.new
字号:
/* ---------------------------------------------------------------------- sf Control Panel - A management software for sf Firewall Copyright (C) 1997 Roland E. Schmid <schmid@acm.org> 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., 675 Mass Ave, Cambridge, MA 02139, USA. Please address all correspondence concerning the software to firewall-bugs@switch.ch. ---------------------------------------------------------------------- */package sfclasses;import java.awt.*;import java.net.*;import java.applet.*;import java.util.*;import java.io.*;import Acme.Widgets.*;/** * <b>Toplevel Frame of Remote Config Tool</b><br> * This class implements the main window of the control panel. The frame * is constructed when the user clicks on a button in the start page (see * sfRemote.java). It contains a drag and drop panel for the network * topology in the client area and provides access to all global * configuration functions. * @version 1.0 12 Dec 1996 * @author Roland E. Schmid */public class ManageControl extends Frame { /** * Initialize new main window<br> * The window is set up and a new ManageDomain object is created * holding the configuration data. * @param titleString Initial window title * @ac Applet context, used for displaying strings in the status line * of the web browser and to open new browser windows. */ public ManageControl(String titleString, AppletContext ac) { // window title bar if (titleString != null) setTitle(titleString); // create menus mbar = new MenuBar(); FileMenu = new Menu("File"); FileMenu.add(new MenuItem("Load from Firewall")); FileMenu.add(new MenuItem("Save to Firewalls")); FileMenu.add(new MenuItem("Load from Local File")); FileMenu.add(new MenuItem("Save to Local File")); FileMenu.add(new MenuItem("Close")); FileMenu.addSeparator(); FileMenu.add(new MenuItem("Quit")); mbar.add(FileMenu); EditMenu = new Menu("Edit"); EditMenu.add(new MenuItem("General")); EditMenu.add(new MenuItem("Autoconfig")); EditMenu.add(new MenuItem("Rules")); EditMenu.add(new MenuItem("Notification Levels")); EditMenu.add(new MenuItem("Macros")); EditMenu.addSeparator(); CheckboxMenuItem cmi = new CheckboxMenuItem("Edit Topology"); cmi.setState(topologyEdit); EditMenu.add(cmi); mbar.add(EditMenu); ReportMenu = new Menu("Reports"); ReportMenu.add(new MenuItem("Configuration Report")); mbar.add(ReportMenu); HelpMenu = new Menu("Help"); HelpMenu.add(new MenuItem("User's Guide")); HelpMenu.add(new MenuItem("About")); mbar.add(HelpMenu); mbar.setHelpMenu(HelpMenu); setMenuBar(mbar); // initialize data appletContext = ac; Communicator.parent = this; if (titleString != null) { byte host[] = Communicator.resolve(titleString); RelayInputStream ris = new RelayInputStream(host, Custom.CONF_DIR + Custom.GLOBAL_CONFIG); if (ris.isEOF()) mgDomain = null; else { PersistentInputStream is = new PersistentInputStream(ris); mgDomain = ManageDomain.loadDomainConfig(is); } } else mgDomain = new ManageDomain(); if (mgDomain == null) { // host is unreachable prepareQuit(); return; } // create drag and drop panel try { hostClass = Class.forName("sfclasses.Host"); netClass = Class.forName("sfclasses.Net"); internetClass = Class.forName("sfclasses.Internet"); } catch (ClassNotFoundException e) { System.out.println("Fatal error: class Host, Net or Internet not found!"); terminated = true; return; } drawClass = hostClass; // create panels ddPanel = new DragDrop(mgDomain.getTopology(), drawClass, topologyEdit); Toolbar = new Panel(); Toolbar.setLayout(new FlowLayout(FlowLayout.LEFT)); CheckboxGroup g = new CheckboxGroup(); Toolbar.add(hostBox = new Checkbox("Host", g, true)); Toolbar.add(netBox = new Checkbox("Net", g, false)); Toolbar.add(internetBox = new Checkbox("Internet", g, false)); setLayout(new BorderLayout()); add("Center", ddPanel); // set window title if (mgDomain.DomainName.length() > 0) setTitle(mgDomain.DomainName); else setTitle("Unnamed domain"); } public boolean action(Event evt, Object arg) { if (evt.target instanceof MenuItem) { if (arg.equals("Quit")) { prepareQuit(); return true; } else if (arg.equals("Save to Firewalls")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } SaveData sd = new SaveData(mgDomain, this, false, false); setEnabled(false); setCursor(Frame.WAIT_CURSOR); sd.start(); return true; } else if (arg.equals("Save to Local File")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } SaveData sd = new SaveData(mgDomain, this, false, true); setEnabled(false); setCursor(Frame.WAIT_CURSOR); sd.start(); return true; } else if (arg.equals("Load from Local File")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } LoadData ld = new LoadData(mgDomain, this, LoadData.LOCAL); setEnabled(false); setCursor(Frame.WAIT_CURSOR); ld.start(); return true; } else if (arg.equals("Load from Firewall")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } LoadData ld = new LoadData(mgDomain, this, LoadData.REMOTE); setEnabled(false); setCursor(Frame.WAIT_CURSOR); ld.start(); return true; } else if (arg.equals("Close")) { LoadData ld = new LoadData(mgDomain, this, LoadData.NONE); setEnabled(false); setCursor(Frame.WAIT_CURSOR); ld.start(); return true; } else if (arg.equals("General")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } if (editRuleFrame != null && editRuleFrame.isShowing()) { ErrorBox eb = new ErrorBox(this, "Function not available while editing rules!"); eb.show(); return true; } mgDomain.changed = true; mgDomain.autoconfValid = false; GeneralSettings gs; if (mgDomain.DomainName.length() == 0) gs = new GeneralSettings(this, "General Settings", mgDomain); else gs = new GeneralSettings(this, mgDomain.DomainName, mgDomain); gs.setVisible(true); return true; } else if (arg.equals("Rules")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } mgDomain.changed = true; if (editRuleFrame == null) { editRuleFrame = new RuleEditor(mgDomain); Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); editRuleFrame.setSize(screensize.width/6*5, screensize.height/4*3); editRuleFrame.setVisible(true); } else editRuleFrame.showAgain(); if (!mgDomain.autoconfValid) { WarningBox wb = new WarningBox(editRuleFrame, "Autoconfig not executed. Rules may not be valid."); wb.show(); } return true; } else if (arg.equals("Autoconfig")) { if (topologyEdit) { ErrorBox eb = new ErrorBox(this, "Function not available while editing the topology!"); eb.show(); return true; } if (editRuleFrame != null && editRuleFrame.isShowing()) { ErrorBox eb = new ErrorBox(this, "Function not available while editing rules!"); eb.show(); return true; } mgDomain.changed = true; AutoconfThread at = new AutoconfThread(mgDomain, this); setEnabled(false); setCursor(Frame.WAIT_CURSOR); at.start(); return true; } else if (arg.equals("Notification Levels")) { NotificationSelect notificationSelect = new NotificationSelect(mgDomain, this); notificationSelect.setVisible(true); return true; } else if (arg.equals("Macros")) { MacroSelect macroSelect = new MacroSelect(mgDomain, this); macroSelect.setVisible(true); return true; } else if (arg.equals("Edit Topology")) { if (editRuleFrame != null && editRuleFrame.isShowing()) { ErrorBox eb = new ErrorBox(this, "Function not available while editing rules!"); eb.show(); topologyEdit = false; ((CheckboxMenuItem)evt.target).setState(topologyEdit); return true; } topologyEdit = ((CheckboxMenuItem)evt.target).getState(); mgDomain.changed = true; mgDomain.autoconfValid = false; if (topologyEdit) { ddPanel.enableEdit(); add("North", Toolbar); validate(); } else { if (!ddPanel.disableEdit()) { topologyEdit = true; ((CheckboxMenuItem)evt.target).setState(topologyEdit); } remove(Toolbar); mgDomain.topologyChanged(); validate(); NoticeBox nb = new NoticeBox(this, "Run autoconfiguration now to update the rules!"); nb.show(); } return true; } else if (arg.equals("Configuration Report")) { ReportThread rt = new ReportThread(mgDomain, this, ReportThread.REPORT_CONFIG); setEnabled(false); setCursor(Frame.WAIT_CURSOR); rt.start(); return true; } else if (arg.equals("User's Guide")) { try { URL u = new URL(Utils.fileURLPrefix()+Custom.DOC_DIR+"control.htm"); appletContext.showDocument(u,"_blank"); } catch (MalformedURLException e) { System.out.println("Malformed URL! "+e); } catch (Exception e) { System.out.println("Unexpected exception "+e); } return true; } else if (arg.equals("About")) { AboutDialog ab = new AboutDialog(this); ab.setVisible(true); return true; } else return super.action(evt, arg); } else if (evt.target == hostBox) { drawClass = hostClass; ddPanel.setClass(drawClass); return true; } else if (evt.target == netBox) { drawClass = netClass; ddPanel.setClass(drawClass); return true; } else if (evt.target == internetBox) { drawClass = internetClass; ddPanel.setClass(drawClass); return true; } else return super.action(evt, arg); } public boolean handleEvent(Event evt) { if (evt.id == Event.WINDOW_DESTROY) { if (isEnabled()) prepareQuit(); return true; } else return super.handleEvent(evt); } protected void prepareQuit() { if (mgDomain != null && mgDomain.changed) { SaveData sd = new SaveData(mgDomain, this, true, false); setEnabled(false); setCursor(Frame.WAIT_CURSOR); sd.start(); return; } /* cleanup stuff */ Communicator.dispose(); setVisible(false); ddPanel = null; mgDomain = null; terminated = true; } protected void setManageDomain(ManageDomain newmd) { remove(ddPanel); ddPanel = new DragDrop(newmd.getTopology(), drawClass, topologyEdit); add("Center", ddPanel); validate(); if (newmd.DomainName.length() > 0) setTitle(newmd.DomainName); else setTitle("Unnamed domain"); mgDomain = newmd; } // public data
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -