getSelectionHint(INode parentNode, INode childNode);
-
- /**
- * Paints any layout-specific selection feedback for the given parent layout.
- *
- * @param graphics the graphics context to paint into
- * @param parentNode the parent layout node
- * @param childNodes the child nodes selected in the parent layout
- */
- void paintSelectionFeedback(IGraphics graphics, INode parentNode,
- List extends INode> childNodes);
-
- // ==== Drag'n'drop support ====
-
- /**
- * Called when the d'n'd starts dragging over the target node.
- * If interested, returns a DropFeedback passed to onDrop/Move/Leave/Paint.
- * If not interested in drop, return null.
- * Followed by a paint.
- */
- DropFeedback onDropEnter(INode targetNode,
- IDragElement[] elements);
-
- /**
- * Called after onDropEnter.
- * Returns a DropFeedback passed to onDrop/Move/Leave/Paint (typically same
- * as input one).
- * Returning null will invalidate the drop workflow.
- */
- DropFeedback onDropMove(INode targetNode,
- IDragElement[] elements,
- DropFeedback feedback,
- Point where);
-
- /**
- * Called when drop leaves the target without actually dropping.
- *
- * When switching between views, onDropLeave is called on the old node *after* onDropEnter
- * is called after a new node that returned a non-null feedback. The feedback received here
- * is the one given by the previous onDropEnter on the same target.
- *
- * E.g. call order is:
- *
- * - onDropEnter(node1) => feedback1
- * ...user moves to new view...
- * - onDropEnter(node2) => feedback2
- * - onDropLeave(node1, feedback1)
- * ...user leaves canvas...
- * - onDropLeave(node2, feedback2)
- *
- */
- void onDropLeave(INode targetNode,
- IDragElement[] elements,
- DropFeedback feedback);
-
- /**
- * Called when drop is released over the target to perform the actual drop.
- *
- * TODO: Document that this method will be called under an edit lock so you can
- * directly manipulate the nodes without wrapping it in an
- * {@link INode#editXml(String, INodeHandler)} call
- */
- void onDropped(INode targetNode,
- IDragElement[] elements,
- DropFeedback feedback,
- Point where);
-
- /**
- * Called when pasting elements in an existing document on the selected target.
- *
- * @param targetNode The first node selected.
- * @param pastedElements The elements being pasted.
- */
- void onPaste(INode targetNode, IDragElement[] pastedElements);
-
- // ==== XML Creation ====
-
- /**
- * Called when a view for this rule is being created. This allows for the rule to
- * customize the newly created object. Note that this method is called not just when a
- * view is created from a palette drag, but when views are constructed via a drag-move
- * (where views are created in the destination and then deleted from the source), and
- * even when views are constructed programmatically from other view rules. The
- * {@link InsertType} parameter can be used to distinguish the context for the
- * insertion. For example, the DialerFilterRule
will insert EditText children
- * when a DialerFilter is first created, but not during a copy/paste or a move.
- *
- * @param node the newly created node (which will always be a View that applies to
- * this {@link IViewRule})
- * @param parent the parent of the node (which may not yet contain the newly created
- * node in its child list)
- * @param insertType whether this node was created as part of a newly created view, or
- * as a copy, or as a move, etc.
- */
- void onCreate(INode node, INode parent, InsertType insertType);
-
- /**
- * Called when a child for this view has been created and is being inserted into the
- * view parent for which this {@link IViewRule} applies. Allows the parent to perform
- * customizations of the object. As with {@link #onCreate}, the {@link InsertType}
- * parameter can be used to handle new creation versus moves versus copy/paste
- * operations differently.
- *
- * @param child the newly created node
- * @param parent the parent of the newly created node (which may not yet contain the
- * newly created node in its child list)
- * @param insertType whether this node was created as part of a newly created view, or
- * as a copy, or as a move, etc.
- */
- void onChildInserted(INode child, INode parent, InsertType insertType);
-
- /**
- * Called when one or more children are about to be deleted by the user. Note that
- * children deleted programmatically from view rules (via
- * {@link INode#removeChild(INode)}) will not notify about deletion.
- *
- * Note that this method will be called under an edit lock, so rules can directly
- * add/remove nodes and attributes as part of the deletion handling (and their
- * actions will be part of the same undo-unit.)
- *
- * @param deleted a nonempty list of children about to be deleted
- * @param parent the parent of the deleted children (which still contains the children
- * since this method is called before the deletion is performed)
- */
- void onRemovingChildren(List deleted, INode parent);
-
- /**
- * Called by the IDE on the parent layout when a child widget is being resized. This
- * is called once at the beginning of the resizing operation. A horizontal edge,
- * or a vertical edge, or both, can be resized simultaneously.
- *
- * @param child the widget being resized
- * @param parent the layout containing the child
- * @param horizEdge The horizontal edge being resized, or null
- * @param verticalEdge the vertical edge being resized, or null
- * @return a {@link DropFeedback} object which performs an update painter callback
- * etc.
- */
- DropFeedback onResizeBegin(INode child, INode parent,
- SegmentType horizEdge, SegmentType verticalEdge);
-
- /**
- * Called by the IDE on the parent layout when a child widget is being resized. This
- * is called repeatedly during the resize as the mouse is dragged to update the drag
- * bounds, recompute guidelines, etc. The resize has not yet been "committed" so the
- * XML should not be edited yet.
- *
- * @param feedback the {@link DropFeedback} object created in {@link #onResizeBegin}
- * @param child the widget being resized
- * @param parent the layout containing the child
- * @param newBounds the new bounds the user has chosen to resize the widget to,
- * in absolute coordinates
- * @param modifierMask The modifier keys currently pressed by the user, as a bitmask
- * of the constants {@link DropFeedback#MODIFIER1}, {@link DropFeedback#MODIFIER2}
- * and {@link DropFeedback#MODIFIER3}.
- */
- void onResizeUpdate(DropFeedback feedback, INode child, INode parent, Rect newBounds,
- int modifierMask);
-
- /**
- * Called by the IDE on the parent layout when a child widget is being resized. This
- * is called once at the end of the resize operation, if it was not canceled.
- * This method can call {@link INode#editXml} to update the node to reflect the
- * new bounds.
- *
- * @param feedback the {@link DropFeedback} object created in {@link #onResizeBegin}
- * @param child the widget being resized
- * @param parent the layout containing the child
- * @param newBounds the new bounds the user has chosen to resize the widget to,
- * in absolute coordinates
- */
- void onResizeEnd(DropFeedback feedback, INode child, INode parent, Rect newBounds);
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/InsertType.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/InsertType.java
deleted file mode 100644
index 806b2bb..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/InsertType.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-/**
- * An enumerated type of different insertion events, such as an insertion from a
- * copy/paste operation or as the first half of a move operation.
- */
-public enum InsertType {
- /** The view is newly created (by for example a palette drag) */
- CREATE,
-
- /**
- * Same as {@link #CREATE} but when the views are constructed for previewing, for
- * example as part of a palette drag.
- */
- CREATE_PREVIEW,
-
- /** The view is being inserted here because it was moved from somewhere else within
- * the same layout */
- MOVE_WITHIN,
-
- /** The view is being inserted here because it was moved from some other layout */
- MOVE_INTO,
-
- /**
- * The view is being inserted here as a result of a copy/paste from elsewhere
- * (including drags, but not from the palette)
- */
- PASTE;
-
- /**
- * Returns true if this insert type is for a newly created view (for example a by
- * palette drag). Note that this includes both normal create events as well as well as
- * views created as part of previewing operations.
- *
- * @return true if this {@link InsertType} is for a newly created view
- */
- public boolean isCreate() {
- return this == CREATE || this == CREATE_PREVIEW;
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Margins.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Margins.java
deleted file mode 100644
index 40f44ce..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Margins.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-/**
- * Set of margins - distances to outer left, top, right and bottom edges. These objects
- * can be used for both actual margins as well as insets - and in general any
- * deltas to the bounds of a rectangle.
- */
-public class Margins {
- /** The left margin */
- public final int left;
-
- /** The right margin */
- public final int right;
-
- /** The top margin */
- public final int top;
-
- /** The bottom margin */
- public final int bottom;
-
- /**
- * Creates a new {@link Margins} instance.
- *
- * @param left the left side margin
- * @param right the right side margin
- * @param top the top margin
- * @param bottom the bottom margin
- */
- public Margins(int left, int right, int top, int bottom) {
- super();
- this.left = left;
- this.right = right;
- this.top = top;
- this.bottom = bottom;
- }
-
- @Override
- public String toString() {
- return "Margins [left=" + left + ", right=" + right + ", top=" + top + ", bottom=" + bottom
- + "]";
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Point.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Point.java
deleted file mode 100755
index 67c41d3..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Point.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-
-/**
- * Mutable point.
- *
- * NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.
- *
- */
-public class Point {
- public int x, y;
-
- public Point(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- public Point(Point p) {
- x = p.x;
- y = p.y;
- }
-
- /** Sets the point to the given coordinates. */
- public void set(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- /** Returns a new instance of a point with the same values. */
- public Point copy() {
- return new Point(x, y);
- }
-
- /**
- * Offsets this point by adding the given x,y deltas to the x,y coordinates.
- * @return Returns self, for chaining.
- */
- public Point offsetBy(int x, int y) {
- this.x += x;
- this.y += y;
- return this;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Point) {
- Point rhs = (Point) obj;
- return this.x == rhs.x && this.y == rhs.y;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- int h = x ^ ((y >> 16) & 0x0FFFF) ^ ((y & 0x0FFFF) << 16);
- return h;
- }
-
- @Override
- public String toString() {
- return String.format("Point [%dx%d]", x, y);
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Rect.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Rect.java
deleted file mode 100755
index f3922e2..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Rect.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-
-
-/**
- * Mutable rectangle bounds.
- *
- * To be valid, w >= 1 and h >= 1.
- * By definition:
- * - right side = x + w - 1.
- * - bottom side = y + h - 1.
- *
- * NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.
- *
- */
-public class Rect {
- public int x, y, w, h;
-
- /** Initialize an invalid rectangle. */
- public Rect() {
- }
-
- /** Initialize rectangle to the given values. They can be invalid. */
- public Rect(int x, int y, int w, int h) {
- set(x, y, w, h);
- }
-
- /** Initialize rectangle to the given values. They can be invalid. */
- public Rect(Rect r) {
- set(r);
- }
-
- /** Initialize rectangle to the given values. They can be invalid. */
- public Rect set(int x, int y, int w, int h) {
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- return this;
- }
-
- /** Initialize rectangle to match the given one. */
- public Rect set(Rect r) {
- set(r.x, r.y, r.w, r.h);
- return this;
- }
-
- /** Returns a new instance of a rectangle with the same values. */
- public Rect copy() {
- return new Rect(x, y, w, h);
- }
-
- /** Returns true if the rectangle has valid bounds, i.e. w>0 and h>0. */
- public boolean isValid() {
- return w > 0 && h > 0;
- }
-
- /** Returns true if the rectangle contains the x,y coordinates, borders included. */
- public boolean contains(int x, int y) {
- return isValid() &&
- x >= this.x &&
- y >= this.y &&
- x < (this.x + this.w) &&
- y < (this.y + this.h);
- }
-
- /** Returns true if the rectangle contains the x,y coordinates, borders included. */
- public boolean contains(Point p) {
- return p != null && contains(p.x, p.y);
- }
-
- /**
- * Moves this rectangle by setting it's x,y coordinates to the new values.
- * @return Returns self, for chaining.
- */
- public Rect moveTo(int x, int y) {
- this.x = x;
- this.y = y;
- return this;
- }
-
- /**
- * Offsets this rectangle by adding the given x,y deltas to the x,y coordinates.
- * @return Returns self, for chaining.
- */
- public Rect offsetBy(int x, int y) {
- this.x += x;
- this.y += y;
- return this;
- }
-
- public Point getCenter() {
- return new Point(x + (w > 0 ? w / 2 : 0),
- y + (h > 0 ? h / 2 : 0));
- }
-
- public Point getTopLeft() {
- return new Point(x, y);
- }
-
- public Point getBottomLeft() {
- return new Point(x,
- y + (h > 0 ? h : 0));
- }
-
- public Point getTopRight() {
- return new Point(x + (w > 0 ? w : 0),
- y);
- }
-
- public Point getBottomRight() {
- return new Point(x + (w > 0 ? w : 0),
- y + (h > 0 ? h : 0));
- }
-
- /**
- * Returns the X coordinate of the right hand side of the rectangle
- *
- * @return the X coordinate of the right hand side of the rectangle
- */
- public int x2() {
- return x + w;
- }
-
- /**
- * Returns the Y coordinate of the bottom of the rectangle
- *
- * @return the Y coordinate of the bottom of the rectangle
- */
- public int y2() {
- return y + h;
- }
-
- /**
- * Returns the X coordinate of the center of the rectangle
- *
- * @return the X coordinate of the center of the rectangle
- */
- public int centerX() {
- return x + w / 2;
- }
-
- /**
- * Returns the Y coordinate of the center of the rectangle
- *
- * @return the Y coordinate of the center of the rectangle
- */
- public int centerY() {
- return y + h / 2;
- }
-
- @Override
- public String toString() {
- return String.format("Rect [(%d,%d)-(%d,%d): %dx%d]", x, y, x + w, y + h, w, h);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Rect) {
- Rect rhs = (Rect) obj;
- // validity must be equal on both sides.
- if (isValid() != rhs.isValid()) {
- return false;
- }
- // an invalid rect is equal to any other invalid rect regardless of coordinates
- if (!isValid() && !rhs.isValid()) {
- return true;
- }
-
- return this.x == rhs.x && this.y == rhs.y && this.w == rhs.w && this.h == rhs.h;
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- int hc = x;
- hc ^= ((y >> 8) & 0x0FFFFFF) | ((y & 0x00000FF) << 24);
- hc ^= ((w >> 16) & 0x000FFFF) | ((w & 0x000FFFF) << 16);
- hc ^= ((h >> 24) & 0x00000FF) | ((h & 0x0FFFFFF) << 8);
- return hc;
- }
-
- /**
- * Returns the center point in the rectangle
- *
- * @return the center point in the rectangle
- */
- public Point center() {
- return new Point(x + w / 2, y + h / 2);
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/ResizePolicy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/ResizePolicy.java
deleted file mode 100644
index 05ad81c..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/ResizePolicy.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ide.common.api;
-
-/**
- * A {@link ResizePolicy} records state for whether a widget is resizable, and if so, in
- * which directions
- */
-public class ResizePolicy {
- private static final int NONE = 0;
- private static final int LEFT_EDGE = 1;
- private static final int RIGHT_EDGE = 2;
- private static final int TOP_EDGE = 4;
- private static final int BOTTOM_EDGE = 8;
- private static final int PRESERVE_RATIO = 16;
-
- // Aliases
- private static final int HORIZONTAL = LEFT_EDGE | RIGHT_EDGE;
- private static final int VERTICAL = TOP_EDGE | BOTTOM_EDGE;
- private static final int ANY = HORIZONTAL | VERTICAL;
-
- // Shared objects for common policies
-
- public static final ResizePolicy sAny = new ResizePolicy(ANY);
- private static final ResizePolicy sNone = new ResizePolicy(NONE);
- private static final ResizePolicy sHorizontal = new ResizePolicy(HORIZONTAL);
- private static final ResizePolicy sVertical = new ResizePolicy(VERTICAL);
- private static final ResizePolicy sScaled = new ResizePolicy(ANY | PRESERVE_RATIO);
-
- private final int mFlags;
-
-
- // Use factory methods to construct
- private ResizePolicy(int flags) {
- mFlags = flags;
- }
-
- /**
- * Returns true if this policy allows resizing in at least one direction
- *
- * @return true if this policy allows resizing in at least one direction
- */
- public boolean isResizable() {
- return (mFlags & ANY) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the top edge
- *
- * @return true if this policy allows resizing the top edge
- */
- public boolean topAllowed() {
- return (mFlags & TOP_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the right edge
- *
- * @return true if this policy allows resizing the right edge
- */
- public boolean rightAllowed() {
- return (mFlags & RIGHT_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the bottom edge
- *
- * @return true if this policy allows resizing the bottom edge
- */
- public boolean bottomAllowed() {
- return (mFlags & BOTTOM_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the left edge
- *
- * @return true if this policy allows resizing the left edge
- */
- public boolean leftAllowed() {
- return (mFlags & LEFT_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy requires resizing in an aspect-ratio preserving manner
- *
- * @return true if this policy requires resizing in an aspect-ratio preserving manner
- */
- public boolean isAspectPreserving() {
- return (mFlags & PRESERVE_RATIO) != 0;
- }
-
- /**
- * Returns a resize policy allowing resizing in any direction
- *
- * @return a resize policy allowing resizing in any direction
- */
- public static ResizePolicy full() {
- return sAny;
- }
-
- /**
- * Returns a resize policy not allowing any resizing
- *
- * @return a policy which does not allow any resizing
- */
- public static ResizePolicy none() {
- return sNone;
- }
-
- /**
- * Returns a resize policy allowing horizontal resizing only
- *
- * @return a policy which allows horizontal resizing only
- */
- public static ResizePolicy horizontal() {
- return sHorizontal;
- }
-
- /**
- * Returns a resize policy allowing vertical resizing only
- *
- * @return a policy which allows vertical resizing only
- */
- public static ResizePolicy vertical() {
- return sVertical;
- }
-
- /**
- * Returns a resize policy allowing scaled / aspect-ratio preserving resizing only
- *
- * @return a resize policy allowing scaled / aspect-ratio preserving resizing only
- */
- public static ResizePolicy scaled() {
- return sScaled;
- }
-
- /**
- * Returns a resize policy with the specified resizability along the edges and the
- * given aspect ratio behavior
- * @param top whether the top edge is resizable
- * @param right whether the right edge is resizable
- * @param bottom whether the bottom edge is resizable
- * @param left whether the left edge is resizable
- * @param preserve whether the policy requires the aspect ratio to be preserved
- * @return a resize policy recording the constraints required by the parameters
- */
- public static ResizePolicy create(boolean top, boolean right, boolean bottom, boolean left,
- boolean preserve) {
- int mask = NONE;
- if (top) mask |= TOP_EDGE;
- if (right) mask |= RIGHT_EDGE;
- if (bottom) mask |= BOTTOM_EDGE;
- if (left) mask |= LEFT_EDGE;
- if (preserve) mask |= PRESERVE_RATIO;
-
- return new ResizePolicy(mask);
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/RuleAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/RuleAction.java
deleted file mode 100755
index 2ebab36..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/RuleAction.java
+++ /dev/null
@@ -1,656 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.util.Pair;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * A {@link RuleAction} represents an action provided by an {@link IViewRule}, typically
- * shown in a context menu or in the layout actions bar.
- *
- * Each action should have a reasonably unique ID. This is used when multiple nodes
- * are selected to filter the actions down to just those actions that are supported
- * across all selected nodes. If an action does not support multiple nodes, it can
- * return false from {@link #supportsMultipleNodes()}.
- *
- * Actions can be grouped into a hierarchy of sub-menus using the {@link NestedAction} class,
- * or into a flat submenu using the {@link Choices} class.
- *
- * Actions (including separators) all have a "sort priority", and this is used to
- * sort the menu items or toolbar buttons into a specific order.
- *
- * NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.
- *
- */
-public class RuleAction implements Comparable {
- /**
- * Character used to split multiple checked choices.
- * The pipe character "|" is used, to natively match Android resource flag separators.
- */
- public final static String CHOICE_SEP = "|"; //$NON-NLS-1$
-
- /**
- * Same as {@link #CHOICE_SEP} but safe for use in regular expressions.
- */
- public final static String CHOICE_SEP_PATTERN = Pattern.quote(CHOICE_SEP);
-
- /**
- * The unique id of the action.
- * @see #getId()
- */
- private final String mId;
- /**
- * The UI-visible title of the action.
- */
- private final String mTitle;
-
- /** A URL pointing to an icon, or null */
- private URL mIconUrl;
-
- /**
- * A callback executed when the action is selected in the context menu.
- */
- private final IMenuCallback mCallback;
-
- /**
- * The sorting priority of this item; actions can be sorted according to these
- */
- protected final int mSortPriority;
-
- /**
- * Whether this action supports multiple nodes, see
- * {@link #supportsMultipleNodes()} for details.
- */
- private final boolean mSupportsMultipleNodes;
-
- /**
- * Special value which will insert a separator in the choices' submenu.
- */
- public final static String SEPARATOR = "----";
-
- // Factories
-
- /**
- * Constructs a new separator which will be shown in places where separators
- * are supported such as context menus
- *
- * @param sortPriority a priority used for sorting this action
- * @return a new separator
- */
- public static Separator createSeparator(int sortPriority) {
- return new Separator(sortPriority, true /* supportsMultipleNodes*/);
- }
-
- /**
- * Constructs a new base {@link RuleAction} with its ID, title and action callback.
- *
- * @param id The unique ID of the action. Must not be null.
- * @param title The title of the action. Must not be null.
- * @param callback The callback executed when the action is selected.
- * Must not be null.
- * @param iconUrl a URL pointing to an icon to use for this action, or null
- * @param sortPriority a priority used for sorting this action
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link RuleAction}
- */
- public static RuleAction createAction(String id, String title,
- IMenuCallback callback, URL iconUrl, int sortPriority, boolean supportsMultipleNodes) {
- RuleAction action = new RuleAction(id, title, callback, sortPriority,
- supportsMultipleNodes);
- action.setIconUrl(iconUrl);
-
- return action;
- }
-
- /**
- * Creates a new immutable toggle action.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The UI-visible title of the context menu item. Cannot be null.
- * @param isChecked Whether the context menu item has a check mark.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param iconUrl a URL pointing to an icon to use for this action, or null
- * @param sortPriority a priority used for sorting this action
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link Toggle}
- */
- public static Toggle createToggle(String id, String title, boolean isChecked,
- IMenuCallback callback, URL iconUrl, int sortPriority,
- boolean supportsMultipleNodes) {
- Toggle toggle = new Toggle(id, title, isChecked, callback, sortPriority,
- supportsMultipleNodes);
- toggle.setIconUrl(iconUrl);
- return toggle;
- }
-
- /**
- * Creates a new immutable multiple-choice action with a defined ordered set
- * of action children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the action to be displayed to the user
- * @param provider Provides the actions to be shown as children of this
- * action
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link NestedAction}
- */
- public static NestedAction createChoices(String id, String title,
- IMenuCallback callback, URL iconUrl,
- int sortPriority, boolean supportsMultipleNodes, ActionProvider provider) {
- NestedAction choices = new NestedAction(id, title, provider, callback,
- sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
- return choices;
- }
-
- /**
- * Creates a new immutable multiple-choice action with a defined ordered set
- * of children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the action to be displayed to the user
- * @param iconUrls The icon urls for the children items (may be null)
- * @param ids The internal ids for the children
- * @param current The id(s) of the current choice(s) that will be check
- * marked. Can be null. Can be an id not present in the choices
- * map. There can be more than one id separated by
- * {@link #CHOICE_SEP}.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param titles The UI-visible titles of the children
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link Choices}
- */
- public static Choices createChoices(String id, String title,
- IMenuCallback callback, List titles, List iconUrls, List ids,
- String current, URL iconUrl, int sortPriority, boolean supportsMultipleNodes) {
- Choices choices = new Choices(id, title, callback, titles, iconUrls,
- ids, current, sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
-
- return choices;
- }
-
- /**
- * Creates a new immutable multiple-choice action with a defined ordered set
- * of children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the action to be displayed to the user
- * @param iconUrls The icon urls for the children items (may be null)
- * @param current The id(s) of the current choice(s) that will be check
- * marked. Can be null. Can be an id not present in the choices
- * map. There can be more than one id separated by
- * {@link #CHOICE_SEP}.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @param idsAndTitles a list of pairs (of ids and titles) to use for the
- * menu items
- * @return the new {@link Choices}
- */
- public static Choices createChoices(String id, String title,
- IMenuCallback callback, List iconUrls,
- String current, URL iconUrl, int sortPriority,
- boolean supportsMultipleNodes, List> idsAndTitles) {
- int itemCount = idsAndTitles.size();
- List titles = new ArrayList(itemCount);
- List ids = new ArrayList(itemCount);
- for (Pair pair : idsAndTitles) {
- ids.add(pair.getFirst());
- titles.add(pair.getSecond());
- }
- Choices choices = new Choices(id, title, callback, titles, iconUrls,
- ids, current, sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
- return choices;
- }
-
- /**
- * Creates a new immutable multiple-choice action with lazily computed children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the multiple-choice itself
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param provider the provider which provides choices lazily
- * @param current The id(s) of the current choice(s) that will be check
- * marked. Can be null. Can be an id not present in the choice
- * alternatives. There can be more than one id separated by
- * {@link #CHOICE_SEP}.
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link Choices}
- */
- public static Choices createChoices(String id, String title,
- IMenuCallback callback, ChoiceProvider provider,
- String current, URL iconUrl, int sortPriority, boolean supportsMultipleNodes) {
- Choices choices = new DelayedChoices(id, title, callback,
- current, provider, sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
- return choices;
- }
-
- /**
- * Creates a new {@link RuleAction} with the given id and the given title.
- * Actions which have the same id and the same title are deemed equivalent.
- *
- * @param id The unique id of the action, which must be similar for all actions that
- * perform the same task. Cannot be null.
- * @param title The UI-visible title of the action.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param sortPriority a priority used for sorting this action
- * @param supportsMultipleNodes the new return value for
- * {@link #supportsMultipleNodes()}
- */
- private RuleAction(String id, String title, IMenuCallback callback, int sortPriority,
- boolean supportsMultipleNodes) {
- mId = id;
- mTitle = title;
- mSortPriority = sortPriority;
- mSupportsMultipleNodes = supportsMultipleNodes;
- mCallback = callback;
- }
-
- /**
- * Returns the unique id of the action. In the context of a multiple selection,
- * actions which have the same id are collapsed together and must represent the same
- * action. Cannot be null.
- *
- * @return the unique id of the action, never null
- */
- public String getId() {
- return mId;
- }
-
- /**
- * Returns the UI-visible title of the action, shown in the context menu.
- * Cannot be null.
- *
- * @return the user name of the action, never null
- */
- public String getTitle() {
- return mTitle;
- }
-
- /**
- * Actions which have the same id and the same title are deemed equivalent.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof RuleAction) {
- RuleAction rhs = (RuleAction) obj;
-
- if (mId != rhs.mId && !(mId != null && mId.equals(rhs.mId))) return false;
- if (mTitle != rhs.mTitle &&
- !(mTitle != null && mTitle.equals(rhs.mTitle))) return false;
- return true;
- }
- return false;
- }
-
- /**
- * Whether this action supports multiple nodes. An action which supports
- * multiple nodes can be applied to different nodes by passing in different
- * nodes to its callback. Some actions are hardcoded for a specific node (typically
- * one that isn't selected, such as an action which affects the parent of a selected
- * node), and these actions will not be added to the context menu when more than
- * one node is selected.
- *
- * @return true if this node supports multiple nodes
- */
- public boolean supportsMultipleNodes() {
- return mSupportsMultipleNodes;
- }
-
- /**
- * Actions which have the same id and the same title have the same hash code.
- */
- @Override
- public int hashCode() {
- int h = mId == null ? 0 : mId.hashCode();
- h = h ^ (mTitle == null ? 0 : mTitle.hashCode());
- return h;
- }
-
- /**
- * Gets a URL pointing to an icon to use for this action, if any.
- *
- * @return a URL pointing to an icon to use for this action, or null
- */
- public URL getIconUrl() {
- return mIconUrl;
- }
-
- /**
- * Sets a URL pointing to an icon to use for this action, if any.
- *
- * @param iconUrl a URL pointing to an icon to use for this action, or null
- * @return this action, to allow setter chaining
- */
- public RuleAction setIconUrl(URL iconUrl) {
- mIconUrl = iconUrl;
-
- return this;
- }
-
- /**
- * Return a priority used for sorting this action
- *
- * @return a priority used for sorting this action
- */
- public int getSortPriority() {
- return mSortPriority;
- }
-
- /**
- * Returns the callback executed when the action is selected in the
- * context menu. Cannot be null.
- *
- * @return the callback, never null
- */
- public IMenuCallback getCallback() {
- return mCallback;
- }
-
- // Implements Comparable
- public int compareTo(RuleAction other) {
- if (mSortPriority != other.mSortPriority) {
- return mSortPriority - other.mSortPriority;
- }
-
- return mTitle.compareTo(other.mTitle);
- }
-
- @Override
- public String toString() {
- return "RuleAction [id=" + mId + ", title=" + mTitle + ", priority=" + mSortPriority + "]";
- }
-
- /** A separator to display between actions */
- public static class Separator extends RuleAction {
- /** Construct using the factory {@link #createSeparator(int)} */
- private Separator(int sortPriority, boolean supportsMultipleNodes) {
- super("_separator", "", null, sortPriority, //$NON-NLS-1$ //$NON-NLS-2$
- supportsMultipleNodes);
- }
- }
-
- /**
- * A toggle is a simple on/off action, displayed as an item in a context menu
- * with a check mark if the item is checked.
- *
- * Two toggles are equal if they have the same id, title and group-id.
- * It is expected for the checked state and action callback to be different.
- */
- public static class Toggle extends RuleAction {
- /**
- * True if the item is displayed with a check mark.
- */
- private final boolean mIsChecked;
-
- /**
- * Creates a new immutable toggle action.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The UI-visible title of the context menu item. Cannot be null.
- * @param isChecked Whether the context menu item has a check mark.
- * @param callback A callback to execute when the context menu item is
- * selected.
- */
- private Toggle(String id, String title, boolean isChecked,
- IMenuCallback callback, int sortPriority, boolean supportsMultipleNodes) {
- super(id, title, callback, sortPriority, supportsMultipleNodes);
- mIsChecked = isChecked;
- }
-
- /**
- * Returns true if the item is displayed with a check mark.
- *
- * @return true if the item is displayed with a check mark.
- */
- public boolean isChecked() {
- return mIsChecked;
- }
-
- /**
- * Two toggles are equal if they have the same id and title.
- * It is acceptable for the checked state and action callback to be different.
- */
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- /**
- * Two toggles have the same hash code if they have the same id and title.
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- }
-
- /**
- * An ordered list of choices the user can choose between. For choosing between
- * actions, there is a {@link NestedAction} class.
- */
- public static class Choices extends RuleAction {
- protected List mTitles;
- protected List mIconUrls;
- protected List mIds;
- private boolean mRadio;
-
- /**
- * One or more id for the checked choice(s) that will be check marked.
- * Can be null. Can be an id not present in the choices map.
- */
- protected final String mCurrent;
-
- private Choices(String id, String title, IMenuCallback callback,
- List titles, List iconUrls, List ids, String current,
- int sortPriority, boolean supportsMultipleNodes) {
- super(id, title, callback, sortPriority, supportsMultipleNodes);
- mTitles = titles;
- mIconUrls = iconUrls;
- mIds = ids;
- mCurrent = current;
- }
-
- /**
- * Returns the list of urls to icons to display for each choice, or null
- *
- * @return the list of urls to icons to display for each choice, or null
- */
- public List getIconUrls() {
- return mIconUrls;
- }
-
- /**
- * Returns the list of ids for the menu choices, never null
- *
- * @return the list of ids for the menu choices, never null
- */
- public List getIds() {
- return mIds;
- }
-
- /**
- * Returns the titles to be displayed for the menu choices, never null
- *
- * @return the titles to be displayed for the menu choices, never null
- */
- public List getTitles() {
- return mTitles;
- }
-
- /**
- * Returns the current value of the choice
- *
- * @return the current value of the choice, possibly null
- */
- public String getCurrent() {
- return mCurrent;
- }
-
- /**
- * Set whether this choice list is best visualized as a radio group (instead of a
- * dropdown)
- *
- * @param radio true if this choice list should be visualized as a radio group
- */
- public void setRadio(boolean radio) {
- mRadio = radio;
- }
-
- /**
- * Returns true if this choice list is best visualized as a radio group (instead
- * of a dropdown)
- *
- * @return true if this choice list should be visualized as a radio group
- */
- public boolean isRadio() {
- return mRadio;
- }
- }
-
- /**
- * An ordered list of actions the user can choose between. Similar to
- * {@link Choices} but for actions instead.
- */
- public static class NestedAction extends RuleAction {
- /** The provider to produce the list of nested actions when needed */
- private final ActionProvider mProvider;
-
- private NestedAction(String id, String title, ActionProvider provider,
- IMenuCallback callback, int sortPriority,
- boolean supportsMultipleNodes) {
- super(id, title, callback, sortPriority, supportsMultipleNodes);
- mProvider = provider;
- }
-
- /**
- * Returns the nested actions available for the given node
- *
- * @param node the node to look up nested actions for
- * @return a list of nested actions
- */
- public List getNestedActions(INode node) {
- return mProvider.getNestedActions(node);
- }
- }
-
- /** Like {@link Choices}, but the set of choices is computed lazily */
- private static class DelayedChoices extends Choices {
- private final ChoiceProvider mProvider;
-
- private DelayedChoices(String id, String title,
- IMenuCallback callback, String current, ChoiceProvider provider,
- int sortPriority, boolean supportsMultipleNodes) {
- super(id, title, callback, null, null, null, current, sortPriority,
- supportsMultipleNodes);
- mProvider = provider;
- }
-
- private void ensureInitialized() {
- if (mTitles == null) {
- mTitles = new ArrayList();
- mIconUrls = new ArrayList();
- mIds = new ArrayList();
-
- mProvider.addChoices(mTitles, mIconUrls, mIds);
- }
- }
-
- @Override
- public List getIconUrls() {
- ensureInitialized();
- return mIconUrls;
- }
-
- @Override
- public List getIds() {
- ensureInitialized();
- return mIds;
- }
-
- @Override
- public List getTitles() {
- ensureInitialized();
- return mTitles;
- }
- }
-
- /**
- * Provides the set of nested action choices associated with a {@link NestedAction}
- * object when they are needed. Useful for lazy initialization of context
- * menus and popup menus until they are actually needed.
- */
- public interface ActionProvider {
- /**
- * Returns the nested actions available for the given node
- *
- * @param node the node to look up nested actions for
- * @return a list of nested actions
- */
- public List getNestedActions(INode node);
- }
-
- /**
- * Provides the set of choices associated with an {@link Choices}
- * object when they are needed. Useful for lazy initialization of context
- * menus and popup menus until they are actually needed.
- */
- public interface ChoiceProvider {
- /**
- * Adds in the needed titles, iconUrls (if any) and ids.
- * Use {@link RuleAction#SEPARATOR} to create separators.
- *
- * @param titles a list of titles that the provider should append to
- * @param iconUrls a list of icon URLs that the provider should append to
- * @param ids a list of ids that the provider should append to
- */
- public void addChoices(List titles, List iconUrls, List ids);
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Segment.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Segment.java
deleted file mode 100644
index 0fb961a..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/Segment.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.ide.common.layout.relative.MarginType;
-
-/**
- * A segment is a straight horizontal or vertical line between two points, typically an
- * edge of a node but also possibly some internal segment like a baseline or a center
- * line, and it can be offset by a margin from the node's visible bounds.
- */
-public class Segment {
- /** For horizontal lines, the y coordinate; for vertical lines the x */
- public final int at;
-
- /** The starting coordinate along the line */
- public final int from;
-
- /** The ending coordinate along the line */
- public final int to;
-
- /** Whether the edge is a top edge, a baseline edge, a left edge, etc */
- public final SegmentType edgeType;
-
- /**
- * Whether the edge is offset from the node by a margin or not, or whether it has no
- * margin
- */
- public final MarginType marginType;
-
- /** The node that contains this edge */
- public final INode node;
-
- /**
- * The id of the node. May be null (in which case id should be generated when
- * move/resize is completed
- */
- public final String id;
-
- public Segment(int at, int from, int to, INode node, String id, SegmentType edgeType,
- MarginType marginType) {
- this.at = at;
- this.from = from;
- this.to = to;
- this.node = node;
- this.id = id;
- this.edgeType = edgeType;
- this.marginType = marginType;
- }
-
- @Override
- public String toString() {
- String nodeStr = node == null ? "null" : node.getFqcn().substring(
- node.getFqcn().lastIndexOf(('.')) + 1);
- return "Segment [edgeType=" + edgeType + ", node=" + nodeStr + ", at=" + at + ", id=" + id
- + ", from=" + from + ", to=" + to + ", marginType=" + marginType + "]";
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/SegmentType.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/SegmentType.java
deleted file mode 100644
index a21247d..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/api/SegmentType.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-/** A segment type describes the different roles or positions a segment can have in a node */
-public enum SegmentType {
- LEFT, TOP, RIGHT, BOTTOM, BASELINE, CENTER_VERTICAL, CENTER_HORIZONTAL, UNKNOWN;
-
- public boolean isHorizontal() {
- return this == TOP || this == BOTTOM || this == BASELINE || this == CENTER_HORIZONTAL;
- }
-
- /**
- * Returns the X coordinate for an edge of this type given its bounds
- *
- * @param node the node containing the edge
- * @param bounds the bounds of the node
- * @return the X coordinate for an edge of this type given its bounds
- */
- public int getX(INode node, Rect bounds) {
- // We pass in the bounds rather than look it up via node.getBounds() because
- // during a resize or move operation, we call this method to look up proposed
- // bounds rather than actual bounds
- switch (this) {
- case RIGHT:
- return bounds.x + bounds.w;
- case TOP:
- case BOTTOM:
- case CENTER_VERTICAL:
- return bounds.x + bounds.w / 2;
- case UNKNOWN:
- assert false;
- return bounds.x;
- case LEFT:
- case BASELINE:
- default:
- return bounds.x;
- }
- }
-
- /**
- * Returns the Y coordinate for an edge of this type given its bounds
- *
- * @param node the node containing the edge
- * @param bounds the bounds of the node
- * @return the Y coordinate for an edge of this type given its bounds
- */
- public int getY(INode node, Rect bounds) {
- switch (this) {
- case TOP:
- return bounds.y;
- case BOTTOM:
- return bounds.y + bounds.h;
- case BASELINE: {
- int baseline = node != null ? node.getBaseline() : -1;
- if (node == null) {
- // This happens when you are dragging an element and we don't have
- // a node (only an IDragElement) such as on a palette drag.
- // For now just hack it.
- baseline = (int) (bounds.h * 0.8f); // HACK
- }
- return bounds.y + baseline;
- }
- case UNKNOWN:
- assert false;
- return bounds.y;
- case RIGHT:
- case LEFT:
- case CENTER_HORIZONTAL:
- default:
- return bounds.y + bounds.h / 2;
- }
- }
-
- @Override
- public String toString() {
- return name();
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
index 5191d25..ab64ef1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/BaseLayoutRule.java
@@ -67,13 +67,13 @@ import com.android.ide.common.api.IMenuCallback;
import com.android.ide.common.api.INode;
import com.android.ide.common.api.INodeHandler;
import com.android.ide.common.api.IViewRule;
-import com.android.ide.common.api.RuleAction;
-import com.android.ide.common.api.RuleAction.ChoiceProvider;
+import com.android.ide.common.api.MarginType;
import com.android.ide.common.api.Point;
import com.android.ide.common.api.Rect;
+import com.android.ide.common.api.RuleAction;
+import com.android.ide.common.api.RuleAction.ChoiceProvider;
import com.android.ide.common.api.Segment;
import com.android.ide.common.api.SegmentType;
-import com.android.ide.common.layout.relative.MarginType;
import com.android.sdklib.SdkConstants;
import com.android.util.Pair;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelineHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelineHandler.java
index 7c6e1d2..45f3008 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelineHandler.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/GuidelineHandler.java
@@ -15,6 +15,9 @@
*/
package com.android.ide.common.layout.relative;
+import static com.android.ide.common.api.MarginType.NO_MARGIN;
+import static com.android.ide.common.api.MarginType.WITHOUT_MARGIN;
+import static com.android.ide.common.api.MarginType.WITH_MARGIN;
import static com.android.ide.common.api.SegmentType.BASELINE;
import static com.android.ide.common.api.SegmentType.BOTTOM;
import static com.android.ide.common.api.SegmentType.CENTER_HORIZONTAL;
@@ -48,9 +51,6 @@ import static com.android.ide.common.layout.LayoutConstants.ATTR_LAYOUT_TO_RIGHT
import static com.android.ide.common.layout.LayoutConstants.VALUE_N_DP;
import static com.android.ide.common.layout.LayoutConstants.VALUE_TRUE;
import static com.android.ide.common.layout.relative.ConstraintType.ALIGN_BASELINE;
-import static com.android.ide.common.layout.relative.MarginType.NO_MARGIN;
-import static com.android.ide.common.layout.relative.MarginType.WITHOUT_MARGIN;
-import static com.android.ide.common.layout.relative.MarginType.WITH_MARGIN;
import static java.lang.Math.abs;
import com.android.ide.common.api.DropFeedback;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MarginType.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MarginType.java
deleted file mode 100644
index 7705958..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MarginType.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.layout.relative;
-
-import com.android.ide.common.api.Segment;
-
-/**
- * A {@link MarginType} indicates whether a {@link Segment} corresponds to the visual edge
- * of the node, or whether it is offset by a margin in the edge's direction, or whether
- * it's both (which is the case when the margin is 0).
- *
- * We need to keep track of the distinction because different constraints apply
- * differently w.r.t. margins. Let's say you have a target node with a 50 dp margin in all
- * directions. If you layout_alignTop with this node, the match will be on the visual
- * bounds of the target node (ignoring the margin). If you layout_above this node, you
- * will be offset by the margin on the target node. Therefore, we have to add both
- * edges (the bounds of the target node with and without edges) and check for matches on
- * each edge depending on the constraint being considered.
- */
-public enum MarginType {
- /**
- * This margin type is used for nodes that have margins, and this segment includes the
- * margin distance
- */
- WITH_MARGIN,
-
- /**
- * This margin type is used for nodes that have margins, and this segment does not
- * include the margin distance
- */
- WITHOUT_MARGIN,
-
- /**
- * This margin type is used for nodes that do not have margins, so margin edges and
- * non-margin edges are the same
- */
- NO_MARGIN;
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MoveHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MoveHandler.java
index a2f9ac2..3b066b7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MoveHandler.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/MoveHandler.java
@@ -15,6 +15,7 @@
*/
package com.android.ide.common.layout.relative;
+import static com.android.ide.common.api.MarginType.NO_MARGIN;
import static com.android.ide.common.api.SegmentType.BASELINE;
import static com.android.ide.common.api.SegmentType.BOTTOM;
import static com.android.ide.common.api.SegmentType.CENTER_HORIZONTAL;
@@ -24,7 +25,6 @@ import static com.android.ide.common.api.SegmentType.RIGHT;
import static com.android.ide.common.api.SegmentType.TOP;
import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI;
import static com.android.ide.common.layout.LayoutConstants.ATTR_ID;
-import static com.android.ide.common.layout.relative.MarginType.NO_MARGIN;
import static java.lang.Math.abs;
import com.android.ide.common.api.DropFeedback;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ResizeHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ResizeHandler.java
index 6cf421a..2e5b4b1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ResizeHandler.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/common/layout/relative/ResizeHandler.java
@@ -15,6 +15,7 @@
*/
package com.android.ide.common.layout.relative;
+import static com.android.ide.common.api.MarginType.NO_MARGIN;
import static com.android.ide.common.api.SegmentType.BASELINE;
import static com.android.ide.common.api.SegmentType.BOTTOM;
import static com.android.ide.common.api.SegmentType.CENTER_HORIZONTAL;
@@ -24,7 +25,6 @@ import static com.android.ide.common.api.SegmentType.RIGHT;
import static com.android.ide.common.api.SegmentType.TOP;
import static com.android.ide.common.layout.LayoutConstants.ANDROID_URI;
import static com.android.ide.common.layout.LayoutConstants.ATTR_ID;
-import static com.android.ide.common.layout.relative.MarginType.NO_MARGIN;
import static java.lang.Math.abs;
import com.android.ide.common.api.DropFeedback;
--
cgit v1.1