Java Reference
In-Depth Information
DiagramContextMenuProvider">
<popupStructuredContributionCriteria
objectClass="org.eclipse.scenario.diagram.custom.edit.parts.
IntermediateEventImageEditPart" />
<popupAction path="/additions"
id="displayDefaultFigureAction"/>
</popupContribution>
</contributionItemProvider>
</extension>
The
ContributionItemProvider
class declared in the extension is shown
next. It extends the abstract provider supplied by the runtime and returns a new
DisplayDefaultFigureAction
class that we'll add to the *.
diagram.cus-
tom.actions
package. The action extends the provided
BooleanProperty
Action
class, leaving us with just an ID field and initialization to add.
public class
ContributionItemProvider
extends
AbstractContributionItemProvider {
protected
IAction createAction(String actionId,
IWorkbenchPartDescriptor partDescriptor) {
if
(actionId.equals(DisplayDefaultFigureAction.ID)) {
return new
DisplayDefaultFigureAction(partDescriptor.getPartPage());
}
return super
.createAction(actionId, partDescriptor);
}
}
public class
DisplayDefaultFigureAction
extends
BooleanPropertyAction {
static public final
String ID = "displayDefaultFigureAction";
public
DisplayDefaultFigureAction(IWorkbenchPage workbenchPage) {
super
(workbenchPage, PackageUtil.getID(
StylePackage.eINSTANCE.getCustomStyle_Default()),
"Display default image");
setId(ID);
setText("Display default image");
setToolTipText("Use the default image display
for this element");
}
}
We need to add the
org.eclipse.gmf.runtime.diagram.ui.actions
plug-in to our dependencies list. The ID declared in our extension matches the
ID field in our action class, which uses the ID of our
default:EBoolean
attrib-
ute of our
CustomStyle
class. We're also declaring that the contribution item
Search WWH ::
Custom Search