@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());
        }
    }
  }
Exemple #2
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());
    }
  }
Exemple #3
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;
  }