Package org.gvt

Source Code of org.gvt.ChsDragEditPartsTracker

package org.gvt;

import java.util.Iterator;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.*;
import org.eclipse.gef.tools.DragEditPartsTracker;
import org.gvt.command.ChsCompoundCommand;

/**
* This class handles the dragging.
*
* @author Cihan Kucukkececi
*
* Copyright: I-Vis Research Group, Bilkent University, 2007
*/
public class ChsDragEditPartsTracker extends DragEditPartsTracker
{
  public ChsDragEditPartsTracker(EditPart sourceEditPart)
  {
    super(sourceEditPart);
  }

  protected Command getCommand()
  {
    ChsCompoundCommand command = new ChsCompoundCommand();
    command.setDebugLabel("Drag Object Tracker");

    Iterator iter = getOperationSet().iterator();

    Request request = getTargetRequest();

    if (isCloneActive())
    {
      request.setType(REQ_CLONE);
    }
    else if (isMove())
    {
      request.setType(REQ_MOVE);
    }
    else
    {
      request.setType(REQ_ORPHAN);
    }

    if (!isCloneActive())
    {
      while (iter.hasNext())
      {
        EditPart editPart = (EditPart)iter.next();
        command.add(editPart.getCommand(request));
      }
    }

    /*OK*/
    if (ChisioMain.transferNode)
    {
      if (!isMove() || isCloneActive())
      {
        if (!isCloneActive())
        {
          request.setType(REQ_ADD);
        }

        if (getTargetEditPart() == null)
        {
          command.add(UnexecutableCommand.INSTANCE);
        }
        else
        {
          command.add(
            getTargetEditPart().getCommand(getTargetRequest()));
        }
      }
    }

    return command;
  }
}
TOP

Related Classes of org.gvt.ChsDragEditPartsTracker

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.