--- /dev/null
+/*\r
+ * Copyright (C) 2009 The Android Open Source Project\r
+ *\r
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.eclipse.org/org/documents/epl-v10.php\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package com.android.ide.eclipse.adt.internal.editors.layout;\r
+\r
+import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode;\r
+import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;\r
+import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;\r
+\r
+import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.gef.ui.parts.SelectionSynchronizer;\r
+import org.eclipse.swt.dnd.Clipboard;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IEditorInput;\r
+import org.eclipse.ui.IEditorSite;\r
+import org.eclipse.ui.PartInitException;\r
+import org.eclipse.ui.part.EditorPart;\r
+\r
+/**\r
+ * Graphical layout editor, version 2.\r
+ */\r
+public class GLE2 extends EditorPart implements IGraphicalLayoutEditor {\r
+\r
+ /*\r
+ * Useful notes:\r
+ * To understand Drag'n'drop:\r
+ * http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html\r
+ */\r
+\r
+ /** Reference to the layout editor */\r
+ private final LayoutEditor mLayoutEditor;\r
+\r
+ public GLE2(LayoutEditor layoutEditor) {\r
+ mLayoutEditor = layoutEditor;\r
+ setPartName("Graphical Layout");\r
+ }\r
+\r
+ // ------------------------------------\r
+ // Methods overridden from base classes\r
+ //------------------------------------\r
+\r
+ /**\r
+ * Initializes the editor part with a site and input.\r
+ * {@inheritDoc}\r
+ */\r
+ @Override\r
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {\r
+ setSite(site);\r
+ setInput(input);\r
+ }\r
+\r
+ @Override\r
+ public void dispose() {\r
+ super.dispose();\r
+ }\r
+\r
+ @Override\r
+ public void doSave(IProgressMonitor monitor) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ @Override\r
+ public void doSaveAs() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ @Override\r
+ public boolean isDirty() {\r
+ // TODO Auto-generated method stub\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public boolean isSaveAsAllowed() {\r
+ // TODO Auto-generated method stub\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public void createPartControl(Composite parent) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ @Override\r
+ public void setFocus() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void activated() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void deactivated() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void editNewFile(FolderConfiguration configuration) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public Clipboard getClipboard() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ public LayoutEditor getLayoutEditor() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ public UiDocumentNode getModel() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ public SelectionSynchronizer getSelectionSynchronizer() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ public void onXmlModelChanged() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void recomputeLayout() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void reloadEditor() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void reloadPalette() {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void selectModel(UiElementNode uiNodeModel) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+ public void reloadLayout(boolean codeChange, boolean rChange,\r
+ boolean resChange) {\r
+ // TODO Auto-generated method stub\r
+\r
+ }\r
+\r
+}\r
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.UiEditorActions;
-import com.android.ide.eclipse.adt.internal.editors.layout.LayoutReloadMonitor.ILayoutReloadListener;
import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite;
import com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationComposite.IConfigListener;
import com.android.ide.eclipse.adt.internal.editors.layout.descriptors.ViewElementDescriptor;
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
* <p/>
* To understand Drag'n'drop: http://www.eclipse.org/articles/Article-Workbench-DND/drag_drop.html
*/
-public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor
- implements ILayoutReloadListener, IConfigListener {
+public class GraphicalLayoutEditor extends GraphicalEditorWithPalette
+ implements IGraphicalLayoutEditor, IConfigListener {
/** Reference to the layout editor */
super.dispose();
}
+ /**
+ * Returns the selection synchronizer object.
+ * The synchronizer can be used to sync the selection of 2 or more EditPartViewers.
+ * <p/>
+ * This is changed from protected to public so that the outline can use it.
+ *
+ * @return the synchronizer
+ */
+ @Override
+ public SelectionSynchronizer getSelectionSynchronizer() {
+ return super.getSelectionSynchronizer();
+ }
+
+ /**
+ * Returns the edit domain.
+ * <p/>
+ * This is changed from protected to public so that the outline can use it.
+ *
+ * @return the edit domain
+ */
+ @Override
+ public DefaultEditDomain getEditDomain() {
+ return super.getEditDomain();
+ }
+
/* (non-Javadoc)
* Creates the palette root.
*/
return mPaletteRoot;
}
- @Override
public Clipboard getClipboard() {
return mClipboard;
}
*
* @param uiNodeModel The {@link UiElementNode} to select.
*/
- @Override
- void selectModel(UiElementNode uiNodeModel) {
+ public void selectModel(UiElementNode uiNodeModel) {
GraphicalViewer viewer = getGraphicalViewer();
// Give focus to the graphical viewer (in case the outline has it)
// Local methods
//--------------
- @Override
public LayoutEditor getLayoutEditor() {
return mLayoutEditor;
}
* Sets the UI for the edition of a new file.
* @param configuration the configuration of the new file.
*/
- @Override
- void editNewFile(FolderConfiguration configuration) {
+ public void editNewFile(FolderConfiguration configuration) {
// update the configuration UI
setConfiguration(configuration, true /*force*/);
/**
* Reloads this editor, by getting the new model from the {@link LayoutEditor}.
*/
- @Override
- void reloadEditor() {
+ public void reloadEditor() {
GraphicalViewer viewer = getGraphicalViewer();
viewer.setContents(getModel());
/**
* Callback for XML model changed. Only update/recompute the layout if the editor is visible
*/
- @Override
- void onXmlModelChanged() {
+ public void onXmlModelChanged() {
if (mLayoutEditor.isGraphicalEditorActive()) {
doXmlReload(true /* force */);
recomputeLayout();
}
- @Override
- UiDocumentNode getModel() {
+ public UiDocumentNode getModel() {
return mLayoutEditor.getUiRootNode();
}
- @Override
- void reloadPalette() {
+ public void reloadPalette() {
PaletteFactory.createPaletteRoot(mPaletteRoot, mLayoutEditor.getTargetData());
}
/**
* Recomputes the layout with the help of layoutlib.
*/
- @Override
@SuppressWarnings("deprecation")
- void recomputeLayout() {
+ public void recomputeLayout() {
doXmlReload(false /* force */);
try {
// check that the resource exists. If the file is opened but the project is closed
/**
* Responds to a page change that made the Graphical editor page the activated page.
*/
- @Override
- void activated() {
+ public void activated() {
if (mNeedsRecompute || mNeedsXmlReload) {
recomputeLayout();
}
/**
* Responds to a page change that made the Graphical editor page the deactivated page
*/
- @Override
- void deactivated() {
+ public void deactivated() {
// nothing to be done here for now.
}
if (frameworkRes == null) {
AdtPlugin.log(IStatus.ERROR, "Failed to get ProjectResource for the framework");
+ } else {
+ // get the framework resource values based on the current config
+ mConfiguredFrameworkRes = frameworkRes.getConfiguredResources(
+ mConfigComposite.getCurrentConfig());
}
-
- // get the framework resource values based on the current config
- mConfiguredFrameworkRes = frameworkRes.getConfiguredResources(
- mConfigComposite.getCurrentConfig());
}
return mConfiguredFrameworkRes;
* 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
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
import com.android.ide.eclipse.adt.internal.resources.configurations.FolderConfiguration;
-import org.eclipse.gef.DefaultEditDomain;
-import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
import org.eclipse.gef.ui.parts.SelectionSynchronizer;
import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IEditorPart;
/**
- * Abstract GraphicalLayoutEditor.
+ * Interface defining what {@link LayoutEditor} expects from a GraphicalLayoutEditor part.
*/
-/*package*/ abstract class AbstractGraphicalLayoutEditor extends GraphicalEditorWithPalette
- implements IWorkbenchPart, ILayoutReloadListener {
+/*package*/ interface IGraphicalLayoutEditor extends IEditorPart, ILayoutReloadListener {
/**
* Sets the UI for the edition of a new file.
/**
* Used by LayoutEditor.UiEditorActions.selectUiNode to select a new UI Node
* created by {@link ElementCreateCommand#execute()}.
- *
+ *
* @param uiNodeModel The {@link UiElementNode} to select.
*/
abstract void selectModel(UiElementNode uiNodeModel);
/**
* Returns the selection synchronizer object.
* The synchronizer can be used to sync the selection of 2 or more EditPartViewers.
- * <p/>
- * This is changed from protected to public so that the outline can use it.
- *
- * @return the synchronizer
- */
- @Override
- public SelectionSynchronizer getSelectionSynchronizer() {
- return super.getSelectionSynchronizer();
- }
-
- /**
- * Returns the edit domain.
- * <p/>
- * This is changed from protected to public so that the outline can use it.
- *
- * @return the edit domain
*/
- @Override
- public DefaultEditDomain getEditDomain() {
- return super.getEditDomain();
- }
+ abstract public SelectionSynchronizer getSelectionSynchronizer();
abstract void reloadPalette();
import org.w3c.dom.Document;
/**
- * Multi-page form editor for /res/layout XML files.
+ * Multi-page form editor for /res/layout XML files.
*/
public class LayoutEditor extends AndroidEditor implements IShowEditorInput, IPartListener {
/** Root node of the UI element hierarchy */
private UiDocumentNode mUiRootNode;
-
- private AbstractGraphicalLayoutEditor mGraphicalEditor;
+
+ private IGraphicalLayoutEditor mGraphicalEditor;
private int mGraphicalEditorIndex;
/** Implementation of the {@link IContentOutlinePage} for this editor */
private UiContentOutlinePage mOutline;
private UiPropertySheetPage mPropertyPage;
private UiEditorActions mUiEditorActions;
-
+
/**
* Creates the form editor for resources XML files.
*/
super.dispose();
}
-
+
/**
* Save the XML.
* <p/>
mGraphicalEditor.doSave(monitor);
}
}
-
+
/**
* Returns whether the "save as" operation is supported by this editor.
* <p/>
* Save-As is a valid operation for the ManifestEditor since it acts on a
- * single source file.
+ * single source file.
*
* @see IEditorPart
*/
// The graphical layout editor is now enabled by default.
// In case there's an issue we provide a way to disable it using an
// env variable.
- if (System.getenv("ANDROID_DISABLE_LAYOUT") == null) {
+ if (System.getenv("ANDROID_DISABLE_LAYOUT") == null) { //$NON-NLS-1$
if (mGraphicalEditor == null) {
- mGraphicalEditor = new GraphicalLayoutEditor(this);
+
+ if (System.getenv("USE_GLE2") != null) { //$NON-NLS-1$ //$NON-NLS-2$
+ mGraphicalEditor = new GLE2(this);
+ } else {
+ mGraphicalEditor = new GraphicalLayoutEditor(this);
+ }
+
mGraphicalEditorIndex = addPage(mGraphicalEditor, getEditorInput());
setPageText(mGraphicalEditorIndex, mGraphicalEditor.getTitle());
} else {
super.setInputWithNotify(input);
handleNewInput(input);
}
-
+
/**
* Called to replace the current {@link IEditorInput} with another one.
* <p/>This is used when {@link MatchingStrategy} returned <code>true</code> which means we're
public void showEditorInput(IEditorInput editorInput) {
// save the current editor input.
doSave(new NullProgressMonitor());
-
+
// get the current page
int currentPage = getActivePage();
-
+
// remove the pages, except for the graphical editor, which will be dynamically adapted
// to the new model.
// page after the graphical editor:
for (int i = mGraphicalEditorIndex - 1 ; i >= 0 ; i--) {
removePage(i);
}
-
+
// set the current input.
setInputWithNotify(editorInput);
-
+
// re-create or reload the pages with the default page shown as the previous active page.
createAndroidPages();
selectDefaultPage(Integer.toString(currentPage));
mOutline.reloadModel();
}
}
-
+
/**
* Processes the new XML Model, which XML root node is given.
- *
+ *
* @param xml_doc The XML document, if available, or null if none exists.
*/
@Override
// update the model first, since it is used by the viewers.
super.xmlModelChanged(xml_doc);
-
+
if (mGraphicalEditor != null) {
mGraphicalEditor.onXmlModelChanged();
}
-
+
if (mOutline != null) {
mOutline.reloadModel();
}
}
-
+
/* (non-java doc)
* Returns the IContentOutlinePage when asked for it.
*/
// This fixes the case where a layout file is opened in XML view first and the outline
// gets stuck in the XML outline.
if (IContentOutlinePage.class == adapter && mGraphicalEditor != null) {
- if (mOutline == null) {
- mOutline = new UiContentOutlinePage(mGraphicalEditor, new TreeViewer());
+
+ if (mOutline == null && mGraphicalEditor instanceof GraphicalLayoutEditor) {
+ // TODO add support for GLE2
+ mOutline = new UiContentOutlinePage(
+ (GraphicalLayoutEditor) mGraphicalEditor,
+ new TreeViewer());
}
-
+
return mOutline;
}
-
+
if (IPropertySheetPage.class == adapter && mGraphicalEditor != null) {
if (mPropertyPage == null) {
mPropertyPage = new UiPropertySheetPage();
}
-
+
return mPropertyPage;
}
// return default
return super.getAdapter(adapter);
}
-
+
@Override
protected void pageChange(int newPageIndex) {
super.pageChange(newPageIndex);
-
+
if (mGraphicalEditor != null) {
if (newPageIndex == mGraphicalEditorIndex) {
mGraphicalEditor.activated();
}
}
}
-
+
// ----- IPartListener Methods ----
-
+
public void partActivated(IWorkbenchPart part) {
if (part == this) {
if (mGraphicalEditor != null) {
EclipseUiHelper.showView(EclipseUiHelper.CONTENT_OUTLINE_VIEW_ID, false /* activate */);
EclipseUiHelper.showView(EclipseUiHelper.PROPERTY_SHEET_VIEW_ID, false /* activate */);
}
-
+
public class UiEditorActions extends UiActions {
@Override
// Pass. There is nothing to commit before the XML is changed here.
}
}
-
+
public UiEditorActions getUiEditorActions() {
if (mUiEditorActions == null) {
mUiEditorActions = new UiEditorActions();
}
return mUiEditorActions;
}
-
+
// ---- Local Methods ----
-
+
/**
* Returns true if the Graphics editor page is visible. This <b>must</b> be
* called from the UI thread.
}
return false;
- }
-
+ }
+
@Override
protected void initUiRootNode(boolean force) {
// The root UI node is always created, even if there's no corresponding XML node.
if (mUiRootNode == null || force) {
// get the target data from the opened file (and its project)
AndroidTargetData data = getTargetData();
-
+
Document doc = null;
if (mUiRootNode != null) {
doc = mUiRootNode.getXmlDocument();
}
-
+
DocumentDescriptor desc;
if (data == null) {
desc = new DocumentDescriptor("temp", null /*children*/);
onDescriptorsChanged(doc);
}
}
-
+
private void onDescriptorsChanged(Document document) {
if (document != null) {
mUiRootNode.loadFromXmlNode(document);
} else {
mUiRootNode.reloadFromXmlNode(mUiRootNode.getXmlDocument());
}
-
+
if (mOutline != null) {
mOutline.reloadModel();
}
-
+
if (mGraphicalEditor != null) {
mGraphicalEditor.reloadEditor();
mGraphicalEditor.reloadPalette();
*/
class UiContentOutlinePage extends ContentOutlinePage {
- private AbstractGraphicalLayoutEditor mEditor;
-
+ private GraphicalLayoutEditor mEditor;
+
private Action mAddAction;
private Action mDeleteAction;
private Action mUpAction;
private Action mDownAction;
-
+
private UiOutlineActions mUiActions = new UiOutlineActions();
- public UiContentOutlinePage(AbstractGraphicalLayoutEditor editor, final EditPartViewer viewer) {
+ public UiContentOutlinePage(GraphicalLayoutEditor editor, final EditPartViewer viewer) {
super(viewer);
mEditor = editor;
IconFactory factory = IconFactory.getInstance();
-
+
mAddAction = new Action("Add...") {
@Override
public void run() {
List<UiElementNode> nodes = getModelSelections();
UiElementNode node = nodes != null && nodes.size() > 0 ? nodes.get(0) : null;
-
+
mUiActions.doAdd(node, viewer.getControl().getShell());
}
};
@Override
public void run() {
List<UiElementNode> nodes = getModelSelections();
-
+
mUiActions.doRemove(nodes, viewer.getControl().getShell());
}
};
@Override
public void run() {
List<UiElementNode> nodes = getModelSelections();
-
+
mUiActions.doUp(nodes);
}
};
@Override
public void run() {
List<UiElementNode> nodes = getModelSelections();
-
+
mUiActions.doDown(nodes);
}
};
addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
-
+
// the selection is never empty. The least it'll contain is the
// UiDocumentTreeEditPart object.
if (selection instanceof StructuredSelection) {
}
});
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
/*
* (non-Javadoc)
* @see org.eclipse.ui.part.Page#setActionBars(org.eclipse.ui.IActionBars)
- *
+ *
* Called automatically after createControl
*/
@Override
toolBarManager.add(new Separator());
toolBarManager.add(mUpAction);
toolBarManager.add(mDownAction);
-
+
IMenuManager menuManager = actionBars.getMenuManager();
menuManager.add(mAddAction);
menuManager.add(mDeleteAction);
public Control getControl() {
return getViewer().getControl();
}
-
+
void setNewEditor(GraphicalLayoutEditor editor) {
mEditor = editor;
setupOutline();
}
-
+
void breakConnectionWithEditor() {
// unhook outline viewer
mEditor.getSelectionSynchronizer().removeViewer(getViewer());
}
-
+
private void setupOutline() {
+
getViewer().setEditDomain(mEditor.getEditDomain());
// hook outline viewer
*/
public void menuAboutToShow(IMenuManager manager) {
List<UiElementNode> selected = getModelSelections();
-
+
if (selected != null) {
doCreateMenuAction(manager, selected);
return;
}
doCreateMenuAction(manager, null /* ui_node */);
- }
+ }
});
Control control = getControl();
Menu contextMenu = menuManager.createContextMenu(control);
/**
* Adds the menu actions to the context menu when the given UI node is selected in
* the tree view.
- *
+ *
* @param manager The context menu manager
* @param selected The UI node selected in the tree. Can be null, in which case the root
* is to be modified.
*/
private void doCreateMenuAction(IMenuManager manager, List<UiElementNode> selected) {
-
+
if (selected != null) {
boolean hasXml = false;
for (UiElementNode uiNode : selected) {
if (selected != null) {
manager.add(mDeleteAction);
manager.add(new Separator());
-
+
manager.add(mUpAction);
manager.add(mDownAction);
}
if (selected != null && selected.size() == 1) {
manager.add(new Separator());
-
+
Action propertiesAction = new Action("Properties") {
@Override
public void run() {
}
/**
- * Updates the outline view with the model of the {@link GraphicalLayoutEditor}.
+ * Updates the outline view with the model of the {@link IGraphicalLayoutEditor}.
* <p/>
* This attemps to preserve the selection, if any.
*/
ISelection selection = getSelection();
if (selection instanceof StructuredSelection) {
StructuredSelection structuredSelection = (StructuredSelection)selection;
-
+
if (structuredSelection.size() > 0) {
ArrayList<UiElementTreeEditPart> selected = new ArrayList<UiElementTreeEditPart>();
-
+
for (Iterator it = structuredSelection.iterator(); it.hasNext(); ) {
Object selectedObj = it.next();
-
+
if (selectedObj instanceof UiElementTreeEditPart) {
selected.add((UiElementTreeEditPart) selectedObj);
}
}
-
+
return selected.size() > 0 ? selected : null;
}
}
-
+
return null;
}
if (parts != null) {
ArrayList<UiElementNode> selected = new ArrayList<UiElementNode>();
-
+
for (UiElementTreeEditPart part : parts) {
if (part instanceof UiViewTreeEditPart || part instanceof UiLayoutTreeEditPart) {
selected.add((UiElementNode) part.getModel());
}
}
-
+
return selected.size() > 0 ? selected : null;
}
-
+
return null;
}
}
}
- /**
+ /**
* Selects the corresponding model element in the tree viewer.
*/
private void setModelSelection(UiElementNode uiNodeToSelect) {
if (uiNodeToSelect != null) {
-
+
// find an edit part that has the requested model element
UiElementTreeEditPart part = findPartForModel(
(UiElementTreeEditPart) getViewer().getContents(),
uiNodeToSelect);
-
+
// if we found a part, select it and reveal it
if (part != null) {
setViewerSelection(part);
/**
* Utility method that tries to find an edit part that matches a given model UI node.
- *
+ *
* @param rootPart The root of the viewer edit parts
* @param uiNode The UI node model to find
* @return The part that matches the model or null if it's not in the sub tree.
if (rootPart.getModel() == uiNode) {
return rootPart;
}
-
+
for (Object part : rootPart.getChildren()) {
if (part instanceof UiElementTreeEditPart) {
UiElementTreeEditPart found = findPartForModel(
*/
private void setupTooltip() {
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:
}
String tooltip = null;
-
+
TreeItem item = tree.getItem(new Point(event.x, event.y));
if (item != null) {
Object data = item.getData();
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();
}
}
};
-
+
tree.addListener(SWT.Dispose, listener);
tree.addListener(SWT.KeyDown, listener);
tree.addListener(SWT.MouseMove, listener);
}
// ---------------
-
+
private class UiOutlineActions extends UiActions {
@Override
public void commitPendingXmlChanges() {
// Pass. There is nothing to commit before the XML is changed here.
}
-
+
}
}