Java Code Examples for org.eclipse.emf.ecore.resource.Resource#isModified()

The following examples show how to use org.eclipse.emf.ecore.resource.Resource#isModified() . 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: 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 2
Source File: ResourceWorkingCopyFileEditorInput.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ResourceWorkingCopyFileInvocationHandler(Resource resource) throws IOException {
			file = ResourceUtil.getFile(resource);
			boolean isModified = resource.isModified();
			ByteArrayOutputStream outputBuffer = new ByteArrayOutputStream();
			OutputStream outputStream = new BufferedOutputStream(outputBuffer);
			try {
				resource.save(outputStream, null);
			} finally {
				outputStream.close();
				resource.setModified(isModified);
			}
			buffer = outputBuffer.toByteArray();
//			debug = new String(buffer);
		}
 
Example 3
Source File: DiagramPartitioningDocumentProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected ElementInfo createElementInfo(Object element) throws CoreException {
	ElementInfo info = super.createElementInfo(element);
	if (element instanceof IDiagramEditorInput) {
		Resource eResource = ((IDiagramEditorInput) element).getDiagram().eResource();
		TransactionalEditingDomain sharedDomain = DiagramPartitioningUtil.getSharedDomain();
		if (eResource.isLoaded() && !sharedDomain.isReadOnly(eResource) && eResource.isModified()) {
			info.fCanBeSaved = true;
		}
	}
	return info;
}
 
Example 4
Source File: BonitaResourceSetInfoDelegate.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return
 *         true if some resource of the resource set is modified
 */
public boolean resourceSetIsDirty() {
    for (final Resource resource : getEditingDomain().getResourceSet().getResources()) {
        if (resource.isLoaded() && !getEditingDomain().isReadOnly(resource) && resource.isModified()) {
            return true;
        }
    }
    return false;
}
 
Example 5
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));
					}
				}
			}
		}
	}
}