* @see org.eclipse.graphiti.tb.DefaultToolBehaviorProvider#getContextButtonPad(org.eclipse.graphiti.features.context.IPictogramElementContext)
*/
@Override
public IContextButtonPadData getContextButtonPad(
IPictogramElementContext context) {
final IFeatureProvider featureProvider = getFeatureProvider();
IContextButtonPadData data = super.getContextButtonPad(context);
PictogramElement pe = context.getPictogramElement();
// 1. set the generic context buttons
// note, that we do not add 'remove' (just as an example)
setGenericContextButtons(data, pe, CONTEXT_BUTTON_DELETE);
// // 2. set the collapse button
// // simply use a dummy custom feature (senseless example)
// CustomContext cc = new CustomContext(new PictogramElement[] { pe });
// ICustomFeature[] cf = getFeatureProvider().getCustomFeatures(cc);
// for (int i = 0; i < cf.length; i++) {
// ICustomFeature iCustomFeature = cf[i];
// if (iCustomFeature instanceof CollapseDummyFeature) {
// IContextButtonEntry collapseButton = ContextEntryHelper.createCollapseContextButton(true, iCustomFeature, cc);
// data.setCollapseContextButton(collapseButton);
// }
// }
// 3. add one domain specific context-button, which offers all
// available connection-features as drag&drop features...
// 3.a. create new CreateConnectionContext
{
CreateConnectionContext ccc = new CreateConnectionContext();
ccc.setSourcePictogramElement(pe);
Anchor anchor = null;
if (pe instanceof Anchor) {
anchor = (Anchor) pe;
} else if (pe instanceof AnchorContainer) {
// assume, that our shapes always have chopbox anchors
anchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
}
ccc.setSourceAnchor(anchor);
// 3.b. create context button and add all applicable features
ContextButtonEntry button = new ContextButtonEntry(null, context);
button.setText("Create connection"); //$NON-NLS-1$
button.setIconId(ImageProvider.IMG_FLOW);
ICreateConnectionFeature[] features = featureProvider.getCreateConnectionFeatures();
for (ICreateConnectionFeature feature : features) {
if (feature.isAvailable(ccc) && feature.canStartConnection(ccc))
button.addDragAndDropFeature(feature);
}