Skip to content
Snippets Groups Projects
Commit db7c92f8 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

bugfix: layout utils reuse old objects if possible

refs 820
parent cc30ea9e
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: 5C92A83202006734362EED9438B3A2D8
* @ConQAT.Rating YELLOW Hash: 5BDF0EA81728D59FBC5E27E00904D085
*/
public final class DimensionUtils {
......@@ -42,11 +42,10 @@ public final class DimensionUtils {
* the layout key
* @return the dimension of the element
*/
public static Dimension getDimension(ILayoutedModelElement layouted,
String key) {
for (ILayoutData ld : layouted.getLayoutDataList()) {
if (ld.getKey().equals(key) && ld instanceof Dimension) {
return (Dimension) ld;
public static Dimension getDimension(ILayoutedModelElement layouted, String key) {
for(ILayoutData ld : layouted.getLayoutDataList()) {
if(ld.getKey().equals(key) && ld instanceof Dimension) {
return (Dimension)ld;
}
}
return null;
......@@ -64,13 +63,13 @@ public final class DimensionUtils {
* @param h
* the height
*/
public static void setDimension(ILayoutedModelElement layouted, String key,
int w, int h) {
public static void setDimension(ILayoutedModelElement layouted, String key, int w, int h) {
Dimension old = getDimension(layouted, key);
if (old != null) {
layouted.getLayoutDataList().remove(old);
if(old != null) {
old.setWidth(w);
old.setHeight(h);
} else {
layouted.getLayoutDataList().add(createDimension(w, h, key));
}
Dimension d = createDimension(w, h, key);
layouted.getLayoutDataList().add(d);
}
}
......@@ -32,7 +32,7 @@ import org.fortiss.tooling.base.model.layout.Point;
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating GREEN Hash: C4401B596767E967B83634EA26A60EC4
* @ConQAT.Rating YELLOW Hash: 497062A726321ADDE1E6991D61DE481F
*/
public final class PointUtils {
......@@ -48,10 +48,10 @@ public final class PointUtils {
public static Point getPosition(ILayoutedModelElement layouted, String key) {
Point point = getPoint(layouted, key);
if (point == null) {
if(point == null) {
int index = 0;
EObject container = layouted.eContainer();
if (container != null) {
if(container != null) {
index = 1 + container.eContents().indexOf(layouted);
}
Point p = createPoint(index * 20, index * 20, key);
......@@ -62,9 +62,9 @@ public final class PointUtils {
/** Returns a {@link Point} layout data object with the given key or null. */
private static Point getPoint(ILayoutedModelElement layouted, String key) {
for (ILayoutData ld : layouted.getLayoutDataList()) {
if (ld.getKey().equals(key) && ld instanceof Point) {
return (Point) ld;
for(ILayoutData ld : layouted.getLayoutDataList()) {
if(ld.getKey().equals(key) && ld instanceof Point) {
return (Point)ld;
}
}
return null;
......@@ -82,13 +82,13 @@ public final class PointUtils {
* @param y
* the y coordinate value
*/
public static void setPoint(ILayoutedModelElement layouted, String key,
int x, int y) {
public static void setPoint(ILayoutedModelElement layouted, String key, int x, int y) {
Point old = getPoint(layouted, key);
if (old != null) {
layouted.getLayoutDataList().remove(old);
if(old != null) {
old.setX(x);
old.setY(y);
} else {
layouted.getLayoutDataList().add(createPoint(x, y, key));
}
Point p = createPoint(x, y, key);
layouted.getLayoutDataList().add(p);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment