public void scheduleUpdateEditorJob(final IResourceDescription.Event event) { UpdateEditorStateJob job = updateEditorStateJob; if (job == null) { job = createUpdateEditorJob(); updateEditorStateJob = job; } job.scheduleFor(event); }
public void verifyText(VerifyEvent e) { if (isDirty || !e.doit) return; e.doit = doVerify(); if (e.doit) isDirty = true; }
public void afterCreatePartControl(final XtextEditor editor) { if (this.currentEditor != editor) throw new IllegalStateException("different instances of editor were given."); editorSupport.initializeDirtyStateSupport(this); }
public Collection<Resource> exec(XtextResource resource) throws Exception { if (resource == null || resource.getResourceSet() == null) return null; Collection<Resource> affectedResources = collectAffectedResources(resource, event.getFirst()); if (monitor.isCanceled() || !affectedResources.isEmpty()) return affectedResources; isReparseRequired[0] = isReparseRequired(resource, event.getFirst()); return affectedResources; } });
public void descriptionsChanged(final IResourceDescription.Event event) { if (!getDirtyResource().isInitialized()) return; for(IResourceDescription.Delta delta: event.getDeltas()) { if (delta.getOld() == getDirtyResource().getDescription() || delta.getNew() == getDirtyResource().getDescription()) return; } scheduleUpdateEditorJob(event); }
public void initializeDirtyStateSupport(IDirtyStateEditorSupportClient client) { if (this.currentClient != null) throw new IllegalStateException("editor was already assigned"); //$NON-NLS-1$ this.currentClient = client; this.isDirty = false; IXtextDocument document = client.getDocument(); document.addModelListener(this); initDirtyResource(document); stateChangeEventBroker.addListener(this); client.addVerifyListener(this); scheduleValidationJobIfNecessary(); }
public boolean doVerify() { if (!dirtyStateManager.manageDirtyState(delegatingClientAwareResource)) { if (dirtyStateManager instanceof DirtyStateManager) { IDirtyResource other = ((DirtyStateManager) dirtyStateManager).getDirtyResource(delegatingClientAwareResource.getURI()); if (other instanceof ClientAwareDirtyResource) { ClientAwareDirtyResource clientAwareDirtyResource = (ClientAwareDirtyResource) other; if (!clientAwareDirtyResource.isDirty()) { clientAwareDirtyResource.discardThisResource(); return doVerify(); } } } if (!isConcurrentEditingIgnored()) { dirtyStateManager.discardDirtyState(delegatingClientAwareResource); return false; } } return true; }
/** * @deprecated Use {@link #haveEObjectDescriptionsChanged(IResourceDescription, org.eclipse.xtext.resource.IResourceDescription.Manager)}. */ @Deprecated public boolean haveEObjectDescriptionsChanged(final IResourceDescription newDescription) { IResourceDescription.Manager resourceDescriptionManager = resourceServiceProviderRegistry.getResourceServiceProvider(newDescription.getURI()).getResourceDescriptionManager(); return haveEObjectDescriptionsChanged(newDescription, resourceDescriptionManager); }
protected Pair<IResourceDescription.Event, Integer> mergePendingDeltas() { Map<URI, IResourceDescription.Delta> uriToDelta = Maps.newLinkedHashMap(); Iterator<IResourceDescription.Delta> iter = pendingChanges.iterator(); int size = 0; while(iter.hasNext()) { IResourceDescription.Delta delta = iter.next(); URI uri = delta.getUri(); IResourceDescription.Delta prev = uriToDelta.get(uri); if (prev == null) { uriToDelta.put(uri, delta); } else if (prev.getOld() != delta.getNew()){ uriToDelta.put(uri, createDelta(delta, prev)); } else { uriToDelta.remove(uri); } size++; } IResourceDescription.Event event = new ResourceDescriptionChangeEvent(uriToDelta.values(), dirtyStateManager); return Tuples.create(event, size); }
protected boolean isReparseRequired(XtextResource resource, IResourceDescription.Event event) { IResourceDescription.Manager resourceDescriptionManager = resource.getResourceServiceProvider().getResourceDescriptionManager(); IResourceDescription description = resourceDescriptionManager.getResourceDescription(resource); if (resourceDescriptionManager.isAffected(event.getDeltas(), description, resourceDescriptions)) { return true; } if (!isDirty() && !dirtyStateManager.hasContent(resource.getURI())) { IResourceDescription originalDescription = resourceDescriptions.getResourceDescription(resource.getURI()); if (originalDescription != null && descriptionUtils != null) { Set<URI> outgoingReferences = descriptionUtils.collectOutgoingReferences(originalDescription); for(IResourceDescription.Delta delta: event.getDeltas()) { if (delta.haveEObjectDescriptionsChanged() && outgoingReferences.contains(delta.getUri())) return true; } } } return false; }
public void modelChanged(XtextResource resource) { if (resource == null || !dirtyResource.isInitialized()) return; if (isDirty || ((!resource.isTrackingModification() || resource.isModified()) && currentClient.isDirty() && dirtyStateManager.manageDirtyState(delegatingClientAwareResource))) { synchronized (dirtyStateManager) { IResourceDescription.Manager resourceDescriptionManager = resource.getResourceServiceProvider().getResourceDescriptionManager(); final IResourceDescription newDescription = resourceDescriptionManager.getResourceDescription(resource); if (haveEObjectDescriptionsChanged(newDescription, resourceDescriptionManager)) { dirtyResource.copyState(newDescription); dirtyStateManager.announceDirtyStateChanged(delegatingClientAwareResource); } } } }
public boolean isEditingPossible(IDirtyStateEditorSupportClient client) { if (this.currentClient == null || this.currentClient != client) throw new IllegalStateException("Was configured with another client or not configured at all."); //$NON-NLS-1$ if (isDirty) return true; if (!doVerify()) return false; isDirty = true; return true; }
public void afterSetInput(XtextEditor editor) { if (this.currentEditor != null) { if (this.currentEditor != editor) throw new IllegalStateException("different instances of editor were given."); editorSupport.initializeDirtyStateSupport(this); } else { this.currentEditor = editor; } }