@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()); } } }
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; }