📄 appmenubar.java
字号:
x.setPort(po); x.setProtocol(pr); x.setDirectory(d); //bookmarks current.add(x); marks.put(x.getLabel(), x); x.addActionListener(this); } //*** Where changes to the file menu are made (iniitalization done here too) public void resetFileItems() { file.removeAll(); file.add(ftpCon); file.add(sftpCon); file.add(smbCon); file.add(nfsCon); file.add(webdavCon); file.addSeparator(); file.add(close); file.addSeparator(); file.addSeparator(); file.add(localFtpCon); file.add(localSftpCon); file.add(localSmbCon); file.add(localNfsCon); //file.add(localWebdavCon); -> not yet file.addSeparator(); file.add(closeLocalCon); file.addSeparator(); //*** ADDITION OF THE REMEMBERED CONNECTIONS boolean connectionsExist = false; try { //*** get the information on the last connections cons = new String[jftp.CAPACITY][jftp.CONNECTION_DATA_LENGTH]; cons = LastConnections.readFromFile(jftp.CAPACITY); String protocol; String htmp; String utmp; String conNumber; String usingLocal = new String(""); Integer conNumberInt; //lastConData = new String(""); //*** for(int i = 0; i < jftp.CAPACITY; i++) { if(!(cons[i][0].equals("null"))) { protocol = cons[i][0]; htmp = cons[i][1]; utmp = cons[i][2]; int j = 3; while(!(cons[i][j].equals(LastConnections.SENTINEL))) { j++; } //usingLocal is always last piece of data! usingLocal = cons[i][j - 1]; if(usingLocal.equals("true")) { usingLocal = "(in local tab)"; } else { usingLocal = ""; } //lastConnections[i] = new JMenuItem(cons[i]); conNumberInt = new Integer(i + 1); conNumber = conNumberInt.toString(); //lastConData[i] = new String(conNumber + " " + protocol + ": Hostname: " + htmp + "; Username: " + utmp); lastConData[i] = new String(conNumber + " " + protocol + ": " + htmp + " " + usingLocal); lastConnections[i] = new JMenuItem(lastConData[i]); lastConnections[i].addActionListener(this); connectionsExist = true; //*** code repetition: maybe getting these tokens //*** should be in a separate private method //file.add(protocol + ": Hostname: " + htmp + "; Username: " + utmp); file.add(lastConnections[i]); } } } catch(Exception ex) { Log.debug("WARNING: Remembered connections broken."); ex.printStackTrace(); } if(connectionsExist) { file.addSeparator(); } file.add(exit); setMnemonics(); } //resetFileItems public void actionPerformed(ActionEvent e) { if(e.getSource() == proxy) { //ProxyChooser p = JFtp.statusP.jftp.addToDesktop("Proxy Settings", new ProxyChooser(), 500, 110); } if(e.getSource() == add) { Log.out("add called"); AddBookmarks a = new AddBookmarks(JFtp.statusP.jftp); a.update(); } else if(e.getSource() == webdavCon) { WebdavHostChooser hc = new WebdavHostChooser(); hc.toFront(); hc.update(); } else if(e.getSource() == insomniac) { //InsomniacClient c = new InsomniacClient(); //JFtp.statusP.jftp.addToDesktop("Insomniac client", c, 500, 350); JFtp.statusP.jftp.switchToInsomniacUI(); } else if((e.getSource() == localFtpCon) && (!jftp.uiBlocked)) { HostChooser hc = new HostChooser(null, true); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == localSmbCon) && (!jftp.uiBlocked)) { SmbHostChooser hc = new SmbHostChooser(null, true); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == localSftpCon) && (!jftp.uiBlocked)) { SftpHostChooser hc = new SftpHostChooser(null, true); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == localNfsCon) && (!jftp.uiBlocked)) { NfsHostChooser hc = new NfsHostChooser(null, true); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == localWebdavCon) && (!jftp.uiBlocked)) { WebdavHostChooser hc = new WebdavHostChooser(null, true); hc.toFront(); //hc.setModal(true); hc.update(); } else if(e.getSource() == closeLocalCon) { JFtp.statusP.jftp.closeCurrentLocalTab(); } else if(e.getSource() == clear) { jftp.clearLog(); } else if(e.getSource() == spider) { jftp.addToDesktop("Http recursive download", new HttpSpider(jftp.localDir.getPath() + "_httpdownload/"), 440, 250); } else if(e.getSource() == hp) { HttpBrowser h = new HttpBrowser("http://j-ftp.sourceforge.net"); JFtp.desktop.add(h, new Integer(Integer.MAX_VALUE - 10)); } else if(e.getSource() == raw) { RawConnection c = new RawConnection(); } else if(e.getSource() == readme) { show(Settings.readme); } else if(e.getSource() == changelog) { show(Settings.changelog); } else if(e.getSource() == todo) { show(Settings.todo); } else if(e.getSource() == exit) { jftp.windowClosing(null); // handles everything } else if(e.getSource() == close) { JFtp.statusP.jftp.closeCurrentTab(); /* jftp.safeDisconnect(); FilesystemConnection con = new FilesystemConnection(); jftp.remoteDir.setCon(con); con.addConnectionListener((ConnectionListener)jftp.remoteDir); if(!con.chdir("/")) con.chdir("C:\\"); */ } else if((e.getSource() == ftpCon) && (!jftp.uiBlocked)) { //jftp.safeDisconnect(); HostChooser hc = new HostChooser(); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == smbCon) && (!jftp.uiBlocked)) { //jftp.safeDisconnect(); SmbHostChooser hc = new SmbHostChooser(); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == sftpCon) && (!jftp.uiBlocked)) { //jftp.safeDisconnect(); SftpHostChooser hc = new SftpHostChooser(); hc.toFront(); //hc.setModal(true); hc.update(); } else if((e.getSource() == nfsCon) && (!jftp.uiBlocked)) { // jftp.safeDisconnect(); NfsHostChooser hc = new NfsHostChooser(); hc.toFront(); //hc.setModal(true); hc.update(); } else if(e.getSource() == resuming) { boolean res = resuming.getState(); Settings.enableResuming = res; Settings.setProperty("jftp.enableResuming", res); ask.setEnabled(Settings.enableResuming); Settings.save(); } else if(e.getSource() == stdback) { Settings.setProperty("jftp.useBackground", stdback.getState()); Settings.save(); JFtp.statusP.jftp.fireUpdate(); } else if(e.getSource() == rssDisabled) { Settings.setProperty("jftp.enableRSS", rssDisabled.getState()); Settings.save(); JFtp.statusP.jftp.fireUpdate(); } else if(e.getSource() == debug) { Settings.setProperty("jftp.enableDebug", debug.getState()); Settings.save(); } else if(e.getSource() == disableLog) { Settings.setProperty("jftp.disableLog", disableLog.getState()); Settings.save(); } else if(e.getSource() == smbThreads) { Settings.setProperty("jftp.enableSmbMultiThreading", smbThreads.getState()); Settings.save(); } else if(e.getSource() == sftpThreads) { Settings.setProperty("jftp.enableSftpMultiThreading", sftpThreads.getState()); Settings.save(); } else if(e.getSource() == ask) { Settings.askToResume = ask.getState(); } else if(e.getSource() == http) { HttpDownloader dl = new HttpDownloader(); jftp.addToDesktop("Http download", dl, 480, 100); jftp.setLocation(dl.hashCode(), 100, 150); } else if(e.getSource() == fadeMenu) { Settings.setProperty("jftp.gui.enableStatusAnimation", fadeMenu.getState()); Settings.save(); } else if(e.getSource() == askToDelete) { Settings.setProperty("jftp.gui.askToDelete", askToDelete.getState()); Settings.save(); } //***MY ADDITIONS (***how can I make this flexible enough to //*** easily add > 5 connections?) else if((e.getSource() == lastConnections[0]) && (!jftp.uiBlocked)) { connectionSelected(0); } else if((e.getSource() == lastConnections[1]) && (!jftp.uiBlocked)) { connectionSelected(1); } else if((e.getSource() == lastConnections[2]) && (!jftp.uiBlocked)) { connectionSelected(2); } else if((e.getSource() == lastConnections[3]) && (!jftp.uiBlocked)) { connectionSelected(3); } else if((e.getSource() == lastConnections[4]) && (!jftp.uiBlocked)) { connectionSelected(4); } else if((e.getSource() == lastConnections[5]) && (!jftp.uiBlocked)) { connectionSelected(5); } else if((e.getSource() == lastConnections[6]) && (!jftp.uiBlocked))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -