⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configuratorlistener.java

📁 jxta_src_2.41b jxta 2.41b 最新版源码 from www.jxta.org
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                    // XXX if there ever are other rdvs than tcp and http, this is the place to change                    // of course you didn't notice, the would require a more flexible handling of the model stuff                    if (addr.getScheme().equalsIgnoreCase(Protocol.TCP)) {                        tcpmodel.addElement(addr.getAuthority());                    } else {                        httpmodel.addElement(addr.getAuthority());                    }                }            } else {                rlyUsageEnabled.setSelected(false);                disable(((JPanel)(rlyPanel.getComponents()[0])).getComponents());                // make sure we can toggle settings after we disabled all components ;-)                enable(rlyUsageEnabled);                requestFocus(rlyUsageEnabled);            }                        //		tcpPublicPort = (JTextField) swix.find("id_tcppublicport");            //		httpPublicAddr = (JTextField) swix.find("id_httppublicaddress");            //		httpPublicPort = (JTextField) swix.find("id_httppublicport");            //		httpProxyAddr = (JTextField) swix.find("id_httpproxyaddress");            //		httpProxyPort = (JTextField) swix.find("id_httpproxyport");            //		tcpEnabled = (JCheckBox) swix.find("id_tcpenabled");            //		httpEnabled = (JCheckBox) swix.find("id_httpenabled");            //		httpManualEnabled = (JCheckBox) swix.find("id_httpmanualaddresses");            //		httpPublicEnabled = (JCheckBox) swix.find("id_httphaspublicaddress");            //		certFile = (JTextField) swix.find("id_certfile");                    } catch (Exception e) {            LOG.error("Could not retrieve existing configuration, aborting.", e);        }            }            /* (non-Javadoc)         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)         */    public void actionPerformed(ActionEvent e) {                // _TODO need to create constants for IDs & ACs        String command = e.getActionCommand();        if (("enableTCPPublicAddress").equals(command)) {            setPublicTcp();        } else if (("enableHTTPPublicAddress").equals(command)) {            setPublicHttp();        } else if (("enableHTTPProxy").equals(command)) {            setHttpProxy();        } else if (("enableTCPSettings").equals(command)) {            if (tcpEnabled.isSelected()) {                enable(((JPanel)(tcpPanel.getComponents()[0])).getComponents());                setPublicTcp();                addTcpTransport();            } else {                clearTcpTransports();            }        } else if (("AC_enableuserly").equals(command)) {            if (rlyUsageEnabled.isSelected()) {                enable(((JPanel)(rlyPanel.getComponents()[0])).getComponents());                setPublicHttp();                setHttpProxy();            } else {                disable(((JPanel)(rlyPanel.getComponents()[0])).getComponents());                // make sure we can toggle settings after we disabled all components ;-)                enable(rlyUsageEnabled);                requestFocus(rlyUsageEnabled);            }        } else if (("AC_enablerdvservice").equals(command)) {            if (rdvSvcEnabled.isSelected()) {                enable(((JPanel)(rdvSvcPanel.getComponents()[0])).getComponents());            } else {                disable(((JPanel)(rdvSvcPanel.getComponents()[0])).getComponents());                // make sure we can toggle settings after we disabled all components ;-)                enable(rdvSvcEnabled);                requestFocus(rdvSvcEnabled);            }        } else if (("AC_enablerlyservice").equals(command)) {            if (rlySvcEnabled.isSelected()) {                enable(((JPanel)(rlySvcPanel.getComponents()[0])).getComponents());            } else {                disable(((JPanel)(rlySvcPanel.getComponents()[0])).getComponents());                // make sure we can toggle settings after we disabled all components ;-)                enable(rlySvcEnabled);                requestFocus(rlySvcEnabled);            }        } else if (("AC_enableendpservice").equals(command)) {            if (endpSvcEnabled.isSelected()) {                enable(((JPanel)(endpSvcPanel.getComponents()[0])).getComponents());            } else {                disable(((JPanel)(endpSvcPanel.getComponents()[0])).getComponents());                // make sure we can toggle settings after we disabled all components ;-)                enable(endpSvcEnabled);                requestFocus(endpSvcEnabled);            }        } else if (("AC_enableproxyservice").equals(command)) {            if (proxySvcEnabled.isSelected()) {                enable(((JPanel)(proxySvcPanel.getComponents()[0])).getComponents());            } else {                disable(((JPanel)(proxySvcPanel.getComponents()[0])).getComponents());                // make sure we can toggle settings after we disabled all components ;-)                enable(proxySvcEnabled);                requestFocus(proxySvcEnabled);            }        } else if (("enableManualTcpAddress").equals(command)) {            JComboBox auto = (JComboBox)swix.find("id_tcpautoentry");            JTextField manual = (JTextField)swix.find("id_tcpmanualentry");            if (tcpManualEnabled.isSelected()) {                manual.setMinimumSize(auto.getMinimumSize());                manual.setPreferredSize(auto.getPreferredSize());                manual.setMaximumSize(auto.getMaximumSize());                show((Component)manual);                hide((Component)auto);            } else {                hide((Component)manual);                show((Component)auto);            }        } else if (("enableManualHttpAddress").equals(command)) {            JComboBox auto = (JComboBox)swix.find("id_httpautoentry");            JTextField manual = (JTextField)swix.find("id_httpmanualentry");            if (httpManualEnabled.isSelected()) {                manual.setMinimumSize(auto.getMinimumSize());                manual.setPreferredSize(auto.getPreferredSize());                manual.setMaximumSize(auto.getMaximumSize());                show((Component)manual);                hide((Component)auto);            } else {                hide((Component)manual);                show((Component)auto);            }        } else if (("enableHTTPSettings").equals(command)) {            if (httpEnabled.isSelected()) {                enable(((JPanel)(httpPanel.getComponents()[0])).getComponents());                setPublicHttp();                setHttpProxy();                addHttpTransport();            } else {                clearHttpTransports();            }        } else if (("enableManualProfile").equals(command)) {            // slightly different logic as we determine status depending on selection            // TODO problem is that this code heavily relies on the XML code in Configurator.xml            // in terms of component (panel) names etc.            JComboBox auto = (JComboBox)swix.find("id_peerprofilecombo");            JTextField manual = (JTextField)swix.find("id_manualpeerprofile");            if (profileManualEnabled.isSelected()) {                hide((Component)manual);                show((Component)auto);            } else {                manual.setMinimumSize(auto.getMinimumSize());                manual.setPreferredSize(auto.getPreferredSize());                manual.setMaximumSize(auto.getMaximumSize());                show((Component)manual);                hide((Component)auto);            }        } else if (("importCAFile").equals(command)) {            FileDialog getFile = new FileDialog( new JFrame(), "Select Root Certificate File", FileDialog.LOAD );            getFile.setDirectory( System.getProperty( "user.home" ) );            getFile.show();                        String inDir = getFile.getDirectory();            String theFile = getFile.getFile();                        if( (null != inDir) && (null != theFile) ) {                String fullPath = inDir + theFile;                certFile.setText( fullPath );            }        } else if (("downloadrdvrly").equals(command)) {            try {                SwingEngine swe = new SwingEngine();                JDialog ldr = (JDialog) swe.render(DLG_AUTOLOAD);                swe.setActionListener(ldr, new AutoLoaderListener(swe, swix));                                // TODO shall we make Default public to allow reflection?                // get rdv bootstrap address from Default class                // otherwise, we could simply make it a literal using SwiXml                // to (possibly even get localized) adresses for the bootstrap//				JTextField tf;//				Class clazz = Default.class;////				Field field;//				try {//					field = clazz.getField("RENDEZVOUS_BOOTSTRAP_ADDRESS");//					tf  = (JTextField) swe.find("id_rdvbootstrap");//					tf.setText(field.get(null).toString());//					field = clazz.getField("RELAY_BOOTSTRAP_ADDRESS");//					tf  = (JTextField) swe.find("id_rlybootstrap");//					tf.setText(field.get(null).toString());////					// TODO we should consider making this smaller//					// by addding proper reporting of the exceptions//				} catch (SecurityException se) {//					// TODO Auto-generated catch block//					se.printStackTrace();//				} catch (NoSuchFieldException nsfe) {//					// TODO Auto-generated catch block//					nsfe.printStackTrace();//				} catch (IllegalArgumentException iarge) {//					// TODO Auto-generated catch block//					iarge.printStackTrace();//				} catch (IllegalAccessException iacce) {//					// TODO Auto-generated catch block//					iacce.printStackTrace();//				}                                JTextField tf;                tf  = (JTextField) swe.find("id_rdvbootstrap");                // _TODO get rdv & rly addresses from somewhere else!                tf.setText("http://rdv.jxtahosts.net/cgi-bin/rendezvous.cgi?2");                tf  = (JTextField) swe.find("id_rlybootstrap");                tf.setText("http://rdv.jxtahosts.net/cgi-bin/relays.cgi?2");                                ldr.setVisible(true);                ldr.dispose();                swe = null;                            } catch (Exception ex) {                JOptionPane.showMessageDialog(swix.getRootComponent(),                    "Could not create dialog, please check log.",                    "Internal Error",                    JOptionPane.ERROR_MESSAGE);                if (LOG.isEnabledFor(Level.ERROR)) {                    LOG.error("Failed to create rdv/rly loader dialog", ex);                }            }        } else if (("advancedAction").equals(command)) {            if (advEnabled.isSelected()) {                insertAdvNodes();            } else {                removeAdvNodes();            }        } else if (("AC_addtcprdv").equals(command)) {            JList list = (JList) swix.find("id_cfgtcprdvlist");            DefaultListModel model = (DefaultListModel) list.getModel();            String addr, port;            addr = ((JTextField)swix.find("id_cfgtcprdvaddr")).getText();            port = ((JTextField)swix.find("id_cfgtcprdvport")).getText();            // TODO more serious address checking required.            if (!addr.equals("") && !port.equals("")) {                model.addElement(addr+":"+port);            }        } else if (("AC_deltcprdv").equals(command)) {            JList list = (JList) swix.find("id_cfgtcprdvlist");            DefaultListModel model = (DefaultListModel) list.getModel();            int i;            if ((i = list.getSelectedIndex()) >= 0) {                model.remove(i);            }        } else if (("AC_addhttprdv").equals(command)) {            JList list = (JList) swix.find("id_cfghttprdvlist");            DefaultListModel model = (DefaultListModel) list.getModel();            String addr, port;            addr = ((JTextField)swix.find("id_cfghttprdvaddr")).getText();            port = ((JTextField)swix.find("id_cfghttprdvport")).getText();            // TODO more serious address checking required.            if (!addr.equals("") && !port.equals("")) {                model.addElement(addr+":"+port);            }        } else if (("AC_delhttprdv").equals(command)) {            JList list = (JList) swix.find("id_cfghttprdvlist");            DefaultListModel model = (DefaultListModel) list.getModel();            int i;            if ((i = list.getSelectedIndex()) >= 0) {                model.remove(i);            }        } else if (("AC_addtcprly").equals(command)) {            JList list = (JList) swix.find("id_cfgtcprlylist");            DefaultListModel model = (DefaultListModel) list.getModel();            String addr, port;            addr = ((JTextField)swix.find("id_cfgtcprlyaddr")).getText();            port = ((JTextField)swix.find("id_cfgtcprlyport")).getText();            // TODO more serious address checking required.            if (!addr.equals("") && !port.equals("")) {                model.addElement(addr+":"+port);            }        } else if (("AC_deltcprly").equals(command)) {            JList list = (JList) swix.find("id_cfgtcprlylist");            DefaultListModel model = (DefaultListModel) list.getModel();            int i;            if ((i = list.getSelectedIndex()) >= 0) {                model.remove(i);            }        } else if (("AC_addhttprly").equals(command)) {            JList list = (JList) swix.find("id_cfghttprlylist");            DefaultListModel model = (DefaultListModel) list.getModel();            String addr, port;            addr = ((JTextField)swix.find("id_cfghttprlyaddr")).getText();            port = ((JTextField)swix.find("id_cfghttprlyport")).getText();            // TODO more serious address checking required.            if (!addr.equals("") && !port.equals("")) {                model.addElement(addr+":"+port);            }        } else if (("AC_delhttprly").equals(command)) {            JList list = (JList) swix.find("id_cfghttprlylist");            DefaultListModel model = (DefaultListModel) list.getModel();            int i;            if ((i = list.getSelectedIndex()) >= 0) {                model.remove(i);            }        } else if (("AC_addtcptransp").equals(command)) {            addTcpTransport();        } else if (("AC_deltcptransp").equals(command)) {            deleteTcpTransport();        } else if (("AC_addhttptransp").equals(command)) {            addHttpTransport();        } else if (("AC_OK").equals(command)) {            // Validate, save (propagate to ext:config) & leave on success            if (validate() && writeConfig()) {                JFrame cfg = (JFrame) swix.find("id_optionsframe");                cfg.dispatchEvent(new WindowEvent(cfg, WindowEvent.WINDOW_CLOSING));            }        } else if (("AC_CANCEL").equals(command)) {            // Discard & leave            JFrame cfg = (JFrame) swix.find("id_optionsframe");            cfg.dispatchEvent(new WindowEvent(cfg, WindowEvent.WINDOW_CLOSING));        }    }        /**     * @return     */    private boolean validate() {        boolean valid = false;                // _TODO This could be much more sophisticated!                // TODO do not forget about manual profiles        // (JComboBox)swix.find("id_peerprofilecombo")).getSelectedItem().toString());        

⌨️ 快捷键说明

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