[yocto] [RFC v2 08/18] plugins/sdk.ide: Set profile on selection change

Timo Mueller mail at timomueller.eu
Wed Jan 30 05:56:24 PST 2013


From: Timo Mueller <timo.mueller at bmw-carit.de>

When a profile is selected through the combo box the value of the
profileElement changed to contain the selected profile.

Signed-off-by: Timo Mueller <timo.mueller at bmw-carit.de>
---
 .../src/org/yocto/sdk/ide/YoctoProfileSetting.java | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
index 7476bd3..b35a167 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoProfileSetting.java
@@ -16,7 +16,9 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Listener;
 
 public class YoctoProfileSetting {
 	private static final String PROFILES_TITLE = "Preferences.Profiles.Title";
@@ -54,6 +56,27 @@ public class YoctoProfileSetting {
 		sdkConfigsCombo.setLayout(new GridLayout(2, false));
 		sdkConfigsCombo.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false));
 
+		Listener selectionListener = new Listener() {
+			@Override
+			public void handleEvent(Event event) {
+				Object source = event.widget;
+				if (!(source instanceof Combo)) {
+					return;
+				}
+
+				Combo sdkCombo = (Combo) source;
+				if (sdkCombo.getSelectionIndex() < 0) {
+					return;
+				}
+
+				String selectedItem = sdkCombo.getItem(sdkCombo.getSelectionIndex());
+				profileElement.setSelectedProfile(selectedItem);
+			}
+		};
+
+		sdkConfigsCombo.addListener(SWT.Selection, selectionListener);
+		sdkConfigsCombo.addListener(SWT.Modify, selectionListener);
+
 		createSaveAsProfileButton(storeYoctoConfigurationsGroup);
 		createRenameButton(storeYoctoConfigurationsGroup);
 		createRemoveButton(storeYoctoConfigurationsGroup);
-- 
1.7.11.7




More information about the yocto mailing list