Search in sources :

Example 1 with SFTP

use of com.jcraft.jcterm.Terminal.SFTP in project narchy by automenta.

the class JCTermSwingFrame method getJMenuBar.

public JMenuBar getJMenuBar() {
    JMenuBar mb = new JMenuBar();
    JMenu m;
    JMenuItem mi;
    m = new JMenu("File");
    mi = new JMenuItem("Open SHELL Session...");
    mi.addActionListener(this);
    mi.setActionCommand("Open SHELL Session...");
    m.add(mi);
    mi = new JMenuItem("Open SFTP Session...");
    mi.addActionListener(this);
    mi.setActionCommand("Open SFTP Session...");
    m.add(mi);
    mi = new JMenuItem("Quit");
    mi.addActionListener(this);
    mi.setActionCommand("Quit");
    m.add(mi);
    mb.add(m);
    m = new JMenu("Proxy");
    mi = new JMenuItem("HTTP...");
    mi.addActionListener(this);
    mi.setActionCommand("HTTP...");
    m.add(mi);
    mi = new JMenuItem("SOCKS5...");
    mi.addActionListener(this);
    mi.setActionCommand("SOCKS5...");
    m.add(mi);
    mb.add(m);
    m = new JMenu("PortForwarding");
    mi = new JMenuItem("Local Port...");
    mi.addActionListener(this);
    mi.setActionCommand("Local Port...");
    m.add(mi);
    mi = new JMenuItem("Remote Port...");
    mi.addActionListener(this);
    mi.setActionCommand("Remote Port...");
    m.add(mi);
    mi = new JMenuItem("X11 Forwarding...");
    mi.addActionListener(this);
    mi.setActionCommand("X11 Forwarding...");
    m.add(mi);
    mb.add(m);
    m = new JMenu("Etc");
    mi = new JMenuItem("AntiAliasing");
    mi.addActionListener(this);
    mi.setActionCommand("AntiAliasing");
    m.add(mi);
    mi = new JMenuItem("Compression...");
    mi.addActionListener(this);
    mi.setActionCommand("Compression...");
    m.add(mi);
    JMenu mcolor = new JMenu("Color");
    final ActionListener mcolor_action = e -> setFgBg(e.getActionCommand());
    mcolor.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent me) {
            JMenu jm = (JMenu) me.getSource();
            String[] fg_bg = JCTermSwing.getCR().load(configName).fg_bg;
            for (int i = 0; i < fg_bg.length; i++) {
                String[] tmp = fg_bg[i].split(":");
                JMenuItem mi = new JMenuItem("ABC");
                mi.setForeground(JCTermSwing.toColor(tmp[0]));
                mi.setBackground(JCTermSwing.toColor(tmp[1]));
                mi.setActionCommand(fg_bg[i]);
                mi.addActionListener(mcolor_action);
                jm.add(mi);
            }
        }

        public void menuDeselected(MenuEvent me) {
            JMenu jm = (JMenu) me.getSource();
            jm.removeAll();
        }

        public void menuCanceled(MenuEvent arg) {
        }
    });
    m.add(mcolor);
    JMenu mfsize = new JMenu("Font size");
    final ActionListener mfsize_action = e -> {
        String _font_size = e.getActionCommand();
        try {
            setFontSize(Integer.parseInt(_font_size));
        } catch (NumberFormatException nfe) {
        }
    };
    mfsize.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent me) {
            JMenuItem mi;
            JMenu jm = (JMenu) me.getSource();
            int font_size = JCTermSwing.getCR().load(configName).font_size;
            mi = new JMenuItem("Smaller (" + (font_size - 1) + ')');
            mi.setActionCommand("" + (font_size - 1));
            mi.addActionListener(mfsize_action);
            jm.add(mi);
            mi = new JMenuItem("Larger (" + (font_size + 1) + ')');
            mi.setActionCommand("" + (font_size + 1));
            mi.addActionListener(mfsize_action);
            jm.add(mi);
        }

        public void menuDeselected(MenuEvent me) {
            JMenu jm = (JMenu) me.getSource();
            jm.removeAll();
        }

        public void menuCanceled(MenuEvent arg) {
        }
    });
    m.add(mfsize);
    mb.add(m);
    m = new JMenu("Help");
    mi = new JMenuItem("About...");
    mi.addActionListener(this);
    mi.setActionCommand("About...");
    m.add(mi);
    mb.add(m);
    return mb;
}
Also used : java.awt(java.awt) OutputStream(java.io.OutputStream) SHELL(com.jcraft.jcterm.Terminal.SHELL) SFTP(com.jcraft.jcterm.Terminal.SFTP) PipedInputStream(java.io.PipedInputStream) java.awt.event(java.awt.event) MenuEvent(javax.swing.event.MenuEvent) PipedOutputStream(java.io.PipedOutputStream) com.jcraft.jsch(com.jcraft.jsch) javax.swing(javax.swing) MenuListener(javax.swing.event.MenuListener) InputStream(java.io.InputStream) MenuListener(javax.swing.event.MenuListener) MenuEvent(javax.swing.event.MenuEvent)

Aggregations

SFTP (com.jcraft.jcterm.Terminal.SFTP)1 SHELL (com.jcraft.jcterm.Terminal.SHELL)1 com.jcraft.jsch (com.jcraft.jsch)1 java.awt (java.awt)1 java.awt.event (java.awt.event)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 javax.swing (javax.swing)1 MenuEvent (javax.swing.event.MenuEvent)1 MenuListener (javax.swing.event.MenuListener)1