Package org.eclipse.gef.examples.logicdesigner.edit

Source Code of org.eclipse.gef.examples.logicdesigner.edit.LogicContainerEditPolicy

/*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* 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:
*     IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.gef.examples.logicdesigner.edit;

import java.util.List;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
import org.eclipse.gef.editpolicies.ContainerEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gef.requests.GroupRequest;

import org.eclipse.gef.examples.logicdesigner.LogicMessages;
import org.eclipse.gef.examples.logicdesigner.model.LogicDiagram;
import org.eclipse.gef.examples.logicdesigner.model.LogicSubpart;
import org.eclipse.gef.examples.logicdesigner.model.commands.OrphanChildCommand;

public class LogicContainerEditPolicy
  extends ContainerEditPolicy
{

protected Command getCreateCommand(CreateRequest request) {
  return null;
}

public Command getOrphanChildrenCommand(GroupRequest request) {
  List parts = request.getEditParts();
  CompoundCommand result =
    new CompoundCommand(LogicMessages.LogicContainerEditPolicy_OrphanCommandLabelText);
  for (int i = 0; i < parts.size(); i++) {
    OrphanChildCommand orphan = new OrphanChildCommand();
    orphan.setChild((LogicSubpart)((EditPart)parts.get(i)).getModel());
    orphan.setParent((LogicDiagram)getHost().getModel());
    orphan.setLabel(LogicMessages.LogicElementEditPolicy_OrphanCommandLabelText);
    result.add(orphan);
  }
  return result.unwrap();
}

}
TOP

Related Classes of org.eclipse.gef.examples.logicdesigner.edit.LogicContainerEditPolicy

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.