ADT: Tag classes with "@since GLE1"

This adds a @since GLE1 to all classes involved in the current GLE
and a @since GLE2 to the new classes. The idea is that both classes
are going to be mixed in the same packages and it will help later
to remove the old GLE by just searching for this specific tag.

The alternative would be to move the classes in a sub-package
layout.gle1 vs layout.gle2, but that seems unecessary.

Change-Id: I577cd81819db4c6e0209ebbd910a393fc2182619
This commit is contained in:
Raphael
2009-08-25 15:29:51 -07:00
parent c216dea016
commit 5837c3cc34
20 changed files with 186 additions and 146 deletions

View File

@@ -30,7 +30,9 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart; 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 { public class GLE2 extends EditorPart implements IGraphicalLayoutEditor {

View File

@@ -111,6 +111,8 @@ import java.util.Map;
* To understand GEF: http://www.ibm.com/developerworks/opensource/library/os-gef/ * To understand GEF: http://www.ibm.com/developerworks/opensource/library/os-gef/
* <p/> * <p/>
* To understand Drag'n'drop: http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html * To understand Drag'n'drop: http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html
*
* @since GLE1
*/ */
public class GraphicalLayoutEditor extends GraphicalEditorWithPalette public class GraphicalLayoutEditor extends GraphicalEditorWithPalette
implements IGraphicalLayoutEditor, IConfigListener { implements IGraphicalLayoutEditor, IConfigListener {

View File

@@ -28,6 +28,8 @@ import org.eclipse.ui.IEditorPart;
/** /**
* Interface defining what {@link LayoutEditor} expects from a GraphicalLayoutEditor part. * Interface defining what {@link LayoutEditor} expects from a GraphicalLayoutEditor part.
*
* @since GLE2
*/ */
/*package*/ interface IGraphicalLayoutEditor extends IEditorPart, ILayoutReloadListener { /*package*/ interface IGraphicalLayoutEditor extends IEditorPart, ILayoutReloadListener {

View File

@@ -28,6 +28,8 @@ import java.util.List;
/** /**
* Factory that creates the palette for the {@link GraphicalLayoutEditor}. * Factory that creates the palette for the {@link GraphicalLayoutEditor}.
*
* @since GLE1
*/ */
public class PaletteFactory { public class PaletteFactory {
@@ -37,7 +39,7 @@ public class PaletteFactory {
public static PaletteRoot createPaletteRoot(PaletteRoot currentPalette, public static PaletteRoot createPaletteRoot(PaletteRoot currentPalette,
AndroidTargetData targetData) { AndroidTargetData targetData) {
if (currentPalette == null) { if (currentPalette == null) {
currentPalette = new PaletteRoot(); currentPalette = new PaletteRoot();
} }
@@ -45,7 +47,7 @@ public class PaletteFactory {
for (int n = currentPalette.getChildren().size() - 1; n >= 0; n--) { for (int n = currentPalette.getChildren().size() - 1; n >= 0; n--) {
currentPalette.getChildren().remove(n); currentPalette.getChildren().remove(n);
} }
if (targetData != null) { if (targetData != null) {
addTools(currentPalette); addTools(currentPalette);
addViews(currentPalette, "Layouts", addViews(currentPalette, "Layouts",
@@ -59,7 +61,7 @@ public class PaletteFactory {
private static void addTools(PaletteRoot paletteRoot) { private static void addTools(PaletteRoot paletteRoot) {
PaletteGroup group = new PaletteGroup("Tools"); PaletteGroup group = new PaletteGroup("Tools");
// Default tools: selection. // Default tools: selection.
// Do not use the MarqueeToolEntry since we don't support multiple 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. /* -- 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, private static void addViews(PaletteRoot paletteRoot, String groupName,
List<ElementDescriptor> descriptors) { List<ElementDescriptor> descriptors) {
PaletteDrawer group = new PaletteDrawer(groupName); PaletteDrawer group = new PaletteDrawer(groupName);
for (ElementDescriptor desc : descriptors) { for (ElementDescriptor desc : descriptors) {
PaletteTemplateEntry entry = new PaletteTemplateEntry( PaletteTemplateEntry entry = new PaletteTemplateEntry(
desc.getUiName(), // label desc.getUiName(), // label
@@ -84,10 +86,10 @@ public class PaletteFactory {
desc.getImageDescriptor(), // small icon desc.getImageDescriptor(), // small icon
desc.getImageDescriptor() // large icon desc.getImageDescriptor() // large icon
); );
group.add(entry); group.add(entry);
} }
paletteRoot.add(group); paletteRoot.add(group);
} }
} }

View File

@@ -67,6 +67,8 @@ import java.util.List;
/** /**
* Implementation of the {@link ContentOutlinePage} to display {@link UiElementNode}. * Implementation of the {@link ContentOutlinePage} to display {@link UiElementNode}.
*
* @since GLE1
*/ */
class UiContentOutlinePage extends ContentOutlinePage { class UiContentOutlinePage extends ContentOutlinePage {

View File

@@ -35,10 +35,12 @@ import org.eclipse.ui.views.properties.PropertySheetPage;
* A customized property sheet page for the graphical layout editor. * A customized property sheet page for the graphical layout editor.
* <p/> * <p/>
* Currently it just provides a custom tooltip to display attributes javadocs. * Currently it just provides a custom tooltip to display attributes javadocs.
*
* @since GLE1
*/ */
public class UiPropertySheetPage extends PropertySheetPage { public class UiPropertySheetPage extends PropertySheetPage {
public UiPropertySheetPage() { public UiPropertySheetPage() {
super(); super();
} }
@@ -46,7 +48,7 @@ public class UiPropertySheetPage extends PropertySheetPage {
@Override @Override
public void createControl(Composite parent) { public void createControl(Composite parent) {
super.createControl(parent); super.createControl(parent);
setupTooltip(); setupTooltip();
} }
@@ -59,14 +61,14 @@ public class UiPropertySheetPage extends PropertySheetPage {
final Tree tree = (Tree) getControl(); 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 * 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() { final Listener listener = new Listener() {
Shell tip = null; Shell tip = null;
Label label = null; Label label = null;
public void handleEvent(Event event) { public void handleEvent(Event event) {
switch(event.type) { switch(event.type) {
case SWT.Dispose: case SWT.Dispose:
@@ -88,7 +90,7 @@ public class UiPropertySheetPage extends PropertySheetPage {
} }
String tooltip = null; String tooltip = null;
TreeItem item = tree.getItem(new Point(event.x, event.y)); TreeItem item = tree.getItem(new Point(event.x, event.y));
if (item != null) { if (item != null) {
Object data = item.getData(); Object data = item.getData();
@@ -102,11 +104,11 @@ public class UiPropertySheetPage extends PropertySheetPage {
tooltip = item.getText() + ":\r" + tooltip; tooltip = item.getText() + ":\r" + tooltip;
} }
} }
if (tooltip != null) { if (tooltip != null) {
Shell shell = tree.getShell(); Shell shell = tree.getShell();
Display display = tree.getDisplay(); Display display = tree.getDisplay();
tip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); tip = new Shell(shell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL);
tip.setBackground(display .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); tip.setBackground(display .getSystemColor(SWT.COLOR_INFO_BACKGROUND));
FillLayout layout = new FillLayout(); FillLayout layout = new FillLayout();
@@ -128,7 +130,7 @@ public class UiPropertySheetPage extends PropertySheetPage {
} }
} }
}; };
tree.addListener(SWT.Dispose, listener); tree.addListener(SWT.Dispose, listener);
tree.addListener(SWT.KeyDown, listener); tree.addListener(SWT.KeyDown, listener);
tree.addListener(SWT.MouseMove, listener); tree.addListener(SWT.MouseMove, listener);

View File

@@ -4,7 +4,7 @@
* Licensed under the Eclipse Public License, Version 1.0 (the "License"); * 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 not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.eclipse.org/org/documents/epl-v10.php * http://www.eclipse.org/org/documents/epl-v10.php
* *
* Unless required by applicable law or agreed to in writing, software * 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 * 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 * drop operations. It is expected to only be invoked from the main UI thread with no
* concurrent access. * concurrent access.
*
* @since GLE1
*/ */
class DropFeedback { class DropFeedback {
@@ -43,12 +45,12 @@ class DropFeedback {
private static final int BOTTOM = 2; private static final int BOTTOM = 2;
private static final int RIGHT = 3; private static final int RIGHT = 3;
private static final int MAX_DIR = RIGHT; private static final int MAX_DIR = RIGHT;
private static final int sOppositeDirection[] = { BOTTOM, RIGHT, TOP, LEFT }; private static final int sOppositeDirection[] = { BOTTOM, RIGHT, TOP, LEFT };
private static final UiElementEditPart sTempClosests[] = new UiElementEditPart[4]; private static final UiElementEditPart sTempClosests[] = new UiElementEditPart[4];
private static final int sTempMinDists[] = new int[4]; private static final int sTempMinDists[] = new int[4];
/** /**
* Target information computed from a drop on a RelativeLayout. * Target information computed from a drop on a RelativeLayout.
@@ -69,20 +71,20 @@ class DropFeedback {
private static final RelativeInfo sRelativeInfo = new RelativeInfo(); private static final RelativeInfo sRelativeInfo = new RelativeInfo();
/** A temporary array of 2 {@link UiElementEditPart} to avoid allocations. */ /** A temporary array of 2 {@link UiElementEditPart} to avoid allocations. */
private static final UiElementEditPart sTempTwoParts[] = new UiElementEditPart[2]; private static final UiElementEditPart sTempTwoParts[] = new UiElementEditPart[2];
private DropFeedback() { private DropFeedback() {
} }
//----- Package methods called by users of this helper class ----- //----- Package methods called by users of this helper class -----
/** /**
* This method is used by {@link ElementCreateCommand#execute()} when a new item * 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 * 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. * the given descriptor as a child of the given parent part.
* *
* @param parentPart The parent part. * @param parentPart The parent part.
* @param descriptor The descriptor for the new XML element. * @param descriptor The descriptor for the new XML element.
* @param where The drop location (in parent coordinates) * @param where The drop location (in parent coordinates)
@@ -91,16 +93,16 @@ class DropFeedback {
static void addElementToXml(UiElementEditPart parentPart, static void addElementToXml(UiElementEditPart parentPart,
ElementDescriptor descriptor, Point where, ElementDescriptor descriptor, Point where,
UiEditorActions actions) { UiEditorActions actions) {
String layoutXmlName = getXmlLocalName(parentPart); String layoutXmlName = getXmlLocalName(parentPart);
RelativeInfo info = null; RelativeInfo info = null;
UiElementEditPart sibling = null; UiElementEditPart sibling = null;
// TODO consider merge like a vertical layout // TODO consider merge like a vertical layout
// TODO consider TableLayout like a linear // TODO consider TableLayout like a linear
if (LayoutConstants.LINEAR_LAYOUT.equals(layoutXmlName)) { if (LayoutConstants.LINEAR_LAYOUT.equals(layoutXmlName)) {
sibling = findLinearTarget(parentPart, where)[1]; sibling = findLinearTarget(parentPart, where)[1];
} else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutXmlName)) { } else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutXmlName)) {
info = findRelativeTarget(parentPart, where, sRelativeInfo); info = findRelativeTarget(parentPart, where, sRelativeInfo);
if (info != null) { if (info != null) {
@@ -114,7 +116,7 @@ class DropFeedback {
UiElementNode uiParent = parentPart.getUiNode(); UiElementNode uiParent = parentPart.getUiNode();
UiElementNode uiNode = actions.addElement(uiParent, uiSibling, descriptor, UiElementNode uiNode = actions.addElement(uiParent, uiSibling, descriptor,
false /*updateLayout*/); false /*updateLayout*/);
if (LayoutConstants.ABSOLUTE_LAYOUT.equals(layoutXmlName)) { if (LayoutConstants.ABSOLUTE_LAYOUT.equals(layoutXmlName)) {
adjustAbsoluteAttributes(uiNode, where); adjustAbsoluteAttributes(uiNode, where);
} else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutXmlName)) { } 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. * highlight information when a drop target is moved over a valid drop area.
* <p/> * <p/>
* Since there are no "out" parameters in Java, all the information is returned * 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 parentPart The parent part, always a layout.
* @param highlightInfo A structure where result is stored to perform highlight. * @param highlightInfo A structure where result is stored to perform highlight.
* @param where The target drop point, in parent's coordinates * @param where The target drop point, in parent's coordinates
@@ -139,16 +141,16 @@ class DropFeedback {
HighlightInfo highlightInfo, HighlightInfo highlightInfo,
Point where) { Point where) {
String layoutType = getXmlLocalName(parentPart); String layoutType = getXmlLocalName(parentPart);
if (LayoutConstants.ABSOLUTE_LAYOUT.equals(layoutType)) { if (LayoutConstants.ABSOLUTE_LAYOUT.equals(layoutType)) {
highlightInfo.anchorPoint = where; highlightInfo.anchorPoint = where;
} else if (LayoutConstants.LINEAR_LAYOUT.equals(layoutType)) { } else if (LayoutConstants.LINEAR_LAYOUT.equals(layoutType)) {
boolean isVertical = isVertical(parentPart); boolean isVertical = isVertical(parentPart);
highlightInfo.childParts = findLinearTarget(parentPart, where); highlightInfo.childParts = findLinearTarget(parentPart, where);
computeLinearLine(parentPart, isVertical, highlightInfo); computeLinearLine(parentPart, isVertical, highlightInfo);
} else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutType)) { } else if (LayoutConstants.RELATIVE_LAYOUT.equals(layoutType)) {
RelativeInfo info = findRelativeTarget(parentPart, where, sRelativeInfo); RelativeInfo info = findRelativeTarget(parentPart, where, sRelativeInfo);
@@ -157,13 +159,13 @@ class DropFeedback {
computeRelativeLine(parentPart, info, highlightInfo); computeRelativeLine(parentPart, info, highlightInfo);
} }
} }
return highlightInfo; return highlightInfo;
} }
//----- Misc utilities ----- //----- Misc utilities -----
/** /**
* Returns the next UI sibling of this part, i.e. the element which is just after in * 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. * 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. * Adjusts the attributes of a new node dropped in an AbsoluteLayout.
* *
* @param uiNode The new node being dropped. * @param uiNode The new node being dropped.
* @param where The drop location (in parent coordinates) * @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 * 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. * empty or the user is attaching to an existing empty border.
* <li> direction: the direction from the anchor part to the drop point. That's also the * <li> 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.
* <li> the new node; it is created either after the anchor for right or top directions * <li> 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 * or before the anchor for left or bottom directions. This means the new part can
* reference the id of the anchor part. * reference the id of the anchor part.
* </ul> * </ul>
* *
* Several cases: * Several cases:
* <ul> * <ul>
* <li> set: layout_above/below/toLeftOf/toRightOf to point to the anchor. * <li> set: layout_above/below/toLeftOf/toRightOf to point to the anchor.
@@ -251,7 +253,7 @@ class DropFeedback {
* <li> copy: layout_above/below/toLeftOf/toRightOf for the orthogonal direction * <li> copy: layout_above/below/toLeftOf/toRightOf for the orthogonal direction
* (i.e. top/bottom or left/right.) * (i.e. top/bottom or left/right.)
* </ul> * </ul>
* *
* @param uiNode The new node being dropped. * @param uiNode The new node being dropped.
* @param info The context computed by {@link #findRelativeTarget(UiElementEditPart, Point, RelativeInfo)}. * @param info The context computed by {@link #findRelativeTarget(UiElementEditPart, Point, RelativeInfo)}.
*/ */
@@ -259,10 +261,10 @@ class DropFeedback {
if (uiNode == null || info == null) { if (uiNode == null || info == null) {
return; 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; final int direction = info.direction;
uiNode.getEditor().editXmlModel(new Runnable() { uiNode.getEditor().editXmlModel(new Runnable() {
public void run() { public void run() {
HashMap<String, String> map = new HashMap<String, String>(); HashMap<String, String> map = new HashMap<String, String>();
@@ -276,7 +278,7 @@ class DropFeedback {
anchorId = DescriptorsUtils.getFreeWidgetId(anchorUiNode); anchorId = DescriptorsUtils.getFreeWidgetId(anchorUiNode);
anchorUiNode.setAttributeValue("id", anchorId, true /*override*/); //$NON-NLS-1$ anchorUiNode.setAttributeValue("id", anchorId, true /*override*/); //$NON-NLS-1$
} }
if (anchorId != null) { if (anchorId != null) {
switch(direction) { switch(direction) {
case TOP: case TOP:
@@ -315,7 +317,7 @@ class DropFeedback {
map.put(LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE, map.put(LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE,
anchorUiNode.getAttributeValue( anchorUiNode.getAttributeValue(
LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE)); LayoutConstants.ATTR_LAYOUT_ALIGN_BASELINE));
map.put(LayoutConstants.ATTR_LAYOUT_ABOVE, map.put(LayoutConstants.ATTR_LAYOUT_ABOVE,
anchorUiNode.getAttributeValue(LayoutConstants.ATTR_LAYOUT_ABOVE)); anchorUiNode.getAttributeValue(LayoutConstants.ATTR_LAYOUT_ABOVE));
map.put(LayoutConstants.ATTR_LAYOUT_BELOW, map.put(LayoutConstants.ATTR_LAYOUT_BELOW,
@@ -344,7 +346,7 @@ class DropFeedback {
break; break;
} }
} }
for (Entry<String, String> entry : map.entrySet()) { for (Entry<String, String> entry : map.entrySet()) {
uiNode.setAttributeValue(entry.getKey(), entry.getValue(), true /* override */); uiNode.setAttributeValue(entry.getKey(), entry.getValue(), true /* override */);
} }
@@ -365,7 +367,7 @@ class DropFeedback {
* <p/> * <p/>
* It returns null if it can't be determined, in which case the element will be added at the * 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. * end of the parent child list.
* *
* @return The edit parts that correspond to what will be the "prev" and "next sibling" of the * @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. * 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. * 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) { private static UiElementEditPart[] findLinearTarget(UiElementEditPart parent, Point point) {
// default orientation is horizontal // default orientation is horizontal
boolean isVertical = isVertical(parent); boolean isVertical = isVertical(parent);
int target = isVertical ? point.y : point.x; int target = isVertical ? point.y : point.x;
UiElementEditPart prev = null; UiElementEditPart prev = null;
UiElementEditPart next = null; UiElementEditPart next = null;
@@ -391,7 +393,7 @@ class DropFeedback {
prev = childPart; prev = childPart;
} }
} }
sTempTwoParts[0] = prev; sTempTwoParts[0] = prev;
sTempTwoParts[1] = next; sTempTwoParts[1] = next;
return sTempTwoParts; return sTempTwoParts;
@@ -405,7 +407,7 @@ class DropFeedback {
* The result is stored in HighlightInfo. * The result is stored in HighlightInfo.
* <p/> * <p/>
* Caller must clear the HighlightInfo as appropriate before this call. * Caller must clear the HighlightInfo as appropriate before this call.
* *
* @param parentPart The parent part, always a layout. * @param parentPart The parent part, always a layout.
* @param isVertical True for vertical parts, thus computing an horizontal line. * @param isVertical True for vertical parts, thus computing an horizontal line.
* @param highlightInfo The in-out highlight info. * @param highlightInfo The in-out highlight info.
@@ -455,18 +457,18 @@ class DropFeedback {
/** /**
* Returns true if the linear layout is marked as vertical. * 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. * @return True if the linear layout has a vertical orientation attribute.
*/ */
private static boolean isVertical(UiElementEditPart parent) { private static boolean isVertical(UiElementEditPart parent) {
String orientation = parent.getStringAttr("orientation"); //$NON-NLS-1$ 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$ "1".equals(orientation); //$NON-NLS-1$
return isVertical; return isVertical;
} }
//----- RelativeLayout -------- //----- RelativeLayout --------
/** /**
@@ -481,26 +483,26 @@ class DropFeedback {
* <p/> * <p/>
* If the drop point is not exactly on a current element, find the closest in each * 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. * 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 * @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. * with); otherwise fills the {@link RelativeInfo} and return it.
*/ */
private static RelativeInfo findRelativeTarget(UiElementEditPart parent, private static RelativeInfo findRelativeTarget(UiElementEditPart parent,
Point point, Point point,
RelativeInfo outInfo) { RelativeInfo outInfo) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
sTempMinDists[i] = Integer.MAX_VALUE; sTempMinDists[i] = Integer.MAX_VALUE;
sTempClosests[i] = null; sTempClosests[i] = null;
} }
for (Object child : parent.getChildren()) { for (Object child : parent.getChildren()) {
if (child instanceof UiElementEditPart) { if (child instanceof UiElementEditPart) {
UiElementEditPart childPart = (UiElementEditPart) child; UiElementEditPart childPart = (UiElementEditPart) child;
Rectangle r = childPart.getBounds(); Rectangle r = childPart.getBounds();
if (r.contains(point)) { if (r.contains(point)) {
float rx = ((float)(point.x - r.x) / (float)r.width ) - 0.5f; float rx = ((float)(point.x - r.x) / (float)r.width ) - 0.5f;
float ry = ((float)(point.y - r.y) / (float)r.height) - 0.5f; float ry = ((float)(point.y - r.y) / (float)r.height) - 0.5f;
@@ -537,18 +539,18 @@ class DropFeedback {
return outInfo; return outInfo;
} }
computeClosest(point, childPart, sTempClosests, sTempMinDists, TOP); computeClosest(point, childPart, sTempClosests, sTempMinDists, TOP);
computeClosest(point, childPart, sTempClosests, sTempMinDists, LEFT); computeClosest(point, childPart, sTempClosests, sTempMinDists, LEFT);
computeClosest(point, childPart, sTempClosests, sTempMinDists, BOTTOM); computeClosest(point, childPart, sTempClosests, sTempMinDists, BOTTOM);
computeClosest(point, childPart, sTempClosests, sTempMinDists, RIGHT); computeClosest(point, childPart, sTempClosests, sTempMinDists, RIGHT);
} }
} }
UiElementEditPart closest = null; UiElementEditPart closest = null;
int minDist = Integer.MAX_VALUE; int minDist = Integer.MAX_VALUE;
int minDir = -1; int minDir = -1;
for (int i = 0; i <= MAX_DIR; i++) { for (int i = 0; i <= MAX_DIR; i++) {
if (sTempClosests[i] != null && sTempMinDists[i] < minDist) { if (sTempClosests[i] != null && sTempMinDists[i] < minDist) {
closest = sTempClosests[i]; closest = sTempClosests[i];
@@ -556,7 +558,7 @@ class DropFeedback {
minDir = i; minDir = i;
} }
} }
if (closest != null) { if (closest != null) {
int index = 0; int index = 0;
switch(minDir) { switch(minDir) {
@@ -662,7 +664,7 @@ class DropFeedback {
Point p = null; Point p = null;
boolean usable = false; boolean usable = false;
switch(direction) { switch(direction) {
case TOP: case TOP:
p = r.getBottom(); p = r.getBottom();
@@ -701,7 +703,7 @@ class DropFeedback {
if (referencePart == null || referencePart.getParent() == null) { if (referencePart == null || referencePart.getParent() == null) {
return null; return null;
} }
Rectangle r = referencePart.getBounds(); Rectangle r = referencePart.getBounds();
Point ref = null; Point ref = null;
switch(direction) { switch(direction) {
@@ -718,16 +720,16 @@ class DropFeedback {
ref = r.getRight(); ref = r.getRight();
break; break;
} }
int minDist = Integer.MAX_VALUE; int minDist = Integer.MAX_VALUE;
UiElementEditPart closestPart = null; UiElementEditPart closestPart = null;
for (Object childPart : referencePart.getParent().getChildren()) { for (Object childPart : referencePart.getParent().getChildren()) {
if (childPart != referencePart && childPart instanceof UiElementEditPart) { if (childPart != referencePart && childPart instanceof UiElementEditPart) {
r = ((UiElementEditPart) childPart).getBounds(); r = ((UiElementEditPart) childPart).getBounds();
Point p = null; Point p = null;
boolean usable = false; boolean usable = false;
switch(direction) { switch(direction) {
case TOP: case TOP:
p = r.getBottom(); p = r.getBottom();
@@ -756,7 +758,7 @@ class DropFeedback {
} }
} }
} }
return closestPart; return closestPart;
} }

View File

@@ -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}, * 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. * the parent {@link UiElementEditPart} and an optional target location.
*
* @since GLE1
*/ */
public class ElementCreateCommand extends Command { public class ElementCreateCommand extends Command {
@@ -41,7 +43,7 @@ public class ElementCreateCommand extends Command {
/** /**
* Creates a new {@link ElementCreateCommand}. * Creates a new {@link ElementCreateCommand}.
* *
* @param descriptor Descriptor of the new element to create * @param descriptor Descriptor of the new element to create
* @param targetPart The edit part that hosts the new edit part * @param targetPart The edit part that hosts the new edit part
* @param targetPoint The drop location in parent coordinates * @param targetPoint The drop location in parent coordinates
@@ -52,7 +54,7 @@ public class ElementCreateCommand extends Command {
mParentPart = targetPart; mParentPart = targetPart;
mTargetPoint = targetPoint; mTargetPoint = targetPoint;
} }
// --- Methods inherited from Command --- // --- Methods inherited from Command ---
@Override @Override
@@ -82,14 +84,14 @@ public class ElementCreateCommand extends Command {
} }
}); });
} }
} }
} }
@Override @Override
public void redo() { public void redo() {
throw new UnsupportedOperationException("redo not supported by this command"); //$NON-NLS-1$ throw new UnsupportedOperationException("redo not supported by this command"); //$NON-NLS-1$
} }
@Override @Override
public void undo() { public void undo() {
throw new UnsupportedOperationException("undo not supported by this command"); //$NON-NLS-1$ throw new UnsupportedOperationException("undo not supported by this command"); //$NON-NLS-1$

View File

@@ -22,11 +22,13 @@ import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
/** /**
* The figure used to draw basic elements. * The figure used to draw basic elements.
* <p/> * <p/>
* The figure is totally empty and transparent except for the selection border. * The figure is totally empty and transparent except for the selection border.
*
* @since GLE1
*/ */
class ElementFigure extends Figure { class ElementFigure extends Figure {
@@ -36,18 +38,18 @@ class ElementFigure extends Figure {
public ElementFigure() { public ElementFigure() {
setOpaque(false); setOpaque(false);
} }
public void setSelected(boolean isSelected) { public void setSelected(boolean isSelected) {
if (isSelected != mIsSelected) { if (isSelected != mIsSelected) {
mIsSelected = isSelected; mIsSelected = isSelected;
repaint(); repaint();
} }
} }
@Override @Override
public void setBounds(Rectangle rect) { public void setBounds(Rectangle rect) {
super.setBounds(rect); super.setBounds(rect);
mInnerBounds = getBounds().getCopy(); mInnerBounds = getBounds().getCopy();
if (mInnerBounds.width > 0) { if (mInnerBounds.width > 0) {
mInnerBounds.width--; mInnerBounds.width--;
@@ -56,11 +58,11 @@ class ElementFigure extends Figure {
mInnerBounds.height--; mInnerBounds.height--;
} }
} }
public Rectangle getInnerBounds() { public Rectangle getInnerBounds() {
return mInnerBounds; return mInnerBounds;
} }
@Override @Override
protected void paintBorder(Graphics graphics) { protected void paintBorder(Graphics graphics) {
super.paintBorder(graphics); super.paintBorder(graphics);

View File

@@ -30,11 +30,13 @@ import org.eclipse.swt.SWT;
* By default the figure is transparent and empty. * By default the figure is transparent and empty.
* The base {@link ElementFigure} knows how to draw the selection border. * The base {@link ElementFigure} knows how to draw the selection border.
* This figure knows how to draw the drop feedback. * This figure knows how to draw the drop feedback.
*
* @since GLE1
*/ */
class LayoutFigure extends ElementFigure { class LayoutFigure extends ElementFigure {
private HighlightInfo mHighlightInfo; private HighlightInfo mHighlightInfo;
public LayoutFigure() { public LayoutFigure() {
super(); super();
} }
@@ -50,12 +52,12 @@ class LayoutFigure extends ElementFigure {
* The parent {@link Figure#paint(Graphics)} calls {@link #paintFigure(Graphics)} then * The parent {@link Figure#paint(Graphics)} calls {@link #paintFigure(Graphics)} then
* {@link #paintClientArea(Graphics)} then {@link #paintBorder(Graphics)}. Here we thus * {@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 * 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.
* <p/> * <p/>
* Note: This method doesn't really need to restore its graphic state. The parent * Note: This method doesn't really need to restore its graphic state. The parent
* Figure will do it for us. * Figure will do it for us.
* <p/> * <p/>
* *
* @param graphics The Graphics object used for painting * @param graphics The Graphics object used for painting
*/ */
@Override @Override
@@ -98,7 +100,7 @@ class LayoutFigure extends ElementFigure {
int y1 = mHighlightInfo.linePoints[0].y; int y1 = mHighlightInfo.linePoints[0].y;
int x2 = mHighlightInfo.linePoints[1].x; int x2 = mHighlightInfo.linePoints[1].x;
int y2 = mHighlightInfo.linePoints[1].y; int y2 = mHighlightInfo.linePoints[1].y;
// if the line is right to the edge, draw it one pixel more inside so that the // if the line is right to the edge, draw it one pixel more inside so that the
// full 2-pixel width be visible. // full 2-pixel width be visible.
if (x1 <= 0) x1++; if (x1 <= 0) x1++;
@@ -110,12 +112,12 @@ class LayoutFigure extends ElementFigure {
if (x2 >= w - 1) x2--; if (x2 >= w - 1) x2--;
if (y1 >= h - 1) y1--; if (y1 >= h - 1) y1--;
if (y2 >= h - 1) y2--; if (y2 >= h - 1) y2--;
x1 += bx; x1 += bx;
x2 += bx; x2 += bx;
y1 += by; y1 += by;
y2 += by; y2 += by;
graphics.setLineWidth(2); graphics.setLineWidth(2);
graphics.setLineStyle(SWT.LINE_DASH); graphics.setLineStyle(SWT.LINE_DASH);
graphics.setLineCap(SWT.CAP_ROUND); graphics.setLineCap(SWT.CAP_ROUND);

View File

@@ -46,27 +46,29 @@ import java.awt.image.DataBufferInt;
/** /**
* Graphical edit part for the root document. * Graphical edit part for the root document.
* <p/> * <p/>
* It acts as a simple container. * It acts as a simple container.
*
* @since GLE1
*/ */
public class UiDocumentEditPart extends UiElementEditPart { public class UiDocumentEditPart extends UiElementEditPart {
private Display mDisplay; private Display mDisplay;
private FreeformLayer mLayer; private FreeformLayer mLayer;
private ImageBackground mImage; private ImageBackground mImage;
private Label mChild = null; private Label mChild = null;
final static class ImageBackground extends AbstractBackground { final static class ImageBackground extends AbstractBackground {
private BufferedImage mBufferedImage; private BufferedImage mBufferedImage;
private Image mImage; private Image mImage;
ImageBackground() { ImageBackground() {
} }
ImageBackground(BufferedImage image, Display display) { ImageBackground(BufferedImage image, Display display) {
setImage(image, display); setImage(image, display);
} }
@Override @Override
public void paintBackground(IFigure figure, Graphics graphics, Insets insets) { public void paintBackground(IFigure figure, Graphics graphics, Insets insets) {
if (mImage != null) { if (mImage != null) {
@@ -74,7 +76,7 @@ public class UiDocumentEditPart extends UiElementEditPart {
graphics.drawImage(mImage, rect.x, rect.y); graphics.drawImage(mImage, rect.x, rect.y);
} }
} }
void setImage(BufferedImage image, Display display) { void setImage(BufferedImage image, Display display) {
if (image != null) { if (image != null) {
int[] data = ((DataBufferInt)image.getData().getDataBuffer()).getData(); int[] data = ((DataBufferInt)image.getData().getDataBuffer()).getData();
@@ -104,27 +106,27 @@ public class UiDocumentEditPart extends UiElementEditPart {
protected IFigure createFigure() { protected IFigure createFigure() {
mLayer = new FreeformLayer(); mLayer = new FreeformLayer();
mLayer.setLayoutManager(new FreeformLayout()); mLayer.setLayoutManager(new FreeformLayout());
mLayer.setOpaque(true); mLayer.setOpaque(true);
mLayer.setBackgroundColor(ColorConstants.lightGray); mLayer.setBackgroundColor(ColorConstants.lightGray);
return mLayer; return mLayer;
} }
@Override @Override
protected void refreshVisuals() { protected void refreshVisuals() {
UiElementNode model = (UiElementNode)getModel(); UiElementNode model = (UiElementNode)getModel();
Object editData = model.getEditData(); Object editData = model.getEditData();
if (editData instanceof BufferedImage) { if (editData instanceof BufferedImage) {
BufferedImage image = (BufferedImage)editData; BufferedImage image = (BufferedImage)editData;
if (mImage == null || image != mImage.getBufferedImage()) { if (mImage == null || image != mImage.getBufferedImage()) {
mImage = new ImageBackground(image, mDisplay); mImage = new ImageBackground(image, mDisplay);
} }
mLayer.setBorder(mImage); mLayer.setBorder(mImage);
if (mChild != null && mChild.getParent() == mLayer) { if (mChild != null && mChild.getParent() == mLayer) {
mLayer.remove(mChild); mLayer.remove(mChild);
} }
@@ -156,7 +158,7 @@ public class UiDocumentEditPart extends UiElementEditPart {
protected void showSelection() { protected void showSelection() {
// no selection at this level. // no selection at this level.
} }
@Override @Override
protected void createEditPolicies() { protected void createEditPolicies() {
super.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 instance this is called during drag'n'drop with a CreateRequest.
* <p/> * <p/>
* For the root document, we want the first child edit part to the be the target * 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. * since an XML document can have only one root element.
* *
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
@@ -194,7 +196,7 @@ public class UiDocumentEditPart extends UiElementEditPart {
return null; return null;
} }
} }
} }
} }

View File

@@ -22,13 +22,15 @@ import java.util.List;
/** /**
* Implementation of {@link UiElementTreeEditPart} for the document root. * Implementation of {@link UiElementTreeEditPart} for the document root.
*
* @since GLE1
*/ */
public class UiDocumentTreeEditPart extends UiElementTreeEditPart { public class UiDocumentTreeEditPart extends UiElementTreeEditPart {
public UiDocumentTreeEditPart(UiDocumentNode model) { public UiDocumentTreeEditPart(UiDocumentNode model) {
super(model); super(model);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected List getModelChildren() { protected List getModelChildren() {

View File

@@ -44,10 +44,12 @@ import java.util.List;
/** /**
* An {@link EditPart} for a {@link UiElementNode}. * An {@link EditPart} for a {@link UiElementNode}.
*
* @since GLE1
*/ */
public abstract class UiElementEditPart extends AbstractGraphicalEditPart public abstract class UiElementEditPart extends AbstractGraphicalEditPart
implements IUiUpdateListener { implements IUiUpdateListener {
public UiElementEditPart(UiElementNode uiElementNode) { public UiElementEditPart(UiElementNode uiElementNode) {
setModel(uiElementNode); setModel(uiElementNode);
} }
@@ -60,7 +62,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
//------------------------- //-------------------------
// Base class overrides // Base class overrides
@Override @Override
public DragTracker getDragTracker(Request request) { public DragTracker getDragTracker(Request request) {
return new SelectEditPartTracker(this); 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. * 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. * Leave this code commented out right now, I'll want to play with this later.
* *
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
new NonResizableSelectionEditPolicy(this)); new NonResizableSelectionEditPolicy(this));
*/ */
} }
/* (non-javadoc) /* (non-javadoc)
* Returns a List containing the children model objects. * Returns a List containing the children model objects.
* Must not return null, instead use the super which returns an empty list. * 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(); super.activate();
getUiNode().addUpdateListener(this); getUiNode().addUpdateListener(this);
} }
@Override @Override
public void deactivate() { public void deactivate() {
super.deactivate(); super.deactivate();
@@ -104,11 +106,11 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
if (getFigure().getParent() != null) { if (getFigure().getParent() != null) {
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), getBounds()); ((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), getBounds());
} }
// update the visuals of the children as well // update the visuals of the children as well
refreshChildrenVisuals(); refreshChildrenVisuals();
} }
protected void refreshChildrenVisuals() { protected void refreshChildrenVisuals() {
if (children != null) { if (children != null) {
for (Object child : children) { for (Object child : children) {
@@ -131,7 +133,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
break; break;
case CHILDREN_CHANGED: case CHILDREN_CHANGED:
refreshChildren(); refreshChildren();
// new children list, need to update the layout // new children list, need to update the layout
refreshVisuals(); refreshVisuals();
break; break;
@@ -151,19 +153,19 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
public final UiElementNode getUiNode() { public final UiElementNode getUiNode() {
return (UiElementNode) getModel(); return (UiElementNode) getModel();
} }
protected final ElementDescriptor getDescriptor() { protected final ElementDescriptor getDescriptor() {
return getUiNode().getDescriptor(); return getUiNode().getDescriptor();
} }
protected final UiElementEditPart getEditPartParent() { protected final UiElementEditPart getEditPartParent() {
EditPart parent = getParent(); EditPart parent = getParent();
if (parent instanceof UiElementEditPart) { if (parent instanceof UiElementEditPart) {
return (UiElementEditPart)parent; return (UiElementEditPart)parent;
} }
return null; return null;
} }
/** /**
* Returns a given XML attribute. * Returns a given XML attribute.
* @param attrName The local name of the attribute. * @param attrName The local name of the attribute.
@@ -186,17 +188,17 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
} }
return null; return null;
} }
protected final Rectangle getBounds() { protected final Rectangle getBounds() {
UiElementNode model = (UiElementNode)getModel(); UiElementNode model = (UiElementNode)getModel();
Object editData = model.getEditData(); Object editData = model.getEditData();
if (editData != null) { if (editData != null) {
// assert with fully qualified class name to prevent import changes to another // assert with fully qualified class name to prevent import changes to another
// Rectangle class. // Rectangle class.
assert (editData instanceof org.eclipse.draw2d.geometry.Rectangle); assert (editData instanceof org.eclipse.draw2d.geometry.Rectangle);
return (Rectangle)editData; 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.
* <p/> * <p/>
* For instance this is called during drag'n'drop with a CreateRequest. * For instance this is called during drag'n'drop with a CreateRequest.
* <p/> * <p/>
* Reject being a target for elements which descriptor does not allow children. * Reject being a target for elements which descriptor does not allow children.
* *
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
@@ -227,7 +229,7 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
/** /**
* Used by derived classes {@link UiDocumentEditPart} and {@link UiLayoutEditPart} * Used by derived classes {@link UiDocumentEditPart} and {@link UiLayoutEditPart}
* to accept drag'n'drop of new items from the palette. * to accept drag'n'drop of new items from the palette.
* *
* @param layoutEditPart The layout edit part where this policy is installed. It can * @param layoutEditPart The layout edit part where this policy is installed. It can
* be either a {@link UiDocumentEditPart} or a {@link UiLayoutEditPart}. * 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 where = request.getLocation().getCopy();
Point origin = getLayoutContainer().getClientArea().getLocation(); Point origin = getLayoutContainer().getClientArea().getLocation();
where.translate(origin.getNegated()); where.translate(origin.getNegated());
// The host is the EditPart where this policy is installed, // The host is the EditPart where this policy is installed,
// e.g. this UiElementEditPart. // e.g. this UiElementEditPart.
EditPart host = getHost(); EditPart host = getHost();
if (host instanceof UiElementEditPart) { if (host instanceof UiElementEditPart) {
return new ElementCreateCommand((ElementDescriptor) newType, return new ElementCreateCommand((ElementDescriptor) newType,
(UiElementEditPart) host, (UiElementEditPart) host,
where); where);
} }
} }
return null; return null;
} }
@@ -289,14 +291,14 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public void showLayoutTargetFeedback(Request request) { public void showLayoutTargetFeedback(Request request) {
super.showLayoutTargetFeedback(request); super.showLayoutTargetFeedback(request);
// for debugging // for debugging
// System.out.println("target: " + request.toString() + " -- " + layoutEditPart.getUiNode().getBreadcrumbTrailDescription(false)); // System.out.println("target: " + request.toString() + " -- " + layoutEditPart.getUiNode().getBreadcrumbTrailDescription(false));
if (layoutEditPart instanceof UiLayoutEditPart && if (layoutEditPart instanceof UiLayoutEditPart &&
request instanceof DropRequest) { request instanceof DropRequest) {
Point where = ((DropRequest) request).getLocation().getCopy(); Point where = ((DropRequest) request).getLocation().getCopy();
@@ -314,24 +316,24 @@ public abstract class UiElementEditPart extends AbstractGraphicalEditPart
((UiLayoutEditPart) layoutEditPart).hideDropTarget(); ((UiLayoutEditPart) layoutEditPart).hideDropTarget();
} }
} }
@Override @Override
protected IFigure createSizeOnDropFeedback(CreateRequest createRequest) { protected IFigure createSizeOnDropFeedback(CreateRequest createRequest) {
// TODO understand if this is useful for us or remove // TODO understand if this is useful for us or remove
return super.createSizeOnDropFeedback(createRequest); return super.createSizeOnDropFeedback(createRequest);
} }
}); });
} }
protected static class NonResizableSelectionEditPolicy extends SelectionEditPolicy { protected static class NonResizableSelectionEditPolicy extends SelectionEditPolicy {
private final UiElementEditPart mEditPart; private final UiElementEditPart mEditPart;
public NonResizableSelectionEditPolicy(UiElementEditPart editPart) { public NonResizableSelectionEditPolicy(UiElementEditPart editPart) {
mEditPart = editPart; mEditPart = editPart;
} }
@Override @Override
protected void hideSelection() { protected void hideSelection() {
mEditPart.hideSelection(); mEditPart.hideSelection();

View File

@@ -25,6 +25,8 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/** /**
* Base {@link AbstractTreeEditPart} to represent {@link UiElementNode} objects in the * Base {@link AbstractTreeEditPart} to represent {@link UiElementNode} objects in the
* {@link IContentOutlinePage} linked to the layout editor. * {@link IContentOutlinePage} linked to the layout editor.
*
* @since GLE1
*/ */
public class UiElementTreeEditPart extends AbstractTreeEditPart { public class UiElementTreeEditPart extends AbstractTreeEditPart {

View File

@@ -26,7 +26,9 @@ import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
/** /**
* {@link EditPartFactory} to create {@link AbstractTreeEditPart} for {@link UiElementNode} objects. * {@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 { public class UiElementTreeEditPartFactory implements EditPartFactory {

View File

@@ -28,15 +28,17 @@ import org.eclipse.swt.widgets.Display;
* <p/> * <p/>
* The only model objects we use are {@link UiElementNode} objects and they are * The only model objects we use are {@link UiElementNode} objects and they are
* edited using {@link UiElementEditPart}. * edited using {@link UiElementEditPart}.
*
* @since GLE1
*/ */
public class UiElementsEditPartFactory implements EditPartFactory { public class UiElementsEditPartFactory implements EditPartFactory {
private Display mDisplay; private Display mDisplay;
public UiElementsEditPartFactory(Display display) { public UiElementsEditPartFactory(Display display) {
mDisplay = display; mDisplay = display;
} }
public EditPart createEditPart(EditPart context, Object model) { public EditPart createEditPart(EditPart context, Object model) {
if (model instanceof UiDocumentNode) { if (model instanceof UiDocumentNode) {
return new UiDocumentEditPart((UiDocumentNode) model, mDisplay); return new UiDocumentEditPart((UiDocumentNode) model, mDisplay);

View File

@@ -29,10 +29,12 @@ import org.eclipse.gef.requests.CreateRequest;
/** /**
* Graphical edit part for an {@link UiElementNode} that represents a ViewLayout. * Graphical edit part for an {@link UiElementNode} that represents a ViewLayout.
* <p/> * <p/>
* It acts as a simple container. * It acts as a simple container.
*
* @since GLE1
*/ */
public final class UiLayoutEditPart extends UiElementEditPart { public final class UiLayoutEditPart extends UiElementEditPart {
static class HighlightInfo { static class HighlightInfo {
public boolean drawDropBorder; public boolean drawDropBorder;
public UiElementEditPart[] childParts; public UiElementEditPart[] childParts;
@@ -48,24 +50,24 @@ public final class UiLayoutEditPart extends UiElementEditPart {
linePoints = null; linePoints = null;
} }
} }
private final HighlightInfo mHighlightInfo = new HighlightInfo(); private final HighlightInfo mHighlightInfo = new HighlightInfo();
public UiLayoutEditPart(UiElementNode uiElementNode) { public UiLayoutEditPart(UiElementNode uiElementNode) {
super(uiElementNode); super(uiElementNode);
} }
@Override @Override
protected void createEditPolicies() { protected void createEditPolicies() {
super.createEditPolicies(); super.createEditPolicies();
installEditPolicy(EditPolicy.CONTAINER_ROLE, new ContainerEditPolicy() { installEditPolicy(EditPolicy.CONTAINER_ROLE, new ContainerEditPolicy() {
@Override @Override
protected Command getCreateCommand(CreateRequest request) { protected Command getCreateCommand(CreateRequest request) {
return null; return null;
} }
}); });
installLayoutEditPolicy(this); installLayoutEditPolicy(this);
} }

View File

@@ -22,13 +22,15 @@ import java.util.List;
/** /**
* Implementation of {@link UiElementTreeEditPart} for layout objects. * Implementation of {@link UiElementTreeEditPart} for layout objects.
*
* @since GLE1
*/ */
public class UiLayoutTreeEditPart extends UiElementTreeEditPart { public class UiLayoutTreeEditPart extends UiElementTreeEditPart {
public UiLayoutTreeEditPart(UiElementNode node) { public UiLayoutTreeEditPart(UiElementNode node) {
super(node); super(node);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
protected List getModelChildren() { protected List getModelChildren() {

View File

@@ -23,6 +23,8 @@ import org.eclipse.draw2d.XYLayout;
/** /**
* Graphical edit part for an {@link UiElementNode} that represents a View. * Graphical edit part for an {@link UiElementNode} that represents a View.
*
* @since GLE1
*/ */
public class UiViewEditPart extends UiElementEditPart { public class UiViewEditPart extends UiElementEditPart {

View File

@@ -20,6 +20,8 @@ import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
/** /**
* Implementation of {@link UiElementTreeEditPart} for view objects. * Implementation of {@link UiElementTreeEditPart} for view objects.
*
* @since GLE1
*/ */
public class UiViewTreeEditPart extends UiElementTreeEditPart { public class UiViewTreeEditPart extends UiElementTreeEditPart {