1 8 package com.nightlabs.editor2d.editpolicy.tree; 9 10 import org.eclipse.draw2d.geometry.Dimension; 11 import org.eclipse.draw2d.geometry.Rectangle; 12 import org.eclipse.gef.commands.Command; 13 14 import com.nightlabs.editor2d.DrawComponent; 15 import com.nightlabs.editor2d.Layer; 16 import com.nightlabs.editor2d.MultiLayerDrawComponent; 17 import com.nightlabs.editor2d.command.CreateDrawComponentCommand; 18 19 20 public class MultiLayerDrawComponentTreeEditPolicy 21 extends DrawComponentTreeContainerEditPolicy 22 { 23 protected Command createCreateCommand(DrawComponent child, Rectangle r, int index, String label) 24 { 25 CreateDrawComponentCommand cmd = new CreateDrawComponentCommand(); 26 Rectangle rect; 27 if(r == null) { 28 rect = new Rectangle(); 29 rect.setSize(new Dimension(-1,-1)); 30 } 31 else { 32 rect = r; 33 } 34 cmd.setLocation(rect); 35 36 MultiLayerDrawComponent mldc = (MultiLayerDrawComponent)getHost().getModel(); 37 Layer currentLayer = mldc.getCurrentLayer(); 38 cmd.setParent(currentLayer); 39 40 cmd.setChild(child); 41 cmd.setLabel(label); 42 if(index >= 0) 43 cmd.setIndex(index); 44 return cmd; 45 } 46 } 47 | Popular Tags |