blob: ea4e01b9a6c2d585ffa0ebf26d95c83f79e6ab83 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/*****************************************************************************
* Copyright (c) 2008 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Cedric Dumoulin Cedric.Dumoulin@lifl.fr - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.diagram.umltools.clazz;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.core.extension.diagrameditor.EditorDescriptor;
import org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory;
import org.eclipse.papyrus.core.services.ServicesRegistry;
import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel;
/**
* @author dumoulin
*
*/
public class ClassDiagramEditorFactory implements IPluggableEditorFactory {
/**
* Expected diagram type
*/
private String expectedType;
/**
* Main service Registry.
* Initialized when the factory is registered to the main editor.
*/
private ServicesRegistry servicesRegistry;
/**
* Editor Descriptor containing data from the Eclipse extension declaration.
*/
private EditorDescriptor editorDescriptor;
/**
* @param diagramClass
* @param expectedType
*/
public ClassDiagramEditorFactory() {
expectedType = getDiagramNotationID();
}
/**
* Initialize the factory.
* @see org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory#init(org.eclipse.papyrus.core.services.ServicesRegistry, org.eclipse.papyrus.core.extension.diagrameditor.EditorDescriptor)
*
* @param serviceRegistry
* @param editorDescriptor
*/
public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) {
this.servicesRegistry = serviceRegistry;
this.editorDescriptor = editorDescriptor;
}
/**
* Return true if this PageModelFactory can create a PageModel for the specified pageIdentifier.
* The pageIdentifier is an instance of Diagram.
*
* @see org.eclipse.papyrus.core.extension.diagrameditor.IEditorFactory#isPageModelFactoryFor(java.lang.Object)
* @param pageIdentifier
* @return
*
*/
public boolean isPageModelFactoryFor(Object pageIdentifier) {
if(pageIdentifier instanceof Diagram) {
Diagram diagram = (Diagram)pageIdentifier;
final String type = diagram.getType();
return getExpectedType().equals(type);
}
// no
return false;
}
/**
* Create a new instance of the EditorModel for the specified pageIdentifier.
* @see org.eclipse.papyrus.core.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object)
*
* @param pageIdentifier
* @return
*/
public IPageModel createIPageModel(Object pageIdentifier) {
return new ClassDiagramEditorModel((Diagram)pageIdentifier, servicesRegistry, editorDescriptor);
}
/**
* @return the diagramClass
*/
// private Class<?> getDiagramClass() {
// return diagramClass;
// }
/**
* @return the expectedType
*/
private String getExpectedType() {
return expectedType;
}
/**
* Get the ID identifying the type of the Diagram.
* {@inheritDoc}
*/
protected String getDiagramNotationID() {
return org.eclipse.uml2.diagram.clazz.edit.parts.PackageEditPart.MODEL_ID;
}
}
|