Java Code Examples for org.eclipse.emf.common.notify.Notification#isTouch()

The following examples show how to use org.eclipse.emf.common.notify.Notification#isTouch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JvmTypeChangeDispatcher.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void notifyChanged(Notification notification) {
	super.notifyChanged(notification);
	if (notification.isTouch() && !isRemoveThis(notification)) 
		return;
	List<Runnable> localListeners = null;
	synchronized (listenerLock) {
		localListeners = listeners;
		if (localListeners.isEmpty()) {
			return;
		}
		listeners = Lists.newLinkedList();
	}
	Iterator<Runnable> iterator = localListeners.iterator();
	while(iterator.hasNext()) {
		Runnable runnable = iterator.next();
		if (runnable != null) {
			try {
				runnable.run();
			} catch(Exception e) {
				LOG.error(e.getMessage(), e);
			}
		}
	}
}
 
Example 2
Source File: DefaultTextEditComposer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean doRecord(Notification notification) {
	if (!recording || notification.isTouch())
		return false;

	switch (notification.getEventType()) {
		case Notification.ADD:
		case Notification.ADD_MANY:
		case Notification.MOVE:
		case Notification.REMOVE:
		case Notification.REMOVE_MANY:
		case Notification.SET:
		case Notification.UNSET:
			return true;
		default:
			return false;
	}
}
 
Example 3
Source File: OnChangeEvictingCache.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.23
 */
protected boolean isSemanticStateChange(Notification notification) {
	if (notification.isTouch()) {
		return false;
	}
	if (notification.getNotifier() instanceof Resource) {
		switch(notification.getFeatureID(Resource.class)) {
		case Resource.RESOURCE__IS_MODIFIED:
		case Resource.RESOURCE__IS_TRACKING_MODIFICATION:
		case Resource.RESOURCE__TIME_STAMP:
		case Resource.RESOURCE__ERRORS:
		case Resource.RESOURCE__WARNINGS:
			return false;
		}
	}
	return true;
}
 
Example 4
Source File: CrossflowDocumentProvider.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public void notifyChanged(Notification notification) {
	if (notification.getNotifier() instanceof ResourceSet) {
		super.notifyChanged(notification);
	}
	if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
		if (notification.getNotifier() instanceof Resource) {
			Resource resource = (Resource) notification.getNotifier();
			if (resource.isLoaded()) {
				boolean modified = false;
				for (Iterator /*<org.eclipse.emf.ecore.resource.Resource>*/ it = myInfo
						.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
					Resource nextResource = (Resource) it.next();
					if (nextResource.isLoaded()) {
						modified = nextResource.isModified();
					}
				}
				boolean dirtyStateChanged = false;
				synchronized (myInfo) {
					if (modified != myInfo.fCanBeSaved) {
						myInfo.fCanBeSaved = modified;
						dirtyStateChanged = true;
					}
					if (!resource.isModified()) {
						myInfo.setSynchronized(resource);
					}
				}
				if (dirtyStateChanged) {
					fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);

					if (!modified) {
						myInfo.setModificationStamp(computeModificationStamp(myInfo));
					}
				}
			}
		}
	}
}
 
Example 5
Source File: ActiveAnnotationContexts.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void notifyChanged(final Notification msg) {
  if ((((!this.running) && (!msg.isTouch())) && (Resource.RESOURCE__CONTENTS == msg.getFeatureID(Resource.class)))) {
    Object _notifier = msg.getNotifier();
    final Resource resource = ((Resource) _notifier);
    resource.eAdapters().remove(this);
    this.contexts.clear();
    this.compilationUnit = null;
  }
}
 
Example 6
Source File: SimpleAttributeResolver.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void notifyChanged(final Notification notification) {
	if (!notification.isTouch() && Notification.SET == notification.getEventType()) {
		final Object feature = notification.getFeature();
		if (feature != null) {
			if (resolver.attributeName.equals(((ENamedElement) feature).getName())) {
				resolver.valueCache.discard((EObject) notification.getNotifier());
				((EObject) notification.getNotifier()).eAdapters().remove(this);
			}
		}

	}
}
 
Example 7
Source File: ProcessDocumentProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public void notifyChanged(Notification notification) {
	if (notification.getNotifier() instanceof ResourceSet) {
		super.notifyChanged(notification);
	}
	if (!notification.isTouch() && myModifiedFilter.matches(notification)) {
		if (notification.getNotifier() instanceof Resource) {
			Resource resource = (Resource) notification.getNotifier();
			if (resource.isLoaded()) {
				boolean modified = false;
				for (Iterator /*<org.eclipse.emf.ecore.resource.Resource>*/ it = myInfo
						.getLoadedResourcesIterator(); it.hasNext() && !modified;) {
					Resource nextResource = (Resource) it.next();
					if (nextResource.isLoaded()) {
						modified = nextResource.isModified();
					}
				}
				boolean dirtyStateChanged = false;
				synchronized (myInfo) {
					if (modified != myInfo.fCanBeSaved) {
						myInfo.fCanBeSaved = modified;
						dirtyStateChanged = true;
					}
					if (!resource.isModified()) {
						myInfo.setSynchronized(resource);
					}
				}
				if (dirtyStateChanged) {
					fireElementDirtyStateChanged(myInfo.getEditorInput(), modified);

					if (!modified) {
						myInfo.setModificationStamp(computeModificationStamp(myInfo));
					}
				}
			}
		}
	}
}
 
