/** * creates a new channel, if the channel exists it is removed (this method doubles as a * removeChannel) * * @param name the name of the channel */ public void newChannel(String name, boolean pass) { if (channels.containsKey(name)) { channels.remove(name); cboChannels.removeItem(name); } else { channels.put(name, new Boolean(pass)); cboChannels.addItem(name); } }
private static Hashtable<String, String> getManifestAttributes(Manifest manifest) { Hashtable<String, String> h = new Hashtable<String, String>(); try { Attributes attrs = manifest.getMainAttributes(); Iterator it = attrs.keySet().iterator(); while (it.hasNext()) { String key = it.next().toString(); h.put(key, attrs.getValue(key)); } } catch (Exception ignore) { } return h; }
/** cleans up a connection by removing all user from all maintained lists */ public void close() { error("Connection to server was lost"); admin = false; users.clear(); afks.clear(); ignores.clear(); admins.clear(); channels.clear(); cboChannels.removeAllItems(); updateList(); }
/** * Class constructor; creates a new Installer object, displays a JFrame introducing the program, * allows the user to select an install directory, and copies files from the jar into the * directory. */ public Installer(String args[]) { // Inputs are --install-dir INSTALL_DIR for (int k = 0; k < args.length; k = k + 2) { switch (args[k]) { case "--install-dir": directory = new File(args[k + 1]); System.out.println(directory); break; case "--port": port = Integer.parseInt(args[k + 1]); break; } } cp = new Stream(); // Find the installer program so we can get to the files. installer = getInstallerProgramFile(); String name = installer.getName(); programName = (name.substring(0, name.indexOf("-"))).toUpperCase(); // Get the installation information thisJava = System.getProperty("java.version"); thisJavaBits = System.getProperty("sun.arch.data.model") + " bits"; // Find the ImageIO Tools and get the version String javaHome = System.getProperty("java.home"); File extDir = new File(javaHome); extDir = new File(extDir, "lib"); extDir = new File(extDir, "ext"); File clib = getFile(extDir, "clibwrapper_jiio", ".jar"); File jai = getFile(extDir, "jai_imageio", ".jar"); imageIOTools = (clib != null) && clib.exists() && (jai != null) && jai.exists(); if (imageIOTools) { Hashtable<String, String> jaiManifest = getManifestAttributes(jai); imageIOVersion = jaiManifest.get("Implementation-Version"); } // Get the CTP.jar parameters Hashtable<String, String> manifest = getJarManifestAttributes("/CTP/libraries/CTP.jar"); programDate = manifest.get("Date"); buildJava = manifest.get("Java-Version"); // Get the util.jar parameters Hashtable<String, String> utilManifest = getJarManifestAttributes("/CTP/libraries/util.jar"); utilJava = utilManifest.get("Java-Version"); // Get the MIRC.jar parameters (if the plugin is present) Hashtable<String, String> mircManifest = getJarManifestAttributes("/CTP/libraries/MIRC.jar"); if (mircManifest != null) { mircJava = mircManifest.get("Java-Version"); mircDate = mircManifest.get("Date"); mircVersion = mircManifest.get("Version"); } // Set up the installation information for display if (imageIOVersion.equals("")) { imageIOVersion = "<b><font color=\"red\">not installed</font></b>"; } else if (imageIOVersion.startsWith("1.0")) { imageIOVersion = "<b><font color=\"red\">" + imageIOVersion + "</font></b>"; } if (thisJavaBits.startsWith("64")) { thisJavaBits = "<b><font color=\"red\">" + thisJavaBits + "</font></b>"; } boolean javaOK = (thisJava.compareTo(buildJava) >= 0); javaOK &= (thisJava.compareTo(utilJava) >= 0); javaOK &= (thisJava.compareTo(mircJava) >= 0); if (!javaOK) { thisJava = "<b><font color=\"red\">" + thisJava + "</font></b>"; } if (directory == null) exit(); // Point to the parent of the directory in which to install the program. // so the copy process works correctly for directory trees. // // If the user has selected a directory named "CTP", // then assume that this is the directory in which // to install the program. // // If the directory is not CTP, see if it is called "RSNA" and contains // the Launcher program, in which case we can assume that it is an // installation that was done with Bill Weadock's all-in-one installer for Windows. // // If neither of those cases is true, then this is already the parent of the // directory in which to install the program if (directory.getName().equals("CTP")) { directory = directory.getParentFile(); } else if (directory.getName().equals("RSNA") && (new File(directory, "Launcher.jar")).exists()) { suppressFirstPathElement = true; } // Cleanup old releases cleanup(directory); // Get a port for the server. if (port < 0) { if (checkServer(-port, false)) { System.err.println( "CTP appears to be running.\nPlease stop CTP and run the installer again."); System.exit(0); } } // Now install the files and report the results. int count = unpackZipFile(installer, "CTP", directory.getAbsolutePath(), suppressFirstPathElement); if (count > 0) { // Create the service installer batch files. updateWindowsServiceInstaller(); updateLinuxServiceInstaller(); // If this was a new installation, set up the config file and set the port installConfigFile(port); // Make any necessary changes in the config file to reflect schema evolution fixConfigSchema(); System.out.println("Installation complete."); System.out.println(programName + " has been installed successfully."); System.out.println(count + " files were installed."); } else { System.err.println("Installation failed."); System.err.println(programName + " could not be fully installed."); } if (!programName.equals("ISN") && startRunner(new File(directory, "CTP"))) System.exit(0); }
static { actions = new Hashtable(); actions.put("backspace",BACKSPACE); actions.put("backspace-word",BACKSPACE_WORD); actions.put("delete",DELETE); actions.put("delete-word",DELETE_WORD); actions.put("end",END); actions.put("select-end",SELECT_END); actions.put("document-end",DOCUMENT_END); actions.put("select-doc-end",SELECT_DOC_END); actions.put("insert-break",INSERT_BREAK); actions.put("insert-tab",INSERT_TAB); actions.put("home",HOME); actions.put("select-home",SELECT_HOME); actions.put("document-home",DOCUMENT_HOME); actions.put("select-doc-home",SELECT_DOC_HOME); actions.put("next-char",NEXT_CHAR); actions.put("next-line",NEXT_LINE); actions.put("next-page",NEXT_PAGE); actions.put("next-word",NEXT_WORD); actions.put("select-next-char",SELECT_NEXT_CHAR); actions.put("select-next-line",SELECT_NEXT_LINE); actions.put("select-next-page",SELECT_NEXT_PAGE); actions.put("select-next-word",SELECT_NEXT_WORD); actions.put("overwrite",OVERWRITE); actions.put("prev-char",PREV_CHAR); actions.put("prev-line",PREV_LINE); actions.put("prev-page",PREV_PAGE); actions.put("prev-word",PREV_WORD); actions.put("select-prev-char",SELECT_PREV_CHAR); actions.put("select-prev-line",SELECT_PREV_LINE); actions.put("select-prev-page",SELECT_PREV_PAGE); actions.put("select-prev-word",SELECT_PREV_WORD); actions.put("repeat",REPEAT); actions.put("toggle-rect",TOGGLE_RECT); actions.put("insert-char",INSERT_CHAR); }
/** * Returns an enumeration of all available actions. */ public static Enumeration getActions() { return actions.keys(); }
/** * Returns a named text area action. * @param name The action name */ public static ActionListener getAction(String name) { return (ActionListener)actions.get(name); }
/** * Saves all configuration settings when the "Save" button is pressed. * * @param e the <tt>ActionEvent</tt> that notified us of the button action */ public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); if (button.equals(saveButton)) { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); // If the field is of type fixed the user could not change it, // so we skip it. if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) continue; JComponent c = uiFieldsTable.get(formField.getName()); if (c instanceof JTextComponent) { String newValue = ((JTextComponent) c).getText(); if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { // extract values StringTokenizer idTokens = new StringTokenizer(newValue, System.getProperty("line.separator")); while (idTokens.hasMoreTokens()) { formField.addValue(idTokens.nextToken()); } } else formField.addValue(newValue); } else if (c instanceof AbstractButton) { boolean isSelected = ((AbstractButton) c).isSelected(); formField.addValue(isSelected); } else if (c instanceof JComboBox) { Object selectedObject = ((JComboBox) c).getSelectedItem(); formField.addValue(selectedObject); } else if (c instanceof JPanel) { Component[] components = c.getComponents(); for (Component comp : components) { if (!(comp instanceof JCheckBox)) continue; JCheckBox checkBox = (JCheckBox) comp; formField.addValue(checkBox.getText()); } } } new Thread() { @Override public void run() { try { configForm.submit(); } catch (Exception e) { new ErrorDialog( ChatRoomConfigurationWindow.this, GuiActivator.getResources().getI18NString("service.gui.ERROR"), GuiActivator.getResources() .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION_SUBMIT_FAILED"), e) .showDialog(); } } }.start(); } this.dispose(); }
/** Loads the configuration form obtained from the chat room. */ protected void loadConfigurationForm() { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); Iterator<?> values = formField.getValues(); Iterator<String> options = formField.getOptions(); JComponent field; JLabel label = new JLabel("", JLabel.RIGHT); if (formField.getLabel() != null) label.setText(formField.getLabel() + ": "); String fieldType = formField.getType(); if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) { // Create a check box when the field is of type boolean. field = new SIPCommCheckBox(formField.getLabel()); label.setText(""); if (values.hasNext()) { ((JCheckBox) field).setSelected((Boolean) values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { field = new JLabel(); if (values.hasNext()) { String value = values.next().toString(); ((JLabel) field).setText(value); field.setFont(new Font(null, Font.ITALIC, 10)); field.setForeground(Color.GRAY); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) { field = new TransparentPanel(new GridLayout(0, 1)); field.setBorder(BorderFactory.createLineBorder(Color.GRAY)); Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>(); while (options.hasNext()) { Object option = options.next(); JCheckBox checkBox = new SIPCommCheckBox(option.toString()); field.add(checkBox); optionCheckBoxes.put(option, checkBox); } while (values.hasNext()) { Object value = values.next(); (optionCheckBoxes.get(value)).setSelected(true); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) { field = new JComboBox(); while (options.hasNext()) { ((JComboBox) field).addItem(options.next()); } if (values.hasNext()) { ((JComboBox) field).setSelectedItem(values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) { field = new JEditorPane(); if (values.hasNext()) { String value = values.next().toString(); ((JEditorPane) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE) || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) { field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) { field = new JPasswordField(); if (values.hasNext()) { String value = values.next().toString(); ((JPasswordField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { StringBuffer buff = new StringBuffer(); while (values.hasNext()) { String value = values.next().toString(); buff.append(value); if (values.hasNext()) buff.append(System.getProperty("line.separator")); } field = new JTextArea(buff.toString()); } else { if (label.getText() == null) continue; field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } // If the field is not fixed (i.e. could be changed) we would like // to save it in a list in order to use it later when user saves // the configuration data. if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { uiFieldsTable.put(formField.getName(), field); } JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2)); fieldPanel.setOpaque(false); if (!(field instanceof JLabel)) fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); fieldPanel.add(label); fieldPanel.add(field); this.mainPanel.add(fieldPanel); } }