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
|
/******************************************************************************
* Copyright (c) 2008, 2020 Borland Software Corporation, CEA LIST, Artal and others
*
* 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
*****************************************************************************/
«IMPORT 'http://www.eclipse.org/papyrus/gmf/2020/GenModel'»
«DEFINE Main FOR gmfgen::GenCustomPreferencePage-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
package «(if qualifiedClassName = getClassName() then getDiagram().preferencesPackageName else qualifiedClassName.substring(1 + 0, qualifiedClassName.size() - getClassName().size() - 1) endif)»;
«EXPAND xpt::Common::generatedClassComment»
public class «getClassName()»«EXPAND extendsList»«EXPAND implementsList» {
«EXPAND _constant FOREACH preferences-»
«EXPAND xpt::Common::generatedMemberComment»
public «getClassName()»() {
setPreferenceStore(«getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().getPreferenceStore());
}
«EXPAND methods»
«EXPAND initDefaultsMethod»
«EXPAND additions»
}
«ENDDEFINE»
«DEFINE extendsList FOR gmfgen::GenCustomPreferencePage» extends org.eclipse.gmf.runtime.common.ui.preferences.AbstractPreferencePage«ENDDEFINE»
«DEFINE implementsList FOR gmfgen::GenCustomPreferencePage»«REM»no-op«ENDREM»«ENDDEFINE»
«DEFINE additions FOR gmfgen::GenCustomPreferencePage»«ENDDEFINE»
// the reason I didn't split this template up into two distinct, addFieldsMethod and initHelpMethod, is that
// using superclass other than oe.gmf...AbstractPreferencePage may require implementation of completely different
// set of methods. Besides, there's not to much generated, anyway.
«DEFINE methods FOR gmfgen::GenCustomPreferencePage»
«EXPAND xpt::Common::generatedMemberComment»
protected void addFields(org.eclipse.swt.widgets.Composite parent) {
// TODO Provide method implementation
throw new UnsupportedOperationException();
}
«EXPAND xpt::Common::generatedMemberComment»
protected void initHelp() {
// TODO implement this method if needed, or leave as no-op
}
«ENDDEFINE»
«DEFINE initDefaultsMethod FOR gmfgen::GenCustomPreferencePage-»
«EXPAND xpt::Common::generatedMemberComment»
public static void initDefaults(org.eclipse.jface.preference.IPreferenceStore store) {
«IF preferences->isEmpty() or preferences->exists(p | p.defaultValue = null)-»
// TODO this code is invoked during preference store initialization, please fill
// the store passed with default preference values.
«ENDIF-»
«EXPAND _setDefaultValue('store') FOREACH preferences->select(p | p.defaultValue <> null)-»
}
«ENDDEFINE»
// pair template to initDefaultsMethod, allows external templates invoke generated initDefaults method
// Note, CustomPage::Main is expected to be invoked only for templates with generateBoilerplate == true,
// hence no extra check when generating with initDefaultsMethod,
// however, call_initDefaults may get invoked for any CustomPreferencePage
«DEFINE call_initDefaults(storeVarName : String) FOR gmfgen::GenCustomPreferencePage-»
«IF generateBoilerplate»«qualifiedClassName».initDefaults(«storeVarName»);«ENDIF-»
«ENDDEFINE»
«DEFINE _constant FOR gmfgen::GenPreference-»
«EXPAND xpt::Common::generatedMemberComment»
public static final String «name» = "«key»";«EXPAND xpt::Common::nonNLS»
«ENDDEFINE»
«DEFINE _setDefaultValue(store : String) FOR gmfgen::GenPreference-»
«store».setDefault(«name», «defaultValue»);
«ENDDEFINE»
|