Ejemplo n.º 1
0
 public static DialogUI create(
     RaplaContext context,
     Component owner,
     boolean modal,
     String title,
     String text,
     String[] options)
     throws RaplaException {
   DialogUI dlg = create(context, owner, modal, new JPanel(), options);
   dlg.createMessagePanel(text);
   dlg.setTitle(title);
   return dlg;
 }
Ejemplo n.º 2
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());
   }
 }
Ejemplo n.º 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();
        }
      }
    }
  }