Package org.eclipse.sapphire.ui.swt.gef.policies

Source Code of org.eclipse.sapphire.ui.swt.gef.policies.NodeEditPolicy

/******************************************************************************
* Copyright (c) 2014 Oracle
* All rights reserved. This program and the accompanying materials
* are 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:
*    Ling Hao - initial implementation and ongoing maintenance
******************************************************************************/

package org.eclipse.sapphire.ui.swt.gef.policies;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;
import org.eclipse.sapphire.ui.swt.gef.commands.DeleteNodeCommand;
import org.eclipse.sapphire.ui.swt.gef.model.DiagramNodeModel;

/**
* @author <a href="mailto:ling.hao@oracle.com">Ling Hao</a>
*/

public class NodeEditPolicy extends ComponentEditPolicy {

  @Override
  protected Command createDeleteCommand(GroupRequest deleteRequest) {
    Object child = getHost().getModel();
    if (child instanceof DiagramNodeModel) {
      DiagramNodeModel nodeModel = (DiagramNodeModel)child;
      return new DeleteNodeCommand(nodeModel.getNodePresentation());
    }
    return super.createDeleteCommand(deleteRequest);
  }

}
TOP

Related Classes of org.eclipse.sapphire.ui.swt.gef.policies.NodeEditPolicy

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.