taskContext.setTargetContainer((ContainerShape) pe.eContainer());
taskContext.putProperty("org.activiti.designer.connectionContext", connectionContext);
if (bo instanceof StartEvent || bo instanceof Task || bo instanceof CallActivity || bo instanceof Gateway) {
CreateUserTaskFeature userTaskfeature = new CreateUserTaskFeature(getFeatureProvider());
ContextButtonEntry newUserTaskButton = new ContextButtonEntry(userTaskfeature, taskContext);
newUserTaskButton.setText("new user task"); //$NON-NLS-1$
newUserTaskButton.setDescription("Create a new task"); //$NON-NLS-1$
newUserTaskButton.setIconId(PluginImage.IMG_USERTASK.getImageKey());
data.getDomainSpecificContextButtons().add(newUserTaskButton);
CreateExclusiveGatewayFeature exclusiveGatewayFeature = new CreateExclusiveGatewayFeature(getFeatureProvider());
ContextButtonEntry newExclusiveGatewayButton = new ContextButtonEntry(exclusiveGatewayFeature, taskContext);
newExclusiveGatewayButton.setText("new exclusive gateway"); //$NON-NLS-1$
newExclusiveGatewayButton.setDescription("Create a new exclusive gateway"); //$NON-NLS-1$
newExclusiveGatewayButton.setIconId(PluginImage.IMG_GATEWAY_EXCLUSIVE.getImageKey());
data.getDomainSpecificContextButtons().add(newExclusiveGatewayButton);
CreateEndEventFeature endFeature = new CreateEndEventFeature(getFeatureProvider());
ContextButtonEntry newEndButton = new ContextButtonEntry(endFeature, taskContext);
newEndButton.setText("new end event"); //$NON-NLS-1$
newEndButton.setDescription("Create a new end event"); //$NON-NLS-1$
newEndButton.setIconId(PluginImage.IMG_ENDEVENT_NONE.getImageKey());
data.getDomainSpecificContextButtons().add(newEndButton);
}
CreateConnectionContext ccc = new CreateConnectionContext();
ccc.setSourcePictogramElement(pe);
Anchor anchor = null;
if (pe instanceof Anchor) {
anchor = (Anchor) pe;
} else if (pe instanceof AnchorContainer) {
anchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
}
ccc.setSourceAnchor(anchor);
ContextButtonEntry button = new ContextButtonEntry(null, context);
button.setText("Create connection"); //$NON-NLS-1$
button.setIconId(PluginImage.IMG_EREFERENCE.getImageKey());
ICreateConnectionFeature[] features = getFeatureProvider().getCreateConnectionFeatures();
for (ICreateConnectionFeature feature : features) {
if (feature.isAvailable(ccc) && feature.canStartConnection(ccc)) {
button.addDragAndDropFeature(feature);
}
}
if (button.getDragAndDropFeatures().size() > 0) {
data.getDomainSpecificContextButtons().add(button);
}
if (bo instanceof StartEvent || bo instanceof Task || bo instanceof CallActivity || bo instanceof Gateway) {
ContextButtonEntry otherElementButton = new ContextButtonEntry(null, null);
otherElementButton.setText("new element"); //$NON-NLS-1$
otherElementButton.setDescription("Create a new element"); //$NON-NLS-1$
otherElementButton.setIconId(PluginImage.NEW_ICON.getImageKey());
data.getDomainSpecificContextButtons().add(otherElementButton);
addContextButton(otherElementButton, new CreateServiceTaskFeature(getFeatureProvider()), taskContext, "Create service task", "Create a new service task",
PluginImage.IMG_SERVICETASK);
addContextButton(otherElementButton, new CreateScriptTaskFeature(getFeatureProvider()), taskContext, "Create script task", "Create a new script task",
PluginImage.IMG_SCRIPTTASK);
addContextButton(otherElementButton, new CreateUserTaskFeature(getFeatureProvider()), taskContext, "Create user task", "Create a new user task",
PluginImage.IMG_USERTASK);
addContextButton(otherElementButton, new CreateMailTaskFeature(getFeatureProvider()), taskContext, "Create mail task", "Create a new mail task",
PluginImage.IMG_MAILTASK);
addContextButton(otherElementButton, new CreateBusinessRuleTaskFeature(getFeatureProvider()), taskContext, "Create business rule task",
"Create a new business rule task", PluginImage.IMG_BUSINESSRULETASK);