Java Reference
In-Depth Information
}
return
element;
}
private
Object unwrapEditPart(EditPart p) {
if
(p.getModel()
instanceof
View) {
return
unwrapView((View) p.getModel());
}
return
p.getModel();
}
private
Object unwrapView(View view) {
return
view.getElement() ==
null
? view : view.getElement();
}
}
As you can see, we need to add an
AdapterFactory
for our plug-in, which
can be configured in our
MindmapDiagramEditorPlugin
class, as shown here:
private
ComposedAdapterFactory adapterFactory;
@Override
public void
start(BundleContext context)
throws
Exception {
super
.start(context);
instance =
this
;
adapterFactory = createAdapterFactory();
}
protected
ComposedAdapterFactory createAdapterFactory() {
final
List<AdapterFactoryImpl> factories =
new
ArrayList<AdapterFactoryImpl>();
factories.add(
new
MindmapItemProviderAdapterFactory());
factories.add(
new
ResourceItemProviderAdapterFactory());
factories.add(
new
ReflectiveItemProviderAdapterFactory());
return new
ComposedAdapterFactory(factories);
}
public
AdapterFactory getItemProvidersAdapterFactory() {
return
adapterFactory;
}
The
propertySections
contribution appears here, along with the imple-
mentation of our
MindmapPropertySection
class. Input types are declared to
be GEF
EditPart
types because they will be selected on our diagram. The
implementation of
MindmapPropertySection
is standard for most diagrams
and can be seen in generated code for the mindmap diagram.
Search WWH ::
Custom Search