Пример #1
0
  @Override
  protected void execute(IModelChangedEvent event, boolean undo) {
    Object[] elements = event.getChangedObjects();
    int type = event.getChangeType();
    String propertyName = event.getChangedProperty();
    IModelChangeProvider model = event.getChangeProvider();

    switch (type) {
      case IModelChangedEvent.INSERT:
        if (undo) executeRemove(model, elements);
        else executeAdd(model, elements);
        break;
      case IModelChangedEvent.REMOVE:
        if (undo) executeAdd(model, elements);
        else executeRemove(model, elements);
        break;
      case IModelChangedEvent.CHANGE:
        if (event instanceof AttributeChangedEvent) {
          executeAttributeChange((AttributeChangedEvent) event, undo);
        } else {
          if (undo)
            executeChange(elements[0], propertyName, event.getNewValue(), event.getOldValue());
          else executeChange(elements[0], propertyName, event.getOldValue(), event.getNewValue());
        }
    }
  }
Пример #2
0
 @Override
 public void modelChanged(IModelChangedEvent event) {
   if (event.getChangeType() == IModelChangedEvent.CHANGE) {
     Object changedObject = event.getChangedObjects()[0];
     if (changedObject instanceof IPluginObject) {
       IPluginObject obj = (IPluginObject) event.getChangedObjects()[0];
       // Ignore events from objects that are not yet in the model.
       if (!(obj instanceof IPluginBase) && obj.isInTheModel() == false) return;
     }
     if (changedObject instanceof IBuildObject) {
       IBuildObject obj = (IBuildObject) event.getChangedObjects()[0];
       // Ignore events from objects that are not yet in the model.
       if (obj.isInTheModel() == false) return;
     }
   }
   super.modelChanged(event);
 }