blob: 9500991fce841c7c66607c52f60fbddc4eb50e7d (
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
|
package org.eclipse.papyrus.palette.customization.modelelement;
import java.util.LinkedList;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.papyrus.diagram.common.service.palette.IAspectAction;
import org.eclipse.papyrus.palette.customization.creation.AspectActionEditionFactory;
import org.eclipse.papyrus.paletteconfiguration.ToolConfiguration;
import org.eclipse.papyrus.properties.modelelement.AbstractModelElement;
import org.eclipse.papyrus.widgets.creation.ReferenceValueFactory;
import org.eclipse.swt.graphics.Image;
public class ToolConfigurationModelElement extends AbstractModelElement {
/**
* The aspectActions property
*/
public static final String ASPECT_ACTIONS = "aspectActions";
/**
* The ToolConfiguration on which the IAspectActions are applied
*/
private ToolConfiguration toolConfiguration;
public ToolConfigurationModelElement(ToolConfiguration toolConfiguration) {
this.toolConfiguration = toolConfiguration;
}
@Override
protected IObservable doGetObservable(String propertyPath) {
if(propertyPath.equals(ASPECT_ACTIONS)) {
//TODO : Retrieve the list of IAspectActions
return new WritableList(new LinkedList<IAspectAction>(), IAspectAction.class);
}
//Unknown property
return null;
}
@Override
public boolean isOrdered(String propertyPath) {
return propertyPath.equals(ASPECT_ACTIONS);
}
@Override
public boolean isUnique(String propertyPath) {
return false;
}
@Override
public boolean getDirectCreation(String propertyPath) {
return propertyPath.equals(ASPECT_ACTIONS);
}
@Override
public ILabelProvider getLabelProvider(String propertyPath) {
return new LabelProvider() {
@Override
public String getText(Object element) {
if(element instanceof IAspectAction) {
return ((IAspectAction)element).getLabel();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if(element instanceof IAspectAction) {
return ((IAspectAction)element).getImage();
}
return super.getImage(element);
}
};
}
@Override
public ReferenceValueFactory getValueFactory(String propertyPath) {
if(propertyPath.equals(ASPECT_ACTIONS)) {
return new AspectActionEditionFactory();
}
return super.getValueFactory(propertyPath);
}
}
|