Beispiel #1
0
    public void actionPerformed(ActionEvent e) {
      Object source = e.getSource();
      if (source == exit) {
        RaplaFrame mainComponent = (RaplaFrame) getMainComponent();
        mainComponent.close();
      } else if (source == templateEdit) {
        if (isTemplateEdit()) {
          getModification().setTemplate(null);
        } else {
          try {
            TemplateEdit edit = templateEditFactory.create();
            edit.startTemplateEdit();
            updateTemplateText();
          } catch (Exception ex) {
            dialogUiFactory.showException(ex, new SwingPopupContext(getMainComponent(), null));
          }
        }
      } else {
        CommandHistory commandHistory = getModification().getCommandHistory();
        try {
          if (source == redo) {
            commandHistory.redo();
          }
          if (source == undo) {
            commandHistory.undo();
          }

        } catch (Exception ex) {
          dialogUiFactory.showException(ex, new SwingPopupContext(getMainComponent(), null));
        }
      }
    }
Beispiel #2
0
 public void historyChanged() {
   CommandHistory history = getModification().getCommandHistory();
   redo.setEnabled(history.canRedo());
   undo.setEnabled(history.canUndo());
   redo.setText(getString("redo") + ": " + history.getRedoText());
   undo.setText(getString("undo") + ": " + history.getUndoText());
 }
Beispiel #3
0
    public void actionPerformed(ActionEvent evt) {
      try {
        ui.mapToObjects();
        bSaving = true;

        // object which is processed by EditComponent
        List<T> saveObjects = ui.getObjects();
        Collection<T> entities = new ArrayList<T>();
        entities.addAll(saveObjects);
        boolean canUndo = true;
        Boolean isReservation = null;
        for (T obj : saveObjects) {
          if (obj instanceof Preferences || obj instanceof DynamicType || obj instanceof Category) {
            canUndo = false;
          }
          if (obj instanceof Reservation) {
            if (isReservation == null) {
              isReservation = true;
            }
          } else {
            isReservation = false;
          }
        }
        if (isReservation != null && isReservation) {
          @SuppressWarnings("unchecked")
          Collection<Reservation> castToReservation = (Collection<Reservation>) saveObjects;
          Component mainComponent = getMainComponent();
          PopupContext popupContext = createPopupContext(mainComponent, null);
          ReservationController reservationController = getReservationController();
          if (!reservationController.save(castToReservation, popupContext)) {
            return;
          }
        } else if (canUndo) {
          @SuppressWarnings({"unchecked", "rawtypes"})
          SaveUndo<T> saveCommand = new SaveUndo(getClientFacade(), getI18n(), entities, originals);
          CommandHistory commandHistory = getModification().getCommandHistory();
          commandHistory.storeAndExecute(saveCommand);
        } else {
          getModification().storeObjects(saveObjects.toArray(new Entity[] {}));
        }

        getPrivateEditDialog().removeEditDialog(EditDialog.this);
        dlg.close();
      } catch (IllegalAnnotationException ex) {
        showWarning(ex.getMessage(), dlg);
      } catch (RaplaException ex) {
        showException(ex, dlg);
      }
    }