Package org.eclipse.graphiti.tb

Examples of org.eclipse.graphiti.tb.IContextButtonPadData


  @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);
      }

      // 3.c. add context button, if it contains at least one feature
      if (button.getDragAndDropFeatures().size() > 0) {
        data.getDomainSpecificContextButtons().add(button);
      }
    }

    /*
    // add a layout button
    {
      ContextButtonEntry button = new ActionContextButtonEntry(featureProvider, context) {

        @Override
        public void execute() {
          Activator.getDiagramEditor().autoLayoutRoute();
        }

      };
      button.setText("Layout Diagram"); //$NON-NLS-1$
      // TODO how to set a different icon ID?
      button.setIconId(ImageProvider.IMG_OUTLINE_THUMBNAIL);
      data.getDomainSpecificContextButtons().add(button);
    }
     */

    /**
     * TODO an attempt at adding a button that then shows the Add menu - not sure how though :)
    {
      ContextEntryFeature menuFeature = new ContextEntryFeature(featureProvider);
      final ContextMenuEntry menu = new ContextMenuEntry(menuFeature, context);
      ContextEntryFeature.configure(menu);

      menu.setSubmenu(true);
      menu.setText("Add Menu");

      AddNodeMenuFactory factory = new AddNodeMenuFactory();
      PictogramElement[] elements = new PictogramElement[] {pe};
      ICustomContext customContext = new CustomContext(elements);;
      factory.setupMenuStructure(menu, customContext , featureProvider);


      ContextButtonEntry button = new ActionContextButtonEntry(featureProvider, context) {

        @Override
        public void execute() {
          Activator.getLogger().debug("====== should be showing my menu now!!!");
          menu.execute();
        }

      };
      button.setText("Add"); //$NON-NLS-1$
      // TODO how to set a different icon ID?
      button.setIconId(ImageProvider.IMG_OUTLINE_THUMBNAIL);
      data.getDomainSpecificContextButtons().add(button);
    }
     *
     */
   
    // add buttons for breakpoint manipulation
    CustomContext cc = new CustomContext(new PictogramElement[] { pe });
    ICustomFeature[] cf = getFeatureProvider().getCustomFeatures(cc);
    for (ICustomFeature f : cf) {
      if (f instanceof DeleteAllEndpointBreakpointsFeature) continue;
      if (f instanceof SetEndpointBreakpointFeature) {
        if (f.isAvailable(cc)) {
          IContextButtonEntry button = new ContextButtonEntry(f, cc);
          data.getDomainSpecificContextButtons().add(button);
   
        }
      }
    }

View Full Code Here


    return super.getDoubleClickFeature(context);
  }

  @Override
  public IContextButtonPadData getContextButtonPad(IPictogramElementContext context) {
    IContextButtonPadData data = super.getContextButtonPad(context);
    PictogramElement pe = context.getPictogramElement();

    setGenericContextButtons(data, pe, CONTEXT_BUTTON_DELETE);

    Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);

    CreateConnectionContext connectionContext = new CreateConnectionContext();
    connectionContext.setSourcePictogramElement(pe);
    Anchor connectionAnchor = null;
    if (pe instanceof Anchor) {
      connectionAnchor = (Anchor) pe;
    } else if (pe instanceof AnchorContainer) {
      connectionAnchor = Graphiti.getPeService().getChopboxAnchor((AnchorContainer) pe);
    }
    connectionContext.setSourceAnchor(connectionAnchor);

    if (pe.eContainer() instanceof ContainerShape == false) {
      return data;
    }

    CreateContext taskContext = new CreateContext();
    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);
      addContextButton(otherElementButton, new CreateManualTaskFeature(getFeatureProvider()), taskContext, "Create manual task", "Create a new manual task",
              PluginImage.IMG_MANUALTASK);
      addContextButton(otherElementButton, new CreateReceiveTaskFeature(getFeatureProvider()), taskContext, "Create receive task", "Create a new receive task",
              PluginImage.IMG_RECEIVETASK);
      addContextButton(otherElementButton, new CreateCallActivityFeature(getFeatureProvider()), taskContext, "Create call activity",
              "Create a new call activiti", PluginImage.IMG_CALLACTIVITY);
      addContextButton(otherElementButton, new CreateExclusiveGatewayFeature(getFeatureProvider()), taskContext, "Create exclusive gateway",
              "Create a new exclusive gateway", PluginImage.IMG_GATEWAY_EXCLUSIVE);
      addContextButton(otherElementButton, new CreateInclusiveGatewayFeature(getFeatureProvider()), taskContext, "Create inclusive gateway",
              "Create a new inclusive gateway", PluginImage.IMG_GATEWAY_INCLUSIVE);
      addContextButton(otherElementButton, new CreateParallelGatewayFeature(getFeatureProvider()), taskContext, "Create parallel gateway",
              "Create a new parallel gateway", PluginImage.IMG_GATEWAY_PARALLEL);
      addContextButton(otherElementButton, new CreateEndEventFeature(getFeatureProvider()), taskContext, "Create end event", "Create a new end event",
              PluginImage.IMG_ENDEVENT_NONE);
      addContextButton(otherElementButton, new CreateErrorEndEventFeature(getFeatureProvider()), taskContext, "Create error end event",
              "Create a new error end event", PluginImage.IMG_ENDEVENT_ERROR);
      addContextButton(otherElementButton, new CreateTerminateEndEventFeature(getFeatureProvider()), taskContext, "Create terminate end event",
              "Create a new terminate end event", PluginImage.IMG_ENDEVENT_TERMINATE);
      addContextButton(otherElementButton, new CreateAlfrescoScriptTaskFeature(getFeatureProvider()), taskContext, "Create alfresco script task",
              "Create a new alfresco script task", PluginImage.IMG_SERVICETASK);
      addContextButton(otherElementButton, new CreateAlfrescoUserTaskFeature(getFeatureProvider()), taskContext, "Create alfresco user task",
              "Create a new alfresco user task", PluginImage.IMG_USERTASK);
      addContextButton(otherElementButton, new CreateAlfrescoMailTaskFeature(getFeatureProvider()), taskContext, "Create alfresco mail task",
              "Create a new alfresco mail task", PluginImage.IMG_MAILTASK);
    }

    ContextButtonEntry editElementButton = new ContextButtonEntry(null, null);
    editElementButton.setText("change element type"); //$NON-NLS-1$
    editElementButton.setDescription("Change the element type to another type"); //$NON-NLS-1$
    editElementButton.setIconId(PluginImage.EDIT_ICON.getImageKey());
    data.getDomainSpecificContextButtons().add(editElementButton);

    CustomContext customContext = new CustomContext();
    customContext.putProperty("org.activiti.designer.changetype.pictogram", pe);

    if (bo instanceof Task) {
View Full Code Here

TOP

Related Classes of org.eclipse.graphiti.tb.IContextButtonPadData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.