CloneSet4


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
459230.995class_body_declarations[18]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
1471288
E:/TSE/Projects-CloneDR/emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java
2459310
E:/TSE/Projects-CloneDR/emf-2.4.1/src/org/eclipse/emf/mapping/ecore2xml/presentation/Ecore2XMLEditor.java
Next
Last
Clone Instance
1
Line Count
471
Source Line
288
Source File
E:/TSE/Projects-CloneDR/emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java

/**
 * 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(EcoreEditor.this );
                                               setCurrentViewer(contentOutlineViewer);
                                             }
                                           }
                                           else
                                             if (p instanceof PropertySheet) {
                                               if (((PropertySheet) p).getCurrentPage() == propertySheetPage) {
                                                 getActionBarContributor().setActiveEditor(EcoreEditor.this );
                                                 handleActivate();
                                               }
                                             }
                                             else
                                               if (p == EcoreEditor.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.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected Collection<Resource> removedResources = new ArrayList<Resource>();

/**
 * 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.
 * <!-- 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(EcoreEditor.this, false);
                                                                                                                   }
                                                                                                                 } );
                                                                   }
                                                                 }
                                                                 if ( !visitor.getChangedResources().isEmpty()) {
                                                                   changedResources.addAll(visitor.getChangedResources());
                                                                   if (getSite().getPage().getActiveEditor() == EcoreEditor.this ) {
                                                                     getSite().getShell().getDisplay().asyncExec(new Runnable() {
                                                                                                                   public void run() {
                                                                                                                     handleActivate();
                                                                                                                   }
                                                                                                                 } );
                                                                   }
                                                                 }
                                                               }
                                                               catch (CoreException
                                                                      exception) {
                                                                 EcoreEditorPlugin.INSTANCE.log(exception);
                                                               }
                                                             }
                                                           };

/**
 * 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(EcoreEditor.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.
 * <!-- 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, "org.eclipse.emf.ecore.editor", 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) {
          EcoreEditorPlugin.INSTANCE.log(exception);
        }
      }
    if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
      markerHelper.deleteMarkers(editingDomain.getResourceSet());
      if (diagnostic.getSeverity() != Diagnostic.OK) {
        try {
          markerHelper.createMarkers(diagnostic);
        }
        catch (CoreException
               exception) {
          EcoreEditorPlugin.INSTANCE.log(exception);
        }
      }
    }
  }
}

/**
 * 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"), getString("_WARN_FileConflict"));
}

/**
 * This creates a model editor.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public EcoreEditor() {
  super();
  initializeEditingDomain();
}


First
Previous
Clone Instance
2
Line Count
459
Source Line
310
Source File
E:/TSE/Projects-CloneDR/emf-2.4.1/src/org/eclipse/emf/mapping/ecore2xml/presentation/Ecore2XMLEditor.java

/**
 * 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(Ecore2XMLEditor.this );
                                               setCurrentViewer(contentOutlineViewer);
                                             }
                                           }
                                           else
                                             if (p instanceof PropertySheet) {
                                               if (((PropertySheet) p).getCurrentPage() == propertySheetPage) {
                                                 getActionBarContributor().setActiveEditor(Ecore2XMLEditor.this );
                                                 handleActivate();
                                               }
                                             }
                                             else
                                               if (p == Ecore2XMLEditor.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
 */
protected Collection<Resource> removedResources = new ArrayList<Resource>();

/**
 * Resources that have been changed since last activation.
 * @generated
 */
protected Collection<Resource> changedResources = new ArrayList<Resource>();

/**
 * Resources that have been saved.
 * @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(Ecore2XMLEditor.this, false);
                                                                                                                   }
                                                                                                                 } );
                                                                   }
                                                                 }
                                                                 if ( !visitor.getChangedResources().isEmpty()) {
                                                                   changedResources.addAll(visitor.getChangedResources());
                                                                   if (getSite().getPage().getActiveEditor() == Ecore2XMLEditor.this ) {
                                                                     getSite().getShell().getDisplay().asyncExec(new Runnable() {
                                                                                                                   public void run() {
                                                                                                                     handleActivate();
                                                                                                                   }
                                                                                                                 } );
                                                                   }
                                                                 }
                                                               }
                                                               catch (CoreException
                                                                      exception) {
                                                                 Ecore2XMLUIPlugin.INSTANCE.log(exception);
                                                               }
                                                             }
                                                           };

/**
 * Handles activation of the editor or it's associated views.
 * @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(Ecore2XMLEditor.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
 */
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, "org.eclipse.emf.mapping.ecore2xml.edit", //$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) {
          Ecore2XMLUIPlugin.INSTANCE.log(exception);
        }
      }
    if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
      markerHelper.deleteMarkers(editingDomain.getResourceSet());
      if (diagnostic.getSeverity() != Diagnostic.OK) {
        try {
          markerHelper.createMarkers(diagnostic);
        }
        catch (CoreException
               exception) {
          Ecore2XMLUIPlugin.INSTANCE.log(exception);
        }
      }
    }
  }
}

/**
 * Shows a dialog that asks if conflicting changes should be discarded.
 * @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 Ecore2XMLEditor() {
  super();
  initializeEditingDomain();
}


Clone AbstractionParameter Count: 3Parameter Bindings

/**
   * 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();
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#190809c0]]
EcoreEditor 
12[[#190809c0]]
Ecore2XMLEditor 
21[[#170fdfa0]]
EcoreEditorPlugin 
22[[#170fdfa0]]
Ecore2XMLUIPlugin 
31[[#14971e80]]
"org.eclipse.emf.ecore.editor" 
32[[#14971e80]]
"org.eclipse.emf.mapping.ecore2xml.edit"