diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GLE2.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GLE2.java
index 8b868e33a..e9059904a 100755
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GLE2.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GLE2.java
@@ -30,7 +30,9 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
/**
- * Graphical layout editor, version 2.
+ * Graphical layout editor part, version 2.
+ *
+ * @since GLE2
*/
public class GLE2 extends EditorPart implements IGraphicalLayoutEditor {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GraphicalLayoutEditor.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GraphicalLayoutEditor.java
index 7cbd19c98..45810aff9 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GraphicalLayoutEditor.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/GraphicalLayoutEditor.java
@@ -111,6 +111,8 @@ import java.util.Map;
* To understand GEF: http://www.ibm.com/developerworks/opensource/library/os-gef/
*
* To understand Drag'n'drop: http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html
+ *
+ * @since GLE1
*/
public class GraphicalLayoutEditor extends GraphicalEditorWithPalette
implements IGraphicalLayoutEditor, IConfigListener {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/IGraphicalLayoutEditor.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/IGraphicalLayoutEditor.java
index 8ed7b3d74..6414b200d 100755
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/IGraphicalLayoutEditor.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/IGraphicalLayoutEditor.java
@@ -28,6 +28,8 @@ import org.eclipse.ui.IEditorPart;
/**
* Interface defining what {@link LayoutEditor} expects from a GraphicalLayoutEditor part.
+ *
+ * @since GLE2
*/
/*package*/ interface IGraphicalLayoutEditor extends IEditorPart, ILayoutReloadListener {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/PaletteFactory.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/PaletteFactory.java
index 950be13a5..7bf6acfb8 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/PaletteFactory.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/PaletteFactory.java
@@ -28,6 +28,8 @@ import java.util.List;
/**
* Factory that creates the palette for the {@link GraphicalLayoutEditor}.
+ *
+ * @since GLE1
*/
public class PaletteFactory {
@@ -37,7 +39,7 @@ public class PaletteFactory {
public static PaletteRoot createPaletteRoot(PaletteRoot currentPalette,
AndroidTargetData targetData) {
-
+
if (currentPalette == null) {
currentPalette = new PaletteRoot();
}
@@ -45,7 +47,7 @@ public class PaletteFactory {
for (int n = currentPalette.getChildren().size() - 1; n >= 0; n--) {
currentPalette.getChildren().remove(n);
}
-
+
if (targetData != null) {
addTools(currentPalette);
addViews(currentPalette, "Layouts",
@@ -59,7 +61,7 @@ public class PaletteFactory {
private static void addTools(PaletteRoot paletteRoot) {
PaletteGroup group = new PaletteGroup("Tools");
-
+
// Default tools: selection.
// Do not use the MarqueeToolEntry since we don't support multiple selection.
/* -- Do not put the selection tool. It's the unique tool so it looks useless.
@@ -75,7 +77,7 @@ public class PaletteFactory {
private static void addViews(PaletteRoot paletteRoot, String groupName,
List descriptors) {
PaletteDrawer group = new PaletteDrawer(groupName);
-
+
for (ElementDescriptor desc : descriptors) {
PaletteTemplateEntry entry = new PaletteTemplateEntry(
desc.getUiName(), // label
@@ -84,10 +86,10 @@ public class PaletteFactory {
desc.getImageDescriptor(), // small icon
desc.getImageDescriptor() // large icon
);
-
+
group.add(entry);
}
-
+
paletteRoot.add(group);
}
}
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiContentOutlinePage.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiContentOutlinePage.java
index 775f23b06..8e1568158 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiContentOutlinePage.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiContentOutlinePage.java
@@ -67,6 +67,8 @@ import java.util.List;
/**
* Implementation of the {@link ContentOutlinePage} to display {@link UiElementNode}.
+ *
+ * @since GLE1
*/
class UiContentOutlinePage extends ContentOutlinePage {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiPropertySheetPage.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiPropertySheetPage.java
index 33d2ed456..43b73b017 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiPropertySheetPage.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/UiPropertySheetPage.java
@@ -35,10 +35,12 @@ import org.eclipse.ui.views.properties.PropertySheetPage;
* A customized property sheet page for the graphical layout editor.
*
* Currently it just provides a custom tooltip to display attributes javadocs.
+ *
+ * @since GLE1
*/
public class UiPropertySheetPage extends PropertySheetPage {
-
+
public UiPropertySheetPage() {
super();
}
@@ -46,7 +48,7 @@ public class UiPropertySheetPage extends PropertySheetPage {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
-
+
setupTooltip();
}
@@ -59,14 +61,14 @@ public class UiPropertySheetPage extends PropertySheetPage {
final Tree tree = (Tree) getControl();
/*
- * Reference:
+ * Reference:
* http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet125.java?view=markup
*/
final Listener listener = new Listener() {
Shell tip = null;
Label label = null;
-
+
public void handleEvent(Event event) {
switch(event.type) {
case SWT.Dispose:
@@ -88,7 +90,7 @@ public class UiPropertySheetPage extends PropertySheetPage {
}
String tooltip = null;
-
+
TreeItem item = tree.getItem(new Point(event.x, event.y));
if (item != null) {
Object data = item.getData();
@@ -102,11 +104,11 @@ public class UiPropertySheetPage extends PropertySheetPage {
tooltip = item.getText() + ":\r" + tooltip;
}
}
-
+
if (tooltip != null) {
Shell shell = tree.getShell();
Display display = tree.getDisplay();
-
+
tip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
tip.setBackground(display .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
FillLayout layout = new FillLayout();
@@ -128,7 +130,7 @@ public class UiPropertySheetPage extends PropertySheetPage {
}
}
};
-
+
tree.addListener(SWT.Dispose, listener);
tree.addListener(SWT.KeyDown, listener);
tree.addListener(SWT.MouseMove, listener);
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/DropFeedback.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/DropFeedback.java
index 327b53c7d..d75e01684 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/DropFeedback.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/DropFeedback.java
@@ -4,7 +4,7 @@
* 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
@@ -35,6 +35,8 @@ import java.util.Map.Entry;
* This class uses some temporary static storage to avoid excessive allocations during
* drop operations. It is expected to only be invoked from the main UI thread with no
* concurrent access.
+ *
+ * @since GLE1
*/
class DropFeedback {
@@ -43,12 +45,12 @@ class DropFeedback {
private static final int BOTTOM = 2;
private static final int RIGHT = 3;
private static final int MAX_DIR = RIGHT;
-
+
private static final int sOppositeDirection[] = { BOTTOM, RIGHT, TOP, LEFT };
private static final UiElementEditPart sTempClosests[] = new UiElementEditPart[4];
private static final int sTempMinDists[] = new int[4];
-
+
/**
* Target information computed from a drop on a RelativeLayout.
@@ -69,20 +71,20 @@ class DropFeedback {
private static final RelativeInfo sRelativeInfo = new RelativeInfo();
/** A temporary array of 2 {@link UiElementEditPart} to avoid allocations. */
private static final UiElementEditPart sTempTwoParts[] = new UiElementEditPart[2];
-
+
private DropFeedback() {
}
-
+
//----- Package methods called by users of this helper class -----
-
-
+
+
/**
* This method is used by {@link ElementCreateCommand#execute()} when a new item
* needs to be "dropped" in the current XML document. It creates the new item using
* the given descriptor as a child of the given parent part.
- *
+ *
* @param parentPart The parent part.
* @param descriptor The descriptor for the new XML element.
* @param where The drop location (in parent coordinates)
@@ -91,16 +93,16 @@ class DropFeedback {
static void addElementToXml(UiElementEditPart parentPart,
ElementDescriptor descriptor, Point where,
UiEditorActions actions) {
-
+
String layoutXmlName = getXmlLocalName(parentPart);
RelativeInfo info = null;
UiElementEditPart sibling = null;
-
+
// TODO consider merge like a vertical layout
// TODO consider TableLayout like a linear
if (LayoutConstants.LINEAR_LAYOUT.equals(layoutXmlName)) {
sibling = findLinearTarget(parentPart, where)[1];
-
+
} else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutXmlName)) {
info = findRelativeTarget(parentPart, where, sRelativeInfo);
if (info != null) {
@@ -114,7 +116,7 @@ class DropFeedback {
UiElementNode uiParent = parentPart.getUiNode();
UiElementNode uiNode = actions.addElement(uiParent, uiSibling, descriptor,
false /*updateLayout*/);
-
+
if (LayoutConstants.ABSOLUTE_LAYOUT.equals(layoutXmlName)) {
adjustAbsoluteAttributes(uiNode, where);
} else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutXmlName)) {
@@ -128,8 +130,8 @@ class DropFeedback {
* highlight information when a drop target is moved over a valid drop area.
*
* Since there are no "out" parameters in Java, all the information is returned
- * via the {@link HighlightInfo} structure passed as parameter.
- *
+ * via the {@link HighlightInfo} structure passed as parameter.
+ *
* @param parentPart The parent part, always a layout.
* @param highlightInfo A structure where result is stored to perform highlight.
* @param where The target drop point, in parent's coordinates
@@ -139,16 +141,16 @@ class DropFeedback {
HighlightInfo highlightInfo,
Point where) {
String layoutType = getXmlLocalName(parentPart);
-
+
if (LayoutConstants.ABSOLUTE_LAYOUT.equals(layoutType)) {
highlightInfo.anchorPoint = where;
-
+
} else if (LayoutConstants.LINEAR_LAYOUT.equals(layoutType)) {
boolean isVertical = isVertical(parentPart);
highlightInfo.childParts = findLinearTarget(parentPart, where);
computeLinearLine(parentPart, isVertical, highlightInfo);
-
+
} else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutType)) {
RelativeInfo info = findRelativeTarget(parentPart, where, sRelativeInfo);
@@ -157,13 +159,13 @@ class DropFeedback {
computeRelativeLine(parentPart, info, highlightInfo);
}
}
-
+
return highlightInfo;
}
-
-
+
+
//----- Misc utilities -----
-
+
/**
* Returns the next UI sibling of this part, i.e. the element which is just after in
* the UI/XML order in the same parent. Returns null if there's no such part.
@@ -208,7 +210,7 @@ class DropFeedback {
/**
* Adjusts the attributes of a new node dropped in an AbsoluteLayout.
- *
+ *
* @param uiNode The new node being dropped.
* @param where The drop location (in parent coordinates)
*/
@@ -237,12 +239,12 @@ class DropFeedback {
* will "attach". The anchor part can be null, either because the layout is currently
* empty or the user is attaching to an existing empty border.
* direction: the direction from the anchor part to the drop point. That's also the
- * direction from the anchor part to the new part.
+ * direction from the anchor part to the new part.
* the new node; it is created either after the anchor for right or top directions
- * or before the anchor for left or bottom directions. This means the new part can
- * reference the id of the anchor part.
+ * or before the anchor for left or bottom directions. This means the new part can
+ * reference the id of the anchor part.
*
- *
+ *
* Several cases:
*
* - set: layout_above/below/toLeftOf/toRightOf to point to the anchor.
@@ -251,7 +253,7 @@ class DropFeedback {
*
- copy: layout_above/below/toLeftOf/toRightOf for the orthogonal direction
* (i.e. top/bottom or left/right.)
*
- *
+ *
* @param uiNode The new node being dropped.
* @param info The context computed by {@link #findRelativeTarget(UiElementEditPart, Point, RelativeInfo)}.
*/
@@ -259,10 +261,10 @@ class DropFeedback {
if (uiNode == null || info == null) {
return;
}
-
- final UiElementEditPart anchorPart = info.targetParts[info.anchorIndex]; // can be null
+
+ final UiElementEditPart anchorPart = info.targetParts[info.anchorIndex]; // can be null
final int direction = info.direction;
-
+
uiNode.getEditor().editXmlModel(new Runnable() {
public void run() {
HashMap map = new HashMap();
@@ -276,7 +278,7 @@ class DropFeedback {
anchorId = DescriptorsUtils.getFreeWidgetId(anchorUiNode);
anchorUiNode.setAttributeValue("id", anchorId, true /*override*/); //$NON-NLS-1$
}
-
+
if (anchorId != null) {
switch(direction) {
case TOP:
@@ -315,7 +317,7 @@ class DropFeedback {
map.put(LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE,
anchorUiNode.getAttributeValue(
LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE));
-
+
map.put(LayoutConstants.ATTR_LAYOUT_ABOVE,
anchorUiNode.getAttributeValue(LayoutConstants.ATTR_LAYOUT_ABOVE));
map.put(LayoutConstants.ATTR_LAYOUT_BELOW,
@@ -344,7 +346,7 @@ class DropFeedback {
break;
}
}
-
+
for (Entry entry : map.entrySet()) {
uiNode.setAttributeValue(entry.getKey(), entry.getValue(), true /* override */);
}
@@ -365,7 +367,7 @@ class DropFeedback {
*
* It returns null if it can't be determined, in which case the element will be added at the
* end of the parent child list.
- *
+ *
* @return The edit parts that correspond to what will be the "prev" and "next sibling" of the
* new element. The previous sibling can be null if adding before the first element.
* The next sibling can be null if adding after the last element.
@@ -373,9 +375,9 @@ class DropFeedback {
private static UiElementEditPart[] findLinearTarget(UiElementEditPart parent, Point point) {
// default orientation is horizontal
boolean isVertical = isVertical(parent);
-
+
int target = isVertical ? point.y : point.x;
-
+
UiElementEditPart prev = null;
UiElementEditPart next = null;
@@ -391,7 +393,7 @@ class DropFeedback {
prev = childPart;
}
}
-
+
sTempTwoParts[0] = prev;
sTempTwoParts[1] = next;
return sTempTwoParts;
@@ -405,7 +407,7 @@ class DropFeedback {
* The result is stored in HighlightInfo.
*
* Caller must clear the HighlightInfo as appropriate before this call.
- *
+ *
* @param parentPart The parent part, always a layout.
* @param isVertical True for vertical parts, thus computing an horizontal line.
* @param highlightInfo The in-out highlight info.
@@ -455,18 +457,18 @@ class DropFeedback {
/**
* Returns true if the linear layout is marked as vertical.
- *
- * @param parent The a layout part that must be a LinearLayout
+ *
+ * @param parent The a layout part that must be a LinearLayout
* @return True if the linear layout has a vertical orientation attribute.
*/
private static boolean isVertical(UiElementEditPart parent) {
String orientation = parent.getStringAttr("orientation"); //$NON-NLS-1$
- boolean isVertical = "vertical".equals(orientation) || //$NON-NLS-1$
+ boolean isVertical = "vertical".equals(orientation) || //$NON-NLS-1$
"1".equals(orientation); //$NON-NLS-1$
return isVertical;
}
-
+
//----- RelativeLayout --------
/**
@@ -481,26 +483,26 @@ class DropFeedback {
*
* If the drop point is not exactly on a current element, find the closest in each
* direction and align with the two closest of these.
- *
+ *
* @return null if we fail to find anything (such as there are currently no items to compare
* with); otherwise fills the {@link RelativeInfo} and return it.
*/
private static RelativeInfo findRelativeTarget(UiElementEditPart parent,
Point point,
RelativeInfo outInfo) {
-
+
for (int i = 0; i < 4; i++) {
sTempMinDists[i] = Integer.MAX_VALUE;
sTempClosests[i] = null;
}
-
+
for (Object child : parent.getChildren()) {
if (child instanceof UiElementEditPart) {
UiElementEditPart childPart = (UiElementEditPart) child;
Rectangle r = childPart.getBounds();
if (r.contains(point)) {
-
+
float rx = ((float)(point.x - r.x) / (float)r.width ) - 0.5f;
float ry = ((float)(point.y - r.y) / (float)r.height) - 0.5f;
@@ -537,18 +539,18 @@ class DropFeedback {
return outInfo;
}
-
+
computeClosest(point, childPart, sTempClosests, sTempMinDists, TOP);
computeClosest(point, childPart, sTempClosests, sTempMinDists, LEFT);
computeClosest(point, childPart, sTempClosests, sTempMinDists, BOTTOM);
computeClosest(point, childPart, sTempClosests, sTempMinDists, RIGHT);
}
}
-
+
UiElementEditPart closest = null;
int minDist = Integer.MAX_VALUE;
int minDir = -1;
-
+
for (int i = 0; i <= MAX_DIR; i++) {
if (sTempClosests[i] != null && sTempMinDists[i] < minDist) {
closest = sTempClosests[i];
@@ -556,7 +558,7 @@ class DropFeedback {
minDir = i;
}
}
-
+
if (closest != null) {
int index = 0;
switch(minDir) {
@@ -662,7 +664,7 @@ class DropFeedback {
Point p = null;
boolean usable = false;
-
+
switch(direction) {
case TOP:
p = r.getBottom();
@@ -701,7 +703,7 @@ class DropFeedback {
if (referencePart == null || referencePart.getParent() == null) {
return null;
}
-
+
Rectangle r = referencePart.getBounds();
Point ref = null;
switch(direction) {
@@ -718,16 +720,16 @@ class DropFeedback {
ref = r.getRight();
break;
}
-
+
int minDist = Integer.MAX_VALUE;
UiElementEditPart closestPart = null;
-
+
for (Object childPart : referencePart.getParent().getChildren()) {
if (childPart != referencePart && childPart instanceof UiElementEditPart) {
r = ((UiElementEditPart) childPart).getBounds();
Point p = null;
boolean usable = false;
-
+
switch(direction) {
case TOP:
p = r.getBottom();
@@ -756,7 +758,7 @@ class DropFeedback {
}
}
}
-
+
return closestPart;
}
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementCreateCommand.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementCreateCommand.java
index 0795b90f1..562570f59 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementCreateCommand.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementCreateCommand.java
@@ -29,6 +29,8 @@ import org.eclipse.gef.commands.Command;
/**
* A command that knows how to instantiate a new element based on a given {@link ElementDescriptor},
* the parent {@link UiElementEditPart} and an optional target location.
+ *
+ * @since GLE1
*/
public class ElementCreateCommand extends Command {
@@ -41,7 +43,7 @@ public class ElementCreateCommand extends Command {
/**
* Creates a new {@link ElementCreateCommand}.
- *
+ *
* @param descriptor Descriptor of the new element to create
* @param targetPart The edit part that hosts the new edit part
* @param targetPoint The drop location in parent coordinates
@@ -52,7 +54,7 @@ public class ElementCreateCommand extends Command {
mParentPart = targetPart;
mTargetPoint = targetPoint;
}
-
+
// --- Methods inherited from Command ---
@Override
@@ -82,14 +84,14 @@ public class ElementCreateCommand extends Command {
}
});
}
- }
+ }
}
@Override
public void redo() {
throw new UnsupportedOperationException("redo not supported by this command"); //$NON-NLS-1$
}
-
+
@Override
public void undo() {
throw new UnsupportedOperationException("undo not supported by this command"); //$NON-NLS-1$
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementFigure.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementFigure.java
index 2d8205860..23c2c9e9d 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementFigure.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/ElementFigure.java
@@ -22,11 +22,13 @@ import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT;
-
+
/**
* The figure used to draw basic elements.
*
* The figure is totally empty and transparent except for the selection border.
+ *
+ * @since GLE1
*/
class ElementFigure extends Figure {
@@ -36,18 +38,18 @@ class ElementFigure extends Figure {
public ElementFigure() {
setOpaque(false);
}
-
+
public void setSelected(boolean isSelected) {
if (isSelected != mIsSelected) {
mIsSelected = isSelected;
repaint();
}
}
-
+
@Override
public void setBounds(Rectangle rect) {
super.setBounds(rect);
-
+
mInnerBounds = getBounds().getCopy();
if (mInnerBounds.width > 0) {
mInnerBounds.width--;
@@ -56,11 +58,11 @@ class ElementFigure extends Figure {
mInnerBounds.height--;
}
}
-
+
public Rectangle getInnerBounds() {
return mInnerBounds;
}
-
+
@Override
protected void paintBorder(Graphics graphics) {
super.paintBorder(graphics);
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/LayoutFigure.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/LayoutFigure.java
index 4e5527f70..633475122 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/LayoutFigure.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/LayoutFigure.java
@@ -30,11 +30,13 @@ import org.eclipse.swt.SWT;
* By default the figure is transparent and empty.
* The base {@link ElementFigure} knows how to draw the selection border.
* This figure knows how to draw the drop feedback.
+ *
+ * @since GLE1
*/
class LayoutFigure extends ElementFigure {
private HighlightInfo mHighlightInfo;
-
+
public LayoutFigure() {
super();
}
@@ -50,12 +52,12 @@ class LayoutFigure extends ElementFigure {
* The parent {@link Figure#paint(Graphics)} calls {@link #paintFigure(Graphics)} then
* {@link #paintClientArea(Graphics)} then {@link #paintBorder(Graphics)}. Here we thus
* draw the actual highlight border but also the highlight anchor lines and points so that
- * we can make sure they are all drawn on top of the border.
+ * we can make sure they are all drawn on top of the border.
*
* Note: This method doesn't really need to restore its graphic state. The parent
* Figure will do it for us.
*
- *
+ *
* @param graphics The Graphics object used for painting
*/
@Override
@@ -98,7 +100,7 @@ class LayoutFigure extends ElementFigure {
int y1 = mHighlightInfo.linePoints[0].y;
int x2 = mHighlightInfo.linePoints[1].x;
int y2 = mHighlightInfo.linePoints[1].y;
-
+
// if the line is right to the edge, draw it one pixel more inside so that the
// full 2-pixel width be visible.
if (x1 <= 0) x1++;
@@ -110,12 +112,12 @@ class LayoutFigure extends ElementFigure {
if (x2 >= w - 1) x2--;
if (y1 >= h - 1) y1--;
if (y2 >= h - 1) y2--;
-
+
x1 += bx;
x2 += bx;
y1 += by;
y2 += by;
-
+
graphics.setLineWidth(2);
graphics.setLineStyle(SWT.LINE_DASH);
graphics.setLineCap(SWT.CAP_ROUND);
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentEditPart.java
index d12856c17..9f6557cbb 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentEditPart.java
@@ -46,27 +46,29 @@ import java.awt.image.DataBufferInt;
/**
* Graphical edit part for the root document.
*
- * It acts as a simple container.
+ * It acts as a simple container.
+ *
+ * @since GLE1
*/
public class UiDocumentEditPart extends UiElementEditPart {
-
+
private Display mDisplay;
private FreeformLayer mLayer;
private ImageBackground mImage;
private Label mChild = null;
-
+
final static class ImageBackground extends AbstractBackground {
-
+
private BufferedImage mBufferedImage;
private Image mImage;
ImageBackground() {
}
-
+
ImageBackground(BufferedImage image, Display display) {
setImage(image, display);
}
-
+
@Override
public void paintBackground(IFigure figure, Graphics graphics, Insets insets) {
if (mImage != null) {
@@ -74,7 +76,7 @@ public class UiDocumentEditPart extends UiElementEditPart {
graphics.drawImage(mImage, rect.x, rect.y);
}
}
-
+
void setImage(BufferedImage image, Display display) {
if (image != null) {
int[] data = ((DataBufferInt)image.getData().getDataBuffer()).getData();
@@ -104,27 +106,27 @@ public class UiDocumentEditPart extends UiElementEditPart {
protected IFigure createFigure() {
mLayer = new FreeformLayer();
mLayer.setLayoutManager(new FreeformLayout());
-
+
mLayer.setOpaque(true);
mLayer.setBackgroundColor(ColorConstants.lightGray);
-
+
return mLayer;
}
-
+
@Override
protected void refreshVisuals() {
UiElementNode model = (UiElementNode)getModel();
-
+
Object editData = model.getEditData();
if (editData instanceof BufferedImage) {
BufferedImage image = (BufferedImage)editData;
-
+
if (mImage == null || image != mImage.getBufferedImage()) {
mImage = new ImageBackground(image, mDisplay);
}
-
+
mLayer.setBorder(mImage);
-
+
if (mChild != null && mChild.getParent() == mLayer) {
mLayer.remove(mChild);
}
@@ -156,7 +158,7 @@ public class UiDocumentEditPart extends UiElementEditPart {
protected void showSelection() {
// no selection at this level.
}
-
+
@Override
protected void createEditPolicies() {
super.createEditPolicies();
@@ -168,12 +170,12 @@ public class UiDocumentEditPart extends UiElementEditPart {
}
/**
- * Returns the EditPart that should be used as the target for the specified Request.
+ * Returns the EditPart that should be used as the target for the specified Request.
* For instance this is called during drag'n'drop with a CreateRequest.
*
* For the root document, we want the first child edit part to the be the target
* since an XML document can have only one root element.
- *
+ *
* {@inheritDoc}
*/
@Override
@@ -194,7 +196,7 @@ public class UiDocumentEditPart extends UiElementEditPart {
return null;
}
}
-
+
}
}
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentTreeEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentTreeEditPart.java
index 57db255a4..b78c51931 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentTreeEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiDocumentTreeEditPart.java
@@ -22,13 +22,15 @@ import java.util.List;
/**
* Implementation of {@link UiElementTreeEditPart} for the document root.
+ *
+ * @since GLE1
*/
public class UiDocumentTreeEditPart extends UiElementTreeEditPart {
public UiDocumentTreeEditPart(UiDocumentNode model) {
super(model);
}
-
+
@SuppressWarnings("unchecked")
@Override
protected List getModelChildren() {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementEditPart.java
index 94590c5a7..75c7b6d11 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementEditPart.java
@@ -44,10 +44,12 @@ import java.util.List;
/**
* An {@link EditPart} for a {@link UiElementNode}.
+ *
+ * @since GLE1
*/
public abstract class UiElementEditPart extends AbstractGraphicalEditPart
implements IUiUpdateListener {
-
+
public UiElementEditPart(UiElementNode uiElementNode) {
setModel(uiElementNode);
}
@@ -60,7 +62,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
//-------------------------
// Base class overrides
-
+
@Override
public DragTracker getDragTracker(Request request) {
return new SelectEditPartTracker(this);
@@ -71,12 +73,12 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
/*
* This is no longer needed, as a selection edit policy is set by the parent layout.
* Leave this code commented out right now, I'll want to play with this later.
- *
+ *
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
new NonResizableSelectionEditPolicy(this));
*/
}
-
+
/* (non-javadoc)
* Returns a List containing the children model objects.
* Must not return null, instead use the super which returns an empty list.
@@ -92,7 +94,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
super.activate();
getUiNode().addUpdateListener(this);
}
-
+
@Override
public void deactivate() {
super.deactivate();
@@ -104,11 +106,11 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
if (getFigure().getParent() != null) {
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), getBounds());
}
-
+
// update the visuals of the children as well
refreshChildrenVisuals();
}
-
+
protected void refreshChildrenVisuals() {
if (children != null) {
for (Object child : children) {
@@ -131,7 +133,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
break;
case CHILDREN_CHANGED:
refreshChildren();
-
+
// new children list, need to update the layout
refreshVisuals();
break;
@@ -151,19 +153,19 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
public final UiElementNode getUiNode() {
return (UiElementNode) getModel();
}
-
+
protected final ElementDescriptor getDescriptor() {
return getUiNode().getDescriptor();
}
-
+
protected final UiElementEditPart getEditPartParent() {
EditPart parent = getParent();
if (parent instanceof UiElementEditPart) {
- return (UiElementEditPart)parent;
+ return (UiElementEditPart)parent;
}
return null;
}
-
+
/**
* Returns a given XML attribute.
* @param attrName The local name of the attribute.
@@ -186,17 +188,17 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
}
return null;
}
-
+
protected final Rectangle getBounds() {
UiElementNode model = (UiElementNode)getModel();
-
+
Object editData = model.getEditData();
if (editData != null) {
// assert with fully qualified class name to prevent import changes to another
// Rectangle class.
assert (editData instanceof org.eclipse.draw2d.geometry.Rectangle);
-
+
return (Rectangle)editData;
}
@@ -205,12 +207,12 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
}
/**
- * Returns the EditPart that should be used as the target for the specified Request.
+ * Returns the EditPart that should be used as the target for the specified Request.
*
* For instance this is called during drag'n'drop with a CreateRequest.
*
* Reject being a target for elements which descriptor does not allow children.
- *
+ *
* {@inheritDoc}
*/
@Override
@@ -227,7 +229,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
/**
* Used by derived classes {@link UiDocumentEditPart} and {@link UiLayoutEditPart}
* to accept drag'n'drop of new items from the palette.
- *
+ *
* @param layoutEditPart The layout edit part where this policy is installed. It can
* be either a {@link UiDocumentEditPart} or a {@link UiLayoutEditPart}.
*/
@@ -269,18 +271,18 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
Point where = request.getLocation().getCopy();
Point origin = getLayoutContainer().getClientArea().getLocation();
where.translate(origin.getNegated());
-
+
// The host is the EditPart where this policy is installed,
// e.g. this UiElementEditPart.
EditPart host = getHost();
if (host instanceof UiElementEditPart) {
-
+
return new ElementCreateCommand((ElementDescriptor) newType,
(UiElementEditPart) host,
where);
}
}
-
+
return null;
}
@@ -289,14 +291,14 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
// TODO Auto-generated method stub
return null;
}
-
+
@Override
public void showLayoutTargetFeedback(Request request) {
super.showLayoutTargetFeedback(request);
-
+
// for debugging
// System.out.println("target: " + request.toString() + " -- " + layoutEditPart.getUiNode().getBreadcrumbTrailDescription(false));
-
+
if (layoutEditPart instanceof UiLayoutEditPart &&
request instanceof DropRequest) {
Point where = ((DropRequest) request).getLocation().getCopy();
@@ -314,24 +316,24 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
((UiLayoutEditPart) layoutEditPart).hideDropTarget();
}
}
-
+
@Override
protected IFigure createSizeOnDropFeedback(CreateRequest createRequest) {
// TODO understand if this is useful for us or remove
return super.createSizeOnDropFeedback(createRequest);
}
-
+
});
}
-
+
protected static class NonResizableSelectionEditPolicy extends SelectionEditPolicy {
-
+
private final UiElementEditPart mEditPart;
public NonResizableSelectionEditPolicy(UiElementEditPart editPart) {
mEditPart = editPart;
}
-
+
@Override
protected void hideSelection() {
mEditPart.hideSelection();
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPart.java
index 459919a25..81737f8b2 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPart.java
@@ -25,6 +25,8 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/**
* Base {@link AbstractTreeEditPart} to represent {@link UiElementNode} objects in the
* {@link IContentOutlinePage} linked to the layout editor.
+ *
+ * @since GLE1
*/
public class UiElementTreeEditPart extends AbstractTreeEditPart {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPartFactory.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPartFactory.java
index 4c9eeb890..c10298c2c 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPartFactory.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementTreeEditPartFactory.java
@@ -26,7 +26,9 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/**
* {@link EditPartFactory} to create {@link AbstractTreeEditPart} for {@link UiElementNode} objects.
- * These objects are used in the {@link IContentOutlinePage} linked to the layout editor.
+ * These objects are used in the {@link IContentOutlinePage} linked to the layout editor.
+ *
+ * @since GLE1
*/
public class UiElementTreeEditPartFactory implements EditPartFactory {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementsEditPartFactory.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementsEditPartFactory.java
index 8fe4702e7..5f179372d 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementsEditPartFactory.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiElementsEditPartFactory.java
@@ -28,15 +28,17 @@ import org.eclipse.swt.widgets.Display;
*
* The only model objects we use are {@link UiElementNode} objects and they are
* edited using {@link UiElementEditPart}.
+ *
+ * @since GLE1
*/
public class UiElementsEditPartFactory implements EditPartFactory {
-
+
private Display mDisplay;
public UiElementsEditPartFactory(Display display) {
mDisplay = display;
}
-
+
public EditPart createEditPart(EditPart context, Object model) {
if (model instanceof UiDocumentNode) {
return new UiDocumentEditPart((UiDocumentNode) model, mDisplay);
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutEditPart.java
index 2fe0a597b..14d6edb0c 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutEditPart.java
@@ -29,10 +29,12 @@ import org.eclipse.gef.requests.CreateRequest;
/**
* Graphical edit part for an {@link UiElementNode} that represents a ViewLayout.
*
- * It acts as a simple container.
+ * It acts as a simple container.
+ *
+ * @since GLE1
*/
public final class UiLayoutEditPart extends UiElementEditPart {
-
+
static class HighlightInfo {
public boolean drawDropBorder;
public UiElementEditPart[] childParts;
@@ -48,24 +50,24 @@ public final class UiLayoutEditPart extends UiElementEditPart {
linePoints = null;
}
}
-
+
private final HighlightInfo mHighlightInfo = new HighlightInfo();
-
+
public UiLayoutEditPart(UiElementNode uiElementNode) {
super(uiElementNode);
}
-
+
@Override
protected void createEditPolicies() {
super.createEditPolicies();
-
+
installEditPolicy(EditPolicy.CONTAINER_ROLE, new ContainerEditPolicy() {
@Override
protected Command getCreateCommand(CreateRequest request) {
return null;
}
});
-
+
installLayoutEditPolicy(this);
}
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutTreeEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutTreeEditPart.java
index 09fdc8637..5e78b4682 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutTreeEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiLayoutTreeEditPart.java
@@ -22,13 +22,15 @@ import java.util.List;
/**
* Implementation of {@link UiElementTreeEditPart} for layout objects.
+ *
+ * @since GLE1
*/
public class UiLayoutTreeEditPart extends UiElementTreeEditPart {
public UiLayoutTreeEditPart(UiElementNode node) {
super(node);
}
-
+
@SuppressWarnings("unchecked")
@Override
protected List getModelChildren() {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewEditPart.java
index e8a1b8368..430e1cec8 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewEditPart.java
@@ -23,6 +23,8 @@ import org.eclipse.draw2d.XYLayout;
/**
* Graphical edit part for an {@link UiElementNode} that represents a View.
+ *
+ * @since GLE1
*/
public class UiViewEditPart extends UiElementEditPart {
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewTreeEditPart.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewTreeEditPart.java
index b505ec03c..22cc952c3 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewTreeEditPart.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/parts/UiViewTreeEditPart.java
@@ -20,6 +20,8 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
/**
* Implementation of {@link UiElementTreeEditPart} for view objects.
+ *
+ * @since GLE1
*/
public class UiViewTreeEditPart extends UiElementTreeEditPart {