Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0568f5f9e21b8ba05dd66ac7548919ced8e623a4 (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
/*
 * Copyright (c) 2008 Atos Origin
 * 
 * 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:
 *    Thibault Landre (Atos Origin) - initial API and implementation
 *    Vincent Lorenzo (CEA-LIST) - 335987: [General][Enhancement] Show/Hide Connectors Labels https://bugs.eclipse.org/bugs/show_bug.cgi?id=335987
 */

«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«IMPORT 'http://www.eclipse.org/papyrus/2009/papyrusgmfgenextension'»

«EXTENSION xpt::preferences::PrefsConstant»

«DEFINE className FOR gmfgen::GenLink»«elementType.displayName»«getPreferencePageSuffix()»«ENDDEFINE»

«DEFINE LinkPreferencePage FOR gmfgen::GenLink-»
package «getDiagram().preferencesPackageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «EXPAND className» extends org.eclipse.papyrus.infra.gmfdiag.preferences.pages.AbstractPapyrusLinkPreferencePage {

«EXPAND xpt::Common::generatedClassComment»
	public «EXPAND className»() {
		super();
		setPreferenceKey( «getDiagram().editPartsPackageName».«getDiagram().editPartClassName».MODEL_ID+"_«elementType.displayName»");
	}
	«EXPAND xpt::Common::generatedClassComment»
	@Override
	protected String getBundleId() {
		return «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».ID;
	}

	«EXPAND xpt::Common::generatedClassComment»
	public static void initDefaults(org.eclipse.jface.preference.IPreferenceStore store) {
	«REM» executed, only if the element has labels with defined role (using papyrusgmfgenextension::LabelVisibilityPreference)  «ENDREM»
		«IF self.labels->exists(lbl0 : gmfgen::GenLinkLabel | (papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label0 : papyrusgmfgenextension::LabelVisibilityPreference | label0.linkLabels->includes(lbl0))->size()<>0))-»
		    String key = «getDiagram().editPartsPackageName».«getDiagram().editPartClassName».MODEL_ID+"_«elementType.displayName»";
		    java.util.Map<String, Boolean> map = getStaticLabelVisibilityPreferences();
			for(String role : map.keySet()){
				String preferenceName = org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.getLabelElementConstant(key, role, org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper.LABEL_VISIBILITY);
				store.setDefault(preferenceName, map.get(role));
			}
		«ENDIF-»
	«REM» end of the add for papyrusgmfgenextension::LabelVisibilityPreference«ENDREM»
	}
	
		«REM» executed, only if the element has labels with defined role (using papyrusgmfgenextension::LabelVisibilityPreference)  «ENDREM»
		«IF self.labels->exists(lbl0 : gmfgen::GenLinkLabel | (papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label0 : papyrusgmfgenextension::LabelVisibilityPreference | label0.linkLabels->includes(lbl0))->size()<>0))-»
			«EXPAND xpt::Common::generatedClassComment»
			private static java.util.TreeMap<String,String> getStaticLabelRole(){
				java.util.TreeMap<String,String> map = new java.util.TreeMap<String, String>(new org.eclipse.papyrus.uml.diagram.common.util.StringComparator());
				«FOREACH labels AS lbl-»
				«IF papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->size()<>0-»
				map.put(
				"«papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->asSequence()->first().role»"
				,"«papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->asSequence()->first().iconPathRole»"
				);//$NON-NLS-1$ //$NON-NLS-2$
				«ENDIF-»
			    «ENDFOREACH-»
				return map;
			}
			
			«EXPAND xpt::Common::generatedClassComment»
			private static java.util.TreeMap<String,Boolean> getStaticLabelVisibilityPreferences(){
				java.util.TreeMap<String,Boolean> map = new java.util.TreeMap<String,Boolean>();
				«FOREACH labels AS lbl-»
				«IF papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->size()<>0-»
					«IF papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->asSequence()->first().visibleByDefault=true-»
						map.put("«papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->asSequence()->first().role»"
					,Boolean.TRUE);
					«ELSE»
					map.put("«papyrusgmfgenextension::LabelVisibilityPreference.allInstances()->select(label : papyrusgmfgenextension::LabelVisibilityPreference | label.linkLabels->includes(lbl))->asSequence()->first().role»"
					,Boolean.FALSE);//$NON-NLS-1$
					«ENDIF»
				«ENDIF-»
			    «ENDFOREACH-»
				return map;
			}
			
			«EXPAND xpt::Common::generatedClassComment»
			protected java.util.TreeMap<String,String> getLabelRole(){
				return getStaticLabelRole();
			}
		«ENDIF»
	«REM» end of the code used to managed papyrusgmfgenextension::LabelVisibilityPreference«ENDREM»
}
«ENDDEFINE»

Back to the top