Package org.eclipse.bpmn2.modeler.core.features.gateway

Source Code of org.eclipse.bpmn2.modeler.core.features.gateway.DirectEditExclusiveGatewayFeature

/*******************************************************************************
* 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.core.features.gateway;

import org.eclipse.bpmn2.ExclusiveGateway;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IDirectEditingContext;
import org.eclipse.graphiti.features.impl.AbstractDirectEditingFeature;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;

public class DirectEditExclusiveGatewayFeature extends AbstractDirectEditingFeature {

  public DirectEditExclusiveGatewayFeature(IFeatureProvider fp) {
    super(fp);
  }

  @Override
  public int getEditingType() {
    return TYPE_TEXT;
  }

  @Override
  public String getInitialValue(IDirectEditingContext context) {
    PictogramElement pe = context.getPictogramElement();
    ExclusiveGateway eClass = (ExclusiveGateway) getBusinessObjectForPictogramElement(pe);
    return eClass.getName();
  }

  @Override
  public void setValue(String value, IDirectEditingContext context) {
    PictogramElement pe = context.getPictogramElement();

    ExclusiveGateway gateway = (ExclusiveGateway) getBusinessObjectForPictogramElement(pe);
    gateway.setName(value);

    updatePictogramElement(((Shape) pe).getContainer());
  }

  @Override
  public boolean canDirectEdit(IDirectEditingContext context) {
    PictogramElement pe = context.getPictogramElement();
    Object bo = getBusinessObjectForPictogramElement(pe);
    GraphicsAlgorithm ga = context.getGraphicsAlgorithm();

    return bo instanceof ExclusiveGateway && ga instanceof Text;
  }
}
TOP

Related Classes of org.eclipse.bpmn2.modeler.core.features.gateway.DirectEditExclusiveGatewayFeature

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.