Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 130651 Details for
Bug 270922
Can't edit the GraphNode directly.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
DirectEdit feature for Zest
celleditor4zest.patch (text/plain), 8.80 KB, created by
DartPeng
on 2009-04-02 03:30:05 EDT
(
hide
)
Description:
DirectEdit feature for Zest
Filename:
MIME Type:
Creator:
DartPeng
Created:
2009-04-02 03:30:05 EDT
Size:
8.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.zest.core >Index: src/org/eclipse/zest/core/widgets/Graph.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.zest.core/src/org/eclipse/zest/core/widgets/Graph.java,v >retrieving revision 1.41 >diff -u -r1.41 Graph.java >--- src/org/eclipse/zest/core/widgets/Graph.java 30 Jan 2009 01:14:33 -0000 1.41 >+++ src/org/eclipse/zest/core/widgets/Graph.java 2 Apr 2009 07:21:38 -0000 >@@ -33,6 +33,8 @@ > import org.eclipse.draw2d.geometry.Dimension; > import org.eclipse.draw2d.geometry.Point; > import org.eclipse.draw2d.geometry.Rectangle; >+import org.eclipse.jface.viewers.CellEditor; >+import org.eclipse.jface.viewers.ICellEditorListener; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.PaintEvent; > import org.eclipse.swt.events.PaintListener; >@@ -57,7 +59,7 @@ > import org.eclipse.zest.layouts.constraints.LayoutConstraint; > > /* >- * Holds the nodes and connections for the graph. >+ * * Holds the nodes and connections for the graph. > * > * @author Chris Callendar > * >@@ -108,6 +110,9 @@ > private ScalableFreeformLayeredPane rootlayer; > private ZestRootLayer zestRootLayer; > >+ /** Listen CellEditor behavior */ >+ private InnerCellEditorListener cellEditorListener = null; >+ > /** > * Constructor for a Graph. This widget represents the root of the graph, > * and can contain graph items such as graph nodes and graph connections. >@@ -203,6 +208,7 @@ > } > }); > >+ cellEditorListener = new InnerCellEditorListener(); > } > > /** >@@ -431,6 +437,25 @@ > return this.layoutAlgorithm; > } > >+ protected void showCellEditor(GraphItem item) { >+ if (!canDirectEdit(item)) { >+ return; >+ } >+ CellEditor cellEditor = item.getCellEditor(); >+ ICellEditorManager manager = item.getCellEditorManager(); >+ if (cellEditor != null && manager != null) { >+ cellEditor.removeListener(cellEditorListener); >+ cellEditorListener.setHostItem(item); >+ cellEditor.setValue(manager.getEditValue(item)); >+ cellEditor.getControl().setFont(item.getFigure().getFont()); >+ manager.locatCellEditor(cellEditor); >+ cellEditor.addListener(cellEditorListener); >+ cellEditor.activate(); >+ cellEditor.getControl().setVisible(true); >+ cellEditor.setFocus(); >+ } >+ } >+ > /** > * Finds a figure at the location X, Y in the graph > * >@@ -498,6 +523,8 @@ > Iterator iterator = selectedItems.iterator(); > while (iterator.hasNext()) { > GraphItem item = (GraphItem) iterator.next(); >+ // If start to drag item , its celleditor must be hidden. >+ hideCellEditor(item); > if ((item.getItemType() == GraphItem.NODE) || (item.getItemType() == GraphItem.CONTAINER)) { > // @tag Zest.selection Zest.move : This is where the node movement is tracked > Point pointCopy = mousePoint.getCopy(); >@@ -667,6 +694,9 @@ > selectedItems.remove(itemUnderMouse); > (itemUnderMouse).unhighlight(); > fireWidgetSelectedEvent(itemUnderMouse); >+ } else { >+ // If click the selected item , prefer to start direct edit >+ showCellEditor(itemUnderMouse); > } > return; > } >@@ -696,22 +726,53 @@ > > public void mouseReleased(org.eclipse.draw2d.MouseEvent me) { > isDragging = false; >- > } > > } > >+ /** >+ * Default return true; >+ * @param item >+ * @return >+ */ >+ protected boolean canDirectEdit(GraphItem item) { >+ return true; >+ } >+ > private void clearSelection() { > if (selectedItems.size() > 0) { > Iterator iterator = selectedItems.iterator(); > while (iterator.hasNext()) { > GraphItem item = (GraphItem) iterator.next(); >+ // If the item dosen't be selected , its celleditor must be hidden. >+ hideCellEditor(item); > item.unhighlight(); > iterator.remove(); > } > } > } > >+ /** >+ * Hide cellEditor >+ * @param cellEditor >+ */ >+ private void hideCellEditor(CellEditor cellEditor) { >+ if (cellEditor != null && cellEditor.getControl().isVisible()) { >+ cellEditor.removeListener(cellEditorListener); >+ cellEditor.deactivate(); >+ cellEditor.getControl().setVisible(false); >+ } >+ } >+ >+ /** >+ * Hide cellEditor >+ * @param cellEditor >+ */ >+ private void hideCellEditor(GraphItem item) { >+ CellEditor cellEditor = item.getCellEditor(); >+ hideCellEditor(cellEditor); >+ } >+ > private void fireWidgetSelectedEvent(Item item) { > Iterator iterator = selectionListeners.iterator(); > while (iterator.hasNext()) { >@@ -722,7 +783,6 @@ > SelectionEvent event = new SelectionEvent(swtEvent); > selectionListener.widgetSelected(event); > } >- > } > > /** >@@ -1195,4 +1255,49 @@ > return (GraphItem) figure2ItemMap.get(figure); > } > >+ private class InnerCellEditorListener implements ICellEditorListener { >+ >+ private GraphItem hostItem = null; >+ >+ public GraphItem getHostItem() { >+ return hostItem; >+ } >+ >+ public void setHostItem(GraphItem hostItem) { >+ this.hostItem = hostItem; >+ } >+ >+ public void applyEditorValue() { >+ if (hostItem != null) { >+ ICellEditorManager manager = hostItem.getCellEditorManager(); >+ CellEditor cellEditor = hostItem.getCellEditor(); >+ if (manager != null && cellEditor != null) { >+ manager.commit(cellEditor.getValue(), hostItem); >+ } >+ } >+ } >+ >+ public void cancelEditor() { >+ if (hostItem != null) { >+ ICellEditorManager manager = hostItem.getCellEditorManager(); >+ CellEditor cellEditor = hostItem.getCellEditor(); >+ if (manager != null && cellEditor != null) { >+ manager.bringDown(); >+ } >+ } >+ } >+ >+ public void editorValueChanged(boolean oldValidState, boolean newValidState) { >+ if (hostItem != null) { >+ ICellEditorManager manager = hostItem.getCellEditorManager(); >+ CellEditor cellEditor = hostItem.getCellEditor(); >+ if (manager != null && cellEditor != null) { >+ cellEditor.removeListener(this); >+ manager.locatCellEditor(cellEditor); >+ cellEditor.addListener(this); >+ } >+ } >+ } >+ } >+ > } >Index: src/org/eclipse/zest/core/widgets/GraphItem.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.zest.core/src/org/eclipse/zest/core/widgets/GraphItem.java,v >retrieving revision 1.9 >diff -u -r1.9 GraphItem.java >--- src/org/eclipse/zest/core/widgets/GraphItem.java 12 Sep 2007 20:44:39 -0000 1.9 >+++ src/org/eclipse/zest/core/widgets/GraphItem.java 2 Apr 2009 07:21:38 -0000 >@@ -10,6 +10,7 @@ > package org.eclipse.zest.core.widgets; > > import org.eclipse.draw2d.IFigure; >+import org.eclipse.jface.viewers.CellEditor; > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Item; > import org.eclipse.swt.widgets.Widget; >@@ -27,6 +28,11 @@ > public static final int CONNECTION = 2; > public static final int CONTAINER = 3; > >+ /**CellEditor */ >+ private CellEditor cellEditor = null; >+ /**CellEditorLocator*/ >+ private ICellEditorManager cellEditorInitor = null; >+ > /** > * @param parent > * @param style >@@ -54,6 +60,9 @@ > public void dispose() { > // @tag zest.bug.167132-ListenerDispose : remove all listeners. > // pcsDelegate = new PropertyChangeSupport(this); >+ if (cellEditor != null) { >+ cellEditor.dispose(); >+ } > super.dispose(); > } > >@@ -111,4 +120,20 @@ > protected boolean checkStyle(int styleToCheck) { > return ((getStyle() & styleToCheck) > 0); > } >+ >+ public CellEditor getCellEditor() { >+ return cellEditor; >+ } >+ >+ public void setCellEditor(CellEditor cellEditor) { >+ this.cellEditor = cellEditor; >+ } >+ >+ public ICellEditorManager getCellEditorManager() { >+ return cellEditorInitor; >+ } >+ >+ public void setCellEditorManager(ICellEditorManager cellEditorInitor) { >+ this.cellEditorInitor = cellEditorInitor; >+ } > } >Index: src/org/eclipse/zest/core/widgets/ICellEditorManager.java >=================================================================== >RCS file: src/org/eclipse/zest/core/widgets/ICellEditorManager.java >diff -N src/org/eclipse/zest/core/widgets/ICellEditorManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/zest/core/widgets/ICellEditorManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 Red Hat, Inc. Distributed under license by Red Hat, Inc. >+ * All rights reserved. This program is made available under the terms of the >+ * Eclipse Public License v1.0 which accompanies this distribution, and is >+ * available at http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: Red Hat, Inc. - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.zest.core.widgets; >+ >+import org.eclipse.jface.viewers.CellEditor; >+ >+/** >+ * @author Dart (dpeng@redhat.com) or (blackfrezee@gmail.com) >+ */ >+public interface ICellEditorManager { >+ >+ public void locatCellEditor(CellEditor cellEditor); >+ >+ public void commit(Object value, GraphItem item); >+ >+ public void bringDown(); >+ >+ public Object getEditValue(GraphItem item); >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 270922
: 130651 |
130652