@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());
        }
    }
  }
 private void handleModelEventChange(IModelChangedEvent event) {
   // Change event
   Object[] objects = event.getChangedObjects();
   IProductObject object = (IProductObject) objects[0];
   if (object == null) {
     // Ignore
   } else if ((object instanceof IProduct) && (event.getChangedProperty() == IProduct.P_ID)) {
     updateFieldEnablement();
   }
 }
  @Override
  public void modelChanged(IModelChangedEvent event) {
    if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
      fHeader = null;
      markStale();
      return;
    }

    if (getExportedPackageHeader().equals(event.getChangedProperty())) {
      refresh();
      // Bug 171896
      // Since the model sends a CHANGE event instead of
      // an INSERT event on the very first addition to the empty table
      // Selection should fire here to take this first insertion into account
      Object lastElement =
          fPackageViewer.getElementAt(fPackageViewer.getTable().getItemCount() - 1);
      if (lastElement != null) {
        fPackageViewer.setSelection(new StructuredSelection(lastElement));
      }

      return;
    }

    Object[] objects = event.getChangedObjects();
    for (Object changedObject : objects) {
      if (changedObject instanceof ExportPackageObject) {
        ExportPackageObject object = (ExportPackageObject) changedObject;
        switch (event.getChangeType()) {
          case IModelChangedEvent.INSERT:
            fPackageViewer.add(object);
            fPackageViewer.setSelection(new StructuredSelection(object), false);
            fPackageViewer.getTable().setFocus();
            break;
          case IModelChangedEvent.REMOVE:
            Table table = fPackageViewer.getTable();
            int index = table.getSelectionIndex();
            fPackageViewer.remove(object);
            table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1);
            break;
          default:
            fPackageViewer.refresh(object);
        }
      }
    }
  }
Example #4
0
  public void modelChanged(IModelChangedEvent e) {
    // No need to call super, handling world changed event here
    if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
      handleModelEventWorldChanged(e);
      return;
    }

    String prop = e.getChangedProperty();
    Object[] objects = e.getChangedObjects();
    if (prop == null || objects == null || !(objects[0] instanceof IProduct)) return;
    if (prop.equals(IProduct.P_UID)) {
      fIdEntry.setValue(e.getNewValue().toString(), true);
    } else if (prop.equals(IProduct.P_NAME)) {
      fNameEntry.setValue(e.getNewValue().toString(), true);
    } else if (prop.equals(IProduct.P_VERSION)) {
      fVersionEntry.setValue(e.getNewValue().toString(), true);
    } else if (prop.equals(IProduct.P_INCLUDE_LAUNCHERS)) {
      fLaunchersButton.setSelection(Boolean.valueOf(e.getNewValue().toString()).booleanValue());
    }
  }
Example #5
0
  public void modelChanged(IModelChangedEvent event) {
    if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) {
      markStale();
    }
    Object changeObject = event.getChangedObjects()[0];

    if (!(changeObject instanceof IBuildEntry
        && (((IBuildEntry) changeObject)
                .getName()
                .equals(IBuildPropertiesConstants.PROPERTY_BIN_EXCLUDES)
            || ((IBuildEntry) changeObject)
                .getName()
                .equals(IBuildPropertiesConstants.PROPERTY_BIN_INCLUDES)))) return;

    if ((fParentResource == null && fOriginalResource != null)
        || (fOriginalResource == null && fParentResource != null)) {
      initializeCheckState();
      return;
    }
    if (fParentResource == null && fOriginalResource == null) {
      if (event.getChangedProperty() != null
          && event.getChangedProperty().equals(IBuildPropertiesConstants.PROPERTY_BIN_INCLUDES)) {

        if (event.getOldValue() == null && event.getNewValue() != null) {
          if (event.getNewValue().equals(".")) // $NON-NLS-1$
          return;
          // adding token
          IFile file = fBundleRoot.getFile(new Path(event.getNewValue().toString()));
          if (!file.exists()) return;
          fParentResource = fOriginalResource = file;
          isChecked = true;
        } else if (event.getOldValue() != null && event.getNewValue() == null) {
          if (event.getOldValue().equals(".")) // $NON-NLS-1$
          return;
          // removing token
          IFile file = fBundleRoot.getFile(new Path(event.getOldValue().toString()));
          if (!file.exists()) return;
          fParentResource = fOriginalResource = file;
          isChecked = false;
        } else {
          return;
        }
      }
      return;
    }
    fTreeViewer.setChecked(fParentResource, isChecked);
    fTreeViewer.setGrayed(fOriginalResource, false);
    fTreeViewer.setParentsGrayed(fParentResource, true);
    setParentsChecked(fParentResource);
    fTreeViewer.setGrayed(fParentResource, false);
    if (fParentResource instanceof IFolder) {
      fTreeViewer.setSubtreeChecked(fParentResource, isChecked);
      setChildrenGrayed(fParentResource, false);
    }
    while (!fOriginalResource.equals(fParentResource)) {
      fTreeViewer.setChecked(fOriginalResource, isChecked);
      fOriginalResource = fOriginalResource.getParent();
    }
    fParentResource = null;
    fOriginalResource = null;
  }