From 0d3cdd95e96b63b7629dcc68ddeadfe2d90cdcfb Mon Sep 17 00:00:00 2001 From: Darin Wright Date: Thu, 9 Nov 2006 21:31:12 +0000 Subject: merge with HEAD --- .../buildnotes_platform-debug.html | 10 + .../eclipse/debug/internal/core/LaunchManager.java | 23 +- .../schema/launchConfigurationTypes.exsd | 32 +- .../RemoveFromWorkingSetAction.java | 65 ++-- .../SelectBreakpointWorkingsetDialog.java | 8 +- .../breakpoints/RemoveBreakpointAction.java | 13 +- .../LaunchConfigurationView.java | 91 +---- .../LaunchConfigurationsDialog.java | 131 +------ .../ui/preferences/PerspectivePreferencePage.java | 10 - .../views/breakpoints/BreakpointSetOrganizer.java | 36 +- .../breakpoints/BreakpointWorkingSetCache.java | 24 +- .../views/breakpoints/BreakpointsDragAdapter.java | 56 ++- .../views/breakpoints/BreakpointsDropAdapter.java | 31 +- .../ui/views/breakpoints/BreakpointsView.java | 387 ++++++--------------- .../ui/views/breakpoints/BreakpointsViewer.java | 188 +++++++++- .../ui/views/variables/MaxDetailsLengthDialog.java | 2 + .../ui/org/eclipse/debug/ui/console/FileLink.java | 53 +-- 17 files changed, 497 insertions(+), 663 deletions(-) diff --git a/org.eclipse.debug.core/buildnotes_platform-debug.html b/org.eclipse.debug.core/buildnotes_platform-debug.html index 933c7988f..6f243f016 100644 --- a/org.eclipse.debug.core/buildnotes_platform-debug.html +++ b/org.eclipse.debug.core/buildnotes_platform-debug.html @@ -187,8 +187,18 @@ The launch framework has been enhanced to support the following: based on the selected variables. + +
TreePath
to the last selected item
- * @param pidx the original index of the parent item
- * @param cidx the original index of the child item
- * @since 3.2
- */
- private void updateSelection(TreePath path, int pidx, int cidx) {
- TreeViewer viewer = fLaunchConfigurationView.getTreeViewer();
- Tree tree = viewer.getTree();
- int pcount = tree.getItemCount();
- if(tree.getItemCount() == 0) {
- setErrorMessage(null);
- setMessage(LaunchConfigurationsMessages.LaunchConfigurationsDialog_7);
- updateButtons();
- }
- else if(path != null) {
- Object sel = path.getLastSegment();
- int pidex = findIndexOfParent(path.getFirstSegment());
- if(path.getSegmentCount() == 1) {
- if(pidex == -1) {
- if(pidx > pcount) {
- pidx = pcount-1;
- }
- sel = (pidx == 0 ? tree.getItem(pidx).getData() : tree.getItem(pidx-1).getData());
- }
- else {
- sel = tree.getItem(pidex).getData();
- }
- }
- else {
- if(pidex == -1) {
- if(pidx > pcount) {
- pidx = pcount-1;
- }
- sel = (pidx == 0 ? tree.getItem(pidx).getData() : tree.getItem(pidx-1).getData());
- }
- else {
- int cidex = findIndexOfChild(findIndexOfParent(path.getFirstSegment()), path.getLastSegment());
- TreeItem parent = tree.getItem(pidex);
- int ccount = parent.getItemCount();
- if(cidex == -1) {
- if(parent.getItemCount() == 0) {
- sel = parent.getData();
- }
- else {
- if(cidx > ccount) {
- cidx = ccount-1;
- }
- sel = (cidx == 0 ? parent.getItem(cidx).getData() : parent.getItem(cidx-1).getData());
- }
- }
- else {
- sel = parent.getItem(cidex).getData();
- }
- }
- }
- viewer.setSelection(new StructuredSelection(sel));
- updateButtons();
- updateMessage();
- }
- else {
- setErrorMessage(null);
- setMessage(LaunchConfigurationsMessages.LaunchConfigurationDialog_Ready_to_launch_2);
- }
- }
-
- /**
- * finds the given parent item in the viewer, in this case the parent item will always be an
- * ILaunchConfigurationType
- * @param parent the parent item to find
- * @return the index of the parent item or -1 if not found
- * @since 3.2
- */
- private int findIndexOfParent(Object parent) {
- Tree tree = fLaunchConfigurationView.getTreeViewer().getTree();
- TreeItem[] roots = tree.getItems();
- for(int i = 0; i < roots.length; i++) {
- if(roots[i].getData().equals(parent)) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Finds the index of a child item in the entire tree using the parent node and the child node
- * derived from a TreePath
- * @param parent the parent, in this case always an ILaunchConfigurationType
- * @param child the child to find within the parent, in this case always an ILaunchConfiguration,
- * @return the index of the child or -1 if not found
- * @since 3.2
- */
- private int findIndexOfChild(int pidx, Object child) {
- Tree tree = fLaunchConfigurationView.getTreeViewer().getTree();
- if(pidx != -1) {
- TreeItem root = tree.getItem(pidx);
- TreeItem[] children = root.getItems();
- Object data = null;
- for(int j = 0; j < children.length; j++) {
- data = children[j].getData();
- if(data != null && data.equals(child)) {
- return j;
- }
- }
- }
- return -1;
- }
}
\ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/PerspectivePreferencePage.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/PerspectivePreferencePage.java
index 326c26068..b6bc86245 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/PerspectivePreferencePage.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/PerspectivePreferencePage.java
@@ -46,7 +46,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
@@ -376,15 +375,6 @@ public class PerspectivePreferencePage extends PreferencePage implements IWorkbe
}
}
fPerspectiveComp.layout(new Control[] {fComboPlaceHolder});
- resizeShell();
- }
-
- private void resizeShell() {
- Point pnt = this.getShell().getSize();
- Point p = this.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- if(pnt.x < p.x) {
- this.getShell().setSize(p);
- }
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java
index c95ea4af1..0d608ed89 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointSetOrganizer.java
@@ -110,10 +110,10 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
Object newValue = event.getNewValue();
if (newValue instanceof IWorkingSet) {
set = (IWorkingSet) newValue;
- }//end if
+ }
else if (event.getOldValue() instanceof IWorkingSet) {
set = (IWorkingSet) event.getOldValue();
- }//end else if
+ }
String property = event.getProperty();
//fix for bug 103731
if (property.equals(IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE)) {
@@ -133,9 +133,9 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
IMarker marker = ((IBreakpoint)breakpoints[i]).getMarker();
fCache.addEntry(marker, set.getName());
fCache.flushMarkerCache(marker);
- }// end if
- }//end for
- }//end if
+ }
+ }
+ }
if (set != null && IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) {
fireCategoryChanged(new WorkingSetCategory(set));
}
@@ -168,11 +168,11 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
// if we cannot find the one we want, try to get the default
if (set == null) {
set = getDefaultWorkingSet();
- }// end if
+ }
addBreakpointToSet(breakpoints[i], set);
- }// end for
+ }
}
- }// end for
+ }
}
/**
@@ -188,8 +188,8 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
for(int i = 0; i < elements.length; i++) {
if(elements[i].equals(breakpoint)) {
return;
- }//end if
- }//end for
+ }
+ }
fCache.addEntry(breakpoint.getMarker(), set.getName()); //fix for bug 103731
fCache.flushMarkerCache(breakpoint.getMarker());
IAdaptable[] newElements = new IAdaptable[elements.length + 1];
@@ -213,9 +213,9 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
set = workingSets[i];
if (IInternalDebugUIConstants.ID_BREAKPOINT_WORKINGSET.equals(set.getId())) {
clean(set);
- }// end if
- }// end for
- }//end breakpointsRemoved
+ }
+ }
+ }
/**
* Removes deleted breakpoints from the given working set.
@@ -330,7 +330,7 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
if (category instanceof WorkingSetCategory) {
IWorkingSet set = ((WorkingSetCategory) category).getWorkingSet();
addBreakpointToSet(breakpoint, set);
- }//end if
+ }
}
/**
@@ -347,8 +347,8 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
String name = (String) marker.getAttribute(type);
if (name != null) {
return name.split("\\" + IImportExportConstants.DELIMITER); //$NON-NLS-1$
- }// end if
- }// end try
+ }
+ }
catch (CoreException e) {DebugPlugin.log(e);}
return new String[] {};
}
@@ -368,8 +368,8 @@ public class BreakpointSetOrganizer extends AbstractBreakpointOrganizerDelegate
IAdaptable adaptable = elements[i];
if (!adaptable.equals(breakpoint)) {
list.add(adaptable);
- }//end if
- }//end for
+ }
+ }
fCache.removeMappedEntry(breakpoint.getMarker(), set.getName());
fCache.flushMarkerCache(breakpoint.getMarker());
set.setElements((IAdaptable[]) list.toArray(new IAdaptable[list.size()]));
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java
index d1f62c7f3..8ad4f6c70 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointWorkingSetCache.java
@@ -46,7 +46,7 @@ public class BreakpointWorkingSetCache {
*/
public BreakpointWorkingSetCache() {
fCache = new HashMap(15);
- }//end constructor
+ }
/**
* Adds an entry into the cache
@@ -59,13 +59,13 @@ public class BreakpointWorkingSetCache {
list = new Vector();
list.addElement(entry);
fCache.put(marker, list);
- }//end if
+ }
else {
if(!list.contains(entry)) {
list.addElement(entry);
- }//end if
- }//end else
- }//end addEntry
+ }
+ }
+ }
/**
* Removes an item from the list contained under the marker key, not the marker entry
@@ -76,8 +76,8 @@ public class BreakpointWorkingSetCache {
Vector list = (Vector)fCache.get(marker);
if(list != null) {
list.remove(entry);
- }//end if
- }//end removeMappedEntry
+ }
+ }
/**
* Flushes the cache of only the sepcified marker
@@ -95,14 +95,14 @@ public class BreakpointWorkingSetCache {
if(ws != null) {
names += name+IImportExportConstants.DELIMITER;
ids += ws.getId()+IImportExportConstants.DELIMITER;
- }//end if
- }//end for
+ }
+ }
try {
marker.setAttribute(IInternalDebugUIConstants.WORKING_SET_NAME, names);
marker.setAttribute(IInternalDebugUIConstants.WORKING_SET_ID, ids);
- }//end try
+ }
catch(CoreException e) {DebugPlugin.log(e);}
- }//end if
+ }
}
-}//end class
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java
index 90536c7bb..e3b498a85 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDragAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -13,23 +13,31 @@ package org.eclipse.debug.internal.ui.views.breakpoints;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.util.TransferDragSourceListener;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Item;
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
+/**
+ * A drag adapter for the breakpoints viewer
+ */
public class BreakpointsDragAdapter extends DragSourceAdapter implements TransferDragSourceListener {
- private ISelectionProvider fProvider;
- private BreakpointsView fView;
- private BreakpointContainer[] fContainers;
+ /**
+ * the associated viewer for the adapter
+ */
+ private BreakpointsViewer fViewer;
+ private Item[] fItems = null;
- public BreakpointsDragAdapter(BreakpointsView view, ISelectionProvider provider) {
- Assert.isNotNull(provider);
- fProvider= provider;
- fView = view;
+ /**
+ * Constructor
+ * @param view the associiated view, which acts as the selection provider and therefore must implement ISelectionProvider
+ */
+ public BreakpointsDragAdapter(BreakpointsViewer viewer) {
+ Assert.isNotNull(viewer);
+ fViewer = viewer;
}
/**
@@ -43,29 +51,13 @@ public class BreakpointsDragAdapter extends DragSourceAdapter implements Transfe
* @see org.eclipse.swt.dnd.DragSourceListener#dragStart
*/
public void dragStart(DragSourceEvent event) {
- ISelection selection= fProvider.getSelection();
+ ISelection selection = fViewer.getSelection();
LocalSelectionTransfer.getInstance().setSelection(selection);
LocalSelectionTransfer.getInstance().setSelectionSetTime(event.time & 0xFFFFFFFFL);
- event.doit= isDragable(selection);
- }
-
- /**
- * Checks if the elements contained in the given selection can
- * be dragged.
- * - * Subclasses may override. - * - * @param selection containing the elements to be dragged - */ - protected boolean isDragable(ISelection selection) { - if (fView.canMove(selection)) { - fContainers = fView.getMovedFromContainers(selection); - return true; - } - return false; + event.doit = fViewer.canDrag(fViewer.getSelectedItems()); + fItems = fViewer.getSelectedItems(); } - - + /* non Java-doc * @see org.eclipse.swt.dnd.DragSourceListener#dragSetData */ @@ -73,18 +65,18 @@ public class BreakpointsDragAdapter extends DragSourceAdapter implements Transfe // For consistency set the data to the selection even though // the selection is provided by the LocalSelectionTransfer // to the drop target adapter. - event.data= LocalSelectionTransfer.getInstance().getSelection(); + event.data = LocalSelectionTransfer.getInstance().getSelection(); } - /* non Java-doc * @see org.eclipse.swt.dnd.DragSourceListener#dragFinished */ public void dragFinished(DragSourceEvent event) { if (event.detail == DND.DROP_MOVE) { // remove from source on move operation - fView.performRemove(fContainers, LocalSelectionTransfer.getInstance().getSelection()); + fViewer.performDrag(fItems); } + fItems = null; LocalSelectionTransfer.getInstance().setSelection(null); LocalSelectionTransfer.getInstance().setSelectionSetTime(0); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java index a72606797..cd4096d9e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsDropAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 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 @@ -10,38 +10,47 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.views.breakpoints; -import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ViewerDropAdapter; +import org.eclipse.swt.dnd.DropTargetEvent; import org.eclipse.swt.dnd.TransferData; +import org.eclipse.swt.widgets.Item; import org.eclipse.ui.views.navigator.LocalSelectionTransfer; /** * BreakpointsDropAdapter */ public class BreakpointsDropAdapter extends ViewerDropAdapter { - - private BreakpointsView fView; + private Item fTarget = null; + /** * @param viewer */ - protected BreakpointsDropAdapter(BreakpointsView view, Viewer viewer) { + protected BreakpointsDropAdapter(BreakpointsViewer viewer) { super(viewer); - fView = view; + setFeedbackEnabled(false); } - /* (non-Javadoc) + /** * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object) */ public boolean performDrop(Object data) { - return fView.performPaste(getCurrentTarget(), LocalSelectionTransfer.getInstance().getSelection()); + return ((BreakpointsViewer)getViewer()).performDrop(fTarget, (IStructuredSelection) LocalSelectionTransfer.getInstance().getSelection()); } - /* (non-Javadoc) + /** + * @see org.eclipse.jface.viewers.ViewerDropAdapter#determineTarget(org.eclipse.swt.dnd.DropTargetEvent) + */ + protected Object determineTarget(DropTargetEvent event) { + fTarget = (Item) event.item; + return fTarget; + } + + /** * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData) */ public boolean validateDrop(Object target, int operation, TransferData transferType) { - return fView.canPaste(target, LocalSelectionTransfer.getInstance().getSelection()); + return ((BreakpointsViewer)getViewer()).canDrop(fTarget, (IStructuredSelection) LocalSelectionTransfer.getInstance().getSelection()); } - } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java index cf020eb28..5728a1a70 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsView.java @@ -63,10 +63,8 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.IMemento; @@ -97,7 +95,12 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList private BreakpointsViewEventHandler fEventHandler; private ICheckStateListener fCheckListener= new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { - handleCheckStateChanged(event); + Object source = event.getElement(); + if (source instanceof BreakpointContainer) { + handleContainerChecked(event, (BreakpointContainer) source); + } else if (source instanceof IBreakpoint) { + handleBreakpointChecked(event, (IBreakpoint) source); + } } }; private boolean fIsTrackingSelection= false; @@ -132,6 +135,7 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList fContentProvider= new BreakpointsContentProvider(); CheckboxTreeViewer viewer = new BreakpointsViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK)); setViewer(viewer); + viewer.setUseHashlookup(true); viewer.setContentProvider(fContentProvider); viewer.setComparator(new BreakpointsComparator()); viewer.setInput(DebugPlugin.getDefault().getBreakpointManager()); @@ -144,7 +148,6 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList } }); viewer.setLabelProvider(new BreakpointsLabelProvider()); - // Necessary so that the PropertySheetView hears about selections in this view getSite().setSelectionProvider(viewer); initIsTrackingSelection(); @@ -154,20 +157,16 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList return viewer; } + /** + * Initializes drag and drop for the breakpoints viewer + */ private void initDragAndDrop() { - StructuredViewer viewer = (StructuredViewer)getViewer(); - int ops= DND.DROP_MOVE | DND.DROP_COPY; + BreakpointsViewer viewer = (BreakpointsViewer) getViewer(); + int ops = DND.DROP_MOVE | DND.DROP_COPY; // drop - Transfer[] dropTransfers= new Transfer[] { - LocalSelectionTransfer.getInstance() - }; - viewer.addDropSupport(ops, dropTransfers, new BreakpointsDropAdapter(this, viewer)); - + viewer.addDropSupport(ops, new Transfer[] {LocalSelectionTransfer.getInstance()}, new BreakpointsDropAdapter(viewer)); // Drag - Transfer[] dragTransfers= new Transfer[] { - LocalSelectionTransfer.getInstance() - }; - viewer.addDragSupport(ops, dragTransfers, new BreakpointsDragAdapter(this, viewer)); + viewer.addDragSupport(ops, new Transfer[] {LocalSelectionTransfer.getInstance()}, new BreakpointsDragAdapter(viewer)); } /** @@ -186,6 +185,9 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList setTrackSelection(false); } + /** + * Initializes the persisted breakpoints organizers + */ private void initBreakpointOrganizers() { IMemento memento = getMemento(); if (memento != null) { @@ -245,20 +247,6 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList return fContentProvider; } - /** - * Responds to the user checking and unchecking breakpoints by enabling - * and disabling them. - * - * @param event the check state change event - */ - private void handleCheckStateChanged(CheckStateChangedEvent event) { - Object source= event.getElement(); - if (source instanceof BreakpointContainer) { - handleContainerChecked(event, (BreakpointContainer) source); - } else if (source instanceof IBreakpoint) { - handleBreakpointChecked(event, (IBreakpoint) source); - } - } /** * A breakpoint has been checked/unchecked. Update the group * element's checked/grayed state as appropriate. @@ -312,9 +300,9 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList IProgressService progressService = PlatformUI.getWorkbench().getProgressService(); try { progressService.busyCursorWhile(runnable); - } catch (InvocationTargetException e) { - } catch (InterruptedException e) { - } + } + catch (InvocationTargetException e) {} + catch (InterruptedException e) {} } /** @@ -535,7 +523,7 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList node.putString(KEY_VALUE, String.valueOf(fIsTrackingSelection)); StringBuffer buffer= new StringBuffer(); - IBreakpointOrganizer[] organizers = getBreakpointOrganizers(); + IBreakpointOrganizer[] organizers = fContentProvider.getOrganizers(); if (organizers != null) { for (int i = 0; i < organizers.length; i++) { IBreakpointOrganizer organizer = organizers[i]; @@ -589,6 +577,10 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList viewer.setSelection(selection); } + /** + * returns the complete listing of breakpoints organizers + * @return the complete listing of breakpoint organizers + */ public IBreakpointOrganizer[] getBreakpointOrganizers() { return fContentProvider.getOrganizers(); } @@ -642,101 +634,99 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList } /** - * Checks if the elements contained in the given selection can - * be moved. - * - * @param selection containing the elements to be moved - */ - public boolean canMove(ISelection selection) { - if (selection.isEmpty() || !fContentProvider.isShowingGroups()) { - return false; - } - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - Object[] objects = ss.toArray(); - for (int i = 0; i < objects.length; i++) { - Object object = objects[i]; - if (object instanceof IBreakpoint) { - IBreakpoint breakpoint = (IBreakpoint) object; - BreakpointContainer[] containers = getMovedFromContainers(breakpoint); - if (containers == null || containers.length == 0) { - return false; - } - } else { - return false; - } - } - } else { - return false; - } - return true; - } + * This method is used solely to preserve the selection state of the viewer in the event that the current selection is to be removed + * @param selection the selection to be removed + * + * @since 3.3 + */ + public void preserveSelection(IStructuredSelection selection) { + if(selection != null && !selection.isEmpty()) { + TreeItem item = (TreeItem) ((BreakpointsViewer)getCheckboxViewer()).searchItem(selection.getFirstElement()); + Object toselect = null; + if(item != null) { + TreeItem parent = item.getParentItem(); + if(parent != null) { + int idx = 0; + if(parent.getItemCount() == 1) { + toselect = parent.getData(); + } + idx = parent.indexOf(item); + if(idx == 0) { + if(parent.getItemCount() > 1) { + toselect = parent.getItem(1).getData(); + } + else { + toselect = parent.getItem(0).getData(); + } + } + if(idx > 0) { + toselect = parent.getItem(idx-1).getData(); + } + } + else { + Tree tree = item.getParent(); + TreeItem[] items = tree.getItems(); + for(int i = 0; i < items.length; i++) { + if(item.equals(items[i])) { + if(i - 1 < 0 && items.length > 1) { + toselect = items[i+1]; + break; + } + else if(items.length > 1){ + toselect = items[i-1].getData(); + break; + } + } + } + } + } + if(toselect != null) { + getViewer().setSelection(new StructuredSelection(toselect), true); + } + } + } /** * Returns whether the given selection can be pasted into the given target. + *
+ * Scheme: + *
TreeItem
s and TreePath
s to determine paste targets
*/
public boolean canPaste(Object target, ISelection selection) {
- if (target instanceof BreakpointContainer) {
- BreakpointContainer container = (BreakpointContainer) target;
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object[] objects = ((IStructuredSelection)selection).toArray();
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof IBreakpoint) {
- IBreakpoint breakpoint = (IBreakpoint)objects[i];
- if (container.contains(breakpoint) || !container.getOrganizer().canAdd(breakpoint, container.getCategory())) {
- return false;
- }
- } else {
- return false;
- }
- }
- return true;
- }
- }
- if(target instanceof IBreakpoint){
- IBreakpoint bp = (IBreakpoint)target;
- BreakpointContainer cont = getBreakpointContainer(bp);
- if(cont!=null){
- return canPaste(cont,selection);
- }
- }
- return false;
- }
-
- /**
- * Returns the BreakpointContainer which holds the
- * given breakpoint, or null if such a container cannot be found.
- * @param breakpoint the breakpoint whose container is to be returned
- * @return the container of the given breakpoint.
- * @since 3.2
- */
- private BreakpointContainer getBreakpointContainer(IBreakpoint breakpoint) {
- BreakpointContainer[] containers = fContentProvider.getContainers(breakpoint);
- if (containers != null && containers.length > 0) {
- return containers[0];
+ if(!(target instanceof BreakpointContainer)) {
+ return false;
}
- return null;
- }
-
- public void performRemove(BreakpointContainer[] containers, ISelection ss) {
- if (ss instanceof IStructuredSelection) {
- // remove from source on move operation
- IStructuredSelection selection = (IStructuredSelection) ss;
- Object[] breakpoints = selection.toArray();
- for (int i = 0; i < breakpoints.length; i++) {
- IBreakpoint breakpoint = (IBreakpoint) breakpoints[i];
- for (int j = 0; j < containers.length; j++) {
- BreakpointContainer container = containers[j];
- container.getOrganizer().removeBreakpoint(breakpoint, container.getCategory());
- }
+ if(selection.isEmpty()) {
+ return false;
+ }
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ BreakpointContainer container = (BreakpointContainer) target;
+ IBreakpoint breakpoint = null;
+ Object element = null;
+ for(Iterator iter = ss.iterator(); iter.hasNext();) {
+ element = iter.next();
+ if(!(element instanceof IBreakpoint)) {
+ return false;
+ }
+ breakpoint = (IBreakpoint) element;
+ if (container.contains(breakpoint) || !container.getOrganizer().canAdd(breakpoint, container.getCategory())) {
+ return false;
}
- }
- }
-
+ }
+ return true;
+ }
+
/**
* Pastes the selection into the given target
*
@@ -744,6 +734,8 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList
* or a Breakpoint within a BreakpointContainer
* @param selection breakpoints
* @return whehther successful
+ *
+ * TODO remove in favour of using TreeItem
as paste target
*/
public boolean performPaste(Object target, ISelection selection) {
if (target instanceof BreakpointContainer && selection instanceof IStructuredSelection) {
@@ -754,169 +746,14 @@ public class BreakpointsView extends AbstractDebugView implements ISelectionList
}
return true;
}
- if(target instanceof IBreakpoint){
- return performPaste(getBreakpointContainer((IBreakpoint)target),selection);
- }
return false;
- }
+ }
- public BreakpointContainer[] getMovedFromContainers(ISelection selection) {
- List list = new ArrayList();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ss = (IStructuredSelection) selection;
- Object[] objects = ss.toArray();
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof IBreakpoint) {
- IBreakpoint breakpoint = (IBreakpoint) objects[i];
- BreakpointContainer[] containers = getMovedFromContainers(breakpoint);
- for (int j = 0; j < containers.length; j++) {
- list.add(containers[j]);
- }
- }
-
- }
- }
- return (BreakpointContainer[]) list.toArray(new BreakpointContainer[list.size()]);
- }
/**
- * Returns the parent of the given breakpoint that allows the breakpoint
- * to be removed. Only parents of selected breakpoints are considered.
- *
- * @param breakpoint candidate for removal
- * @return containers that the breakpoint should be removed from
+ * Returns if the breakpoints view is currently showing groups or not
+ * @return true of the breakpoints view showing groups, false otherwise
*/
- public BreakpointContainer[] getMovedFromContainers(IBreakpoint breakpoint) {
- BreakpointsViewer viewer = (BreakpointsViewer) getViewer();
- Item[] items = viewer.getSelectedItems();
- List list = new ArrayList();
- for (int i = 0; i < items.length; i++) {
- TreeItem item = (TreeItem) items[i];
- if (breakpoint.equals(item.getData())) {
- BreakpointContainer parent = getRemoveableParent(item, breakpoint);
- if (parent != null) {
- list.add(parent);
- }
- }
- }
- return (BreakpointContainer[]) list.toArray(new BreakpointContainer[list.size()]);
- }
-
- private BreakpointContainer getRemoveableParent(TreeItem item, IBreakpoint breakpoint) {
- TreeItem parentItem = item.getParentItem();
- if (parentItem != null) {
- Object data = parentItem.getData();
- if (data instanceof BreakpointContainer) {
- BreakpointContainer container = (BreakpointContainer) data;
- if (container.getOrganizer().canRemove(breakpoint, container.getCategory())) {
- return container;
- }
- }
- return getRemoveableParent(parentItem, breakpoint);
- }
- return null;
- }
-
public boolean isShowingGroups() {
return fContentProvider.isShowingGroups();
}
-
- /**
- * Returns a list containing a point indicating the breakpoint to attempt to
- * select a list of groups to select, or null
if none.
- *
- * @return
- */
- public List getSelectionState() {
- Tree tree = ((BreakpointsViewer)getViewer()).getTree();
- TreeItem[] selection = tree.getSelection();
- if (selection.length > 0) {
- List list = new ArrayList();
- TreeItem[] roots = tree.getItems();
- TreeItem first = getFirstSelectedItem(roots, selection);
- if (first.getData() instanceof IBreakpoint) {
- TreeItem parentItem = first.getParentItem();
- if (parentItem == null) {
- list.add(new Point(0, indexOf(roots, first)));
- } else {
- int breakpointIndex = indexOf(parentItem.getItems(),first);
- while (parentItem.getParentItem() != null) {
- parentItem = parentItem.getParentItem();
- }
- int groupIndex = indexOf(roots, parentItem);
- list.add(new Point(groupIndex, breakpointIndex));
- }
- } else {
- for (int i = 0; i < selection.length; i++) {
- TreeItem item = selection[i];
- list.add(item.getData());
- }
- }
- return list;
- }
- return null;
- }
-
- private TreeItem getFirstSelectedItem(TreeItem[] items, TreeItem[] selection) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- if (indexOf(selection, item) >= 0) {
- return item;
- }
- TreeItem first = getFirstSelectedItem(item.getItems(), selection);
- if (first != null) {
- return first;
- }
- }
- return null;
- }
-
- private int indexOf(Object[] list, Object object) {
- for (int i = 0; i < list.length; i++) {
- if (object.equals(list[i])) {
- return i;
- }
- }
- return -1;
- }
-
- public void preserveSelectionState(List state) {
- if (state != null) {
- if (state.get(0) instanceof Point) {
- Point p = (Point) state.get(0);
- int groupIndex = p.x;
- int bpIndex = p.y;
- Tree tree = ((BreakpointsViewer)getViewer()).getTree();
- TreeItem[] roots = tree.getItems();
- TreeItem selection = null;
- if (roots.length > 0 && groupIndex < roots.length) {
- TreeItem group = roots[groupIndex];
- if (group.getData() instanceof IBreakpoint) {
- if (bpIndex < roots.length) {
- selection = roots[bpIndex];
- } else {
- selection = roots[roots.length -1];
- }
- } else {
- TreeItem[] bps = group.getItems();
- while (bps.length > 0 && !(bps[0].getData() instanceof IBreakpoint)) {
- group = bps[0];
- bps = group.getItems();
- }
- if (bpIndex < bps.length) {
- selection = bps[bpIndex];
- } else if (bps.length > 0) {
- selection = bps[bps.length - 1];
- } else {
- selection = group;
- }
- }
- }
- if (selection != null) {
- ((BreakpointsViewer)getViewer()).setSelection(selection);
- }
- } else {
- getViewer().setSelection(new StructuredSelection(state));
- }
- }
- }
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java
index a697cef9d..073bf6dfe 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 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
@@ -11,6 +11,7 @@
package org.eclipse.debug.internal.ui.views.breakpoints;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -19,7 +20,9 @@ import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.TreePath;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
@@ -29,7 +32,7 @@ import org.eclipse.swt.widgets.Widget;
* Breakpoints viewer.
*/
public class BreakpointsViewer extends CheckboxTreeViewer {
-
+
/**
* Constructs a new breakpoints viewer with the given tree.
*
@@ -115,8 +118,185 @@ public class BreakpointsViewer extends CheckboxTreeViewer {
getTree().setSelection(new TreeItem[]{item});
updateSelection(getSelection());
}
+
+ /**
+ * Returns the container from within the specified path that is the container the breakpoint can be removed from
+ * @param breakpoint the breakpoint to get the container for
+ * @return the first found container that includes the breakpoint that allows removal, or null
if none found
+ * @since 3.3
+ */
+ public BreakpointContainer getRemovableContainer(Item item) {
+ if(item == null) {
+ return null;
+ }
+ if(item.getData() instanceof IBreakpoint) {
+ TreePath path = getTreePathFromItem(item);
+ if(path != null) {
+ IBreakpoint breakpoint = (IBreakpoint) path.getLastSegment();
+ BreakpointContainer container = null;
+ for(int i = path.getSegmentCount()-2; i > -1; i--) {
+ container = (BreakpointContainer) path.getSegment(i);
+ if(container.contains(breakpoint) && container.getOrganizer().canRemove(breakpoint, container.getCategory())) {
+ return container;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the addable breakpoint container of the specified breakpoint
+ * @param breakpoint the breakpoint to get the container for
+ * @return the first found addable container for the specified breakpoint or null
if none found
+ * @since 3.3
+ */
+ public BreakpointContainer getAddableContainer(Item item) {
+ TreePath path = getTreePathFromItem(item);
+ if(path != null) {
+ Object element = path.getLastSegment();
+ if(element instanceof IBreakpoint) {
+ BreakpointContainer container = null;
+ IBreakpoint breakpoint = (IBreakpoint) element;
+ for(int i = path.getSegmentCount()-2; i > -1; i--) {
+ container = (BreakpointContainer) path.getSegment(i);
+ if(container.contains(breakpoint) && container.getOrganizer().canAdd(breakpoint, container.getCategory())) {
+ return container;
+ }
+ }
+ }
+ }
+ return null;
+ }
+ /**
+ * Returns if the selected item in the tree can be dragged
+ * + * Scheme: + *
+ * Scheme: + *
+ * A drop target can be either a BreakpointContainer
or an IBreakpoint
. This method always checks the entire heirarchy
+ * of the tree path for the specified target in the event one of the parent element does not support dropping.
+ *