01: package newprocess.diagram.part;
02:
03: import org.eclipse.emf.common.util.URI;
04:
05: import org.eclipse.emf.ecore.resource.Resource;
06:
07: import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorInput;
08:
09: import org.eclipse.gmf.runtime.notation.Diagram;
10:
11: import org.eclipse.ui.IEditorInput;
12: import org.eclipse.ui.IEditorMatchingStrategy;
13: import org.eclipse.ui.IEditorPart;
14: import org.eclipse.ui.IEditorReference;
15: import org.eclipse.ui.IFileEditorInput;
16: import org.eclipse.ui.PartInitException;
17:
18: /**
19: * @generated
20: */
21: public class New_processMatchingStrategy implements
22: IEditorMatchingStrategy {
23:
24: /**
25: * @generated
26: */
27: public boolean matches(IEditorReference editorRef,
28: IEditorInput input) {
29: IEditorInput editorInput;
30: try {
31: editorInput = editorRef.getEditorInput();
32: } catch (PartInitException e) {
33: return false;
34: }
35:
36: if (editorInput.equals(input)) {
37: return true;
38: }
39:
40: if (editorInput instanceof IFileEditorInput
41: && input instanceof IFileEditorInput) {
42: return ((IFileEditorInput) editorInput).getFile().equals(
43: ((IFileEditorInput) input).getFile());
44: }
45:
46: IEditorPart editor = editorRef.getEditor(false);
47: if (input instanceof DiagramEditorInput
48: && editor instanceof New_processDiagramEditor) {
49: Diagram editorDiagram = ((New_processDiagramEditor) editor)
50: .getDiagram();
51: Diagram otherDiagram = ((DiagramEditorInput) input)
52: .getDiagram();
53: return equals(editorDiagram, otherDiagram);
54: }
55: return false;
56: }
57:
58: /**
59: * @generated
60: */
61: private boolean equals(Diagram editorDiagram, Diagram otherDiagram) {
62: Resource editorResource = editorDiagram.eResource();
63: Resource otherResource = otherDiagram.eResource();
64: if (editorResource != null && otherResource != null) {
65: URI editorURI = editorResource.getURI();
66: URI otherURI = otherResource.getURI();
67: String editorURIFragment = editorResource
68: .getURIFragment(editorDiagram);
69: String otherURIFragment = otherResource
70: .getURIFragment(otherDiagram);
71: return editorURI.equals(otherURI)
72: && editorURIFragment.equals(otherURIFragment);
73: }
74: return false;
75: }
76:
77: }
|