blob: 4d46d6cd2740a15259526c4dec7f7b743b8b5379 (
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
|
/*****************************************************************************
* Copyright (c) 2010 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:
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
package org.eclipse.papyrus.diagramtemplate.editor.provider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.papyrus.commands.CreationCommandDescriptor;
import org.eclipse.papyrus.commands.CreationCommandRegistry;
import org.eclipse.papyrus.commands.ICreationCommandRegistry;
import org.eclipse.papyrus.diagramtemplate.DiagramDefinition;
import org.eclipse.swt.graphics.Image;
/**
*
* Label provider for the diagram definition
*
*/
public class DiagramDefinitionLabelProvider implements ILabelProvider {
/**
* {@inheritDoc}
*/
public void addListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
/**
* {@inheritDoc}
*/
public void dispose() {
// TODO Auto-generated method stub
}
/**
* {@inheritDoc}
*/
public boolean isLabelProperty(Object element, String property) {
// TODO Auto-generated method stub
return false;
}
/**
* {@inheritDoc}
*/
public void removeListener(ILabelProviderListener listener) {
// TODO Auto-generated method stub
}
/**
* {@inheritDoc}
*/
public Image getImage(Object element) {
if (element instanceof DiagramDefinition) {
DiagramDefinition diagramDefinition = (DiagramDefinition) element;
for (CreationCommandDescriptor desc : getCreationCommandRegistry().getCommandDescriptors()) {
if (diagramDefinition != null && diagramDefinition.getDiagramKind().equalsIgnoreCase(desc.getCommandId())) {
return desc.getIcon().createImage();
}
}
}
return null;
}
/**
* {@inheritDoc}
*/
public String getText(Object element) {
if (element instanceof DiagramDefinition) {
return ((DiagramDefinition) element).getName();
}
return null;
}
/**
* Gets the creation command registry.
*
* @return the creation command registry
*/
private ICreationCommandRegistry getCreationCommandRegistry() {
return CreationCommandRegistry.getInstance(org.eclipse.papyrus.infra.core.Activator.PLUGIN_ID);
}
}
|