appmenubar.java

来自「java ftp 操作代码,程序可以直接运行」· Java 代码 · 共 1,273 行 · 第 1/3 页

JAVA
1,273
字号
    {        BookmarkItem x = new BookmarkItem(h);        x.setUserdata(u, p);        if(l.trim().startsWith("t"))        {            x.setLocal(true);        }        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);        }        else 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() == 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() == shell)        {        	UIUtils.runCommand("/bin/bash");        }        else if(e.getSource() == loadAudio)        {            try            {                JFileChooser f = new JFileChooser();                f.showOpenDialog(jftp);                File file = f.getSelectedFile();                Player p = new Player(new FileInputStream(file));                p.play();            }            catch(Exception ex)            {                ex.printStackTrace();                Log.debug("Error: (" + ex + ")");            }        }        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() == useTableLayout)        {            boolean res = useTableLayout.getState();            Settings.setProperty("jftp.useJTableLayout", res);            Settings.save();                        JOptionPane.showMessageDialog(this, "Please restart JFtp to have the UI changed.");        }        else if(e.getSource() == useNewIcons)        {            boolean res = useNewIcons.getState();            Settings.setProperty("jftp.gui.look.newIcons", res);            Settings.save();                        JOptionPane.showMessageDialog(this, "Please restart JFtp to have the UI changed.");        }        else if(e.getSource() == hideHidden)        {            boolean res = hideHidden.getState();            Settings.setProperty("jftp.hideHiddenDotNames", res);            Settings.save();                        JFtp.localUpdate();        }        else if(e.getSource() == nl)        {            boolean res = nl.getState();            Settings.showNewlineOption = res;        }        else if(e.getSource() == stdback)        {            Settings.setProperty("jftp.useBackground", stdback.getState());            Settings.save();            JFtp.statusP.jftp.fireUpdate();        }        else if(e.getSource() == sshKeys)        {            Settings.setProperty("jftp.useSshKeyVerification",                                 sshKeys.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() == loadRss)        {            String what = JOptionPane.showInputDialog("Enter URL", "http://");            if(what == null)            {                return;            }            Settings.setProperty("jftp.customRSSFeed", what);            Settings.save();            JFtp.statusP.jftp.feeder.switchTo(what);        }        else if(e.getSource() == loadSlash)        {            Settings.setProperty("jftp.customRSSFeed",                                 "http://slashdot.org/rss/slashdot.rss");            Settings.save();            JFtp.statusP.jftp.feeder.switchTo("http://slashdot.org/rss/slashdot.rss");        }        else if(e.getSource() == loadCNN1)        {            Settings.setProperty("jftp.customRSSFeed",                                 "http://rss.cnn.com/rss/cnn_topstories.rss");            Settings.save();            JFtp.statusP.jftp.feeder.switchTo("http://rss.cnn.com/rss/cnn_topstories.rss");        }        else if(e.getSource() == loadCNN2)        {            Settings.setProperty("jftp.customRSSFeed",                                 "http://rss.cnn.com/rss/cnn_world.rss");            Settings.save();            JFtp.statusP.jftp.feeder.switchTo("http://rss.cnn.com/rss/cnn_world.rss");        }        else if(e.getSource() == loadCNN3)        {            Settings.setProperty("jftp.customRSSFeed",                                 "http://rss.cnn.com/rss/cnn_tech.rss");            Settings.save();            JFtp.statusP.jftp.feeder.switchTo("http://rss.cnn.com/rss/cnn_tech.rss");        }        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();        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?