blob: 387875def4afcea7e2abbf6b22289664823987ca (
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
|
/*****************************************************************************
* 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.infra.ui.extension.diagrameditor;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.ui.editorsfactory.IEditorFactory;
/**
* Abstract base class for Factory of editors. See {@link IEditorFactory}.
*
*
* @author Remi Schnekenburger
* @author Patrick Tessier
* @author cedric dumoulin
* @since 1.2
*/
public abstract class AbstractEditorFactory implements IPluggableEditorFactory {
/**
* Expected Class of the diagram to create.
*/
private Class<?> diagramClass;
/** Expected diagram type (@see {@link Diagram#getType()}) */
private String expectedType;
/**
* EditorDescriptor associated to the factory. TODO : Maybe use individual
* setters to set the requested data (ContributorId and Icon).
*/
protected EditorDescriptor editorDescriptor;
/**
* ServiceRegistry that can be provided to created editors.
*/
private ServicesRegistry serviceRegistry;
/**
* Creates a new AbstractEditorFactory.
*
* @param diagramClass
* expected Class of the diagram to create.
* @param expectedType
* expected diagram type (@see {@link Diagram#getType()})
*/
public AbstractEditorFactory(Class<?> diagramClass, String expectedType) {
assert (expectedType != null);
this.diagramClass = diagramClass;
this.expectedType = expectedType;
}
/**
* Initialize the factory with useful Classes.
*
* @param serviceRegistry
* Service registry that will be provided to created editor.
* @param editorDescriptor
* Descriptor containing data from the Eclipse Extension.
*/
@Override
public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) {
this.editorDescriptor = editorDescriptor;
this.serviceRegistry = serviceRegistry;
}
/**
* @return the serviceRegistry
*/
public ServicesRegistry getServiceRegistry() {
return serviceRegistry;
}
/**
* Returns the expected class for the diagram implementation
*
* @return the expected class for the diagram implementation
*/
public Class<?> getDiagramClass() {
return diagramClass;
}
/**
* Returns the expected type of the diagram
*
* @return the expected diagram type (@see {@link Diagram#getType()})
*/
public String getExpectedType() {
return expectedType;
}
/**
* @return the editorDescriptor
*/
public EditorDescriptor getEditorDescriptor() {
return editorDescriptor;
}
}
|