Procházet zdrojové kódy

Extracted common code to commons plugin

Andreas Mülder před 14 roky
rodič
revize
14d7f38fc1

+ 0 - 48
plugins/org.yakindu.sct.statechart.diagram/src/org/yakindu/sct/statechart/diagram/commands/CompartmentRepositionEObjectCommand.java

@@ -1,48 +0,0 @@
-package org.yakindu.sct.statechart.diagram.commands;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
-import org.eclipse.gmf.runtime.emf.commands.core.commands.RepositionEObjectCommand;
-import org.eclipse.gmf.runtime.notation.View;
-
-@SuppressWarnings("rawtypes")
-public class CompartmentRepositionEObjectCommand extends RepositionEObjectCommand {
-
-	EditPart childToMove = null;
-	int newIndex = 0;
-	
-	public CompartmentRepositionEObjectCommand(
-			TransactionalEditingDomain editingDomain, String label,
-			EList elements, EObject element, int displacement) {
-		super(editingDomain, label, elements, element, displacement);
-	}
-	
-	public CompartmentRepositionEObjectCommand(EditPart childToMove,
-			TransactionalEditingDomain editingDomain, String label,
-			EList elements, EObject element, int displacement, int newIndex) {
-		super(editingDomain, label, elements, element, displacement);
-		
-		this.childToMove = childToMove;
-		this.newIndex = newIndex;
-	}
-	
-	public CommandResult doExecuteWithResult(
-			IProgressMonitor progressMonitor, IAdaptable info)
-			throws ExecutionException {
-		CommandResult rs = super.doExecuteWithResult(progressMonitor, info);
-				
-		EditPart compartment = childToMove.getParent(); 
-		
-		ViewUtil.repositionChildAt((View)compartment.getModel(), (View)childToMove.getModel(), newIndex);
-		compartment.refresh();		
-		
-		return rs;
-	}
-}

+ 0 - 102
plugins/org.yakindu.sct.statechart.diagram/src/org/yakindu/sct/statechart/diagram/policies/CompartmentEditPolicy.java

@@ -1,102 +0,0 @@
-package org.yakindu.sct.statechart.diagram.policies;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.EditPolicy;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.gef.requests.CreateRequest;
-import org.eclipse.gmf.runtime.diagram.core.commands.AddCommand;
-import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
-import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
-import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx;
-import org.eclipse.gmf.runtime.emf.commands.core.commands.RepositionEObjectCommand;
-import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
-import org.eclipse.gmf.runtime.notation.View;
-import org.yakindu.sct.statechart.diagram.commands.CompartmentRepositionEObjectCommand;
-
-//TODO: Move to commons
-public class CompartmentEditPolicy extends
-		org.eclipse.gef.editpolicies.FlowLayoutEditPolicy {
-
-	private EStructuralFeature feature = null;
-
-	protected Command createAddCommand(EditPart child, EditPart after) {
-		int index = getHost().getChildren().indexOf(after);
-		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
-				.getEditingDomain();
-		AddCommand command = new AddCommand(editingDomain, new EObjectAdapter(
-				(View) getHost().getModel()), new EObjectAdapter(
-				(View) child.getModel()), index);
-		return new ICommandProxy(command);
-	}
-
-	protected EditPolicy createChildEditPolicy(EditPart child) {
-		ResizableEditPolicyEx policy = new ResizableEditPolicyEx();
-		policy.setResizeDirections(0);
-		return policy;
-	}
-
-	@SuppressWarnings("rawtypes")
-	protected Command createMoveChildCommand(EditPart child, EditPart after) {
-
-		int newIndex;
-		int displacement;
-
-		int childIndex = getHost().getChildren().indexOf(child);
-		int afterIndex = getHost().getChildren().indexOf(after);
-
-		if (afterIndex == -1) {
-			newIndex = getHost().getChildren().size() - 1;
-			displacement = newIndex - childIndex;
-		} else {
-			newIndex = afterIndex;
-			displacement = afterIndex - childIndex;
-			if (childIndex <= afterIndex) {
-				newIndex--;
-				displacement--;
-			}
-		}
-
-		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
-				.getEditingDomain();
-
-		RepositionEObjectCommand command = new CompartmentRepositionEObjectCommand(
-				child, editingDomain, "", (EList) ((View) child.getParent()
-						.getModel()).getElement().eGet(feature),
-				((View) child.getModel()).getElement(), displacement, newIndex);
-
-		// TODO ev. reintroduce target feedback (actual problem: line is not
-		// deleted after dropping)
-		eraseLayoutTargetFeedback(null);
-
-		return new ICommandProxy(command);
-	}
-
-	protected Command getCreateCommand(CreateRequest request) {
-		return null;
-	}
-
-	protected Command getDeleteDependantCommand(Request request) {
-		return null;
-	}
-
-	protected Command getOrphanChildrenCommand(Request request) {
-		return null;
-	}
-
-	/**
-	 * @param feature
-	 *            has to be an EList
-	 */
-	public CompartmentEditPolicy(EStructuralFeature feature) {
-		super();
-		this.feature = feature;
-	}
-	@Override
-	protected boolean isHorizontal() {
-		return true;
-	}
-}