Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3ed2fac57a7e0c727f0ab79f5f9b5ac2f9a4c916 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*****************************************************************************
 * 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.core.extension.diagrameditor;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;

/**
 * This descriptor describes a nested diagram. It is used by MultiDiagramEditor
 * to know about the nested diagram. It is fill by an extension.
 * 
 * @author Cedric Dumoulin
 * 
 */
public class EditorDescriptor {

	/**
	 * Editor factory implementation class.
	 */
	private Class<IPluggableEditorFactory> editorFactoryClass;

	/**
	 * EditorActionBarContributor Id used to search the
	 * EditorActionBarContributor requested by the editor.
	 */
	private String actionBarContributorId;

	/**
	 * The icon representing the diagram
	 */
	private ImageDescriptor icon;
	/**
	 * Resource path to the icon
	 */
	private String inconPath;

	/**
	 * Constructor.
	 */
	public EditorDescriptor() {

	}

	/**
	 * 
	 * @param attribute
	 */
	public void setActionBarContributorId(String actionBarContributorId) {
		this.actionBarContributorId = actionBarContributorId;

	}

	/**
	 * @see org.eclipse.papyrus.infra.core.extension.diagrameditor.IEditorDescriptor#getActionBarContributorId()
	 * @return
	 * 
	 */
	public String getActionBarContributorId() {
		return actionBarContributorId;
	}

	/**
	 * get the editor icon path
	 * 
	 * @return the editor icon path
	 */
	public ImageDescriptor getIcon() {
		return icon;
	}

	/**
	 * set the editor icon
	 * 
	 * @param icon
	 *        the icon path
	 */
	public void setIcon(ImageDescriptor icon) {
		this.icon = icon;
	}

	/**
	 * get the class of the editor factory
	 * 
	 * @return the class of the editor
	 */
	public Class<IPluggableEditorFactory> getEditorFactoryClass() {
		return editorFactoryClass;
	}

	/**
	 * set the editor facoty to this descriptor
	 * 
	 * @param editorFactoryClass
	 *        the class that represents the editor factory
	 */
	public void setEditorFactoryClass(Class<IPluggableEditorFactory> editorFactoryClass) {
		this.editorFactoryClass = editorFactoryClass;
	}

	/**
	 * 
	 * {@inheritDoc}
	 */
	public String toString() {
		if(editorFactoryClass == null || editorFactoryClass.getName() == null) {
			return "[nestedEditor  editorFactory:" + editorFactoryClass + "(null)]";
		}
		return "[nestedEditor  editorFactory:" + editorFactoryClass.getName() + "]";
	}

	/**
	 * Set the URL of the Icon
	 * 
	 * @param iconPath
	 *        path of the Icon
	 */
	public void setIconURL(String iconPath) {
		inconPath = iconPath;
	}

	/**
	 * Get the URL of the based images
	 * 
	 * @return the path of the mai image. can return null if this property is not set
	 */
	public String getIconURL() {
		return inconPath;
	}

	/**
	 * set the Icon thanks to a {@link IConfigurationElement} and {@link String}which represent the path of the Icon
	 * 
	 * @param element
	 * @param iconPath
	 */
	public void setIcon(IConfigurationElement element, String iconPath, String pluginID) {
		setIcon(AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconPath));
		setIconURL(element.getNamespaceIdentifier() + '/' + iconPath);
	}

}

Back to the top