From ff9a3748226fa8ec75b5b08a246a510fd089e746 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Tue, 18 Feb 2014 14:48:15 +0100 Subject: TCF Debugger: Bug 428202 - Allow to edit the breakpoint scope expression when offline --- .../tcf/internal/cdt/ui/breakpoints/Messages.java | 6 ++++- .../cdt/ui/breakpoints/TCFThreadFilterEditor.java | 27 ++++++++++++++-------- .../ui/breakpoints/TCFToggleBreakpointAdapter.java | 5 ++-- .../TCFToggleBreakpointsTargetFactory.java | 7 +++--- .../cdt/ui/breakpoints/messages.properties | 4 +++- 5 files changed, 32 insertions(+), 17 deletions(-) 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 9328a42df..e0e9b1fbb 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2012, 2014 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 @@ -23,6 +23,10 @@ public class Messages extends NLS { public static String TCFThreadFilterQueryButtonEdit; public static String TCFThreadFilterQueryAdvancedLabel; public static String TCFThreadFilterQueryTreeViewLabel; + public static String TCFThreadFilterEditor_cannotValidate; + + public static String TCFThreadFilterEditor_defaultScopePrefsLink; + public static String TCFThreadFilterEditorFormatError; public static String TCFThreadFilterEditorUnbalancedParameters; public static String TCFThreadFilterEditorNoOpenChannel; 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 ddd81d23c..f260a194e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 QNX Software Systems and others. + * Copyright (c) 2004, 2014 QNX Software Systems 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 @@ -41,6 +41,7 @@ import org.eclipse.jface.viewers.ITreeContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.window.Window; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; @@ -78,7 +79,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; public class TCFThreadFilterEditor { - public static final String PLUGIN_ID="org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFThreadFilterEditor"; + public static final String PLUGIN_ID="org.eclipse.tcf.internal.cdt.ui.breakpoints.TCFThreadFilterEditor"; //$NON-NLS-1$ private static class Context { private final String fName; @@ -102,7 +103,7 @@ public class TCFThreadFilterEditor { fParentId = ctx.getParentID(); fIsContainer = !ctx.hasState(); fBpGroup = ctx.getBPGroup(); - fAdditionalInfo = ctx.getProperties().get("AdditionalInfo"); + fAdditionalInfo = ctx.getProperties().get("AdditionalInfo"); //$NON-NLS-1$ } @@ -308,7 +309,7 @@ public class TCFThreadFilterEditor { ILaunchConfiguration config = ((ILaunch) element).getLaunchConfiguration(); if (config != null) return config.getName(); } - return "?"; + return "?"; //$NON-NLS-1$ } } @@ -400,7 +401,7 @@ public class TCFThreadFilterEditor { private String getQueryFilteredContexts (final String query, final Set contextList) { TCFLaunch launch = (TCFLaunch)getAttributeLaunch(); - if (launch == null) { + if (launch == null || launch.isTerminated()) { return Messages.TCFThreadFilterEditorNoOpenChannel; } final IChannel channel = launch.getChannel(); @@ -434,16 +435,16 @@ public class TCFThreadFilterEditor { String result = null; // Ignore content in double-quotes. - Pattern p = Pattern.compile("\"((?:\\\\\\\\|\\\\\"|[^\"])*)\""); + Pattern p = Pattern.compile("\"((?:\\\\\\\\|\\\\\"|[^\"])*)\""); //$NON-NLS-1$ Matcher m = p.matcher(expression); - expression = m.replaceAll("temp"); + expression = m.replaceAll("temp"); //$NON-NLS-1$ // No whitespace - if (expression.matches("^(.*?)(\\s)(.*)$")) + if (expression.matches("^(.*?)(\\s)(.*)$")) //$NON-NLS-1$ return Messages.TCFThreadFilterEditorFormatError; // Check characters around equals. - if (expression.matches("^(.*?)[^a-zA-Z0-9_]=[^a-zA-Z0-9_](.*)$")) + if (expression.matches("^(.*?)[^a-zA-Z0-9_]=[^a-zA-Z0-9_](.*)$")) //$NON-NLS-1$ return Messages.TCFThreadFilterEditorUnbalancedParameters; return result; @@ -467,6 +468,12 @@ public class TCFThreadFilterEditor { fPage.setErrorMessage(null); fPage.setValid(true); } + else if (error == Messages.TCFThreadFilterEditorNoOpenChannel) { + // if no open channel, allow to edit expression nonetheless + scopeExpressionDecoration.hide(); + fPage.setErrorMessage(NLS.bind(Messages.TCFThreadFilterEditor_cannotValidate, error)); + fPage.setValid(true); + } else { scopeExpressionDecoration.show(); fPage.setErrorMessage(error); @@ -628,7 +635,7 @@ public class TCFThreadFilterEditor { preferencesLink = new Link(parent, SWT.WRAP); preferencesLink.setLayoutData(twoColumnLayout); - preferencesLink.setText("Breakpoint Default Scope Preferences"); + preferencesLink.setText(Messages.TCFThreadFilterEditor_defaultScopePrefsLink); preferencesLink.addSelectionListener(new linkSelectAdapter(parent.getShell())); parent.layout(); } 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 index 1994a259e..a83da11f6 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 @@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.tcf.internal.cdt.ui.Activator; import org.eclipse.tcf.internal.cdt.ui.preferences.PreferenceConstants; import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel; +import org.eclipse.tcf.internal.debug.model.TCFLaunch; import org.eclipse.tcf.internal.debug.ui.model.TCFNode; import org.eclipse.ui.IWorkbenchPart; @@ -79,7 +80,7 @@ public class TCFToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter Map attributes = new TreeMap(); if ( part != null ) { Object obj = getDebugContext(part).getFirstElement(); - if ( obj instanceof TCFNode ) { + if ( obj instanceof TCFNode || obj instanceof TCFLaunch ) { if ( toggleType.length() != 0) { attributes.clear(); if (isDefaultBPContextQueryEnabled() == true) { 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 index 69930df43..055a70846 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2014 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 @@ -27,6 +27,7 @@ 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.TCFLaunch; import org.eclipse.tcf.internal.debug.ui.model.TCFNode; import org.eclipse.ui.IWorkbenchPart; @@ -108,7 +109,7 @@ public class TCFToggleBreakpointsTargetFactory implements IToggleBreakpointsTarg // If the selection has the context data we want, use it. if (selection instanceof IStructuredSelection) { Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj instanceof TCFNode) { + if (obj instanceof TCFNode || obj instanceof TCFLaunch) { return true; } } @@ -116,7 +117,7 @@ public class TCFToggleBreakpointsTargetFactory implements IToggleBreakpointsTarg if (part != null) { // Get the debug context from the WorkbenchPart. Object obj = getDebugContext(part).getFirstElement(); - if (obj instanceof TCFNode) { + if (obj instanceof TCFNode || obj instanceof TCFLaunch) { return true; } } 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 a9b6716f5..e1c908a8c 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 @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. +# Copyright (c) 2012, 2014 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 @@ -16,6 +16,8 @@ TCFThreadFilterQueryButtonAdvanced=Default Settings TCFThreadFilterQueryButtonEdit=Edit TCFThreadFilterQueryAdvancedLabel=Breakpoint Scoping Expression: TCFThreadFilterQueryTreeViewLabel=Restrict to Selected Contexts: +TCFThreadFilterEditor_cannotValidate=Cannot validate scope expression: {0} +TCFThreadFilterEditor_defaultScopePrefsLink=Breakpoint Default Scope Preferences TCFThreadFilterEditorUnbalancedParameters=Parameters must be name value pairs TCFThreadFilterEditorFormatError=Unquoted text must contain alphanumeric characters or '_' TCFThreadFilterEditorNoOpenChannel=No open connection to target -- cgit v1.2.3