aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Tepavich2012-05-19 20:28:56 (EDT)
committerEugene Tarassov2012-05-23 18:10:31 (EDT)
commit165591bf7ba5a9701c5c615449a15b23c3aa727f (patch)
treed1d87f57809122d9c1e99558c6144aa4b2133e41
parentdfd48727e8fabd1596afb1e3c93e1b68291760f8 (diff)
downloadorg.eclipse.tcf-165591bf7ba5a9701c5c615449a15b23c3aa727f.zip
org.eclipse.tcf-165591bf7ba5a9701c5c615449a15b23c3aa727f.tar.gz
org.eclipse.tcf-165591bf7ba5a9701c5c615449a15b23c3aa727f.tar.bz2
Bug [379413] Allow user to set a default trigger scope
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/plugin.properties1
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/plugin.xml56
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java13
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java6
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java4
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFThreadFilterEditor.java300
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointAdapter.java239
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointsTargetFactory.java145
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/ToggleTCFBreakpointTester.java42
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties15
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/BreakpointPreferencePage.java155
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceConstants.java19
-rw-r--r--plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceInitializer.java32
14 files changed, 887 insertions, 141 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.tcf.cdt.ui/META-INF/MANIFEST.MF
index af76170..ac777f3 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.tcf.cdt.ui/META-INF/MANIFEST.MF
@@ -32,4 +32,5 @@ Export-Package: org.eclipse.tcf.internal.cdt.launch;x-internal:=true,
org.eclipse.tcf.internal.cdt.ui.disassembly;x-internal:=true,
org.eclipse.tcf.internal.cdt.ui.hover;x-internal:=true,
org.eclipse.tcf.internal.cdt.ui.launch;x-internal:=true,
+ org.eclipse.tcf.internal.cdt.ui.preferences,
org.eclipse.tcf.internal.cdt.ui.sourcelookup;x-internal:=true
diff --git a/plugins/org.eclipse.tcf.cdt.ui/plugin.properties b/plugins/org.eclipse.tcf.cdt.ui/plugin.properties
index cb00040..374a188 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/plugin.properties
+++ b/plugins/org.eclipse.tcf.cdt.ui/plugin.properties
@@ -46,4 +46,5 @@ item.addWatchpoint.name=Add Watchpoint...
editor.sourceNotFound.name=Source Not Found
+breakpointsPreferencePage.name = Breakpoints
breakpointScope.label=Scope
diff --git a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml
index 905a9f7..adee602 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml
+++ b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml
@@ -84,7 +84,6 @@
</enabledWhen>
</page>
</extension>
-
<extension point="org.eclipse.ui.propertyPages">
<page class="org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFBreakpointThreadFilterPage"
id="org.eclipse.tcf.breakpoint.scope.filtering"
@@ -353,7 +352,40 @@
menubarPath="additions"/>
</objectContribution>
</extension>
-
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.eclipse.tcf.internal.cdt.ui.breakpoints.ToggleTCFBreakpointTester"
+ id="org.eclipse.tcf.cdt.ui.editorToggleBreakpointTester"
+ namespace="org.eclipse.tcf.cdt.ui"
+ properties="isTCFBreakpointSupported"
+ type="org.eclipse.ui.IWorkbenchPart">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.tcf.internal.cdt.ui.breakpoints.ToggleTCFBreakpointTester"
+ id="org.eclipse.tcf.cdt.ui.declarationToggleBreakpointTester"
+ namespace="org.eclipse.tcf.cdt.ui"
+ properties="isTCFBreakpointSupported"
+ type="java.util.List">
+ </propertyTester>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.toggleBreakpointsTargetFactories">
+ <toggleTargetFactory
+ id="org.eclipse.tcf.debug.toggleTCFThreadBreakpointTarget"
+ class="org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFToggleBreakpointsTargetFactory">
+ <enablement>
+ <!-- TODO: SDT: Comment out the testers for now. Create a new one, to test if
+ the current launch is TCF or not. Should be enough. -->
+ <or>
+ <test property="org.eclipse.tcf.cdt.ui.isTCFBreakpointSupported"/>
+ <test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/>
+ <test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/>
+ <test property="org.eclipse.cdt.debug.ui.isDisassemblyEditorSupportsCBreakpoint"/>
+ </or>
+ </enablement>
+ </toggleTargetFactory>
+ </extension>
<extension
point="org.eclipse.ui.editors">
<editor
@@ -365,6 +397,21 @@
</editor>
</extension>
<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.debug.ui.DebugPreferencePage"
+ class="org.eclipse.tcf.internal.cdt.ui.preferences.BreakpointPreferencePage"
+ id="org.eclipse.tcf.cdt.ui.preferences.BreakpointPreferencePage"
+ name="%breakpointsPreferencePage.name">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.tcf.internal.cdt.ui.preferences.PreferenceInitializer">
+ </initializer>
+ </extension>
+ <extension
point="org.eclipse.debug.ui.breakpointOrganizers">
<breakpointOrganizer
class="org.eclipse.tcf.internal.cdt.ui.breakpoints.BreakpointScopeOrganizer"
@@ -373,7 +420,6 @@
label="%breakpointScope.label">
</breakpointOrganizer>
</extension>
-
<extension
point="org.eclipse.ui.menus">
<menuContribution
@@ -396,9 +442,5 @@
</visibleWhen>
</command>
</menuContribution>
-
-
</extension>
-
-
</plugin>
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java
index f7cf3a4..b124bbc 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/Messages.java
@@ -17,18 +17,27 @@ public class Messages extends NLS {
public static String TCFThreadFilterQueryExpressionStore;
public static String TCFThreadFilterQueryModeButtonState;
+ public static String TCFThreadUseDefaultTriggerScoping;
+ public static String TCFThreadDefaultTriggerScope;
public static String TCFThreadFilterQueryButtonBasic;
public static String TCFThreadFilterQueryButtonAdvanced;
public static String TCFThreadFilterQueryButtonEdit;
public static String TCFThreadFilterQueryAdvancedLabel;
public static String TCFThreadFilterQueryTreeViewLabel;
public static String TCFThreadFilterEditorFormatError;
-
+ public static String TCFThreadFilterEditorNoOpenChannel;
+ public static String TCFThreadFileterEditorInvalidQuery;
+ public static String TCFBreakpointPreferencesEnableDefaultTriggerScope;
+ public static String TCFBreakpointPreferencesTriggerScopeExpression;
+ public static String TCFBreakpointPreferencesDescription;
+ public static String TCFBreakpointToggle;
+ public static String TCFBreakpointToggleCannotFindMemory;
+ public static String TCFBreakpointToggleError;
+ public static String TCFBreakpointPrefrencesError;
public static String BreakpointScopeCategory_filter_label;
public static String BreakpointScopeCategory_contexts_label;
public static String BreakpointScopeCategory_global_label;
-
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java
index a7545d0..6fa9166 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFBreakpointScopeExtension.java
@@ -86,7 +86,11 @@ public class TCFBreakpointScopeExtension implements ICBreakpointExtension {
public void run(IProgressMonitor monitor) throws CoreException {
final IMarker m = fBreakpoint.getMarker();
if (m == null || !m.exists()) return;
- m.setAttribute(TCFBreakpointsModel.ATTR_CONTEXT_QUERY, fProperties);
+ if (fProperties.length() != 0)
+ m.setAttribute(TCFBreakpointsModel.ATTR_CONTEXT_QUERY, fProperties);
+ else
+ m.setAttribute(TCFBreakpointsModel.ATTR_CONTEXT_QUERY, null);
+
}
}, null);
}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java
index 92d8531..3de5d50 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFContextQueryExpressionDialog.java
@@ -257,7 +257,9 @@ public class TCFContextQueryExpressionDialog extends SelectionDialog {
param.setData("");
}
}
- if (expression == null || expression.length() == 0 || originalExpression.contentEquals(expression)) {
+ if (expression == null ||
+ (expression.length() == 0 && originalExpression.length() == 0) ||
+ originalExpression.contentEquals(expression)) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
else {
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 edd55c2..ddc7c6f 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
@@ -41,7 +41,6 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
@@ -54,10 +53,12 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
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;
@@ -71,9 +72,12 @@ import org.eclipse.tcf.services.IContextQuery;
import org.eclipse.tcf.services.IRunControl;
import org.eclipse.tcf.util.TCFDataCache;
import org.eclipse.tcf.util.TCFTask;
+import org.eclipse.ui.dialogs.PreferencesUtil;
public class TCFThreadFilterEditor {
+ public static final String PLUGIN_ID="org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFThreadFilterEditor";
+
private static class Context {
private final String fName;
private final String fId;
@@ -182,17 +186,38 @@ public class TCFThreadFilterEditor {
public Object[] getChildren(Object parent) {
if (parent instanceof Context) {
- return syncGetThreads((Context) parent);
+ return filterList(syncGetThreads((Context) parent));
}
if (parent instanceof ILaunch) {
- return syncGetContainers((TCFLaunch) parent);
+ return filterList(syncGetContainers((TCFLaunch) parent));
}
if (parent instanceof ILaunchManager) {
- return getLaunches();
+ return filterList(getLaunches());
}
return new Object[0];
}
+ public Object[] filterList(Object[] resultArray) {
+ ArrayList<Object> filteredList = new ArrayList<Object>();
+ if (fContextList.size() != 0) {
+ for (Object obj : resultArray) {
+ for (String id : fContextList) {
+ if (obj instanceof ILaunch || obj instanceof ILaunchManager ||
+ obj instanceof Context && id.equals(((Context)obj).fId)) {
+ filteredList.add(obj);
+ break;
+ }
+ }
+ }
+ }
+ if (filteredList.size() != 0) {
+ return filteredList.toArray(new Object[filteredList.size()]);
+ }
+ else {
+ return resultArray;
+ }
+ }
+
public Object getParent(Object element) {
if (element instanceof Context) {
Context ctx = (Context) element;
@@ -210,11 +235,12 @@ public class TCFThreadFilterEditor {
}
public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
+ return filterList(getChildren(inputElement));
}
public void dispose() {
}
+
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
}
@@ -259,33 +285,11 @@ public class TCFThreadFilterEditor {
private final List<Context> fContexts = new ArrayList<Context>();
private final Map<TCFLaunch, Context[]> fContainersPerLaunch = new HashMap<TCFLaunch, Context[]>();
private final Map<Context, Context[]> fContextsPerContainer = new HashMap<Context, Context[]>();
- private StackLayout stackLayout;
- private Composite basicPage;
- private Composite advancedPage;
private Combo scopeExprCombo;
private ControlDecoration scopeExpressionDecoration;
- private Button radioBasic;
- private Button radioAdvanced;
-
- public class ScopingModeListener implements SelectionListener {
- private Composite fParent;
-
- public ScopingModeListener(Composite parent) {
- fParent = parent;
- }
- public void widgetSelected(SelectionEvent e) {
- if (radioBasic.getSelection()) {
- stackLayout.topControl = basicPage;
- }
- else {
- stackLayout.topControl = advancedPage;
- }
- fParent.layout();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- }
-
+ private final ArrayList<String> fContextList = new ArrayList<String>();
+ private Link preferencesLink;
+
/**
* Returns the dialog settings or <code>null</code> if none
*
@@ -307,35 +311,10 @@ public class TCFThreadFilterEditor {
fPage = page;
fContentProvider = new ThreadFilterContentProvider();
fCheckHandler = new CheckHandler();
- Composite buttonComposite = new Composite(parent, SWT.NONE);
- buttonComposite.setLayout( new GridLayout(3, false));
- buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite mainComposite = new Composite(parent, SWT.NONE);
mainComposite.setFont(parent.getFont());
- stackLayout = new StackLayout();
mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- mainComposite.setLayout(stackLayout);
-
- radioBasic = new Button(buttonComposite, SWT.RADIO);
- radioBasic.setText(Messages.TCFThreadFilterQueryButtonBasic);
- radioBasic.addSelectionListener(new ScopingModeListener(mainComposite));
- radioAdvanced = new Button(buttonComposite, SWT.RADIO);
- radioAdvanced.setText(Messages.TCFThreadFilterQueryButtonAdvanced);
- radioAdvanced.addSelectionListener(new ScopingModeListener(mainComposite));
-
- IDialogSettings settings= getDialogSettings(false);
- if (settings != null) {
- boolean basicSelected = settings.getBoolean(Messages.TCFThreadFilterQueryModeButtonState);
- if ( basicSelected ) {
- radioBasic.setSelection(true);
- }
- else {
- radioAdvanced.setSelection(true);
- }
- }
- else {
- radioBasic.setSelection(true);
- }
+ mainComposite.setLayout(new GridLayout(2,false));
createThreadViewer(mainComposite);
}
@@ -391,6 +370,54 @@ public class TCFThreadFilterEditor {
return result;
}
+ /**
+ * Validate a Context query using the context query service.
+ * If the query is valid, also get the list of filtered contexts.
+ *
+ * @param query The query to validate
+ * @return Error String if validation has failed, else null.
+ */
+ private String getQueryFilteredContexts (final String query, final ArrayList<String> contextList) {
+
+ TCFLaunch launch = (TCFLaunch)getAttributeLaunch();
+ if (launch == null) {
+ return Messages.TCFThreadFilterEditorNoOpenChannel;
+ }
+ final IChannel channel = launch.getChannel();
+
+ if (channel == null){
+ return Messages.TCFThreadFilterEditorNoOpenChannel;
+ }
+ String result = new TCFTask<String>() {
+ public void run() {
+ IContextQuery service = channel.getRemoteService(IContextQuery.class);
+ service.query(query, new IContextQuery.DoneQuery() {
+ public void doneQuery (IToken token, Exception error, String[] contexts) {
+ String errorMessage = null;
+ if (error != null) {
+ String[] errorMessages= error.getMessage().split("\n");
+
+ for (int i=0; i < errorMessages.length; i++) {
+ String startError = Messages.TCFThreadFileterEditorInvalidQuery;
+ if (errorMessages[i].startsWith(startError)) {
+ errorMessage = errorMessages[i].substring(startError.length(), errorMessages[i].length());
+ }
+ }
+ done(errorMessage);
+ }else {
+ for (String context : contexts) {
+ contextList.add(context);
+ }
+ done(null);
+ }
+ }
+ });
+ return;
+ }
+ }.getE();
+ return result;
+ }
+
boolean missingParameterValue(String expression, int fromIndex) {
boolean result = false;
int lastIndex = expression.length();
@@ -430,9 +457,22 @@ public class TCFThreadFilterEditor {
fPage.setValid(false);
}
else {
- scopeExpressionDecoration.hide();
- fPage.setErrorMessage(null);
- fPage.setValid(true);
+ fContextList.clear();
+ String error = getQueryFilteredContexts (expression, fContextList);
+ if (error == null ) {
+ scopeExpressionDecoration.hide();
+ fPage.setErrorMessage(null);
+ fPage.setValid(true);
+ }
+ else {
+ scopeExpressionDecoration.show();
+ fPage.setErrorMessage(Messages.TCFThreadFilterEditorFormatError);
+ fPage.setValid(false);
+ }
+ scopeExprCombo.getParent().layout();
+ if (fThreadViewer != null) {
+ fThreadViewer.refresh();
+ }
}
}
}
@@ -458,8 +498,8 @@ public class TCFThreadFilterEditor {
}
}
}
-
- private void setupScopeExpressionCombo(IDialogSettings settings, String bpContextQuery) {
+
+ private void setupScopeExpressionCombo(IDialogSettings settings, String bpContextQuery, Combo comboBox) {
String [] expresionList = null;
if ( settings != null ) {
expresionList = settings.getArray(Messages.TCFThreadFilterQueryExpressionStore);
@@ -481,8 +521,8 @@ public class TCFThreadFilterEditor {
}
}
if (found != -1) {
- scopeExprCombo.setItems(copyList);
- scopeExprCombo.select(found);
+ comboBox.setItems(copyList);
+ comboBox.select(found);
}
else {
int pad = 0;
@@ -494,76 +534,86 @@ public class TCFThreadFilterEditor {
setList[0] = bpContextQuery;
}
System.arraycopy(copyList, 0, setList, pad, copyList.length);
- scopeExprCombo.setItems(setList);
+ comboBox.setItems(setList);
if (bpContextQuery != null) {
- scopeExprCombo.select(0);
+ comboBox.select(0);
}
}
}
else if (bpContextQuery != null) {
- scopeExprCombo.setItems(new String[]{bpContextQuery});
- scopeExprCombo.select(0);
+ comboBox.setItems(new String[]{bpContextQuery});
+ comboBox.select(0);
}
}
else if (bpContextQuery != null) {
- scopeExprCombo.setItems(new String[]{bpContextQuery});
- scopeExprCombo.select(0);
+ comboBox.setItems(new String[]{bpContextQuery});
+ comboBox.select(0);
+ }
+ }
+
+ public class linkSelectAdapter implements SelectionListener {
+
+ private Shell parentShell;
+
+ public linkSelectAdapter(Shell shell) {
+ parentShell = shell;
+ }
+ public void widgetSelected(SelectionEvent e) {
+ PreferencesUtil.createPreferenceDialogOn(parentShell,
+ BreakpointPreferencePage.PLUGIN_ID,
+ new String[] { BreakpointPreferencePage.PLUGIN_ID },
+ null).open();
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
}
}
private void createThreadViewer(Composite parent) {
GridData twoColumnLayout = new GridData(SWT.FILL,0, true, false);
twoColumnLayout.horizontalSpan = 2;
- advancedPage = new Composite(parent,SWT.NONE);
- advancedPage.setLayout(new GridLayout(2,false));
- advancedPage.setFont(parent.getFont());
- Label epressionLabel = new Label(advancedPage, SWT.NONE);
+ GridData comboGridData = new GridData(SWT.FILL,0, true, false);
+ comboGridData .horizontalIndent = 5;
+ IDialogSettings settings= getDialogSettings(false);
+ FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
+
+ Label epressionLabel = new Label(parent, SWT.NONE);
epressionLabel.setText(Messages.TCFThreadFilterQueryAdvancedLabel);
- epressionLabel.setFont(advancedPage.getFont());
+ epressionLabel.setFont(parent.getFont());
epressionLabel.setLayoutData(twoColumnLayout);
- scopeExprCombo = new Combo(advancedPage,SWT.DROP_DOWN);
- GridData comboGridData = new GridData(SWT.FILL,0, true, false);
- comboGridData .horizontalIndent = 5;
+ scopeExprCombo = new Combo(parent,SWT.DROP_DOWN);
scopeExprCombo.setLayoutData(comboGridData);
scopeExprCombo.addModifyListener(new ExpressionModifier());
- scopeExpressionDecoration = new ControlDecoration(scopeExprCombo, SWT.LEFT, advancedPage);
+ scopeExpressionDecoration = new ControlDecoration(scopeExprCombo, SWT.LEFT, parent);
scopeExpressionDecoration.hide();
scopeExpressionDecoration.setDescriptionText(Messages.TCFThreadFilterEditorFormatError);
- FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
scopeExpressionDecoration.setImage(fieldDecoration.getImage());
String bpContextQuery = getBPFilterExpression();
- IDialogSettings settings= getDialogSettings(false);
- setupScopeExpressionCombo(settings, bpContextQuery);
- Button selectExpression = new Button(advancedPage, SWT.PUSH);
+ setupScopeExpressionCombo(settings, bpContextQuery, scopeExprCombo);
+ Button selectExpression = new Button(parent, SWT.PUSH);
selectExpression.setText(Messages.TCFThreadFilterQueryButtonEdit);
selectExpression.setLayoutData(new GridData(SWT.RIGHT,0, false, false));
- selectExpression.addListener(SWT.Selection, new ExpressionSelectButton(parent.getShell()));
-
- basicPage = new Composite(parent, SWT.NONE);
- basicPage .setLayout(new GridLayout(1,false));
- basicPage .setFont(parent.getFont());
- Label contextTreeLabel = new Label(basicPage, SWT.NONE);
+ selectExpression.addListener(SWT.Selection, new ExpressionSelectButton(parent.getShell()));
+
+ Label contextTreeLabel = new Label(parent, SWT.NONE);
contextTreeLabel.setText(Messages.TCFThreadFilterQueryTreeViewLabel); //$NON-NLS-1$
- contextTreeLabel.setFont(basicPage.getFont());
- contextTreeLabel.setLayoutData(new GridData(SWT.FILL,0, true, false));
+ contextTreeLabel.setFont(parent.getFont());
+ contextTreeLabel.setLayoutData(twoColumnLayout);
GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = 100;
- fThreadViewer = new CheckboxTreeViewer(basicPage, SWT.BORDER);
+ fThreadViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
fThreadViewer.addCheckStateListener(fCheckHandler);
fThreadViewer.getTree().setLayoutData(data);
- fThreadViewer.getTree().setFont(basicPage.getFont());
+ fThreadViewer.getTree().setFont(parent.getFont());
fThreadViewer.setContentProvider(fContentProvider);
fThreadViewer.setLabelProvider(new ThreadFilterLabelProvider());
fThreadViewer.setInput(DebugPlugin.getDefault().getLaunchManager());
setInitialCheckedState();
- if (radioBasic.getSelection()) {
- stackLayout.topControl = basicPage;
- }
- else {
- stackLayout.topControl = advancedPage;
- }
+ preferencesLink = new Link(parent, SWT.WRAP);
+ preferencesLink.setLayoutData(twoColumnLayout);
+ preferencesLink.setText("<a>Breakpoint Default Scope Preferences</a>");
+ preferencesLink.addSelectionListener(new linkSelectAdapter(parent.getShell()));
parent.layout();
}
@@ -694,40 +744,34 @@ public class TCFThreadFilterEditor {
protected void doStore() {
IDialogSettings settings= getDialogSettings(true);
- if (settings != null) {
- settings.put(Messages.TCFThreadFilterQueryModeButtonState, radioBasic.getSelection());
- }
- if (radioAdvanced.getSelection()) {
- String scopedExpression = getScopeExpression();
+ String scopedExpression = getScopeExpression();
+ if (scopedExpression.length() != 0)
updateExpressionsDialogSettings(settings, scopedExpression);
- TCFBreakpointScopeExtension filterExtension = fPage.getFilterExtension();
- if (filterExtension == null) return;
- filterExtension.setPropertiesFilter(scopedExpression);
- filterExtension.setThreadFilter(null);
- } else if (radioBasic.getSelection()) {
- CheckboxTreeViewer viewer = getThreadViewer();
- Object[] elements = viewer.getCheckedElements();
- String[] threadIds;
- List<String> checkedIds = new ArrayList<String>();
- for (int i = 0; i < elements.length; ++i) {
- if (elements[i] instanceof Context) {
- Context ctx = (Context) elements[i];
- if (!viewer.getGrayed(ctx)) {
- checkedIds.add(ctx.fScopeId);
- }
+ TCFBreakpointScopeExtension filterExtension = fPage.getFilterExtension();
+ if (filterExtension == null) return;
+ filterExtension.setPropertiesFilter(scopedExpression);
+
+ CheckboxTreeViewer viewer = getThreadViewer();
+ Object[] elements = viewer.getCheckedElements();
+ String[] threadIds;
+ List<String> checkedIds = new ArrayList<String>();
+ for (int i = 0; i < elements.length; ++i) {
+ if (elements[i] instanceof Context) {
+ Context ctx = (Context) elements[i];
+ if (!viewer.getGrayed(ctx)) {
+ checkedIds.add(ctx.fScopeId);
}
}
- if (checkedIds.size() == fContexts.size()) {
- threadIds = null;
- }
- else {
- threadIds = checkedIds.toArray(new String[checkedIds.size()]);
- }
- TCFBreakpointScopeExtension filterExtension = fPage.getFilterExtension();
- if (filterExtension == null) return;
- filterExtension.setThreadFilter(threadIds);
- filterExtension.setPropertiesFilter(null);
}
+ if (checkedIds.size() == fContexts.size()) {
+ threadIds = null;
+ }
+ else {
+ threadIds = checkedIds.toArray(new String[checkedIds.size()]);
+ }
+ filterExtension = fPage.getFilterExtension();
+ if (filterExtension == null) return;
+ filterExtension.setThreadFilter(threadIds);
}
private Context[] syncGetContainers(final TCFLaunch launch) {
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointAdapter.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointAdapter.java
new file mode 100644
index 0000000..bac71f6
--- /dev/null
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointAdapter.java
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.cdt.ui.breakpoints;
+
+import java.math.BigInteger;
+import java.util.HashMap;
+
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.model.ICBreakpointType;
+import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint;
+import org.eclipse.cdt.debug.ui.breakpoints.AbstractToggleBreakpointAdapter;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.internal.cdt.ui.Activator;
+import org.eclipse.tcf.internal.cdt.ui.preferences.PreferenceConstants;
+import org.eclipse.tcf.internal.debug.model.ITCFConstants;
+import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel;
+import org.eclipse.tcf.internal.debug.ui.model.TCFNode;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Toggles a TCF Scoped breakpoint in a C/C++ editor.
+ */
+public class TCFToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter {
+
+ private final String TOGGLE_TYPE;
+ private bpAttributes attributes;
+
+ TCFToggleBreakpointAdapter(String toggle_type ) {
+ TOGGLE_TYPE = toggle_type;
+ attributes = new bpAttributes();
+ }
+
+ private class bpAttributes {
+ private HashMap<String, Object> attributes;
+ private String error;
+
+ bpAttributes() {
+ attributes = new HashMap<String, Object>();
+ error = null;
+ }
+
+ public void put (String str, Object obj) {
+ attributes.put(str, obj);
+ }
+
+ public HashMap<String, Object> getMap() {
+ return attributes;
+ }
+
+ public void clear() {
+ attributes.clear();
+ }
+
+ public String getError() {
+ return error;
+ }
+ }
+
+ private static IStructuredSelection getDebugContext(IWorkbenchPart part) {
+ ISelection selection = DebugUITools.getDebugContextManager().
+ getContextService(part.getSite().getWorkbenchWindow()).getActiveContext();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection)selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ private static boolean isDefaultBPContextQueryEnabled() {
+ return Platform.getPreferencesService().getBoolean(
+ Activator.PLUGIN_ID,
+ PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE_ENABLED,
+ false,
+ null);
+ }
+
+ private static String getDefaultBPContextQuery() {
+ return Platform.getPreferencesService().getString(
+ Activator.PLUGIN_ID,
+ PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE,
+ null,
+ null);
+ }
+
+ private static Boolean checkToggleType ( IWorkbenchPart part, final String toggleType, final bpAttributes attributes) {
+ Boolean bFoundError = false;
+ if ( part != null ) {
+ Object obj = getDebugContext(part).getFirstElement();
+ if ( obj instanceof TCFNode ) {
+ if ( toggleType.length() != 0) {
+ attributes.clear();
+ if (isDefaultBPContextQueryEnabled() == true) {
+ String query = getDefaultBPContextQuery();
+ attributes.put(TCFBreakpointsModel.ATTR_CONTEXT_QUERY, query);
+ }
+ }
+ }
+ }
+ return bFoundError;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractToggleBreakpointAdapter#findLineBreakpoint(java.lang.String, org.eclipse.core.resources.IResource, int)
+ */
+ @Override
+ protected ICLineBreakpoint findLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
+ return CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractToggleBreakpointAdapter#createLineBreakpoint(java.lang.String, org.eclipse.core.resources.IResource, int)
+ */
+ @Override
+ protected void createLineBreakpoint( boolean interactive, IWorkbenchPart part, final String sourceHandle, final IResource resource, final int lineNumber ) throws CoreException {
+ Boolean bFoundError = checkToggleType(part, TOGGLE_TYPE, attributes);
+ if (!bFoundError ) {
+ ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineBreakpoint();
+ CDIDebugModel.setLineBreakpointAttributes(
+ attributes.getMap(), sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$
+ if ( !interactive ) {
+ CDIDebugModel.createBreakpointMarker(lineBp, resource, attributes.getMap(), true);
+ }
+ else {
+ openBreakpointPropertiesDialog(lineBp, part, resource, attributes.getMap());
+ }
+ }
+ else {
+ // Throw an error to the user.
+ IStatus error = new Status(IStatus.ERROR, ITCFConstants.ID_TCF_DEBUG_MODEL, attributes.getError(), null);
+ ErrorDialog.openError(null, Messages.TCFBreakpointToggleError, null, error);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractToggleBreakpointAdapter#findFunctionBreakpoint(java.lang.String, org.eclipse.core.resources.IResource, java.lang.String)
+ */
+ @Override
+ protected ICFunctionBreakpoint findFunctionBreakpoint(
+ String sourceHandle,
+ IResource resource,
+ String functionName ) throws CoreException {
+ return CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractToggleBreakpointAdapter#createFunctionBreakpoint(java.lang.String, org.eclipse.core.resources.IResource, java.lang.String, int, int, int)
+ */
+ @Override
+ protected void createFunctionBreakpoint(
+ boolean interactive,
+ IWorkbenchPart part,
+ String sourceHandle,
+ IResource resource,
+ String functionName,
+ int charStart,
+ int charEnd,
+ int lineNumber ) throws CoreException {
+ Boolean bFoundError = checkToggleType(part, TOGGLE_TYPE, attributes);
+ if (!bFoundError) {
+ ICFunctionBreakpoint bp = CDIDebugModel.createBlankFunctionBreakpoint();
+ CDIDebugModel.setFunctionBreakpointAttributes( attributes.getMap(), sourceHandle, getBreakpointType(), functionName,
+ charStart, charEnd, lineNumber, true, 0, "" ); //$NON-NLS-1$
+ if (!interactive) {
+ CDIDebugModel.createBreakpointMarker(bp, resource, attributes.getMap(), true);
+ }
+ else {
+ openBreakpointPropertiesDialog(bp, part, resource, attributes.getMap());
+ }
+ }
+ else {
+ // Throw an error to the user.
+ IStatus error = new Status(IStatus.ERROR, ITCFConstants.ID_TCF_DEBUG_MODEL, attributes.getError(), null);
+ ErrorDialog.openError(null, Messages.TCFBreakpointToggleError, null, error);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.ui.actions.AbstractToggleBreakpointAdapter#findWatchpoint(java.lang.String, org.eclipse.core.resources.IResource, java.lang.String)
+ */
+ @Override
+ protected ICWatchpoint findWatchpoint( String sourceHandle, IResource resource, String expression ) throws CoreException {
+ return CDIDebugModel.watchpointExists( sourceHandle, resource, expression );
+ }
+
+ protected int getBreakpointType() {
+ return ICBreakpointType.REGULAR;
+ }
+
+ @Override
+ protected void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, int charStart, int charEnd, int lineNumber,
+ String expression, String memorySpace, String range) throws CoreException {
+ Boolean bFoundError = checkToggleType(part, TOGGLE_TYPE, attributes);
+ if (!bFoundError) {
+ ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
+ CDIDebugModel.setWatchPointAttributes(attributes.getMap(), sourceHandle, resource, true, false,
+ expression, memorySpace, new BigInteger(range), true, 0, ""); //$NON-NLS-1$
+ openBreakpointPropertiesDialog(bp, part, resource, attributes.getMap());
+ }
+ else {
+ // Throw an error to the user.
+ IStatus error = new Status(IStatus.ERROR, ITCFConstants.ID_TCF_DEBUG_MODEL, attributes.getError(), null);
+ ErrorDialog.openError(null, Messages.TCFBreakpointToggleError, null, error);
+ }
+ }
+
+ @Override
+ protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type, String arg) throws CoreException {
+ Boolean bFoundError = checkToggleType(part, TOGGLE_TYPE, attributes);
+ if (!bFoundError) {
+ ICEventBreakpoint bp = CDIDebugModel.createBlankEventBreakpoint();
+ CDIDebugModel.setEventBreakpointAttributes(attributes.getMap(),type, arg);
+ openBreakpointPropertiesDialog(bp, part, resource, attributes.getMap());
+ }
+ else {
+ // Throw an error to the user.
+ IStatus error = new Status(IStatus.ERROR, ITCFConstants.ID_TCF_DEBUG_MODEL, attributes.getError(), null);
+ ErrorDialog.openError(null, Messages.TCFBreakpointToggleError, null, error);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointsTargetFactory.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointsTargetFactory.java
new file mode 100644
index 0000000..45c4fbc
--- /dev/null
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/TCFToggleBreakpointsTargetFactory.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.cdt.ui.breakpoints;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.internal.cdt.ui.Activator;
+import org.eclipse.tcf.internal.cdt.ui.preferences.PreferenceConstants;
+import org.eclipse.tcf.internal.debug.model.ITCFConstants;
+import org.eclipse.tcf.internal.debug.ui.model.TCFNode;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Toggle breakpoints target factory.
+ * We use a separate factory so that we can control it through an action set.
+ *
+ */
+
+public class TCFToggleBreakpointsTargetFactory implements IToggleBreakpointsTargetFactory {
+
+ public static final String ID_TCF_BREAKPOINT_TOGGLE_TARGET = ITCFConstants.ID_TCF_DEBUG_MODEL + ".toggleTCFBreakpoint";
+
+ private static final Set<String> BP_TOGGLE_TYPE_SET = new HashSet<String>(2);
+
+ static {
+ BP_TOGGLE_TYPE_SET.add(ID_TCF_BREAKPOINT_TOGGLE_TARGET);
+ }
+
+ private Map<String, TCFToggleBreakpointAdapter> fAdapterMap = new HashMap<String, TCFToggleBreakpointAdapter>();
+
+ public IToggleBreakpointsTarget createToggleTarget(String targetID) {
+ TCFToggleBreakpointAdapter adapter = null;
+ if ( ID_TCF_BREAKPOINT_TOGGLE_TARGET.equals(targetID)) {
+ if (fAdapterMap != null && !fAdapterMap.isEmpty()) {
+ adapter = fAdapterMap.get(ID_TCF_BREAKPOINT_TOGGLE_TARGET);
+ }
+ if (adapter == null) {
+ adapter = new TCFToggleBreakpointAdapter(ID_TCF_BREAKPOINT_TOGGLE_TARGET);
+ fAdapterMap.put(ID_TCF_BREAKPOINT_TOGGLE_TARGET, adapter);
+ }
+ }
+ return adapter;
+ }
+
+ public String getToggleTargetDescription(String targetID) {
+ if (ID_TCF_BREAKPOINT_TOGGLE_TARGET.equals(targetID)) {
+ String scope = getDefaultBPContextQuery();
+ if (scope == null) scope = "None";
+ return MessageFormat.format(Messages.TCFBreakpointToggle, scope);
+ }
+ return null;
+ }
+
+ public String getToggleTargetName(String targetID) {
+ if (ID_TCF_BREAKPOINT_TOGGLE_TARGET.equals(targetID)) {
+ String scope = getDefaultBPContextQuery();
+ if (scope == null ) scope = "None";
+ return MessageFormat.format(Messages.TCFBreakpointToggle, scope);
+ }
+ return null;
+ }
+
+ public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
+ if (isTCFBreakpointActive(part, selection)) {
+ return ID_TCF_BREAKPOINT_TOGGLE_TARGET;
+ }
+ return null;
+ }
+
+ public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) {
+ if (isTCFBreakpointActive(part, selection)) {
+ return BP_TOGGLE_TYPE_SET;
+ }
+ return Collections.emptySet();
+ }
+
+ private static IStructuredSelection getDebugContext(IWorkbenchPart part) {
+ ISelection selection = DebugUITools.getDebugContextManager().
+ getContextService(part.getSite().getWorkbenchWindow()).getActiveContext();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection)selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ private static boolean isTCFBreakpointActive(IWorkbenchPart part, ISelection selection) {
+ if (selection != null && !selection.isEmpty()) {
+ // If the selection has the context data we want, use it.
+ if (selection instanceof IStructuredSelection) {
+ Object obj = ((IStructuredSelection)selection).getFirstElement();
+ if (obj instanceof TCFNode) {
+ return true;
+ }
+ }
+ }
+ if (part != null) {
+ // Get the debug context from the WorkbenchPart.
+ Object obj = getDebugContext(part).getFirstElement();
+ if (obj instanceof TCFNode) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean isDefaultBPContextQueryEnabled() {
+ return Platform.getPreferencesService().getBoolean(
+ Activator.PLUGIN_ID,
+ PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE_ENABLED,
+ false,
+ null);
+ }
+
+ private static String getDefaultBPContextQuery() {
+ String result = null;
+ if (isDefaultBPContextQueryEnabled()) {
+ result = Platform.getPreferencesService().getString(
+ Activator.PLUGIN_ID,
+ PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE,
+ null,
+ null);
+ }
+ return result;
+ }
+}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/ToggleTCFBreakpointTester.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/ToggleTCFBreakpointTester.java
new file mode 100644
index 0000000..2de3852
--- /dev/null
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/ToggleTCFBreakpointTester.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.cdt.ui.breakpoints;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.tcf.internal.debug.model.TCFLaunch;
+
+public class ToggleTCFBreakpointTester extends PropertyTester {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if ( "isTCFBreakpointSupported".equals(property) ) { //$NON-NLS-1$
+ ILaunch launch = getAttributeLaunch();
+ if (launch != null && launch instanceof TCFLaunch) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected ILaunch getAttributeLaunch() {
+ ILaunch launch = null;
+ IAdaptable dbgContext = DebugUITools.getDebugContext();
+ if (dbgContext != null) {
+ launch = (ILaunch)dbgContext.getAdapter(ILaunch.class);
+ }
+ return launch;
+ }
+}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties
index 3b29d8d..9e26f3c 100644
--- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/messages.properties
@@ -10,12 +10,23 @@
###############################################################################
TCFThreadFilterQueryExpressionStore=TCFThreadFilter.ScopedExpressionList
TCFThreadFilterQueryModeButtonState=TCFThreadFilter.radioBasic.Selection
-TCFThreadFilterQueryButtonBasic=Basic
-TCFThreadFilterQueryButtonAdvanced=Advanced
+TCFThreadUseDefaultTriggerScoping=TCFThreadFilter.enableDefaulTriggerScopeCheckBox.Selection
+TCFThreadDefaultTriggerScope=Default Trigger Scope
+TCFThreadFilterQueryButtonBasic=Scope Settings
+TCFThreadFilterQueryButtonAdvanced=Default Settings
TCFThreadFilterQueryButtonEdit=Edit
TCFThreadFilterQueryAdvancedLabel=Breakpoint Scoping Expression:
TCFThreadFilterQueryTreeViewLabel=Restrict to Selected Contexts:
TCFThreadFilterEditorFormatError=Parameters must be name value pairs
+TCFThreadFilterEditorNoOpenChannel=No open connection to target
+TCFThreadFileterEditorInvalidQuery=Invalid context query syntax:
+TCFBreakpointPreferencesEnableDefaultTriggerScope=Apply scope to new breakpoints
+TCFBreakpointPreferencesTriggerScopeExpression=Default Scope Expression
+TCFBreakpointPreferencesDescription=Breakpoint settings for debuggers using Target Communication Framework (TCF)
+TCFBreakpointPrefrencesError=TCF Breakpoint Types must be selected for these options
+TCFBreakpointToggle=C/C++ Breakpoints ( Scope: {0} )
+TCFBreakpointToggleCannotFindMemory=Could not find a memory context. Please double check context selection, or change scoping rules
+TCFBreakpointToggleError=Error In Processing Breakpoint
BreakpointScopeCategory_filter_label=Filter: {0}
BreakpointScopeCategory_contexts_label=Contexts: {0}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/BreakpointPreferencePage.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/BreakpointPreferencePage.java
new file mode 100644
index 0000000..d9f8eac
--- /dev/null
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/BreakpointPreferencePage.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.cdt.ui.preferences;
+
+import java.util.Set;
+
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.preference.*;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.tcf.internal.cdt.ui.Activator;
+import org.eclipse.tcf.internal.cdt.ui.breakpoints.Messages;
+import org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFThreadFilterEditor;
+import org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFToggleBreakpointsTargetFactory;
+
+public class BreakpointPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
+
+ public static final String PLUGIN_ID="org.eclipse.tcf.cdt.ui.preferences.BreakpointPreferencePage";
+
+ BooleanFieldEditor setDefaultTriggerCheckbox;
+ ComboFieldEditor defaultTriggerExpressoinCombo;
+ public BreakpointPreferencePage() {
+ super(GRID);
+ setPreferenceStore(Activator.getDefault().getPreferenceStore());
+ setDescription(Messages.TCFBreakpointPreferencesDescription);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ super.propertyChange(event);
+ Object button = event.getSource();
+ if (button instanceof BooleanFieldEditor) {
+ BooleanFieldEditor fe = (BooleanFieldEditor)button;
+ defaultTriggerExpressoinCombo.setEnabled(fe.getBooleanValue(), getFieldEditorParent());
+ }
+ }
+
+ public void createFieldEditors() {
+ setDefaultTriggerCheckbox = new BooleanFieldEditor(
+ PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE_ENABLED,
+ Messages.TCFBreakpointPreferencesEnableDefaultTriggerScope,
+ getFieldEditorParent());
+
+ addField(setDefaultTriggerCheckbox);
+ String [] expressionList = getTriggerExpressions();
+
+ defaultTriggerExpressoinCombo = new ComboFieldEditor(
+ PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE,
+ Messages.TCFBreakpointPreferencesTriggerScopeExpression,
+ joinToArray2D(expressionList,expressionList),
+ getFieldEditorParent());
+
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ defaultTriggerExpressoinCombo.setEnabled(
+ store.getBoolean(PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE_ENABLED),
+ getFieldEditorParent());
+
+ addField(defaultTriggerExpressoinCombo);
+
+ if (!checkTCFToggleBreakpointAdapter()) {
+ setMessage(Messages.TCFBreakpointPrefrencesError, WARNING);
+ setValid(false);
+ setDefaultTriggerCheckbox.setEnabled(false, getFieldEditorParent());
+ defaultTriggerExpressoinCombo.setEnabled(false, getFieldEditorParent());
+ }
+ else {
+ setErrorMessage(null);
+ setValid(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ private String[] getTriggerExpressions() {
+ IDialogSettings dialogSettings = getBreakpointScopeDialogSettings();
+ String[] returnList = null;
+ String[] expressionList = null;
+
+ if ( dialogSettings != null ) {
+ expressionList = dialogSettings.getArray(Messages.TCFThreadFilterQueryExpressionStore);
+ int index;
+ // Find if there is a null entry.
+ for(index = 0; index < expressionList.length; index++) {
+ String member = expressionList[index];
+ if (member == null || member.length() == 0) {
+ break;
+ }
+ }
+ returnList = new String[index+1];
+ returnList[0]="";
+ for (int loop = 0; loop < index; loop++) {
+ returnList[loop+1] = expressionList[loop];
+ }
+ }
+ return returnList;
+ }
+
+ private IDialogSettings getBreakpointScopeDialogSettings() {
+ String component = TCFThreadFilterEditor.PLUGIN_ID;
+ IDialogSettings settings = Activator.getDefault()
+ .getDialogSettings();
+ IDialogSettings section = settings.getSection(component);
+ return section;
+ }
+
+ private String[][] joinToArray2D(String[] labels, String[] values) {
+ String[][] array2d = new String[labels.length][];
+ for (int i = 0; i < labels.length; i++) {
+ array2d[i] = new String[2];
+ array2d[i][0] = labels[i];
+ array2d[i][1] = values[i];
+ }
+ return array2d;
+ }
+
+ private boolean checkTCFToggleBreakpointAdapter() {
+ IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if (part == null) {
+ part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
+ }
+ if (part != null) {
+ ISelection selection = part.getSite().getWorkbenchWindow().getSelectionService().getSelection();
+ Set<?> enablers = DebugUITools.getToggleBreakpointsTargetManager().getEnabledToggleBreakpointsTargetIDs(part, selection);
+
+ if (enablers != null &&
+ !enablers.contains(TCFToggleBreakpointsTargetFactory.ID_TCF_BREAKPOINT_TOGGLE_TARGET)) {
+ return true;
+ }
+
+ String preferred = DebugUITools.getToggleBreakpointsTargetManager().getPreferredToggleBreakpointsTargetID(part, selection);
+ if (preferred != null &&
+ !preferred.equals(TCFToggleBreakpointsTargetFactory.ID_TCF_BREAKPOINT_TOGGLE_TARGET)) {
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceConstants.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..941d40c
--- /dev/null
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceConstants.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.cdt.ui.preferences;
+
+/**
+ * Constant definitions for plug-in preferences
+ */
+public class PreferenceConstants {
+ public static final String PREF_DEFAULT_TRIGGER_SCOPE_ENABLED = BreakpointPreferencePage.PLUGIN_ID + ".setDefaultTriggerScopeEnabled";
+ public static final String PREF_DEFAULT_TRIGGER_SCOPE = BreakpointPreferencePage.PLUGIN_ID + ".defaultTriggerExpression";
+}
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceInitializer.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceInitializer.java
new file mode 100644
index 0000000..28babdc
--- /dev/null
+++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/preferences/PreferenceInitializer.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.internal.cdt.ui.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+import org.eclipse.tcf.internal.cdt.ui.Activator;
+
+/**
+ * Class used to initialize default preference values.
+ */
+public class PreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ store.setDefault(PreferenceConstants.PREF_DEFAULT_TRIGGER_SCOPE_ENABLED, false);
+ }
+}