org.eclipse.xtext.ui.editor.DirtyStateEditorSupport Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.DirtyStateEditorSupport. 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: PrevStateAwareDirtyStateManager.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private DocumentBasedDirtyResource reflectiveGetInnerResource(final IDirtyResource dirtyResource) {
	Field[] declaredFields = dirtyResource.getClass().getDeclaredFields();
	DocumentBasedDirtyResource myDirtyResource = null;
	try {
		Field field = declaredFields[0];
		field.setAccessible(true);

		Object fieldValue = field.get(dirtyResource);

		if (fieldValue instanceof DirtyStateEditorSupport) {
			myDirtyResource = ((DirtyStateEditorSupport) fieldValue).getDirtyResource();
		}
	} catch (IllegalArgumentException | IllegalAccessException e) {
		// ignore
	}
	return myDirtyResource;
}
 
Example #2
Source File: XtextDocument.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void addModelListener(IXtextModelListener listener) {
	Assert.isNotNull(listener);
	synchronized (modelListeners) {
		if (modelListeners.contains(listener))
			return;
		if (listener instanceof DirtyStateEditorSupport) {
			modelListeners.add(0,listener);
		} else {
			modelListeners.add(listener);
		}
	}
}
 
Example #3
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * A custom {@link DirtyStateEditorSupport} that uses a custom JobFamily.
 */
public Class<? extends DirtyStateEditorSupport> bindDirtyStateEditorSupport() {
	return N4JSDirtyStateEditorSupport.class;
}
 
Example #4
Source File: DirtyStateEditorSupportTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	document = this;
	resourceSet = new ResourceSetImpl();
	resourceURI = URI.createURI("scheme://foo");
	resource = new XtextResource(resourceURI);
	resource.setLanguageName("FooLanguage");
	final DefaultResourceServiceProvider resourceServiceProvider = new DefaultResourceServiceProvider() {
		@Override
		public org.eclipse.xtext.resource.IResourceDescription.Manager getResourceDescriptionManager() {
			return DirtyStateEditorSupportTest.this;
		}
		
		@SuppressWarnings("unchecked")
		@Override
		public <T> T get(Class<T> t) {
			if(DirtyStateResourceDescription.Manager.class.isAssignableFrom(t)) 
				return (T) new DirtyStateResourceDescription.Manager(DirtyStateEditorSupportTest.this);
			if(LanguageInfo.class.isAssignableFrom(t))
				return (T) new LanguageInfo("FooLanguage");
			return super.get(t);
		}
	};
	ResourceServiceProviderRegistryImpl registry = new ResourceServiceProviderRegistryImpl() {
		@Override
		public IResourceServiceProvider getResourceServiceProvider(URI uri) {
			return resourceServiceProvider;
		}
	};
	resource.setResourceServiceProvider(resourceServiceProvider);
	resourceSet.getResources().add(resource);
	dirtyStateSupport = new DirtyStateEditorSupport();
	dirtyStateSupport.setConcurrentEditingWarningDialog(this);
	dirtyStateSupport.setResourceDescriptions(this);
	dirtyStateManager = new DirtyStateManager();
	stateChangeEventBroker = new StateChangeEventBroker();
	dirtyStateManager.addListener(stateChangeEventBroker);
	dirtyStateSupport.setDirtyStateManager(dirtyStateManager);
	dirtyStateSupport.setStateChangeEventBroker(stateChangeEventBroker);
	dirtyResource = new DocumentBasedDirtyResource();
	dirtyStateSupport.setDirtyResource(dirtyResource);
	dirtyStateSupport.setResourceServiceProviderRegistry(registry);
	ignoreConcurrentEditing = Lists.newLinkedList();
	exportedObjects = Collections.emptyList();
}
 
Example #5
Source File: DefaultCommonTypesUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends DirtyStateEditorSupport> bindDirtyStateEditorSupport(){
	return JvmTypesAwareDirtyStateEditorSupport.class;
}
 
Example #6
Source File: CheckUiModule.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=383919 (honor container visibility).
 *
 * @return FixedDirtyStateEditorSupport
 */
@Override
public Class<? extends DirtyStateEditorSupport> bindDirtyStateEditorSupport() {
  return FixedDirtyStateEditorSupport.class;
}
 
Example #7
Source File: CheckCfgUiModule.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=383919 (honor container visibility).
 *
 * @return FixedDirtyStateEditorSupport
 */
@Override
public Class<? extends DirtyStateEditorSupport> bindDirtyStateEditorSupport() {
  return FixedDirtyStateEditorSupport.class;
}