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

📄 configdialog.java

📁 jxta_src_2.41b jxta 2.41b 最新版源码 from www.jxta.org
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            passwd.setText("");            vpasswd.setText("");        }                /**         *  {@inheritDoc}         **/        public void actionPerformed(ActionEvent e) {            if (e.getSource() == file) {                FileDialog getFile = new FileDialog(ConfigDialog.this, "Select Root Certificate File", FileDialog.LOAD);                                getFile.setDirectory(System.getProperty("user.home"));                                getFile.setVisible(true);                                String inDir = getFile.getDirectory();                String theFile = getFile.getFile();                                if ((null != inDir) && (null != theFile)) {                    String fullPath = inDir + theFile;                                        certFile.setText(fullPath);                                        // XXX 20030520 bondolo@jxta.org We could actually read the                    // cert here and fill in the principal name.                }            }        }    }            /**     *  Manages Log4J options     **/    final static class DebugPanel extends BorderPanelGBL {                private final Choice debugLevel;                public DebugPanel(String  dftDebugLevel) {                        super("Logging Settings");                        debugLevel = new Choice();            debugLevel.addItem("fatal");            debugLevel.addItem("error");            debugLevel.addItem("warn");            debugLevel.addItem("info");            debugLevel.addItem("debug");            debugLevel.addItem("user default");            debugLevel.select(dftDebugLevel);                        GridBagConstraints c1 = new GridBagConstraints();                        c1.gridx = 0;            c1.gridy = 0;            c1.anchor = GridBagConstraints.LINE_START;            c1.fill = GridBagConstraints.NONE;            add(new Label("Trace Level"), c1);                        c1.gridx++;            c1.anchor = GridBagConstraints.LINE_END;            add(debugLevel, c1);        }                public String getDebugLevel() {            return debugLevel.getSelectedItem();        }    }            /**     *  Manages Service Enabling     **/    final static class EnablingPanel extends BorderPanelGBL {                private final Checkbox isRelay;        private final Checkbox isRendezvous;        private final Checkbox isJxmeProxy;                EnablingPanel(boolean actAsRelay, boolean actAsRendezvous, boolean actAsJxmeProxy) {            super("Services Settings");                        isRelay = new Checkbox("Act as a Relay", null, actAsRelay);            isRendezvous = new Checkbox("Act as a Rendezvous", null, actAsRendezvous);            isJxmeProxy = new Checkbox("Act as a JXME proxy", null, actAsJxmeProxy);                        add(isRelay, stdConstr);            add(isRendezvous, stdConstr);            add(isJxmeProxy, stdConstr);        }    }            /**     *  Manages Rendezvous service options     **/    final static class RdvPanel extends BorderPanelGBL {                private final Checkbox useOnlySeeds;        private final HostListPanel seeds;        private final HostListPanel seeding;                RdvPanel(boolean onlySeeds) {            super("Rendezvous Settings");                        useOnlySeeds = new Checkbox("Use only configured seed rendezvous", null, onlySeeds);            seeds = new HostListPanel("Seeds", "Rendezvous seed peers", true, false);            seeding = new HostListPanel("Seeding", "Rendezvous seeding URIs", true, false);                        GridBagConstraints c1 = new GridBagConstraints();                        c1.gridx = 0;            c1.gridy = 0;            c1.anchor = GridBagConstraints.LINE_START;            add(useOnlySeeds, c1);                        c1.gridy++;            c1.weightx = 1.0;            c1.fill = GridBagConstraints.HORIZONTAL;            c1.anchor = GridBagConstraints.LINE_START;            add(seeds, c1);                        c1.gridy++;            add(seeding, c1);        }    }            /**     *  Manages relay service parameters     **/    final static class RelayPanel extends BorderPanelGBL implements ItemListener {                private final Checkbox useRelay;        private final Checkbox useOnlySeeds;        private final HostListPanel seeds;        private final HostListPanel seeding;                public RelayPanel(boolean useARelay, boolean onlySeeds) {                        super("Relay Settings");                        useRelay = new Checkbox("Use a relay", null, useARelay);            useOnlySeeds = new Checkbox("Use only configured seed relays", null, onlySeeds);            useOnlySeeds.setEnabled(useARelay);            seeds = new HostListPanel("Seeds", "Relay seed peers", useARelay, false);            seeding = new HostListPanel("Seeding", "Relay seeding URIs", useARelay, false);                        GridBagConstraints c1 = new GridBagConstraints();                        c1.gridx = 0;            c1.gridy = 0;            c1.anchor = GridBagConstraints.LINE_START;            add(useRelay, c1);            useRelay.addItemListener(this);                        c1.gridx++;            c1.anchor = GridBagConstraints.LINE_END;            add(useOnlySeeds, c1);                        c1.gridy++;            c1.gridx = 0;            c1.gridwidth = 2;            c1.weightx = 1.0;            c1.fill = GridBagConstraints.HORIZONTAL;            c1.anchor = GridBagConstraints.LINE_START;            add(seeds, c1);                        c1.gridy++;            add(seeding, c1);        }                /**         *  {@inheritDoc}         **/        public void itemStateChanged(ItemEvent e) {            seeds.setEnabled(useRelay.getState());            seeding.setEnabled(useRelay.getState());            useOnlySeeds.setEnabled(useRelay.getState());        }    }        private final PlatformConfig configAdv;        private final Label helpLabel;    private final IdPanel idPanel;    private final DebugPanel debugPanel;    private final EnablingPanel enablingPanel;    private final IPTptPanel tcpPanel;    private final IPTptPanel httpPanel;    private final RdvPanel rdvPanel;    private final RelayPanel relayPanel;        private final Button ok;    private final Button cancel;    private final PagesPanel pages = new PagesPanel();        boolean done = false;    boolean canceled = false;        String tcpMulticastAddr;    int tcpMulticastPort;    int tcpMulticastLength;        public ConfigDialog(PlatformConfig configAdv) throws ConfiguratorException {        super("JXTA Configurator");                this.configAdv = configAdv;                // Identity settings        String peerName = configAdv.getName();                if ((null == peerName) || (0 == peerName.trim().length())) {            peerName = "";        }                // Security settings        boolean needSecurityConfig = true;                // If security is already in place, then the security info is not shown.        XMLElement param = (XMLElement) configAdv.getServiceParam(PeerGroup.membershipClassID);                if (param != null) {            Advertisement adv = null;                        try {                adv = AdvertisementFactory.newAdvertisement(param);            } catch (NoSuchElementException notAnAdv) {                ; // that's ok.            } catch (IllegalArgumentException badAdv) {                ; // that's ok.            }                        if (adv instanceof PSEConfigAdv) {                PSEConfigAdv pseConfig = (PSEConfigAdv) adv;                                // no certificate? That means we need to make one.                needSecurityConfig = (null == pseConfig.getCertificate());            }        }                // Logging settings        String dftDebugLevel = configAdv.getDebugLevel();                // JXME Proxy Settings        boolean isJxmeProxy = false;                try {            param = (XMLElement) configAdv.getServiceParam(PeerGroup.proxyClassID);                        if (param != null && !param.getChildren("isOff").hasMoreElements()) {                isJxmeProxy = true;            }        } catch (Exception nobigdeal) {            nobigdeal.printStackTrace();        }                int index;                // TCP Settings        boolean tcpEnabled;        boolean clientDefaultT;        boolean serverDefaultT;        String defaultInterfaceAddressT;        String defaultPortT;        String defaultServerNameT;        String defaultServerPortT;        boolean multicastEnabledT;        boolean noPublicAddressesT;                try {            param = (XMLElement) configAdv.getServiceParam(PeerGroup.tcpProtoClassID);                        tcpEnabled = param.getChildren("isOff").hasMoreElements() ? false : true;                        Enumeration tcpChilds = param.getChildren(TransportAdvertisement.getAdvertisementType());                        // get the TransportAdv from either TransportAdv or tcpAdv            if (tcpChilds.hasMoreElements()) {                param = (XMLElement) tcpChilds.nextElement();            } else {                throw new IllegalStateException("Missing TCP Advertisment");            }                        TCPAdv tcpAdv = (TCPAdv) AdvertisementFactory.newAdvertisement(param);                        clientDefaultT = tcpAdv.isClientEnabled();            serverDefaultT = tcpAdv.isServerEnabled();                        String configModeT = tcpAdv.getConfigMode();                        defaultInterfaceAddressT = tcpAdv.getInterfaceAddress();                        if ((null == defaultInterfaceAddressT) || (0 == defaultInterfaceAddressT.trim().length())) {                defaultInterfaceAddressT = null;            }                        defaultPortT = Integer.toString(tcpAdv.getPort());            if ((defaultPortT == null) || (0 == defaultPortT.trim().length())) {                defaultPortT = "9701";            }                        defaultServerNameT = tcpAdv.getServer();                        if ((null == defaultServerNameT) || (0 == defaultServerNameT.trim().length())) {                defaultServerNameT = "";            }                        defaultServerPortT = "9701";                        if (defaultServerNameT != null && (index = defaultServerNameT.lastIndexOf(":")) != -1) {                if ((0 == index) || (index == defaultServerNameT.length())) {                    throw new IllegalArgumentException("Bad TCP server name . Cannot proceed.");                }                defaultServerPortT = defaultServerNameT.substring(index + 1);                defaultServerNameT = defaultServerNameT.substring(0, index);            } else {                defaultServerNameT = "";                defaultServerPortT = "9701";            }                        noPublicAddressesT = tcpAdv.getPublicAddressOnly();            multicastEnabledT = tcpAdv.getMulticastState();                        // we will just pass these to save.            tcpMulticastAddr = tcpAdv.getMulticastAddr();            tcpMulticastPort  = tcpAdv.getMulticastPort();            tcpMulticastLength = tcpAdv.getMulticastSize();        } catch (Exception failure) {            throw new ConfiguratorException("Broken Platform Config. Cannot proceed.", failure);        }                // HTTP Settings        boolean httpEnabled;        boolean clientDefaultH;        boolean serverDefaultH;        String defaultInterfaceAddressH;        String defaultPortH;        String defaultServerNameH;        String defaultServerPortH;        boolean noPublicAddressesH;                try {            param = (XMLElement) configAdv.getServiceParam(PeerGroup.httpProtoClassID);                        httpEnabled = param.getChildren("isOff").hasMoreElements() ? false : true;                        Enumeration httpChilds = param.getChildren(TransportAdvertisement.getAdvertisementType());                        // get the TransportAdv from either TransportAdv            if (httpChilds.hasMoreElements()) {                param = (XMLElement) httpChilds.nextElement();            } else {                throw new IllegalStateException("Missing HTTP Advertisment");            }                        // Read-in the adv as it is now.            HTTPAdv httpAdv = (HTTPAdv) AdvertisementFactory.newAdvertisement(param);                        clientDefaultH = httpAdv.isClientEnabled();            serverDefaultH = httpAdv.isServerEnabled();                        String configModeH = httpAdv.getConfigMode();                        defaultInterfaceAddressH = httpAdv.getInterfaceAddress();                        if ((null == defaultInterfaceAddressH) || (0 == defaultInterfaceAddressH.trim().length())) {                defaultInterfaceAddressH = null;            }                        defaultPortH = Integer.toString(httpAdv.getPort());                        if ((defaultPortH == null) || (0 == defaultPortH.trim().length())) {                defaultPortH = "9700";            }                        defaultServerNameH = httpAdv.getServer();                        if ((null != defaultServerNameH) && (0 == defaultServerNameH.trim().length())) {                defaultServerNameH = "";            }                        defaultServerPortH = "9700";

⌨️ 快捷键说明

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