public void userHasLogged(String user) {
   boolean isAnonymous = "".equals(StringUtils.parseName(user));
   String title =
       "Smack Debug Window -- "
           + (isAnonymous ? "" : StringUtils.parseBareAddress(user))
           + "@"
           + connection.getServiceName()
           + ":"
           + connection.getPort();
   title += "/" + StringUtils.parseResource(user);
   frame.setTitle(title);
 }
Exemple #2
0
  public boolean moveToGroup(String group) {
    String currentParent = Group.substractParentName(getName());
    if (group.equals(currentParent)) return false;

    // String oldName = getName();
    String newName;
    if (group.equals(nullString)) newName = Group.substractObjectName(getName());
    else newName = group + Constants.GROUP_SEPARATOR + Group.substractObjectName(getName());

    // object with new name already exists, add suffix // !!!
    Object obj;
    boolean renameNeeded = false;
    while ((obj = Group.getRoot().findObject(newName, true)) != null) {
      if (obj == this) // it's me :) already moved, fix data
      {
        name = newName;
        return true;
      } else {
        renameNeeded = true;
        newName = StringUtils.incrementName(newName, Constants.MOVE_SUFFIX);
      }
    }

    if (renameNeeded) return rename(newName);

    getParent().removeObject(Group.substractObjectName(getName()));
    setParent(null);
    Group.getRoot().addSubObject(newName, this, true);

    name = newName;
    unconditionalValidation();

    return true;
  }
Exemple #3
0
  public Flexible copyToGroup(String group) {

    String newName;
    if (group.equals(nullString)) newName = Group.substractObjectName(getName());
    else newName = group + Constants.GROUP_SEPARATOR + Group.substractObjectName(getName());

    // object with new name already exists, add suffix ///!!!
    while (Group.getRoot().findObject(newName, true) != null)
      newName = StringUtils.incrementName(newName, Constants.COPY_SUFFIX);

    Box grBox =
        new Box(
            newName,
            null,
            startVertex.getX(),
            startVertex.getY(),
            endVertex.getX(),
            endVertex.getY());
    grBox.setColor(getColor());
    Group.getRoot().addSubObject(newName, grBox, true);

    // ViewState view = ViewState.getInstance();
    // grBox.move(20 - view.getRx(), 20 - view.getRy());

    unconditionalValidation();
    return grBox;
  }
 public void validateDestinationScan(String scannedDestination) {
   if (StringUtils.isNullOrEmpty(scannedDestination)) {
     throw new ChippingManagerException(SEED_PLATE_DESTINATION);
   }
   // IS THIS A TRAY ?
   if (scannedDestination.length() != 4 || !StringUtils.isNumeric(scannedDestination)) {
     throw new ChippingManagerException(scannedDestination + " is not a valid Tray barcode");
   }
   if (isContainedInList(scannedDestination, destinationsList)) {
     throw new ChippingManagerException(DUPLICATE_DESTINATION_SCANNED);
   }
   // CHECK WITH DB THAT TRAY DOES NOT HAVE OTHER NON SORTED PROJECT ASSOCIATIONS
   if (seedChipperGUIController
       .getSeedChipperController()
       .isTrayUsedInOtherProjects(scannedDestination)) {
     throw new ChippingManagerException(TRAY_IN_MULTIPLE_PROJECTS);
   }
 }
