Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-09-21 18:53:36 +0000
committerDarin Wright2009-09-21 18:53:36 +0000
commited78ed05880e04b3e9e062ef2a4d9da484d793d5 (patch)
tree97fd1fae36cd24e39178924e00af21565e36f943 /org.eclipse.debug.ui
parentc1a8f2cccf676d67c324b0ca4c8e0f14a8751ca3 (diff)
downloadeclipse.platform.debug-ed78ed05880e04b3e9e062ef2a4d9da484d793d5.tar.gz
eclipse.platform.debug-ed78ed05880e04b3e9e062ef2a4d9da484d793d5.tar.xz
eclipse.platform.debug-ed78ed05880e04b3e9e062ef2a4d9da484d793d5.zip
Bug 286310 - Checkbox support for Flexible Hierachy view
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java40
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelCheckProviderTarget.java34
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalTreeModelViewer.java59
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java18
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckUpdate.java36
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckboxModelProxy.java37
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelProxy.java1
7 files changed, 222 insertions, 3 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java
index 111b9bdc7..0c867bd64 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/model/elements/ElementLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2009 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
*******************************************************************************/
package org.eclipse.debug.internal.ui.model.elements;
@@ -19,6 +20,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
@@ -214,6 +216,12 @@ public abstract class ElementLabelProvider implements IElementLabelProvider {
update.setBackground(getBackground(elementPath, presentationContext, columnId), i);
update.setForeground(getForeground(elementPath, presentationContext, columnId), i);
update.setFontData(getFontData(elementPath, presentationContext, columnId), i);
+ if (update instanceof ICheckUpdate &&
+ Boolean.TRUE.equals(presentationContext.getProperty(ICheckUpdate.PROP_CHECK)))
+ {
+ ((ICheckUpdate) update).setChecked(
+ getChecked(elementPath, presentationContext), getGrayed(elementPath, presentationContext));
+ }
}
}
@@ -270,6 +278,36 @@ public abstract class ElementLabelProvider implements IElementLabelProvider {
*/
protected abstract String getLabel(TreePath elementPath, IPresentationContext presentationContext, String columnId) throws CoreException;
+ /**
+ * Returns the checked state for the given path.
+ *
+ * @param path Path of the element to retrieve the grayed state for.
+ * @param presentationContext Presentation context where the element is
+ * displayed.
+ * @return <code>true<code> if the element check box should be checked
+ * @throws CoreException
+ *
+ * @since 3.6
+ */
+ protected boolean getChecked(TreePath path, IPresentationContext presentationContext) throws CoreException {
+ return false;
+ }
+
+ /**
+ * Returns the grayed state for the given path.
+ *
+ * @param path Path of the element to retrieve the grayed state for.
+ * @param presentationContext Presentation context where the element is
+ * displayed.
+ * @return <code>true<code> if the element check box should be grayed
+ * @throws CoreException
+ *
+ * @since 3.6
+ */
+ protected boolean getGrayed(TreePath path, IPresentationContext presentationContext) throws CoreException {
+ return false;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate[])
*/
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelCheckProviderTarget.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelCheckProviderTarget.java
new file mode 100644
index 000000000..c56581396
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/ITreeModelCheckProviderTarget.java
@@ -0,0 +1,34 @@
+/*****************************************************************
+ * Copyright (c) 2009 Texas Instruments 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:
+ * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 286310)
+ *****************************************************************/
+package org.eclipse.debug.internal.ui.viewers.model;
+
+import org.eclipse.jface.viewers.TreePath;
+
+/**
+ * This interface can be implemented by the viewer which uses the
+ * {@link TreeModelLabelProvider} label provider and supports the
+ * {@link org.eclipse.swt.SWT.CHECK} style. It allows the label provider to
+ * update the viewer with check-box information retrieved from the
+ * element-based label providers.
+ *
+ * @since 3.6
+ */
+public interface ITreeModelCheckProviderTarget extends ITreeModelLabelProviderTarget {
+
+ /**
+ * Sets the element check state data.
+ *
+ * @param path
+ * @param checked
+ * @param grayed
+ */
+ public void setElementChecked(TreePath path, boolean checked, boolean grayed);
+}
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 10d404cad..449dff75f 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Pawel Piech (Wind River) - added support for a virtual tree model viewer (Bug 242489)
+ * Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
*******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.model;
@@ -24,6 +25,8 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.internal.core.IInternalDebugCoreConstants;
import org.eclipse.debug.internal.core.commands.Request;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckboxModelProxy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
@@ -33,6 +36,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProv
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelChangedListener;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelSelectionPolicy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
@@ -43,6 +47,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ILazyTreePathContentProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.TreePath;
@@ -55,6 +60,7 @@ import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
@@ -78,7 +84,7 @@ import org.eclipse.ui.IMemento;
* @since 3.3
*/
public class InternalTreeModelViewer extends TreeViewer
- implements ITreeModelViewer, ITreeModelContentProviderTarget, ITreeModelLabelProviderTarget
+ implements ITreeModelViewer, ITreeModelContentProviderTarget, ITreeModelLabelProviderTarget, ITreeModelCheckProviderTarget
{
private IPresentationContext fContext;
@@ -1015,6 +1021,9 @@ public class InternalTreeModelViewer extends TreeViewer
if (fIsPopup) {
((ITreeModelContentProvider)getContentProvider()).setSuppressModelControlDeltas(true);
}
+ if ((style & SWT.CHECK) != 0) {
+ context.setProperty(ICheckUpdate.PROP_CHECK, Boolean.TRUE);
+ }
}
/**
@@ -2248,4 +2257,52 @@ public class InternalTreeModelViewer extends TreeViewer
public void updateViewer(IModelDelta delta) {
((ITreeModelContentProvider)getContentProvider()).updateModel(delta);
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.ITreeModelCheckProvider#setElementChecked(org.eclipse.jface.viewers.TreePath, boolean, boolean)
+ */
+ public void setElementChecked(TreePath path, boolean checked, boolean grayed) {
+ Widget widget = findItem(path);
+
+ if (widget != null && widget instanceof TreeItem && !widget.isDisposed()) {
+ TreeItem item = (TreeItem)widget;
+
+ item.setChecked(checked);
+ item.setGrayed(grayed);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#handleSelect(org.eclipse.swt.events.SelectionEvent)
+ */
+ protected void handleSelect(SelectionEvent event) {
+ if (event.detail == SWT.CHECK) {
+ TreeItem item = (TreeItem) event.item;
+ super.handleSelect(event);
+
+ Object element = item.getData();
+ if (element != null) {
+ boolean checked = item.getChecked();
+
+ TreePath path = getTreePathFromItem(item);
+
+ boolean accepted = false;
+ IContentProvider contentProvider = getContentProvider();
+ if (contentProvider instanceof TreeModelContentProvider) {
+ IModelProxy elementProxy = ((TreeModelContentProvider) contentProvider).getElementProxy(path);
+ if (elementProxy instanceof ICheckboxModelProxy) {
+ accepted = ((ICheckboxModelProxy) elementProxy).setChecked(getPresentationContext(), getInput(), path, checked);
+ }
+ }
+
+ // if the listen rejects the change or there is not ICheckboxModelProxy, than revert the check state
+ if (!accepted)
+ item.setChecked(!checked);
+ }
+ } else {
+ super.handleSelect(event);
+ }
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java
index 5be643c51..46d760aad 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/LabelUpdate.java
@@ -8,10 +8,12 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Pawel Piech (Wind River) - added support for a virtual tree model viewer (Bug 242489)
+ * Patrick Chuong (Texas Instruments) - added support for checkbox (Bug 286310)
*******************************************************************************/
package org.eclipse.debug.internal.ui.viewers.model;
import org.eclipse.debug.internal.core.commands.Request;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -22,7 +24,7 @@ import org.eclipse.swt.graphics.RGB;
/**
* @since 3.3
*/
-class LabelUpdate extends Request implements ILabelUpdate {
+class LabelUpdate extends Request implements ILabelUpdate, ICheckUpdate {
private TreePath fElementPath;
private String[] fColumnIds;
@@ -36,6 +38,8 @@ class LabelUpdate extends Request implements ILabelUpdate {
private int fNumColumns;
private IPresentationContext fContext;
private Object fViewerInput;
+ private boolean fChecked;
+ private boolean fGrayed;
/**
* @param viewerInput input at the time the request was made
@@ -151,6 +155,9 @@ class LabelUpdate extends Request implements ILabelUpdate {
*/
public void update() {
fTreeViewer.setElementData(fElementPath, fNumColumns, fLabels, fImageDescriptors, fFontDatas, fForegrounds, fBackgrounds);
+ if (fTreeViewer instanceof ITreeModelCheckProviderTarget)
+ ((ITreeModelCheckProviderTarget) fTreeViewer).setElementChecked(fElementPath, fChecked, fGrayed);
+
fProvider.updateComplete(this);
}
@@ -174,4 +181,13 @@ class LabelUpdate extends Request implements ILabelUpdate {
public Object getViewerInput() {
return fViewerInput;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.debug.internal.ui.viewers.model.provisional.ICheckable#setChecked(boolean, boolean)
+ */
+ public void setChecked(boolean checked, boolean grayed) {
+ fChecked = checked;
+ fGrayed = grayed;
+ }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckUpdate.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckUpdate.java
new file mode 100644
index 000000000..91d90ef10
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckUpdate.java
@@ -0,0 +1,36 @@
+/*****************************************************************
+ * Copyright (c) 2009 Texas Instruments 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:
+ * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 286310)
+ *****************************************************************/
+package org.eclipse.debug.internal.ui.viewers.model.provisional;
+
+/**
+ * Label update which allows the label provider to set the checked element state.
+ * The label provider can use the presentation context to determine whether the
+ * viewer is showing item check boxes.
+ *
+ * @since 3.6
+ */
+public interface ICheckUpdate extends ILabelUpdate {
+
+ /**
+ * Property of the presentation context which indicates that the viewer
+ * has the check box style.
+ */
+ public static final String PROP_CHECK = "org.eclipse.debug.ui.check"; //$NON-NLS-1$
+
+ /**
+ * Sets the check state of the tree node.
+ *
+ * @param checked
+ * @param grayed
+ */
+ public void setChecked(boolean checked, boolean grayed);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckboxModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckboxModelProxy.java
new file mode 100644
index 000000000..71ac66958
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/ICheckboxModelProxy.java
@@ -0,0 +1,37 @@
+/*****************************************************************
+ * Copyright (c) 2009 Texas Instruments 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:
+ * Patrick Chuong (Texas Instruments) - Initial API and implementation (Bug 286310)
+ *****************************************************************/
+package org.eclipse.debug.internal.ui.viewers.model.provisional;
+
+import org.eclipse.jface.viewers.TreePath;
+
+
+/**
+ * Optional extension to a model proxy for models that use a check box tree viewer. Provides
+ * notification for check state changes in the tree.
+ *
+ * @since 3.6
+ */
+public interface ICheckboxModelProxy extends IModelProxy {
+
+ /**
+ * Notifies the receiver that the given element has had its
+ * checked state modified in the viewer.
+ *
+ * @param context Presentation context in which the element was updated.
+ * @param viewerInput The root element of the viewer where the check
+ * selection took place.
+ * @param path Path of the element that had its checked state changed
+ * @param checked The new checked state of the element
+ * @return false if the check state should not change
+ */
+ public boolean setChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked);
+
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelProxy.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelProxy.java
index 98c60b14d..65613521d 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelProxy.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/IModelProxy.java
@@ -31,6 +31,7 @@ import org.eclipse.jface.viewers.Viewer;
* @see IModelDelta
* @see IModelProxyFactory
* @see IModelChangedListener
+ * @see ICheckboxModelProxy
* @since 3.2
*/
public interface IModelProxy {

Back to the top