/**
* This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Viewer currentViewer;
/**
* This listens to which ever viewer is active.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ISelectionChangedListener selectionChangedListener;
/**
* This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
/**
* This keeps track of the selection of the editor as a whole.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ISelection editorSelection = StructuredSelection.EMPTY;
/**
* The MarkerHelper is responsible for creating workspace resource markers presented
* in Eclipse's Problems View.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected MarkerHelper markerHelper = new EditUIMarkerHelper();
/**
* This listens for when the outline becomes active
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart p) {
if (p instanceof ContentOutline) {
if (((ContentOutline) p).getCurrentPage() == contentOutlinePage) {
getActionBarContributor().setActiveEditor( [[#variable190809c0]].this );
setCurrentViewer(contentOutlineViewer);
}
}
else
if (p instanceof PropertySheet) {
if (((PropertySheet) p).getCurrentPage() == propertySheetPage) {
getActionBarContributor().setActiveEditor( [[#variable190809c0]].this );
handleActivate();
}
}
else
if (p == [[#variable190809c0]].this ) {
handleActivate();
}
}
public void partBroughtToTop(IWorkbenchPart p) {
// Ignore.
}
public void partClosed(IWorkbenchPart p) {
// Ignore.
}
public void partDeactivated(IWorkbenchPart p) {
// Ignore.
}
public void partOpened(IWorkbenchPart p) {
// Ignore.
}
};
/**
* Resources that have been removed since last activation.
* @generated
*/
/**
* Resources that have been removed since last activation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<Resource> removedResources = new ArrayList<Resource>();
/**
* Resources that have been changed since last activation.
* @generated
*/
/**
* Resources that have been changed since last activation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<Resource> changedResources = new ArrayList<Resource>();
/**
* Resources that have been saved.
* @generated
*/
/**
* Resources that have been saved.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Collection<Resource> savedResources = new ArrayList<Resource>();
/**
* Map to store the diagnostic associated with a resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
/**
* Controls whether the problem indication should be updated.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected boolean updateProblemIndication = true;
/**
* Adapter used to update the problem indication when resources are demanded loaded.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EContentAdapter problemIndicationAdapter = new EContentAdapter() {
@Override public void notifyChanged(Notification notification) {
if (notification.getNotifier() instanceof Resource) {
switch (notification.getFeatureID(Resource.class )) {
case Resource.RESOURCE__IS_LOADED:
case Resource.RESOURCE__ERRORS:
case Resource.RESOURCE__WARNINGS:
{
Resource resource = (Resource) notification.getNotifier();
Diagnostic diagnostic = analyzeResourceProblems(resource, null);
if (diagnostic.getSeverity() != Diagnostic.OK) {
resourceToDiagnosticMap.put(resource, diagnostic);
}
else {
resourceToDiagnosticMap.remove(resource);
}
if (updateProblemIndication) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
updateProblemIndication();
}
} );
}
break;
}
}
}
else {
super.notifyChanged(notification);
}
}
@Override protected void setTarget(Resource target) {
basicSetTarget(target);
}
@Override protected void unsetTarget(Resource target) {
basicUnsetTarget(target);
}
};
/**
* This listens for workspace changes.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected IResourceChangeListener resourceChangeListener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
try {
class ResourceDeltaVisitor implements IResourceDeltaVisitor {
protected ResourceSet resourceSet = editingDomain.getResourceSet();
protected Collection<Resource> changedResources = new ArrayList<Resource>();
protected Collection<Resource> removedResources = new ArrayList<Resource>();
public boolean visit(IResourceDelta delta) {
if (delta.getResource().getType() == IResource.FILE) {
if (delta.getKind() == IResourceDelta.REMOVED || delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) {
Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false);
if (resource != null) {
if (delta.getKind() == IResourceDelta.REMOVED) {
removedResources.add(resource);
}
else
if ( !savedResources.remove(resource)) {
changedResources.add(resource);
}
}
}
}
return true;
}
public Collection<Resource> getChangedResources() {
return changedResources;
}
public Collection<Resource> getRemovedResources() {
return removedResources;
}
}
ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
delta.accept(visitor);
if ( !visitor.getRemovedResources().isEmpty()) {
removedResources.addAll(visitor.getRemovedResources());
if ( !isDirty()) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
getSite().getPage().closeEditor( [[#variable190809c0]].this, false);
}
} );
}
}
if ( !visitor.getChangedResources().isEmpty()) {
changedResources.addAll(visitor.getChangedResources());
if (getSite().getPage().getActiveEditor() == [[#variable190809c0]].this ) {
getSite().getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
handleActivate();
}
} );
}
}
}
catch (CoreException
exception) {
[[#variable170fdfa0]].INSTANCE.log(exception);
}
}
};
/**
* Handles activation of the editor or it's associated views.
* @generated
*/
/**
* Handles activation of the editor or it's associated views.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void handleActivate() {
// Recompute the read only state.
//
if (editingDomain.getResourceToReadOnlyMap() != null) {
editingDomain.getResourceToReadOnlyMap().clear();
// Refresh any actions that may become enabled or disabled.
//
setSelection(getSelection());
}
if ( !removedResources.isEmpty()) {
if (handleDirtyConflict()) {
getSite().getPage().closeEditor( [[#variable190809c0]].this, false);
}
else {
removedResources.clear();
changedResources.clear();
savedResources.clear();
}
}
else
if ( !changedResources.isEmpty()) {
changedResources.removeAll(savedResources);
handleChangedResources();
changedResources.clear();
savedResources.clear();
}
}
/**
* Handles what to do with changed resources on activation.
* @generated
*/
/**
* Handles what to do with changed resources on activation.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void handleChangedResources() {
if ( !changedResources.isEmpty() && ( !isDirty() || handleDirtyConflict())) {
if (isDirty()) {
changedResources.addAll(editingDomain.getResourceSet().getResources());
}
editingDomain.getCommandStack().flush();
updateProblemIndication = false;
for (Resource resource: changedResources) {
if (resource.isLoaded()) {
resource.unload();
try {
resource.load(Collections.EMPTY_MAP);
}
catch (IOException
exception) {
if ( !resourceToDiagnosticMap.containsKey(resource)) {
resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
}
}
}
}
if (AdapterFactoryEditingDomain.isStale(editorSelection)) {
setSelection(StructuredSelection.EMPTY);
}
updateProblemIndication = true;
updateProblemIndication();
}
}
/**
* Updates the problems indication with the information described in the specified diagnostic.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected void updateProblemIndication() {
if (updateProblemIndication) {
BasicDiagnostic diagnostic = new BasicDiagnostic(Diagnostic.OK, [[#variable14971e80]], //$NON-NLS-1$
0, null, new Object[] {
editingDomain.getResourceSet()
} );
for (Diagnostic childDiagnostic: resourceToDiagnosticMap.values()) {
if (childDiagnostic.getSeverity() != Diagnostic.OK) {
diagnostic.add(childDiagnostic);
}
}
int lastEditorPage = getPageCount() - 1;
if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
((ProblemEditorPart) getEditor(lastEditorPage)).setDiagnostic(diagnostic);
if (diagnostic.getSeverity() != Diagnostic.OK) {
setActivePage(lastEditorPage);
}
}
else
if (diagnostic.getSeverity() != Diagnostic.OK) {
ProblemEditorPart problemEditorPart = new ProblemEditorPart();
problemEditorPart.setDiagnostic(diagnostic);
problemEditorPart.setMarkerHelper(markerHelper);
try {
addPage( ++lastEditorPage, problemEditorPart, getEditorInput());
setPageText(lastEditorPage, problemEditorPart.getPartName());
setActivePage(lastEditorPage);
showTabs();
}
catch (PartInitException
exception) {
[[#variable170fdfa0]].INSTANCE.log(exception);
}
}
if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
markerHelper.deleteMarkers(editingDomain.getResourceSet());
if (diagnostic.getSeverity() != Diagnostic.OK) {
try {
markerHelper.createMarkers(diagnostic);
}
catch (CoreException
exception) {
[[#variable170fdfa0]].INSTANCE.log(exception);
}
}
}
}
}
/**
* Shows a dialog that asks if conflicting changes should be discarded.
* @generated
*/
/**
* Shows a dialog that asks if conflicting changes should be discarded.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected boolean handleDirtyConflict() {
return MessageDialog.openQuestion(getSite().getShell(), getString("_UI_FileConflict_label"), //$NON-NLS-1$
getString("_WARN_FileConflict")); //$NON-NLS-1$
}
/**
* This creates a model editor.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public [[#variable190809c0]]() {
super();
initializeEditingDomain();
}
|