Exemple #5
0
  public boolean rename(String newName) {
    String newObjName = Group.substractObjectName(newName);
    String oldObjName = Group.substractObjectName(getName());

    if (!oldObjName.equals(newObjName)) {
      getParent().removeObject(oldObjName);
      String fullName = StringUtils.replaceEnding(getName(), oldObjName, newObjName);
      name = fullName;
      getParent().addSubObject(newObjName, this);
    }

    // move if needed
    moveToGroup(Group.substractParentName(newName));

    return true;
  }
  private boolean checkFlagDatasetIncluded() {
    final String[] nodeNames = productSubsetDef.getNodeNames();
    final List<String> flagDsNameList = new ArrayList<String>(10);
    boolean flagDsInSubset = false;
    for (int i = 0; i < product.getNumBands(); i++) {
      Band band = product.getBandAt(i);
      if (band.getFlagCoding() != null) {
        flagDsNameList.add(band.getName());
        if (StringUtils.contains(nodeNames, band.getName())) {
          flagDsInSubset = true;
        }
        break;
      }
    }

    final int numFlagDs = flagDsNameList.size();
    boolean ok = true;
    if (numFlagDs > 0 && !flagDsInSubset) {
      int status =
          JOptionPane.showConfirmDialog(
              getJDialog(),
              "No flag dataset selected.\n\n"
                  + "If you do not include a flag dataset in the subset,\n"
                  + "you will not be able to create bitmask overlays.\n\n"
                  + "Do you wish to include the available flag dataset(s)\n"
                  + "in the current subset?\n",
              "No Flag Dataset Selected",
              JOptionPane.YES_NO_CANCEL_OPTION);
      if (status == JOptionPane.YES_OPTION) {
        productSubsetDef.addNodeNames(flagDsNameList.toArray(new String[numFlagDs]));
        ok = true;
      } else if (status == JOptionPane.NO_OPTION) {
        /* OK, no flag datasets wanted */
        ok = true;
      } else if (status == JOptionPane.CANCEL_OPTION) {
        ok = false;
      }
    }

    return ok;
  }
 private ProductNodeSubsetPane createAnnotationSubsetPane() {
   final MetadataElement metadataRoot = product.getMetadataRoot();
   final MetadataElement[] metadataElements = metadataRoot.getElements();
   final String[] metaNodes;
   if (metadataElements.length == 0) {
     return null;
   }
   // metadata elements must be added to includeAlways list
   // to ensure that they are selected if isIgnoreMetada is set to false
   if (givenProductSubsetDef != null && !givenProductSubsetDef.isIgnoreMetadata()) {
     metaNodes = new String[metadataElements.length];
     for (int i = 0; i < metadataElements.length; i++) {
       final MetadataElement metadataElement = metadataElements[i];
       metaNodes[i] = metadataElement.getName();
     }
   } else {
     metaNodes = new String[0];
   }
   final String[] includeNodes = StringUtils.addToArray(metaNodes, Product.HISTORY_ROOT_NAME);
   return new ProductNodeSubsetPane(metadataElements, includeNodes, true);
 }
    private void createUI() {

      ActionListener productNodeCheckListener =
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              updateUIState();
            }
          };

      checkers = new ArrayList<JCheckBox>(10);
      JPanel checkersPane = GridBagUtils.createPanel();
      setComponentName(checkersPane, "CheckersPane");

      GridBagConstraints gbc =
          GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=HORIZONTAL");
      for (int i = 0; i < productNodes.length; i++) {
        ProductNode productNode = (ProductNode) productNodes[i];

        String name = productNode.getName();
        JCheckBox productNodeCheck = new JCheckBox(name);
        productNodeCheck.setSelected(selected);
        productNodeCheck.setFont(SMALL_PLAIN_FONT);
        productNodeCheck.addActionListener(productNodeCheckListener);

        if (includeAlways != null && StringUtils.containsIgnoreCase(includeAlways, name)) {
          productNodeCheck.setSelected(true);
          productNodeCheck.setEnabled(false);
        } else if (givenProductSubsetDef != null) {
          productNodeCheck.setSelected(givenProductSubsetDef.containsNodeName(name));
        }
        checkers.add(productNodeCheck);

        String description = productNode.getDescription();
        JLabel productNodeLabel = new JLabel(description != null ? description : " ");
        productNodeLabel.setFont(SMALL_ITALIC_FONT);

        GridBagUtils.addToPanel(
            checkersPane, productNodeCheck, gbc, "weightx=0,gridx=0,gridy=" + i);
        GridBagUtils.addToPanel(
            checkersPane, productNodeLabel, gbc, "weightx=1,gridx=1,gridy=" + i);
      }
      // Add a last 'filler' row
      GridBagUtils.addToPanel(
          checkersPane,
          new JLabel(" "),
          gbc,
          "gridwidth=2,weightx=1,weighty=1,gridx=0,gridy=" + productNodes.length);

      ActionListener allCheckListener =
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              if (e.getSource() == allCheck) {
                checkAllProductNodes(true);
              } else if (e.getSource() == noneCheck) {
                checkAllProductNodes(false);
              }
              updateUIState();
            }
          };

      allCheck = new JCheckBox("Select all");
      allCheck.setName("selectAll");
      allCheck.setMnemonic('a');
      allCheck.addActionListener(allCheckListener);

      noneCheck = new JCheckBox("Select none");
      noneCheck.setName("SelectNone");
      noneCheck.setMnemonic('n');
      noneCheck.addActionListener(allCheckListener);

      JScrollPane scrollPane = new JScrollPane(checkersPane);
      scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

      JPanel buttonRow = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 4));
      buttonRow.add(allCheck);
      buttonRow.add(noneCheck);

      setLayout(new BorderLayout());
      add(scrollPane, BorderLayout.CENTER);
      add(buttonRow, BorderLayout.SOUTH);
      setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

      updateUIState();
    }
  /**
   * Installs the account defined in this wizard.
   *
   * @param userName the user name to sign in with
   * @param password the password to sign in with
   * @return the created <tt>ProtocolProviderService</tt> corresponding to the new account
   * @throws OperationFailedException if the operation didn't succeed
   */
  public ProtocolProviderService signin(final String userName, final String password)
      throws OperationFailedException {
    /*
     * If firstWizardPage is null we are requested sign-in from initial
     * account registration form we must init firstWizardPage in order to
     * init default values
     * Pawel: firstWizardPage is never null, and commitPage fails with no
     * user ID provided for simple account wizard. Now userName and password
     * are reentered here.
     */
    final AccountPanel accPanel = (AccountPanel) firstWizardPage.getSimpleForm();
    /*
     * XXX Swing is not thread safe! We've experienced deadlocks on OS X
     * upon invoking accPanel's setters. In order to address them, (1)
     * invoke accPanel's setters on the AWT event dispatching thread and (2)
     * do it only if absolutely necessary.
     */
    String accPanelUsername = accPanel.getUsername();
    boolean equals = false;
    final boolean rememberPassword = (password != null);

    if (StringUtils.isEquals(accPanelUsername, userName)) {
      char[] accPanelPasswordChars = accPanel.getPassword();
      char[] passwordChars = (password == null) ? null : password.toCharArray();

      if (accPanelPasswordChars == null)
        equals = ((passwordChars == null) || passwordChars.length == 0);
      else if (passwordChars == null) equals = (accPanelPasswordChars.length == 0);
      else equals = Arrays.equals(accPanelPasswordChars, passwordChars);
      if (equals) {
        boolean accPanelRememberPassword = accPanel.isRememberPassword();

        equals = (accPanelRememberPassword == rememberPassword);
      }
    }
    if (!equals) {
      try {
        if (SwingUtilities.isEventDispatchThread()) {
          accPanel.setUsername(userName);
          accPanel.setPassword(password);
          accPanel.setRememberPassword(rememberPassword);
        } else {
          SwingUtilities.invokeAndWait(
              new Runnable() {
                public void run() {
                  accPanel.setUsername(userName);
                  accPanel.setPassword(password);
                  accPanel.setRememberPassword(rememberPassword);
                }
              });
        }
      } catch (Exception e) {
        if (e instanceof OperationFailedException) {
          throw (OperationFailedException) e;
        } else {
          throw new OperationFailedException(
              "Failed to set username and password on " + accPanel.getClass().getName(),
              OperationFailedException.INTERNAL_ERROR,
              e);
        }
      }
    }

    if (!firstWizardPage.isCommitted()) firstWizardPage.commitPage();
    if (!firstWizardPage.isCommitted()) {
      throw new OperationFailedException(
          "Could not confirm data.", OperationFailedException.GENERAL_ERROR);
    }

    ProtocolProviderFactory factory = JabberAccRegWizzActivator.getJabberProtocolProviderFactory();

    return installAccount(
        factory,
        registration.getUserID(), // The user id may get changed.
        // Server part can be added in the
        // data commit.
        password);
  }
