示例#1
0
 public void actionPerformed(ActionEvent arg0) {
   try {
     DialogUI dlg;
     JPanel content = new JPanel();
     GridLayout layout = new GridLayout();
     layout.setColumns(3);
     layout.setRows(2);
     content.setLayout(layout);
     content.add(new JLabel(getString("new_mail")));
     content.add(emailField);
     sendCode.setText(getString("send_code"));
     content.add(sendCode);
     sendCode.setAction(new EmailChangeActionB(emailField, codeField, validate));
     content.add(new JLabel(getString("code_message3") + "  "));
     codeField.setEnabled(false);
     content.add(codeField);
     validate.setText(getString("code_validate"));
     content.add(validate);
     addCopyPaste(emailField);
     addCopyPaste(codeField);
     dlg =
         DialogUI.create(
             getContext(),
             getComponent(),
             true,
             content,
             new String[] {getString("save"), getString("abort")});
     validate.setAction(new EmailChangeActionA(dlg));
     validate.setEnabled(false);
     dlg.setDefault(0);
     dlg.setTitle("Email");
     dlg.getButton(0).setAction(new EmailChangeActionC(getUserModule().getUser(), dlg));
     dlg.getButton(0).setEnabled(false);
     dlg.start();
   } catch (RaplaException ex) {
     showException(ex, getMainComponent());
   }
 }
示例#2
0
      public void actionPerformed(ActionEvent arg0) {
        try {
          User user = getUserModule().getUser();
          boolean correct;
          try {
            int wert = Integer.parseInt(codeField.getText());
            correct = wert == (Math.abs(user.getEmail().hashCode()));
          } catch (NumberFormatException er) {
            correct = false;
          }
          if (correct) {
            dlg.getButton(0).setEnabled(true);
          } else {
            JOptionPane.showMessageDialog(
                getMainComponent(),
                getString("code_error1"),
                getString("error"),
                JOptionPane.ERROR_MESSAGE);
          }

        } catch (RaplaException ex) {
          showException(ex, getMainComponent());
        }
      }
示例#3
0
  public void start(
      Collection<T> editObjects,
      String title,
      PopupContext popupContext,
      boolean isNew,
      EditController.EditCallback<List<T>> callback)
      throws RaplaException {
    // sets for every object in this array an edit item in the logfile
    originals = new ArrayList<T>();
    Map<T, T> persistant = getModification().getPersistant(editObjects);
    for (T entity : editObjects) {

      getLogger().debug("Editing Object: " + entity);
      @SuppressWarnings("unchecked")
      Entity<T> mementable = persistant.get(entity);
      if (mementable != null) {
        if (originals == null) {
          throw new RaplaException("You cannot edit persistant and new entities in one operation");
        }
        originals.add(mementable.clone());
      } else {
        if (originals != null && !originals.isEmpty()) {
          throw new RaplaException("You cannot edit persistant and new entities in one operation");
        }
        originals = null;
      }
    }

    List<T> toEdit = new ArrayList<T>(editObjects);
    ui.setObjects(toEdit);

    JComponent editComponent = (JComponent) ui.getComponent();
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(editComponent, BorderLayout.CENTER);
    editComponent.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    boolean modal = false;
    dlg =
        DialogUI.create(
            getContext(),
            SwingPopupContext.extractParent(popupContext),
            modal,
            panel,
            new String[] {getString("save"), getString("cancel")});

    final AbortAction action = new AbortAction(callback);
    dlg.setAbortAction(action);
    dlg.getButton(0).setAction(new SaveAction(callback));
    dlg.getButton(1).setAction(action);
    dlg.getButton(0).setIcon(getIcon("icon.save"));
    dlg.getButton(1).setIcon(getIcon("icon.cancel"));
    dlg.setTitle(getI18n().format("edit.format", title));
    getUpdateModule().addModificationListener(this);
    dlg.addWindowListener(new DisposingTool(this));
    dlg.start();
    {
      getPrivateEditDialog().addEditDialog(this);
      // to avoid java compiler error
      EditComponent test = ui;
      if (test instanceof CategoryEditUI) {
        if (isNew) {
          ((CategoryEditUI) test).processCreateNew();
        }
      }
    }
  }