Commits

Anonymous committed 167cedf

adding code fragments to classes is allowed

  • Participants
  • Parent commits b647615

Comments (0)

Files changed (6)

src/nl/tudelft/lime/edit/policy/LimeXYLayoutEditPolicy.java

 
         LimeSubpart newPart = (LimeSubpart) request.getNewObject();
         create.setChild(newPart);
-
-        Rectangle constraint = (Rectangle) getConstraintFor(request);
-        create.setLocation(constraint);
+        
+        Rectangle constraint; 
+        if (getLayoutContainer().getLayoutManager() instanceof XYLayout)
+        	create.setLocation((Rectangle) getConstraintFor(request));
+        
         create.setLabel(LimeMessages.LimeXYLayoutEditPolicy_CreateCommandLabelText);
 
         Command cmd = chainGuideAttachmentCommand(request, newPart, create, true);

src/nl/tudelft/lime/model/LimeElement.java

-/*******************************************************************************
- * 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 nl.tudelft.lime.model;
 
 import java.beans.PropertyChangeListener;
 import org.eclipse.ui.views.properties.IPropertySource;
 
 
-public class LimeElement implements IPropertySource, Cloneable,
+public abstract class LimeElement implements IPropertySource, Cloneable,
     Serializable {
     public static final String BOUNDS = "BOUNDS"; //$NON-NLS-1$
     public static final String CHILDREN = "Children"; //$NON-NLS-1$
      * Concrete models should write their own copy functions
      * @return
      */
-    public LimeSubpart getCopy(){
-    	return null;
-    }
+    public abstract LimeSubpart getCopy();
 }

src/nl/tudelft/lime/model/codefragment/LimeCodeFragment.java

 import nl.tudelft.lime.constants.LimeMessages;
 import nl.tudelft.lime.constants.SystemSettings;
 import nl.tudelft.lime.model.LimeSubpart;
+import nl.tudelft.lime.model.port.OutputPort;
 
 import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.swt.graphics.Image;
 	public void setContext(String context) {
 		this.context = context;
 	}
-    
+
+	@Override
+	public LimeSubpart getCopy() {
+		LimeCodeFragment fragment = new LimeCodeFragment();
+		//use reflection further
+		fragment.context = this.context;
+		fragment.text = this.text;
+		this.addToInstances(fragment);
+		fragment.setAnInstanceOf(this);
+		return fragment;
+	}
+
+	
 }

src/nl/tudelft/lime/model/component/LimeDiagram.java

 	public LimeComponent getComponentForName(String componentName) {
 		return componentClassDictionary.get(componentName);
 	}
+	/**
+	 * a diagram should not be instantiated
+	 */
+	public LimeSubpart getCopy(){
+    	return null;
+    }
 
 }

src/nl/tudelft/lime/model/connection/Arc.java

     public static void clearTakenNumbers() {
         count = 0;
     }
-
+    
 
 }

src/nl/tudelft/lime/model/connection/Connection.java

 
         firePropertyChange("value", null, null); //$NON-NLS-1$
     }
+    
+    /**
+     * Arcs and associations are not copied. 
+     * Arcs should be drawn by hands
+     * Assocations should be copied in a complex way (look at @code{LimeComponent}).
+     */
+    public LimeSubpart getCopy(){
+    	return null;
+    }
 }