Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2012-06-11 23:36:51 +0000
committerEugene Tarassov2012-06-12 00:05:49 +0000
commit717517dcf250e01f25e19ad6e863fea623457527 (patch)
tree785be4dd8d30f46165d97a254b5d6c09415ed178 /plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints
parentd4fce15928897a3cb0c9757ea5abf50a93c49051 (diff)
downloadorg.eclipse.tcf-717517dcf250e01f25e19ad6e863fea623457527.tar.gz
org.eclipse.tcf-717517dcf250e01f25e19ad6e863fea623457527.tar.xz
org.eclipse.tcf-717517dcf250e01f25e19ad6e863fea623457527.zip
TCF Debugger: code cleanup, TCFContextQueryDescendants is converted to a function that implements ACPM transaction
Diffstat (limited to 'plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints')
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java113
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java4
2 files changed, 55 insertions, 62 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java
index 6f201090e..770ca1d13 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeDetailPane.java
@@ -12,6 +12,7 @@ package org.eclipse.tcf.internal.cdt.ui.breakpoints;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -52,17 +53,17 @@ import org.eclipse.tcf.debug.ui.ITCFDebugUIConstants;
import org.eclipse.tcf.internal.cdt.ui.ImageCache;
import org.eclipse.tcf.internal.debug.model.ITCFConstants;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
-import org.eclipse.tcf.internal.debug.ui.model.TCFContextQueryDescendants;
+import org.eclipse.tcf.internal.debug.ui.model.TCFChildrenContextQuery;
import org.eclipse.tcf.internal.debug.ui.model.TCFModel;
import org.eclipse.tcf.internal.debug.ui.model.TCFModelManager;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.ui.IWorkbenchPartSite;
/**
- * This detail pane uses a tree viewer to show which contexts a given breakpoint
+ * This detail pane uses a tree viewer to show which contexts a given breakpoint
* can potentially trigger.
*/
-@SuppressWarnings("restriction")
+@SuppressWarnings("restriction")
public class TCFBreakpointScopeDetailPane implements IDetailPane {
public static final String ID = "org.eclipse.tcf.debug.DetailPaneFactory";
@@ -70,17 +71,17 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
public static final String DESC = "TCF Detail Pane";
private Composite fComposite;
- private Label fFilterName;
+ private Label fFilterName;
private TreeModelViewer fTreeViewer;
public static class ScopeDetailInputObject extends PlatformObject implements IElementContentProvider, IModelProxyFactory {
-
+
private final ContextQueryElement fContextQueryElement;
-
+
public ScopeDetailInputObject(ContextQueryElement query) {
fContextQueryElement = query;
}
-
+
@Override
public boolean equals(Object other) {
if (other instanceof ScopeDetailInputObject) {
@@ -88,19 +89,19 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
return false;
}
-
+
@Override
public int hashCode() {
return fContextQueryElement.hashCode();
}
-
+
public void update(IChildrenCountUpdate[] updates) {
for (IChildrenCountUpdate update : updates) {
update.setChildCount(1);
update.done();
}
}
-
+
public void update(IChildrenUpdate[] updates) {
for (IChildrenUpdate update : updates) {
if (update.getOffset() == 0) {
@@ -109,14 +110,14 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
}
}
-
+
public void update(IHasChildrenUpdate[] updates) {
for (IHasChildrenUpdate update : updates) {
update.setHasChilren(true);
update.done();
}
}
-
+
public IModelProxy createModelProxy(Object element, IPresentationContext context) {
return new AbstractModelProxy() {
@Override
@@ -129,59 +130,59 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
};
}
}
-
- public static class ContextQueryElement extends PlatformObject
- implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory
+
+ public static class ContextQueryElement extends PlatformObject
+ implements IElementContentProvider, IElementLabelProvider, IModelProxyFactory
{
private final String fQuery;
private Set<String> fContexts;
-
+
public ContextQueryElement(String query, Set<String> contexts) {
fQuery = query;
fContexts = contexts;
}
-
+
@Override
public boolean equals(Object other) {
if (other instanceof ContextQueryElement) {
ContextQueryElement element = (ContextQueryElement)other;
- return ((fQuery == null && element.fQuery == null) ||
+ return ((fQuery == null && element.fQuery == null) ||
(fQuery != null && fQuery.equals(element.fQuery))) &&
- ((fContexts == null && element.fContexts == null) ||
+ ((fContexts == null && element.fContexts == null) ||
(fContexts != null && fContexts.equals(element.fContexts)));
}
return false;
}
-
+
@Override
public int hashCode() {
return (fQuery != null ? fQuery.hashCode() : 0) + (fContexts != null ? fContexts.hashCode() : 0);
}
-
+
public void update(IChildrenCountUpdate[] updates) {
for (IViewerUpdate update : updates) {
getFilteredLaunches(update);
}
}
-
+
public void update(IChildrenUpdate[] updates) {
for (IViewerUpdate update : updates) {
getFilteredLaunches(update);
}
}
-
+
public void update(IHasChildrenUpdate[] updates) {
for (IViewerUpdate update : updates) {
getFilteredLaunches(update);
}
}
-
+
public void update(ILabelUpdate[] updates) {
for (ILabelUpdate update : updates) {
getQueryFilteredContexts(update);
}
}
-
+
private List<TCFLaunch> getTCFLaunches() {
List<TCFLaunch> tcfLaunches = new ArrayList<TCFLaunch>();
for (ILaunch launch : DebugPlugin.getDefault().getLaunchManager().getLaunches()) {
@@ -192,7 +193,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
return tcfLaunches;
}
-
+
private void getFilteredLaunches (final IViewerUpdate update) {
Protocol.invokeLater( new Runnable() {
public void run() {
@@ -201,15 +202,13 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
for (TCFLaunch launch : getTCFLaunches()) {
TCFModel model = modelManager.getModel(launch);
if (model != null && model.getRootNode() != null) {
- TCFContextQueryDescendants query_descendants = model.getRootNode().getContextQueryDescendants();
- if (!query_descendants.setQuery(fQuery, launch.getModelContexts(fContexts), this)) return;
- if (!query_descendants.validate(this)) return;
- if (query_descendants.getData() != null && !query_descendants.getData().isEmpty()) {
- filteredLaunches.add(launch);
- }
+ TCFChildrenContextQuery.Descendants des = TCFChildrenContextQuery.getDescendants(
+ model.getRootNode(), fQuery, fContexts, this);
+ if (des == null) return;
+ if (des.map != null && des.map.size() > 0) filteredLaunches.add(launch);
}
}
-
+
done(filteredLaunches, update);
}
});
@@ -219,31 +218,29 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
Protocol.invokeLater( new Runnable() {
public void run() {
TCFModelManager modelManager = TCFModelManager.getModelManager();
- Set<String> set = new TreeSet<String>();
+ Set<String> descendants = new HashSet<String>();
for (TCFLaunch launch : getTCFLaunches()) {
TCFModel model = modelManager.getModel(launch);
if (model != null && model.getRootNode() != null) {
- TCFContextQueryDescendants query_descendants = model.getRootNode().getContextQueryDescendants();
- if (!query_descendants.setQuery(fQuery, launch.getModelContexts(fContexts), this)) return;
- if (!query_descendants.validate(this)) return;
- if (query_descendants.getData() != null) {
- set.addAll(query_descendants.getData());
- }
+ TCFChildrenContextQuery.Descendants des = TCFChildrenContextQuery.getDescendants(
+ model.getRootNode(), fQuery, fContexts, this);
+ if (des == null) return;
+ if (des.map != null) descendants.addAll(des.map.keySet());
}
}
-
+
StringBuffer label = new StringBuffer();
label.append("(");
- label.append(set.size());
+ label.append(descendants.size());
label.append(") ");
-
+
if (fQuery != null) {
label.append("Filter: ");
label.append(fQuery);
if (fContexts != null) {
label.append(", ");
}
- }
+ }
if (fContexts != null) {
label.append("Contexts: ");
label.append(fContexts);
@@ -254,7 +251,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
});
}
-
+
private void done(List<TCFLaunch> launches, IViewerUpdate update) {
if (update instanceof IHasChildrenUpdate) {
((IHasChildrenUpdate)update).setHasChilren(!launches.isEmpty());
@@ -270,7 +267,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
}
update.done();
}
-
+
public IModelProxy createModelProxy(Object element, IPresentationContext context) {
return new QueryInputObjectProxy();
}
@@ -288,7 +285,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
fLaunchManager = DebugPlugin.getDefault().getLaunchManager();
fLaunchManager.addLaunchListener(this);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy#installed(org.eclipse.jface.viewers.Viewer)
*/
@@ -334,11 +331,11 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
/* (non-Javadoc)
* @see org.eclipse.debug.core.ILaunchesListener#launchesChanged(org.eclipse.debug.core.ILaunch[])
*/
- public void launchesChanged(ILaunch[] launches) {
+ public void launchesChanged(ILaunch[] launches) {
}
-
+
/**
- * Convenience method for firing a delta
+ * Convenience method for firing a delta
* @param launches the launches to set in the delta
* @param launchFlags the flags for the delta
*/
@@ -349,11 +346,11 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
delta.addNode(launches[i], launchFlags);
}
}
- fireModelChanged(delta);
+ fireModelChanged(delta);
}
}
-
+
public Control createControl(Composite parent) {
fComposite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
fFilterName = SWTFactory.createLabel(fComposite, "Scope", 1);
@@ -364,13 +361,13 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
control.setLayoutData(treeLayoutData);
GridData gd = new GridData(GridData.FILL_BOTH);
control.setLayoutData(gd);
-
+
return fComposite;
}
public void display(IStructuredSelection selection) {
if (fTreeViewer == null) return;
-
+
TCFBreakpointScopeExtension extension = getTCFBreakpointScopeExtension((ICBreakpoint)selection.getFirstElement());
if (extension != null) {
String filter = extension.getPropertiesFilter();
@@ -378,10 +375,10 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
filter = null;
}
String[] contexts = extension.getThreadFilters();
-
+
if (filter != null || contexts != null) {
fFilterName.setText("Scope");
- Set<String> contextsSet = contexts != null ? new TreeSet<String>(Arrays.asList(contexts)) : null;
+ Set<String> contextsSet = contexts != null ? new TreeSet<String>(Arrays.asList(contexts)) : null;
fTreeViewer.setInput( new ScopeDetailInputObject(
new ContextQueryElement(filter, contextsSet)) );
fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY, filter);
@@ -393,7 +390,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
fFilterName.setText("No scope specified.");
fTreeViewer.setInput(null);
fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_CONTEXT_QUERY, null);
- fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS, null);
+ fTreeViewer.getPresentationContext().setProperty(ITCFDebugUIConstants.PROP_FILTER_CONTEXTS, null);
}
private TCFBreakpointScopeExtension getTCFBreakpointScopeExtension(ICBreakpoint bp) {
@@ -404,7 +401,7 @@ public class TCFBreakpointScopeDetailPane implements IDetailPane {
} catch (CoreException e) {}
return null;
}
-
+
public void dispose() {
if (fTreeViewer != null) {
fTreeViewer.getControl().dispose();
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
index 1ee2a6205..bf6b66f40 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java
@@ -18,9 +18,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.eclipse.cdt.debug.core.model.ICBreakpoint;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
@@ -59,7 +56,6 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.tcf.internal.cdt.ui.Activator;
import org.eclipse.tcf.internal.cdt.ui.ImageCache;
import org.eclipse.tcf.internal.cdt.ui.preferences.BreakpointPreferencePage;
-import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel;
import org.eclipse.tcf.internal.debug.model.TCFLaunch;
import org.eclipse.tcf.internal.debug.ui.model.TCFChildren;
import org.eclipse.tcf.internal.debug.ui.model.TCFModel;

Back to the top