📄 sshmenuhandlerfull.java
字号:
public void close() { // !!! TODO, note that this can only be generated in SSH2 clone window now // so we don't need to care about this... } public void prepareMenuBar(MenuBar mb) { mb.add(getMenu(0)); mb.add(((TerminalMenuHandlerFull)term.getMenus()).getMenu(1)); mb.add(getMenu(1)); Menu pm = getPluginMenu(); if(pm != null) { mb.add(pm); } mb.add(((TerminalMenuHandlerFull)term.getMenus()).getMenu(3)); mb.add(getMenu(2)); mb.setHelpMenu(getMenu(3)); term.updateMenus(); } public void preparePopupMenu(PopupMenu popupmenu) { havePopupMenu = true; popupmenu.add(getMenu(0)); popupmenu.add(((TerminalMenuHandlerFull)term.getMenus()).getMenu(1)); popupmenu.add(getMenu(1)); Menu pm = getPluginMenu(); if(pm != null) { popupmenu.add(pm); } popupmenu.add(((TerminalMenuHandlerFull)term.getMenus()).getMenu(3)); popupmenu.add(getMenu(2)); popupmenu.addSeparator(); popupmenu.add(getMenu(3)); update(); } Dialog settingsDialog2 = null; Choice choiceCipherC2S, choiceCipherS2C, choiceMacC2S, choiceMacS2C, choiceCompC2S, choiceCompS2C, choiceProto, choiceHKey; Checkbox cbX11, cbIdHost, cbKeyNoise, cbLocHst, cbAlive, cbForcPty; TextField textDisp, textMtu, textAlive, textRealAddr, textLocHost; String[] hktypes, ciphers, macs; static final String[] compc2s = { "none", "low", "medium", "high" }; static final String[] comps2c = { "none", "medium" }; static final String[] lvl2comp = { "none", "low", "low", "low", "medium", "medium", "medium", "high", "high", "high" }; static final String[] protos = { "auto", "ssh2", "ssh1" }; static final int[] comp2lvl = { 0, 2, 6, 9 }; public final void sshSettingsDialog2() { if(settingsDialog2 == null) { ciphers = SSH2ListUtil.arrayFromList(SSHPropertyHandler.ciphAlgsSort); macs = SSH2ListUtil.arrayFromList(SSHPropertyHandler.macAlgs); hktypes = SSH2ListUtil.arrayFromList(SSHPropertyHandler.hostKeyAlgs); settingsDialog2 = new Dialog(parent, "MindTerm - SSH Preferences", true); Label lbl; Button okBut, cancBut; ItemListener il; AWTGridBagContainer grid = new AWTGridBagContainer(settingsDialog2); lbl = new Label("Protocol:"); grid.add(lbl, 0, 1); choiceProto = AWTConvenience.newChoice(protos); choiceProto.addItemListener(il = new Actions(ACT_UPDATE2)); grid.add(choiceProto, 0, 1); lbl = new Label("Host key type:"); grid.add(lbl, 0, 2); choiceHKey = AWTConvenience.newChoice(hktypes); grid.add(choiceHKey, 0, 1); grid.getConstraints().insets = new Insets(16, 4, 0, 4); lbl = new Label("Transport prefs."); grid.add(lbl, 1, 2); lbl = new Label("Client to Server:"); grid.add(lbl, 1, 2); lbl = new Label("Server to Client:"); grid.add(lbl, 1, 2); grid.getConstraints().insets = new Insets(4, 4, 0, 4); lbl = new Label("Cipher:"); grid.add(lbl, 2, 2); lbl = new Label("Mac:"); grid.add(lbl, 3, 2); lbl = new Label("Compression:"); grid.add(lbl, 4, 2); choiceCipherC2S = AWTConvenience.newChoice(ciphers); choiceCipherS2C = AWTConvenience.newChoice(ciphers); choiceMacC2S = AWTConvenience.newChoice(macs); choiceMacS2C = AWTConvenience.newChoice(macs); choiceCompC2S = AWTConvenience.newChoice(compc2s); choiceCompS2C = AWTConvenience.newChoice(comps2c); choiceCipherC2S.insert("any standard", 0); choiceCipherS2C.insert("any standard", 0); choiceMacC2S.insert("any standard", 0); choiceMacS2C.insert("any standard", 0); choiceHKey.insert("any standard", 0); grid.add(choiceCipherC2S, 2, 2); grid.add(choiceMacC2S, 3, 2); grid.add(choiceCompC2S, 4, 2); grid.add(choiceCipherS2C, 2, 2); grid.add(choiceMacS2C, 3, 2); grid.add(choiceCompS2C, 4, 2); choiceCipherC2S.addItemListener(new Actions(ACT_CIPHER)); choiceMacC2S.addItemListener(new Actions(ACT_MAC)); choiceCompC2S.addItemListener(new Actions(ACT_COMP)); grid.getConstraints().insets = new Insets(16, 4, 0, 4); cbX11 = new Checkbox("X11 forward"); cbX11.addItemListener(il); grid.add(cbX11, 5, 2); lbl = new Label("Local display:"); grid.add(lbl, 5, 2); textDisp = new TextField("", 12); grid.add(textDisp, 5, 2); grid.getConstraints().insets = new Insets(4, 4, 0, 4); cbAlive = new Checkbox("Send keep-alive"); cbAlive.addItemListener(il); grid.add(cbAlive, 6, 2); lbl = new Label("Interval (seconds):"); grid.add(lbl, 6, 2); textAlive = new TextField("", 12); grid.add(textAlive, 6, 2); cbLocHst = new Checkbox("Bind address"); cbLocHst.addItemListener(il); grid.add(cbLocHst, 7, 2); lbl = new Label("Local address:"); grid.add(lbl, 7, 2); textLocHost = new TextField("", 12); grid.add(textLocHost, 7, 2); cbIdHost = new Checkbox("Strict host verify"); grid.add(cbIdHost, 8, 2); cbForcPty = new Checkbox("Allocate PTY"); grid.add(cbForcPty, 8, 2); cbKeyNoise = new Checkbox("Key timing noise"); grid.add(cbKeyNoise, 8, 2); grid.getConstraints().insets = new Insets(0, 0, 0, 0); grid.getConstraints().anchor = GridBagConstraints.CENTER; Panel bp = new Panel(new FlowLayout()); bp.add(okBut = new Button("OK")); okBut.addActionListener(new Actions(ACT_SETTINGS2)); bp.add(cancBut = new Button("Cancel")); cancBut.addActionListener(new AWTConvenience.CloseAction(settingsDialog2)); grid.add(bp, 9, GridBagConstraints.REMAINDER); settingsDialog2.addWindowListener(new AWTConvenience.CloseAdapter(cancBut)); AWTConvenience.setBackgroundOfChildren(settingsDialog2); AWTConvenience.setKeyListenerOfChildren(settingsDialog2, new AWTConvenience.OKCancelAdapter(okBut, cancBut), null); settingsDialog2.setResizable(true); settingsDialog2.pack(); } choiceHKey.select(0); choiceCipherC2S.select(0); choiceCipherS2C.select(0); choiceMacC2S.select(0); choiceMacS2C.select(0); choiceProto.select(client.propsHandler.getProperty("protocol")); choiceHKey.select(client.propsHandler.getProperty("server-host-key-algorithms")); choiceCipherC2S.select(client.propsHandler.getProperty("enc-algorithms-cli2srv")); choiceCipherS2C.select(client.propsHandler.getProperty("enc-algorithms-srv2cli")); choiceMacC2S.select(client.propsHandler.getProperty("mac-algorithms-cli2srv")); choiceMacS2C.select(client.propsHandler.getProperty("mac-algorithms-srv2cli"));// String c2sComp = client.propsHandler.getProperty("comp-algorithms-cli2srv"); int compLevel = client.propsHandler.getCompressionLevel(); choiceCompC2S.select(lvl2comp[compLevel]); String s2cComp = client.propsHandler.getProperty("comp-algorithms-srv2cli"); if("none".equals(s2cComp)) { choiceCompS2C.select("none"); } else { choiceCompS2C.select("medium"); } textDisp.setText(client.propsHandler.getProperty("display")); textAlive.setText(client.propsHandler.getProperty("alive")); cbX11.setState(Boolean.valueOf(client.propsHandler.getProperty("x11fwd")).booleanValue()); cbAlive.setState(!client.propsHandler.getProperty("alive").equals("0")); cbLocHst.setState(!client.propsHandler.getProperty("localhst").equals("0.0.0.0")); textLocHost.setEnabled(false); cbIdHost.setState(Boolean.valueOf(client.propsHandler.getProperty("stricthostid")).booleanValue()); cbKeyNoise.setState(Boolean.valueOf(client.propsHandler.getProperty("key-timing-noise")).booleanValue()); cbForcPty.setState(Boolean.valueOf(client.propsHandler.getProperty("forcpty")).booleanValue()); updateChoices2(); AWTConvenience.placeDialog(settingsDialog2); settingsDialog2.setVisible(true); } void updateChoices2() { boolean isOpen = client.isOpened(); boolean isSSH2 = !("ssh1".equals(choiceProto.getSelectedItem())) || (isOpen && client.isSSH2); choiceProto.setEnabled(!isOpen); choiceHKey.setEnabled(isSSH2 && !isOpen); cbX11.setEnabled(!isOpen); cbIdHost.setEnabled(!isOpen); cbForcPty.setEnabled(!isOpen); boolean incompat = false; if(client.transport != null) { incompat = client.transport.incompatibleCantReKey; } boolean tpset = !isOpen || (isSSH2 && isOpen && !incompat); choiceCipherS2C.setEnabled(tpset && isSSH2); choiceMacS2C.setEnabled(tpset && isSSH2); choiceCompS2C.setEnabled(tpset && isSSH2); choiceCipherC2S.setEnabled(tpset); choiceMacC2S.setEnabled(tpset && isSSH2); choiceCompC2S.setEnabled(tpset); updateCheckedText(cbAlive, textAlive, "alive"); updateCheckedText(cbLocHst, textLocHost, "localhst"); updateCheckedText(cbX11, textDisp, "display"); } private void updateCheckedText(Checkbox cb, TextField text, String propName) { if(!text.isEnabled()) { if(cb.getState()) { text.setText(client.propsHandler.getProperty(propName)); } else { text.setText(client.propsHandler.getDefaultProperty(propName)); } } text.setEnabled(cb.isEnabled() && cb.getState()); if(!text.isEnabled()) { text.setText(client.propsHandler.getDefaultProperty(propName)); } } Dialog settingsDialog = null; Choice choiceAuthTyp; Checkbox cbSaveAlias; TextField textSrv, textPort, textUser, textAlias, textId, textAuthList, textPwd; FileDialog idFileFD; Button idFileBut, advButton; CardLayout authCL; Panel authCP; public final static String[] authtyp = { "password", "publickey", "securid", "cryptocard", "tis", "kbd-interact", "custom list..." }; public final void sshSettingsDialog() { if(settingsDialog == null) { settingsDialog = new Dialog(parent, "MindTerm - New Server", true); Label lbl; Button okBut, cancBut; ItemListener il; AWTGridBagContainer grid = new AWTGridBagContainer(settingsDialog); lbl = new Label("Server:"); grid.add(lbl, 0, 2); textSrv = new TextField("", 12); grid.add(textSrv, 0, 3); lbl = new Label("Port:"); grid.add(lbl, 0, 1); textPort = new TextField("", 4); grid.add(textPort, 0, 1); lbl = new Label("Username:"); grid.add(lbl, 1, 2); textUser = new TextField("", 12); grid.add(textUser, 1, 3); cbSaveAlias = new Checkbox("Save as alias"); cbSaveAlias.addItemListener(il = new Actions(ACT_UPDATE)); grid.add(cbSaveAlias, 1, 3); lbl = new Label("Authentication:"); grid.add(lbl, 2, 3); choiceAuthTyp = AWTConvenience.newChoice(authtyp); grid.add(choiceAuthTyp, 2, 2); choiceAuthTyp.addItemListener(il); textAlias = new TextField("", 8); grid.add(textAlias, 2, 2); grid.add(getAuthPanel(), 3, GridBagConstraints.REMAINDER); Panel bp = new Panel(new FlowLayout(FlowLayout.RIGHT)); Button prxBut = new Button("Use Proxy..."); prxBut.addActionListener(new Actions(ACT_PROXY)); bp.add(prxBut); advButton = new Button("Preferences..."); advButton.addActionListener(new Actions(ACT_PREFS)); bp.add(advButton); bp.add(new Panel()); // Spacing bp.add(okBut = new Button("Connect")); okBut.addActionListener(new Actions(ACT_CONNECT)); bp.add(cancBut = new Button("Cancel")); cancBut.addActionListener(new AWTConvenience.CloseAction(settingsDialog)); grid.getConstraints().anchor = GridBagConstraints.EAST; grid.add(bp, 4, GridBagConstraints.REMAINDER); settingsDialog.addWindowListener(new AWTConvenience.CloseAdapter(cancBut)); AWTConvenience.setBackgroundOfChildren(settingsDialog); AWTConvenience.setKeyListenerOfChildren(settingsDialog, new AWTConvenience.OKCancelAdapter(okBut, cancBut), null); settingsDialog.setResizable(true); settingsDialog.pack(); } client.propsHandler.clearServerSetting(); textPort.setText(client.propsHandler.getProperty("port")); textUser.setText(client.propsHandler.getProperty("username")); cbSaveAlias.setState(false); String at = client.propsHandler.getProperty("authtyp"); if(at.indexOf(',') == -1) { choiceAuthTyp.select(at); } else { choiceAuthTyp.select("custom list..."); textAuthList.setText(at); } textId.setText(client.propsHandler.getProperty("idfile")); textPwd.setText(""); updateChoices(); AWTConvenience.placeDialog(settingsDialog); if(textSrv.isEnabled()) textSrv.requestFocus(); else textUser.requestFocus(); settingsDialog.setVisible(true); } private Panel getAuthPanel() { authCP = new Panel(); authCP.setLayout(authCL = new CardLayout()); Panel p; p = new Panel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.add(new Label("Password:")); p.add(textPwd = new TextField("", 16)); textPwd.setEchoChar('*'); authCP.add(p, "password"); p = new Panel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.add(new Label("Method list:")); p.add(textAuthList = new TextField("", 24)); authCP.add(p, "custom list..."); p = new Panel(new FlowLayout(FlowLayout.LEFT, 0, 0)); p.add(new Label("Identity:")); p.add(textId = new TextField("", 20)); p.add(new Panel()); // Spacing p.add(idFileBut = new Button("Browse...")); idFileBut.addActionListener(new Actions(ACT_IDFILE)); authCP.add(p, "publickey");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -