Пример #1
0
 /**
  * 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);
   }
 }
Пример #2
0
  private void updateParams(EDPCellData data) {
    paramComboBox.removeAllItems();
    paramKeys = data.getPlugin().getPrintfDescrs(!m_isCrawlRuleEditor);
    if (!m_isCrawlRuleEditor) {
      paramComboBox.addItem(STRING_LITERAL);
    }

    for (Iterator it = paramKeys.values().iterator(); it.hasNext(); ) {
      ConfigParamDescr descr = (ConfigParamDescr) it.next();
      int type = descr.getType();
      if (!m_isCrawlRuleEditor
          && (type == ConfigParamDescr.TYPE_SET || type == ConfigParamDescr.TYPE_RANGE)) continue;
      paramComboBox.addItem(descr);
    }
    paramComboBox.setEnabled(true);
    paramComboBox.setSelectedIndex(0);
    paramComboBox.setToolTipText("Select a parameter to insert into the format string");
    insertButton.setEnabled(true);
  }
Пример #3
0
 protected void updateCategoryChooser() {
   if (categoryChooser != null) {
     ArrayList<String> categories;
     categoryChooser.removeAllItems();
     categories = new ArrayList<String>(contribListing.getCategories(filter));
     //      for (int i = 0; i < categories.size(); i++) {
     //        System.out.println(i + " category: " + categories.get(i));
     //      }
     Collections.sort(categories);
     //    categories.add(0, ContributionManagerDialog.ANY_CATEGORY);
     boolean categoriesFound = false;
     categoryChooser.addItem(ContributionManagerDialog.ANY_CATEGORY);
     for (String s : categories) {
       categoryChooser.addItem(s);
       if (!s.equals(Contribution.UNKNOWN_CATEGORY)) {
         categoriesFound = true;
       }
     }
     categoryChooser.setVisible(categoriesFound);
   }
 }
Пример #4
0
  private void initMatches() {
    matchesKeys.put(STRING_LITERAL, "");
    matchesKeys.put("Any number", "[0-9]+");
    matchesKeys.put("Anything", ".*");
    matchesKeys.put("Start", "^");
    matchesKeys.put("End", "$");
    matchesKeys.put("Single path component", "[^/]+");

    for (Iterator it = matchesKeys.keySet().iterator(); it.hasNext(); ) {
      matchComboBox.addItem(it.next());
    }
  }
Пример #5
0
  public NewUser() {
    super("Adding New User");
    label1 = new JLabel("Name");
    label2 = new JLabel("Category");
    username = new JLabel("Username");
    password = new JLabel("Password");
    confirm = new JLabel("Re-enter Password");
    pass1 = new JPasswordField();
    pass2 = new JPasswordField();
    txtusername = new JTextField();
    name = new JTextField();
    combo1 = new JComboBox();
    button1 = new JButton("Ok", new ImageIcon("Icon/i16x16/ok.png"));
    button2 = new JButton("Cancel", new ImageIcon("Icon/i16x16/exit.png"));

    panel1 = new JPanel(new GridLayout(6, 2));
    panel1.add(label1);
    panel1.add(name);
    panel1.add(label2);
    panel1.add(combo1);
    panel1.add(username);
    panel1.add(txtusername);
    panel1.add(password);
    panel1.add(pass1);
    panel1.add(confirm);
    panel1.add(pass2);
    panel1.add(button1);
    panel1.add(button2);
    combo1.addItem("Manager");
    combo1.addItem("Booking Clerk");
    combo1.addItem("Supervisor");
    panel2 = new JPanel();
    panel2.add(panel1);
    getContentPane().add(panel2);
    setSize(350, 195);
    setVisible(true);
    setLocation((screen.width - 500) / 2, ((screen.height - 350) / 2));
    setResizable(false);
    name.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!(Character.isLetter(c)
                || (c == KeyEvent.VK_BACK_SPACE)
                || (c == KeyEvent.VK_SPACE)
                || (c == KeyEvent.VK_DELETE))) {

              getToolkit().beep();
              JOptionPane.showMessageDialog(
                  null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION);
              e.consume();
            }
          }
        });
    txtusername.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent e) {
            char c = e.getKeyChar();
            if (!(Character.isLetter(c)
                || (c == KeyEvent.VK_BACK_SPACE)
                || (c == KeyEvent.VK_SPACE)
                || (c == KeyEvent.VK_DELETE))) {

              getToolkit().beep();
              JOptionPane.showMessageDialog(
                  null, "Invalid Character", "ERROR", JOptionPane.DEFAULT_OPTION);
              e.consume();
            }
          }
        });
    button1.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent e) {

            if (name.getText() == null || name.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter name", "ERROR", JOptionPane.DEFAULT_OPTION);
              name.requestFocus();
              return;
            }
            if (txtusername.getText() == null || txtusername.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter username", "ERROR", JOptionPane.DEFAULT_OPTION);
              txtusername.requestFocus();
              return;
            }
            if (pass1.getText() == null || pass1.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Enter password", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass1.requestFocus();
              return;
            }
            if (pass2.getText() == null || pass2.getText().equals("")) {
              JOptionPane.showMessageDialog(
                  null, "Confirm your password", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass2.requestFocus();
              return;
            }
            if (!pass1.getText().equals(pass2.getText())) {
              JOptionPane.showMessageDialog(
                  null, "passwords do not match.", "ERROR", JOptionPane.DEFAULT_OPTION);
              pass2.requestFocus();
              return;
            }
            try {
              Statement statement = Connect.getConnection().createStatement();
              {
                String temp =
                    "INSERT INTO users (Name,Category,username, password) VALUES ('"
                        + name.getText()
                        + "', '"
                        + combo1.getSelectedItem()
                        + "', '"
                        + txtusername.getText()
                        + "', '"
                        + pass1.getText()
                        + "')";

                int result = statement.executeUpdate(temp);
                JOptionPane.showMessageDialog(
                    null, "User is succesfully added", "SUCCESS", JOptionPane.DEFAULT_OPTION);
                dispose();
              }

            } catch (Exception in) {
              in.printStackTrace();
            }
          }
        });
    button2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            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);
    }
  }