Java Reference
In-Depth Information
@Override
protected void setForegroundColor(org.eclipse.swt.graphics.Color
color) {
super.setForegroundColor(getPreferenceColor());
}
«
ENDDEFINE
»
Moving on to the preference page templates, we find the original
AppearancePreferencePage.xpt
template in
/templates/xpt/diagram/
preferences
. We need to override this template, along with
PreferenceInitializer.xpt
, because they were apparently not created
with extensibility in mind, as was the case with the
NodeEditPart.xpt
template. This means that we simply copy these two templates into our own
/templates-diagram/xpt/diagram/preferences
folder and modify them
to suit our needs. Most of the changes required for the preference page code is
straightforward copy and paste from our earlier handcrafted code, so we don't
repeat it here. However, we do need to explore how GMF deals with globaliza-
tion because we need to add referenced elements to our generated Messages class
and
messages.properties
file. Looking at the template files, we find an
Externalizer.xpt
template in the
/templates/xpt
folder in the generator
plug-in. The Externalizer template provides a centralized means by which to gen-
erate the Messages class and properties file. The template is organized in two
main definition blocks, as shown here. Basically, GMF convention is to declare
an
i18nAccessors
and
i18nValues
definition in templates that require local-
ization and invoke them from the
Fields
and
Values
definitions, respectively.
«
DEFINE
Fields
FOR
gmfgen::GenEditorGenerator»
«
EXPAND
xpt::editor::CreateShortcutAction::i18nAccessors
FOR
diagram-»
«
EXPAND
xpt::editor::CreationWizard::i18nAccessors
FOR
diagram-»
«
EXPAND
xpt::editor::CreationWizardPage::i18nAccessors
FOR
diagram-»
. . .
«
ENDDEFINE
»
«
DEFINE
Values
FOR
gmfgen::GenEditorGenerator»
«
EXPAND
xpt::editor::CreateShortcutAction::i18nValues
FOR
diagram-»
«
EXPAND
xpt::editor::CreationWizard::i18nValues
FOR
diagram-»
«
EXPAND
xpt::editor::CreationWizardPage::i18nValues
FOR
diagram-»
. . .
«
ENDDEFINE
»
We follow suit with our properties preference page by defining similar blocks
for invocation by our overridden
Externalizer.xpt
template. First, we take a
look at the externalizer, which is placed in our
/templates-diagram/
aspects/xpt
directory.
Search WWH ::
Custom Search