Package org.eclipse.bpmn2.modeler.ui.features.participant

Source Code of org.eclipse.bpmn2.modeler.ui.features.participant.CreateParticipantFeature

/*******************************************************************************
* Copyright (c) 2011 Red Hat, Inc.
*  All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.eclipse.bpmn2.modeler.ui.features.participant;

import java.io.IOException;

import org.eclipse.bpmn2.Participant;
import org.eclipse.bpmn2.modeler.core.Activator;
import org.eclipse.bpmn2.modeler.core.ModelHandler;
import org.eclipse.bpmn2.modeler.core.ModelHandlerLocator;
import org.eclipse.bpmn2.modeler.ui.ImageProvider;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICreateContext;
import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.mm.pictograms.Diagram;

public class CreateParticipantFeature extends AbstractCreateFeature {
 
  private static int index = 1;
 
  public CreateParticipantFeature(IFeatureProvider fp) {
      super(fp, "Pool", "Container for partitioning a set of activities");
    }

  @Override
    public boolean canCreate(ICreateContext context) {
    return context.getTargetContainer() instanceof Diagram;
    }

  @Override
    public Object[] create(ICreateContext context) {
    Participant p = null;
   
    try {
          ModelHandler mh = ModelHandlerLocator.getModelHandler(getDiagram().eResource());
          p = mh.addParticipant();
          p.setName("Pool nr " + index++);
        } catch (IOException e) {
          Activator.logError(e);
        }
       
        addGraphicalRepresentation(context, p);
    return new Object[] { p };
    }
 
  @Override
  public String getCreateImageId() {
      return ImageProvider.IMG_16_PARTICIPANT;
  }
 
  @Override
  public String getCreateLargeImageId() {
      return getCreateImageId(); // FIXME
  }
}
TOP

Related Classes of org.eclipse.bpmn2.modeler.ui.features.participant.CreateParticipantFeature

TOP
Copyright © 2018 www.massapi.com. 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.