From 47eeed4670e96cd506b2ba1860758d7c23bbd025 Mon Sep 17 00:00:00 2001 From: Rafael Peria de Sene Date: Mon, 1 Jul 2013 14:25:33 -0300 Subject: [linuxtools settings | bug 412003] - This commit includes the capability to change the ComboFieldEditor according the selected path I have read and agree to abide term by the terms of the Eclipse Foundation Commiter Guidelines Change-Id: Ia09fffaec2e9fda5f3b152caf0ecb876e047793f Signed-off-by: Rafael Peria de Sene Reviewed-on: https://git.eclipse.org/r/14171 Tested-by: Hudson CI Reviewed-by: Wainer dos Santos Moschetta Reviewed-by: Rafael Medeiros Teixeira IP-Clean: Rafael Medeiros Teixeira Tested-by: Rafael Medeiros Teixeira --- .../ui/properties/CustomComboFieldEditor.java | 38 ++++++++++++++++++++++ .../ui/properties/LinuxtoolsPathPropertyPage.java | 16 +++++---- 2 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/CustomComboFieldEditor.java diff --git a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/CustomComboFieldEditor.java b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/CustomComboFieldEditor.java new file mode 100644 index 0000000000..c369500386 --- /dev/null +++ b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/CustomComboFieldEditor.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2013 IBM Corporation + * 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: + * Rafael Peria de Sene - initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tools.launch.ui.properties; + +import org.eclipse.jface.preference.ComboFieldEditor; +import org.eclipse.swt.widgets.Composite; + +/** + * Extends the class ComboFieldEditor including the capability to set and get + * the selected value from a ComboFieldEditor. + * + */ +public class CustomComboFieldEditor extends ComboFieldEditor { + + public CustomComboFieldEditor(String name, String labelText, + String[][] entryNamesAndValues, Composite parent) { + super(name, labelText, entryNamesAndValues, parent); + } + + public String getSelectedValue() { + doStore(); + return getPreferenceStore().getString(getPreferenceName()); + } + + public void setSelectedValue(String newValue) { + getPreferenceStore().setValue(getPreferenceName(), newValue); + doLoad(); + } +} \ No newline at end of file diff --git a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java index a83fe70bac..bb999aeebb 100644 --- a/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java +++ b/profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011 IBM Corporation + * Copyright (c) 2011,2013 IBM Corporation * 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 @@ -7,6 +7,7 @@ * * Contributors: * Otavio Busatto Pontes - initial API and implementation + * Rafael Peria de Sene *******************************************************************************/ package org.eclipse.linuxtools.tools.launch.ui.properties; @@ -21,7 +22,6 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.preference.ComboFieldEditor; import org.eclipse.jface.preference.StringFieldEditor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; @@ -63,7 +63,7 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { {"Custom", ""}, //$NON-NLS-1$ //$NON-NLS-2$ }; private StringFieldEditor linuxtoolsPath; - private ComboFieldEditor linuxtoolsPathCombo; + private CustomComboFieldEditor linuxtoolsPathCombo; private IAdaptable element = null; private Composite result; private Button systemEnvButton, customButton; @@ -107,6 +107,7 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { layoutRadios.marginWidth= 0; layoutRadios.numColumns= 1; radios.setLayout(layoutRadios); + Composite space = new Composite(result, SWT.NONE); boolean systemPathSelected = getPreferenceStore().getBoolean(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME); @@ -126,7 +127,7 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { customButton.setSelection(!systemPathSelected); //Add combo box - linuxtoolsPathCombo = new ComboFieldEditor( + linuxtoolsPathCombo = new CustomComboFieldEditor( LINUXTOOLS_PATH_COMBO_NAME, Messages.LINUXTOOLS_PATH_COMBO, paths, @@ -138,8 +139,9 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { @Override public void propertyChange(PropertyChangeEvent event) { customSelected = event.getNewValue().toString().equals(""); //$NON-NLS-1$ - if (!customSelected) + if (!customSelected){ linuxtoolsPath.setStringValue(event.getNewValue().toString()); + } updateOptionsEnable(); } }); @@ -157,7 +159,7 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { customSelected = selected.equals(""); //$NON-NLS-1$ getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PATH_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathDefault()); linuxtoolsPath.load(); - + linuxtoolsPathCombo.setSelectedValue(linuxtoolsPath.getStringValue()); Dialog.applyDialogFont(result); updateOptionsEnable(); return result; @@ -228,4 +230,4 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage { return element; } -} +} \ No newline at end of file -- cgit v1.2.3