Exemple #10
0
  /** Creating the configuration form */
  private void init() {
    ResourceManagementService resources = LoggingUtilsActivator.getResourceService();

    enableCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE"));
    enableCheckBox.addActionListener(this);

    sipProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME"));
    sipProtocolCheckBox.addActionListener(this);

    jabberProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME"));
    jabberProtocolCheckBox.addActionListener(this);

    String rtpDescription =
        resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION");
    rtpProtocolCheckBox =
        new SIPCommCheckBox(
            resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP")
                + " "
                + rtpDescription);
    rtpProtocolCheckBox.addActionListener(this);
    rtpProtocolCheckBox.setToolTipText(rtpDescription);

    ice4jProtocolCheckBox =
        new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J"));
    ice4jProtocolCheckBox.addActionListener(this);

    JPanel mainPanel = new TransparentPanel();

    add(mainPanel, BorderLayout.NORTH);

    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    mainPanel.add(enableCheckBox, c);

    String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION");
    JLabel descriptionLabel = new JLabel(label);
    descriptionLabel.setToolTipText(label);
    enableCheckBox.setToolTipText(label);
    descriptionLabel.setForeground(Color.GRAY);
    descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8));
    c.gridy = 1;
    c.insets = new Insets(0, 25, 10, 0);
    mainPanel.add(descriptionLabel, c);

    final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1));

    loggersButtonPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL")));

    loggersButtonPanel.add(sipProtocolCheckBox);
    loggersButtonPanel.add(jabberProtocolCheckBox);
    loggersButtonPanel.add(rtpProtocolCheckBox);
    loggersButtonPanel.add(ice4jProtocolCheckBox);

    c.insets = new Insets(0, 20, 10, 0);
    c.gridy = 2;
    mainPanel.add(loggersButtonPanel, c);

    final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2));

    advancedPanel.setBorder(
        BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED")));

    fileCountField.getDocument().addDocumentListener(this);
    fileSizeField.getDocument().addDocumentListener(this);

    fileCountLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT"));
    advancedPanel.add(fileCountLabel);
    advancedPanel.add(fileCountField);
    fileSizeLabel =
        new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE"));
    advancedPanel.add(fileSizeLabel);
    advancedPanel.add(fileSizeField);

    c.gridy = 3;
    mainPanel.add(advancedPanel, c);

    archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON"));
    archiveButton.addActionListener(this);

    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.LINE_START;
    c.weightx = 0;
    c.gridx = 0;
    c.gridy = 4;
    mainPanel.add(archiveButton, c);

    if (!StringUtils.isNullOrEmpty(getUploadLocation())) {
      uploadLogsButton =
          new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON"));
      uploadLogsButton.addActionListener(this);

      c.insets = new Insets(10, 0, 0, 0);
      c.gridy = 5;
      mainPanel.add(uploadLogsButton, c);
    }
  }