Пример #1
0
 private void duplicateCurrentSelection(KeyEvent e) {
   ISelection selection = treeViewer.getSelection();
   if (selection.isEmpty()) {
     return; // nothing to do
   }
   PlanStructureModifier modifier = getStructureModifier();
   PlanTransferable source = modifier.getTransferable(selection);
   PlanTransferable copy = (PlanTransferable) modifier.copy(source);
   IStructureLocation location =
       modifier.getInsertionLocation(copy, selection, InsertionSemantics.AFTER);
   AbstractOperation op = new PlanAddOperation(copy, modifier, location);
   op.setLabel("Duplicate element(s)");
   WidgetUtils.execute(op, getUndoContext(), e.widget, getSite());
 }
Пример #2
0
    public ListPropertyAction(
        final String propertyName,
        final Editable[] editable,
        final Method getter,
        final Method setter,
        final Object newValue,
        final Layers layers,
        final Layer parentLayer) {
      super(
          propertyName
              + " for "
              + (editable.length > 1 ? "multiple items" : editable[0].getName()));
      _setter = setter;
      _layers = layers;
      _parentLayer = parentLayer;
      _subjects = editable;
      _newValue = newValue;

      try {
        _oldValue = getter.invoke(editable[0], (Object[]) null);
      } catch (final Exception e) {
        CorePlugin.logError(
            Status.ERROR,
            "Failed to retrieve old value for:"
                + "Multiple items starting with:"
                + _subjects[0].getName(),
            e);
      }

      if (CorePlugin.getUndoContext() != null) {
        super.addContext(CorePlugin.getUndoContext());
      }
    }
Пример #3
0
 public UndoableAction(
     final String propertyName,
     final Editable[] editable,
     final SubjectAction action,
     final Layers layers,
     final Layer parentLayer) {
   super(
       propertyName
           + " for "
           + (editable.length > 1 ? "multiple items" : editable[0].getName()));
   _layers = layers;
   _action = action;
   _parentLayer = parentLayer;
   _subjects = editable;
   if (CorePlugin.getUndoContext() != null) {
     super.addContext(CorePlugin.getUndoContext());
   }
 }
Пример #4
0
 @Override
 public void addContext(IUndoContext context) {
   super.addContext(context);
 }