blob: 3da2afec5f9dc32befe13945cb4d893eb0971452 (
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
|
/******************************************************************************
* Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.bridge.genmodel;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.gmf.codegen.gmfgen.GMFGenFactory;
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenCustomPropertyTab;
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenPropertySheet;
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenPropertyTab;
import org.eclipse.papyrus.gmf.codegen.gmfgen.GenStandardPropertyTab;
import org.eclipse.papyrus.gmf.codegen.gmfgen.GeneratedType;
import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeTabFilter;
import org.eclipse.papyrus.gmf.mappings.CanvasMapping;
/**
* @author artem
*/
public class PropertySheetHandler {
protected static final String APPEARANCE = "appearance";
protected static final String DIAGRAM = "diagram";
protected static final String ADVANCED = "advanced";
protected static final String DOMAIN = "domain";
private GenPropertySheet myPropertySheet;
public void initialize(GenPropertySheet propertySheet) {
assert propertySheet != null;
myPropertySheet = propertySheet;
}
public void process(CanvasMapping canvas) {
addStandardTabs();
addCustomTabs(canvas);
}
protected void addStandardTabs() {
GenStandardPropertyTab t1 = GMFGenFactory.eINSTANCE.createGenStandardPropertyTab();
t1.setID(APPEARANCE);
addTab(t1);
t1 = GMFGenFactory.eINSTANCE.createGenStandardPropertyTab();
t1.setID(DIAGRAM);
addTab(t1);
}
protected void addCustomTabs(CanvasMapping canvas) {
if (!hasDomainModel(canvas)) {
return;
}
GenCustomPropertyTab t1 = GMFGenFactory.eINSTANCE.createGenCustomPropertyTab();
t1.setID(DOMAIN);
t1.setLabel("Core");
TypeTabFilter f = GMFGenFactory.eINSTANCE.createTypeTabFilter();
f.getTypes().add(View.class.getName());
f.getTypes().add("org.eclipse.gef.EditPart");
if (myPropertySheet.getEditorGen().getNavigator() != null) {
f.getGeneratedTypes().add(GeneratedType.ABSTRACT_NAVIGATOR_ITEM_LITERAL);
}
t1.setFilter(f);
addTab(t1);
}
private void addTab(GenPropertyTab tab) {
myPropertySheet.getTabs().add(tab);
}
private static boolean hasDomainModel(CanvasMapping canvas) {
return canvas.getDomainModel() != null;
}
}
|