Example 8
Source File: XtextLinker.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void notifyChanged(Notification msg) {
	super.notifyChanged(msg);
	if (!msg.isTouch() && msg.getOldValue() != null) {
		ResourceSet set;
		Resource notifyingResource;
		if (!(msg.getNotifier() instanceof Resource)) {
			Object feature = msg.getFeature();
			if (!(feature instanceof EReference))
				return;
			EReference ref = (EReference) feature;
			if (!ref.isContainment())
				return;
			notifyingResource = ((EObject) msg.getNotifier()).eResource();
		} else {
			notifyingResource = ((Resource) msg.getNotifier());
		}
		if (notifyingResource == null)
			return;
		set = notifyingResource.getResourceSet();
		if (set == null)
			return;
		switch (msg.getEventType()) {
			case Notification.REMOVE_MANY:
			case Notification.REMOVE:
			case Notification.SET:
				Object oldValue = msg.getOldValue();
				Collection<Resource> resourcesToRemove = Sets.newHashSet();
				Collection<Resource> resourcesToUnload = Sets.newHashSet();
				Collection<Resource> referencedResources = Sets.newHashSet(notifyingResource);
				if (oldValue instanceof Grammar) {
					processMetamodelDeclarations(((Grammar) oldValue).getMetamodelDeclarations(), set, resourcesToRemove,
							resourcesToUnload, referencedResources);
				} else if (oldValue instanceof AbstractMetamodelDeclaration) {
					processMetamodelDeclarations(Collections
							.singletonList((AbstractMetamodelDeclaration) oldValue), set, resourcesToRemove, resourcesToUnload, referencedResources);
				} else if (oldValue instanceof Collection<?>) {
					if (XtextPackage.Literals.GRAMMAR__METAMODEL_DECLARATIONS == msg.getFeature()) {
						Collection<AbstractMetamodelDeclaration> metamodelDeclarations = (Collection<AbstractMetamodelDeclaration>) oldValue;
						processMetamodelDeclarations(metamodelDeclarations, set, resourcesToRemove, resourcesToUnload, referencedResources);
					}
				}
				resourcesToRemove.removeAll(referencedResources);
				if (unloader != null) {
					resourcesToUnload.removeAll(referencedResources);
					for (Resource resource : resourcesToUnload) {
						if(resource.getResourceSet() == set) {
							for (EObject content : resource.getContents())
								unloader.unloadRoot(content);
						}
					}
				}
				set.getResources().removeAll(resourcesToRemove);
				break;
			default:
				break;
		}
	}
}
 
Example 9
Source File: ChartAdapter.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
public void notifyChanged( Notification notification )
{
	if ( needUpdateApply && wizardContainer instanceof ChartWizard )
	{
		// Update Apply button status when notification may be ignored.
		( (ChartWizard) wizardContainer ).updateApplyButton( );
	}

	if ( bIgnoreNotifications || notification.isTouch( ) )
	{
		needUpdateApply = false;
		return;
	}

	logger.log( ILogger.INFORMATION,
			new MessageFormat( Messages.getString( "ChartAdapter.Info.NotificationRecieved" ) ).format( new Object[]{notification.getNotifier( ).getClass( ).getName( )} ) ); //$NON-NLS-1$
	logger.log( ILogger.INFORMATION,
			new MessageFormat( Messages.getString( "ChartAdapter.Info.NewValue" ) ).format( new Object[]{notification.getNewValue( )} ) ); //$NON-NLS-1$

	// Notify registered change listeners
	for ( int iC = 0; iC < vListeners.size( ); iC++ )
	{
		ITaskChangeListener changeLs = vListeners.elementAt( iC );
		// Only change current task
		if ( wizardContainer.getCurrentTask( ) == changeLs
				|| !( wizardContainer.getCurrentTask( ) instanceof ITaskChangeListener ) )
		{
			changeLs.changeTask( notification );
		}
	}

	if ( !needUpdateApply && wizardContainer instanceof ChartWizard )
	{
		// Update Apply button status after notification
		( (ChartWizard) wizardContainer ).updateApplyButton( );
	}
	else
	{
		needUpdateApply = false;
	}
}