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
|
/*****************************************************************************
* Copyright (c) 2011-2012 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.sysml.diagram.blockdefinition.preferences;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.infra.gmfdiag.preferences.utils.PreferenceConstantHelper;
import org.eclipse.papyrus.sysml.diagram.blockdefinition.provider.ElementTypes;
import org.eclipse.papyrus.sysml.diagram.common.utils.SysMLGraphicalTypes;
public class BlockPreferencePage extends BlockDefinitionDiagramNodePreferencePage {
/** Constant key to access preferences */
public static String prefKey = ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_CLASSIFIER_ID; //$NON-NLS-1$
/** The compartments default visibility for preferences */
public static final Map<String, Boolean> compartmentDefaultVisibilityMap;
/** The compartment titles default visibility for preferences */
public static final Map<String, Boolean> compartmentTitleDefaultVisibilityMap;
/** Static attribute initialization */
static {
compartmentDefaultVisibilityMap = new LinkedHashMap<String, Boolean>();
compartmentDefaultVisibilityMap.put("properties", Boolean.TRUE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("parts", Boolean.FALSE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("references", Boolean.FALSE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("standard ports", Boolean.FALSE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("flow ports", Boolean.FALSE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("operations", Boolean.TRUE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("constraints", Boolean.TRUE); //$NON-NLS-1$
compartmentDefaultVisibilityMap.put("values", Boolean.FALSE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap = new LinkedHashMap<String, Boolean>();
compartmentTitleDefaultVisibilityMap.put("properties", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("parts", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("references", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("standard ports", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("flow ports", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("operations", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("constraints", Boolean.TRUE); //$NON-NLS-1$
compartmentTitleDefaultVisibilityMap.put("values", Boolean.TRUE); //$NON-NLS-1$
// Start of user code custom static initializations
// End of user code
Collections.unmodifiableMap(compartmentDefaultVisibilityMap);
Collections.unmodifiableMap(compartmentTitleDefaultVisibilityMap);
}
/** Constructor */
public BlockPreferencePage() {
super();
setPreferenceKey(ElementTypes.DIAGRAM_ID + "_" + SysMLGraphicalTypes.SHAPE_SYSML_BLOCK_AS_CLASSIFIER_ID); //$NON-NLS-1$
}
/** Default preferences initializer */
public static void initDefaults(IPreferenceStore store) {
// Start of user code custom default initializations
store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.WIDTH), 100);
store.setDefault(PreferenceConstantHelper.getElementConstant(prefKey, PreferenceConstantHelper.HEIGHT), 150);
// End of user code
// Initialize default visibility for compartments in preference page.
for(String compartmentName : compartmentDefaultVisibilityMap.keySet()) {
String showCompartmentKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_VISIBILITY);
store.setDefault(showCompartmentKey, compartmentDefaultVisibilityMap.get(compartmentName));
}
// Initialize default title visibility for compartments in preference page.
for(String compartmentName : compartmentTitleDefaultVisibilityMap.keySet()) {
String showCompartmentTitleKey = PreferenceConstantHelper.getCompartmentElementConstant(prefKey, compartmentName, PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY);
store.setDefault(showCompartmentTitleKey, compartmentTitleDefaultVisibilityMap.get(compartmentName));
}
}
/**
* {@inheritDoc}
*/
@Override
protected void initializeCompartmentNamesList() {
for(String name : compartmentDefaultVisibilityMap.keySet()) {
this.compartmentNamesList.add(name);
}
}
/**
* {@inheritDoc}
*/
@Override
protected void initializeCompartmentTitlesList() {
for(String name : compartmentTitleDefaultVisibilityMap.keySet()) {
this.compartmentTitlesList.add(name);
}
}
}
|