Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2006-10-11 20:19:37 +0000
committerDarin Wright2006-10-11 20:19:37 +0000
commit0bda80e3cecdd0b30bd23f464d8ace88cd3d5684 (patch)
treeae18baa50fc0265f52af5e53a181c369f42ee521
parenteac0a7ef073c77da5774101065fc0fce9b3402e1 (diff)
downloadeclipse.platform.debug-0bda80e3cecdd0b30bd23f464d8ace88cd3d5684.tar.gz
eclipse.platform.debug-0bda80e3cecdd0b30bd23f464d8ace88cd3d5684.tar.xz
eclipse.platform.debug-0bda80e3cecdd0b30bd23f464d8ace88cd3d5684.zip
simplify element editing
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableColumnFactoryAdapter.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java92
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementEditor.java44
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractColumnEditor.java1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/IColumnEditor.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IColumnEditor.java)3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/IColumnEditorFactoryAdapter.java (renamed from org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IColumnEditorFactoryAdapter.java)4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java17
9 files changed, 136 insertions, 73 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableColumnFactoryAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableColumnFactoryAdapter.java
index 9220a7298..d6d5ef606 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableColumnFactoryAdapter.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/VariableColumnFactoryAdapter.java
@@ -12,11 +12,11 @@ package org.eclipse.debug.internal.ui.elements.adapters;
import org.eclipse.debug.core.model.IStackFrame;
import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditor;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditorFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditor;
+import org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditorFactoryAdapter;
import org.eclipse.debug.ui.IDebugUIConstants;
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java
new file mode 100644
index 000000000..b886d20ed
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/VariableEditor.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.model.elements;
+
+import org.eclipse.debug.internal.ui.elements.adapters.DefaultVariableCellModifier;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.3
+ */
+public class VariableEditor implements IElementEditor {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellEditor(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.String, java.lang.Object, org.eclipse.swt.widgets.Composite)
+ */
+ public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) {
+ return new TextCellEditor(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor#getCellModifier(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
+ */
+ public ICellModifier getCellModifier(IPresentationContext context, Object element) {
+ return new DefaultVariableCellModifier();
+ }
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java
index d725fea55..b302bd119 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/AsynchronousTreeViewer.java
@@ -22,12 +22,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditor;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditorFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapter;
+import org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditor;
+import org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditorFactoryAdapter;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.viewers.CellEditor;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java
index 1e2a16deb..2b1f9b1a1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java
@@ -16,10 +16,9 @@ import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditor;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditorFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactoryAdapter;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactoryAdapter;
@@ -157,30 +156,30 @@ public class InternalTreeModelViewer extends TreeViewer {
*/
class CellModifierProxy implements ICellModifier {
- private IColumnEditor fColumnEditor = null;
+ private ICellModifier fModifier;
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
*/
public boolean canModify(Object element, String property) {
- updateColumnEditor(element);
- if (fColumnEditor != null) {
- boolean canModify = fColumnEditor.getCellModifier().canModify(element, property);
- if (canModify) {
- // install cell editor
- CellEditor cellEditor = fColumnEditor.getCellEditor(property, element, (Composite)getControl());
- if (cellEditor == null) {
- // contradiction, oh well
- return false;
- }
- disposeCellEditors();
- CellEditor[] newEditors = new CellEditor[getVisibleColumns().length];
- for (int i = 0; i < newEditors.length; i++) {
- newEditors[i] = cellEditor;
+ IElementEditor editor = getElementEditorAdapter(element);
+ if (editor != null) {
+ fModifier = editor.getCellModifier(getPresentationContext(), element);
+ if (fModifier != null) {
+ if (fModifier.canModify(element, property)) {
+ // install cell editor
+ CellEditor cellEditor = editor.getCellEditor(getPresentationContext(), property, element, (Composite)getControl());
+ if (cellEditor != null) {
+ disposeCellEditors();
+ CellEditor[] newEditors = new CellEditor[getVisibleColumns().length];
+ for (int i = 0; i < newEditors.length; i++) {
+ newEditors[i] = cellEditor;
+ }
+ setCellEditors(newEditors);
+ return true;
+ }
}
- setCellEditors(newEditors);
}
- return canModify;
}
return false;
}
@@ -189,8 +188,8 @@ public class InternalTreeModelViewer extends TreeViewer {
* @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
*/
public Object getValue(Object element, String property) {
- if (fColumnEditor != null) {
- return fColumnEditor.getCellModifier().getValue(element, property);
+ if (fModifier != null) {
+ return fModifier.getValue(element, property);
}
return null;
}
@@ -199,11 +198,11 @@ public class InternalTreeModelViewer extends TreeViewer {
* @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
*/
public void modify(Object element, String property, Object value) {
- if (fColumnEditor != null) {
+ if (fModifier != null) {
if (element instanceof Item) {
element = ((Item)element).getData();
}
- fColumnEditor.getCellModifier().modify(element, property, value);
+ fModifier.modify(element, property, value);
}
}
@@ -211,11 +210,9 @@ public class InternalTreeModelViewer extends TreeViewer {
* Disposes client's column editor and cell editors
*/
protected void dispose() {
+ fModifier = null;
disposeCellEditors();
setCellEditors(null);
- if (fColumnEditor != null) {
- fColumnEditor.dispose();
- }
}
/**
@@ -234,49 +231,18 @@ public class InternalTreeModelViewer extends TreeViewer {
}
/**
- * Sets the column editor for the given element
- *
- * @param element
- */
- protected void updateColumnEditor(Object element) {
- IColumnEditorFactoryAdapter factoryAdapter = getColumnEditorFactoryAdapter(element);
- if (factoryAdapter != null) {
- if (fColumnEditor != null) {
- if (fColumnEditor.getId().equals(factoryAdapter.getColumnEditorId(getPresentationContext(), element))) {
- // no change
- return;
- } else {
- // dispose current
- fColumnEditor.dispose();
- }
- }
- // create new one
- fColumnEditor = factoryAdapter.createColumnEditor(getPresentationContext(), element);
- if (fColumnEditor != null) {
- fColumnEditor.init(getPresentationContext());
- }
- } else {
- // no editor - dispose current
- if (fColumnEditor != null) {
- fColumnEditor.dispose();
- fColumnEditor = null;
- }
- }
- }
-
- /**
- * Returns the column editor factory for the given element or <code>null</code>.
+ * Returns the element editor for the given element or <code>null</code>.
*
* @param input
- * @return column editor factory of <code>null</code>
+ * @return element editor or <code>null</code>
*/
- protected IColumnEditorFactoryAdapter getColumnEditorFactoryAdapter(Object input) {
- if (input instanceof IColumnEditorFactoryAdapter) {
- return (IColumnEditorFactoryAdapter) input;
+ protected IElementEditor getElementEditorAdapter(Object input) {
+ if (input instanceof IElementEditor) {
+ return (IElementEditor) input;
}
if (input instanceof IAdaptable) {
IAdaptable adaptable = (IAdaptable) input;
- return (IColumnEditorFactoryAdapter) adaptable.getAdapter(IColumnEditorFactoryAdapter.class);
+ return (IElementEditor) adaptable.getAdapter(IElementEditor.class);
}
return null;
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementEditor.java
new file mode 100644
index 000000000..7320bb58f
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IElementEditor.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.internal.ui.viewers.model.provisional;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Creates context specific cell modifiers and editors for an elements.
+ *
+ * @since 3.3
+ */
+public interface IElementEditor {
+
+ /**
+ * Returns a cell editor to use for the specified column and object or <code>null</code>
+ * if none.
+ *
+ * @param context presentation context
+ * @param id column id
+ * @param element object to be edited
+ * @param parent parent control to create the cell editor in
+ * @return cell editor or <code>null</code>
+ */
+ public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent);
+
+ /**
+ * Returns a cell modifier for the specified element in the given context
+ * or <code>null</code> if none.
+ *
+ * @return cell modifier or <code>null</code>
+ */
+ public ICellModifier getCellModifier(IPresentationContext context, Object element);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractColumnEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractColumnEditor.java
index 496fbda5a..d9bf4f414 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractColumnEditor.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/AbstractColumnEditor.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.provisional;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IColumnEditor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/IColumnEditor.java
index c84a39c78..f31343e3c 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IColumnEditor.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/IColumnEditor.java
@@ -8,8 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.viewers.model.provisional;
+package org.eclipse.debug.internal.ui.viewers.provisional;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.swt.widgets.Composite;
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IColumnEditorFactoryAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/IColumnEditorFactoryAdapter.java
index 8c04d3262..3dbc2186a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IColumnEditorFactoryAdapter.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/provisional/IColumnEditorFactoryAdapter.java
@@ -8,7 +8,9 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.debug.internal.ui.viewers.model.provisional;
+package org.eclipse.debug.internal.ui.viewers.provisional;
+
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
/**
* An adapter used to column editors. Used in conjunction with a column presentation.
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
index fe3150ad7..ae9265849 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/DebugElementAdapterFactory.java
@@ -52,19 +52,21 @@ import org.eclipse.debug.internal.ui.model.elements.ExpressionManagerContentProv
import org.eclipse.debug.internal.ui.model.elements.LaunchContentProvider;
import org.eclipse.debug.internal.ui.model.elements.LaunchManagerContentProvider;
import org.eclipse.debug.internal.ui.model.elements.StackFrameContentProvider;
-import org.eclipse.debug.internal.ui.model.elements.VariablesViewElementMementoProvider;
import org.eclipse.debug.internal.ui.model.elements.ThreadContentProvider;
import org.eclipse.debug.internal.ui.model.elements.VariableContentProvider;
+import org.eclipse.debug.internal.ui.model.elements.VariableEditor;
import org.eclipse.debug.internal.ui.model.elements.VariableLabelProvider;
-import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnEditorFactoryAdapter;
+import org.eclipse.debug.internal.ui.model.elements.VariablesViewElementMementoProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicyFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousContentAdapter;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapter;
+import org.eclipse.debug.internal.ui.viewers.provisional.IColumnEditorFactoryAdapter;
import org.eclipse.debug.internal.ui.viewers.update.DefaultModelProxyFactory;
import org.eclipse.debug.internal.ui.viewers.update.DefaultModelSelectionPolicyFactory;
import org.eclipse.debug.internal.ui.views.memory.renderings.MemorySegment;
@@ -91,6 +93,8 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
private static IElementLabelProvider fgLPVariable = new VariableLabelProvider();
private static IElementLabelProvider fgLPExpression = new ExpressionLabelProvider();
+ private static IElementEditor fgEEVariable = new VariableEditor();
+
private static IAsynchronousContentAdapter fgAsyncLaunchManager = new LauchManagerContentAdapter();
private static IAsynchronousContentAdapter fgAsyncLaunch = new LaunchContentAdapter();
private static IAsynchronousContentAdapter fgAsyncTarget = new DebugTargetContentAdapter();
@@ -258,6 +262,13 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
return fgMPFrame;
}
}
+
+ if (adapterType.equals(IElementEditor.class)) {
+ if (adaptableObject instanceof IVariable) {
+ return fgEEVariable;
+ }
+ }
+
return null;
}
@@ -267,7 +278,7 @@ public class DebugElementAdapterFactory implements IAdapterFactory {
public Class[] getAdapterList() {
return new Class[] {IWorkbenchAdapter.class, IWorkbenchAdapter2.class, IDeferredWorkbenchAdapter.class, IAsynchronousLabelAdapter.class, IAsynchronousContentAdapter.class,
IModelProxyFactoryAdapter.class, ISourceDisplayAdapter.class, IModelSelectionPolicyFactoryAdapter.class, IColumnPresentationFactoryAdapter.class, IColumnEditorFactoryAdapter.class,
- IElementContentProvider.class, IElementLabelProvider.class, IElementMementoProvider.class};
+ IElementContentProvider.class, IElementLabelProvider.class, IElementMementoProvider.class, IElementEditor.class};
}
}

Back to the top