diff options
7 files changed, 359 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/META-INF/MANIFEST.MF index 4aa7332e5..1b613ca35 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/META-INF/MANIFEST.MF @@ -44,3 +44,4 @@ Export-Package: org.eclipse.tcf.te.tcf.launch.cdt.activator;x-internal:=true, org.eclipse.tcf.te.tcf.launch.cdt.preferences, org.eclipse.tcf.te.tcf.launch.cdt.tabs, org.eclipse.tcf.te.tcf.launch.cdt.utils +Bundle-Localization: plugin diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/build.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/build.properties index 421679e2d..89fbb912a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/build.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/build.properties @@ -17,4 +17,5 @@ bin.includes = META-INF/,\ about.ini,\ about.mappings,\ about.properties,\ - te-feature.png + te-feature.png,\ + plugin.properties diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.properties new file mode 100644 index 000000000..2402a1ad6 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.properties @@ -0,0 +1,13 @@ +################################################################################## +# Copyright (c) 2015 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 +################################################################################## + +# ***** Preference and Property Pages ***** + +preference.page.name = GDB Launcher diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml index f6225dbbd..38b341941 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/plugin.xml @@ -171,5 +171,15 @@ Anna Dushistova (MontaVista) - adapted from org.eclipse.cdt.launch.remote class="org.eclipse.tcf.te.tcf.launch.cdt.preferences.PreferencesInitializer"> </initializer> </extension> + +<!-- Preference page contributions --> + <extension point="org.eclipse.ui.preferencePages"> + <page + category="org.eclipse.tcf.te.ui.preferences.general" + class="org.eclipse.tcf.te.tcf.launch.cdt.preferences.GdbPreferencePage" + id="org.eclipse.tcf.te.tcf.launch.cdt.preferences.gdb" + name="%preference.page.name"> + </page> + </extension> </plugin> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java index 97f0be5a5..9a7bef9dd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java @@ -57,6 +57,15 @@ public class Messages extends NLS { public static String TEGdbAbstractLaunchDelegate_error_addressInUse; public static String TEGdbAbstractLaunchDelegate_error_nosuchfileordirectory; + public static String GdbPreferencePage_label; + public static String GdbPreferencePage_portList_label; + public static String GdbPreferencePage_mappedToPortList_label; + public static String GdbPreferencePage_appLaunchGroup_label; + public static String GdbPreferencePage_attachLaunchGroup_label; + public static String GdbPreferencePage_portList_error; + public static String GdbPreferencePage_portList_error_portList; + public static String GdbPreferencePage_portList_error_mappedToPortList; + static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties index 0f2a2bf0c..930814755 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties @@ -60,3 +60,13 @@ Also check that the gdbserver package is installed on the target. TCFPeerSelector_0=Connection: TEGdbAbstractLaunchDelegate_canceledMsg=Canceled by user + +GdbPreferencePage_label=Gdbserver port settings +GdbPreferencePage_portList_label=Port numbers: +GdbPreferencePage_mappedToPortList_label=Mapped to: +GdbPreferencePage_appLaunchGroup_label=C/C++ Remote Application Launches +GdbPreferencePage_attachLaunchGroup_label=C/C++ Attach to Application Launches +GdbPreferencePage_portList_error=Please enter a comma separated list of {0}. +GdbPreferencePage_portList_error_portList=port numbers +GdbPreferencePage_portList_error_mappedToPortList=mapped port numbers + diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/GdbPreferencePage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/GdbPreferencePage.java new file mode 100644 index 000000000..fbe8f5d95 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/preferences/GdbPreferencePage.java @@ -0,0 +1,314 @@ +/******************************************************************************* + * Copyright (c) 2015 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.te.tcf.launch.cdt.preferences; + +import java.util.regex.Pattern; + +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceStore; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences; +import org.eclipse.tcf.te.tcf.launch.cdt.activator.Activator; +import org.eclipse.tcf.te.tcf.launch.cdt.nls.Messages; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * GDB launcher preference page implementation. + */ +public class GdbPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + // References to the field editors + private StringFieldEditor portList; + private StringFieldEditor mappedToPortList; + private StringFieldEditor portListAttach; + private StringFieldEditor mappedToPortListAttach; + + + // The preference store used internally for the field editors + private IPreferenceStore store; + + /** + * Port list field editor implementation. + */ + private abstract class PortListFieldEditor extends StringFieldEditor { + private Pattern valid = Pattern.compile("[1-9][0-9,]*"); //$NON-NLS-1$ + + /** + * Constructor. + * + * @param name The name of the preference this field editor works on. + * @param labelText The label text. + * @param parent the parent of the field editor's control + */ + public PortListFieldEditor(String name, String labelText, Composite parent) { + super(name, labelText, parent); + this.setEmptyStringAllowed(true); + this.setErrorMessage(NLS.bind(Messages.GdbPreferencePage_portList_error, getErrorLabel())); + } + + /** + * Returns the label of the port list for the error message. + */ + protected abstract String getErrorLabel(); + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.StringFieldEditor#doCheckState() + */ + @Override + protected boolean doCheckState() { + if ("".equals(getStringValue())) { //$NON-NLS-1$ + return isEmptyStringAllowed(); + } else if (valid.matcher(getStringValue()).matches()) { + return true; + } + return false; + } + } + + /** + * Constructor + */ + public GdbPreferencePage() { + super(FieldEditorPreferencePage.GRID); + + // The internal preference store never needs saving + store = new PreferenceStore() { + @Override + public boolean needsSaving() { + return false; + } + }; + } + + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + @Override + public void init(IWorkbench workbench) { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() + */ + @Override + protected void createFieldEditors() { + Composite parent = getFieldEditorParent(); + ((GridLayout)parent.getLayout()).makeColumnsEqualWidth = false; + + Composite panel = new Composite(parent, SWT.NONE); + panel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; layout.marginWidth = 0; + panel.setLayout(layout); + panel.setFont(parent.getFont()); + + Label label = new Label(panel, SWT.HORIZONTAL); + label.setText(Messages.GdbPreferencePage_label); + GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false); + label.setLayoutData(layoutData); + + Group appLaunchGroup = new Group(panel, SWT.NONE); + appLaunchGroup.setText(Messages.GdbPreferencePage_appLaunchGroup_label); + appLaunchGroup.setLayout(new GridLayout()); + appLaunchGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + Composite panel2 = new Composite(appLaunchGroup, SWT.NONE); + panel2.setLayout(new GridLayout()); + panel2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + portList = new PortListFieldEditor("portList", Messages.GdbPreferencePage_portList_label, panel2) { //$NON-NLS-1$ + @Override + protected String getErrorLabel() { + return Messages.GdbPreferencePage_portList_error_portList; + } + }; + addField(portList); + + mappedToPortList = new PortListFieldEditor("mappedToPortList", Messages.GdbPreferencePage_mappedToPortList_label, panel2) { //$NON-NLS-1$ + @Override + protected String getErrorLabel() { + return Messages.GdbPreferencePage_portList_error_mappedToPortList; + } + }; + addField(mappedToPortList); + + Group attachLaunchGroup = new Group(panel, SWT.NONE); + attachLaunchGroup.setText(Messages.GdbPreferencePage_attachLaunchGroup_label); + attachLaunchGroup.setLayout(new GridLayout()); + attachLaunchGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + Composite panel3 = new Composite(attachLaunchGroup, SWT.NONE); + panel3.setLayout(new GridLayout()); + panel3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + portListAttach = new PortListFieldEditor("portListAttach", Messages.GdbPreferencePage_portList_label, panel3) { //$NON-NLS-1$ + @Override + protected String getErrorLabel() { + return Messages.GdbPreferencePage_portList_error_portList; + } + }; + addField(portListAttach); + + mappedToPortListAttach = new PortListFieldEditor("mappedToPortListAttach", Messages.GdbPreferencePage_mappedToPortList_label, panel3) { //$NON-NLS-1$ + @Override + protected String getErrorLabel() { + return Messages.GdbPreferencePage_portList_error_mappedToPortList; + } + }; + addField(mappedToPortListAttach); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore() + */ + @Override + public IPreferenceStore getPreferenceStore() { + return store; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#initialize() + */ + @Override + protected void initialize() { + ScopedEclipsePreferences prefs = Activator.getScopedPreferences(); + + String port = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT); + String portAlternatives = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_ALTERNATIVES); + + String portList = ""; //$NON-NLS-1$ + if (port != null && !"".equals(port)) portList += port.trim(); //$NON-NLS-1$ + if (portAlternatives != null && !"".equals(portAlternatives)) portList += "," + portAlternatives.trim(); //$NON-NLS-1$ //$NON-NLS-2$ + + store.setDefault("portList", portList); //$NON-NLS-1$ + store.setValue("portList", portList); //$NON-NLS-1$ + + String mappedTo = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO); + String mappedToAlternatives = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES); + + String mappedToList = ""; //$NON-NLS-1$ + if (mappedTo != null && !"".equals(mappedTo)) mappedToList += mappedTo.trim(); //$NON-NLS-1$ + if (mappedToAlternatives != null && !"".equals(mappedToAlternatives)) mappedToList += "," + mappedToAlternatives.trim(); //$NON-NLS-1$ //$NON-NLS-2$ + + store.setDefault("mappedToPortList", mappedToList); //$NON-NLS-1$ + store.setValue("mappedToPortList", mappedToList); //$NON-NLS-1$ + + port = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH); + portAlternatives = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_ALTERNATIVES); + + portList = ""; //$NON-NLS-1$ + if (port != null && !"".equals(port)) portList += port.trim(); //$NON-NLS-1$ + if (portAlternatives != null && !"".equals(portAlternatives)) portList += "," + portAlternatives.trim(); //$NON-NLS-1$ //$NON-NLS-2$ + + store.setDefault("portListAttach", portList); //$NON-NLS-1$ + store.setValue("portListAttach", portList); //$NON-NLS-1$ + + mappedTo = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO); + mappedToAlternatives = prefs.getString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO_ALTERNATIVES); + + mappedToList = ""; //$NON-NLS-1$ + if (mappedTo != null && !"".equals(mappedTo)) mappedToList += mappedTo.trim(); //$NON-NLS-1$ + if (mappedToAlternatives != null && !"".equals(mappedToAlternatives)) mappedToList += "," + mappedToAlternatives.trim(); //$NON-NLS-1$ //$NON-NLS-2$ + + store.setDefault("mappedToPortListAttach", mappedToList); //$NON-NLS-1$ + store.setValue("mappedToPortListAttach", mappedToList); //$NON-NLS-1$ + + // Load values into field editors + super.initialize(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() + */ + @Override + public boolean performOk() { + boolean success = super.performOk(); + + if (success) { + ScopedEclipsePreferences prefs = Activator.getScopedPreferences(); + + String portList = store.getString("portList"); //$NON-NLS-1$ + + if ("".equals(portList.trim())) { //$NON-NLS-1$ + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT, null); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ALTERNATIVES, null); + } else { + int idx = portList.indexOf(','); + if (idx == -1) { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT, portList.trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ALTERNATIVES, null); + } else { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT, portList.substring(0, idx).trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ALTERNATIVES, portList.length() > (idx + 1) ? portList.substring(idx + 1) : null); + } + } + + portList = store.getString("mappedToPortList"); //$NON-NLS-1$ + + if ("".equals(portList.trim())) { //$NON-NLS-1$ + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO, null); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES, null); + } else { + int idx = portList.indexOf(','); + if (idx == -1) { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO, portList.trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES, null); + } else { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO, portList.substring(0, idx).trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_MAPPED_TO_ALTERNATIVES, portList.length() > (idx + 1) ? portList.substring(idx + 1) : null); + } + } + + portList = store.getString("portListAttach"); //$NON-NLS-1$ + + if ("".equals(portList.trim())) { //$NON-NLS-1$ + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH, null); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_ALTERNATIVES, null); + } else { + int idx = portList.indexOf(','); + if (idx == -1) { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH, portList.trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_ALTERNATIVES, null); + } else { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH, portList.substring(0, idx).trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_ALTERNATIVES, portList.length() > (idx + 1) ? portList.substring(idx + 1) : null); + } + } + + portList = store.getString("mappedToPortListAttach"); //$NON-NLS-1$ + + if ("".equals(portList.trim())) { //$NON-NLS-1$ + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO, null); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO_ALTERNATIVES, null); + } else { + int idx = portList.indexOf(','); + if (idx == -1) { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO, portList.trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO_ALTERNATIVES, null); + } else { + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO, portList.substring(0, idx).trim()); + prefs.putString(IPreferenceKeys.PREF_GDBSERVER_PORT_ATTACH_MAPPED_TO_ALTERNATIVES, portList.length() > (idx + 1) ? portList.substring(idx + 1) : null); + } + } + } + + return success; + } + +} |