diff options
| author | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 13:36:50 +0100 |
|---|---|---|
| committer | Adrian Dudau <adrian.dudau@enea.com> | 2013-12-12 15:25:03 +0100 |
| commit | 41ac47d732eed8392d60d0f6773e5a279d49b999 (patch) | |
| tree | cf19d099db9cfdb8d73aa21c31e7aa1cc86ff860 /plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java | |
| download | eclipse-poky-juno-master.tar.gz | |
Migrated from the internal git server on the dora-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java')
| -rw-r--r-- | plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java | 555 |
1 files changed, 555 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java new file mode 100644 index 0000000..d192538 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java | |||
| @@ -0,0 +1,555 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2010 Intel Corporation. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.eclipse.org/legal/epl-v10.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Intel - initial API and implementation | ||
| 10 | *******************************************************************************/ | ||
| 11 | package org.yocto.sdk.ide; | ||
| 12 | |||
| 13 | import java.io.File; | ||
| 14 | import java.util.ArrayList; | ||
| 15 | |||
| 16 | import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement; | ||
| 17 | import org.eclipse.core.runtime.Status; | ||
| 18 | import org.eclipse.jface.dialogs.ErrorDialog; | ||
| 19 | import org.eclipse.jface.preference.IPreferenceStore; | ||
| 20 | import org.eclipse.swt.SWT; | ||
| 21 | import org.eclipse.swt.events.ModifyEvent; | ||
| 22 | import org.eclipse.swt.events.ModifyListener; | ||
| 23 | import org.eclipse.swt.events.SelectionAdapter; | ||
| 24 | import org.eclipse.swt.events.SelectionEvent; | ||
| 25 | import org.eclipse.swt.events.SelectionListener; | ||
| 26 | import org.eclipse.swt.layout.GridData; | ||
| 27 | import org.eclipse.swt.layout.GridLayout; | ||
| 28 | import org.eclipse.swt.widgets.Button; | ||
| 29 | import org.eclipse.swt.widgets.Combo; | ||
| 30 | import org.eclipse.swt.widgets.Composite; | ||
| 31 | import org.eclipse.swt.widgets.Control; | ||
| 32 | import org.eclipse.swt.widgets.DirectoryDialog; | ||
| 33 | import org.eclipse.swt.widgets.Display; | ||
| 34 | import org.eclipse.swt.widgets.Event; | ||
| 35 | import org.eclipse.swt.widgets.FileDialog; | ||
| 36 | import org.eclipse.swt.widgets.Group; | ||
| 37 | import org.eclipse.swt.widgets.Label; | ||
| 38 | import org.eclipse.swt.widgets.Text; | ||
| 39 | import org.eclipse.swt.widgets.Widget; | ||
| 40 | import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom; | ||
| 41 | import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults; | ||
| 42 | import org.yocto.sdk.ide.preferences.PreferenceConstants; | ||
| 43 | |||
| 44 | public class YoctoUISetting { | ||
| 45 | private static final String ENV_SCRIPT_FILE_PREFIX = "environment-setup-"; | ||
| 46 | |||
| 47 | private SelectionListener fSelectionListener; | ||
| 48 | private ModifyListener fModifyListener; | ||
| 49 | private YoctoUIElement yoctoUIElement; | ||
| 50 | |||
| 51 | private Group crossCompilerGroup; | ||
| 52 | |||
| 53 | private Button btnSDKRoot; | ||
| 54 | private Button btnQemu; | ||
| 55 | private Button btnPokyRoot; | ||
| 56 | private Button btnDevice; | ||
| 57 | |||
| 58 | private Button btnKernelLoc; | ||
| 59 | private Button btnSysrootLoc; | ||
| 60 | private Button btnToolChainLoc; | ||
| 61 | |||
| 62 | private Text textKernelLoc; | ||
| 63 | private Text textQemuOption; | ||
| 64 | private Text textSysrootLoc; | ||
| 65 | private Text textRootLoc; | ||
| 66 | private Combo targetArchCombo; | ||
| 67 | |||
| 68 | private Label root_label; | ||
| 69 | private Label sysroot_label; | ||
| 70 | private Label targetArchLabel; | ||
| 71 | private Label kernel_label; | ||
| 72 | private Label option_label; | ||
| 73 | |||
| 74 | public YoctoUISetting(YoctoUIElement elem) | ||
| 75 | { | ||
| 76 | yoctoUIElement = elem; | ||
| 77 | elem.setStrTargetsArray(getTargetArray(elem)); | ||
| 78 | |||
| 79 | fSelectionListener= new SelectionListener() { | ||
| 80 | public void widgetDefaultSelected(SelectionEvent e) {} | ||
| 81 | |||
| 82 | public void widgetSelected(SelectionEvent e) { | ||
| 83 | controlChanged(e.widget); | ||
| 84 | relayEvent(e); | ||
| 85 | } | ||
| 86 | |||
| 87 | private void relayEvent(SelectionEvent e) { | ||
| 88 | Event event = new Event(); | ||
| 89 | event.data = e.data; | ||
| 90 | event.detail = e.detail; | ||
| 91 | event.display = e.display; | ||
| 92 | event.doit = e.doit; | ||
| 93 | event.height = e.height; | ||
| 94 | event.item = e.item; | ||
| 95 | event.stateMask = e.stateMask; | ||
| 96 | event.text = e.text; | ||
| 97 | event.time = e.time; | ||
| 98 | event.widget = e.widget; | ||
| 99 | event.width = e.width; | ||
| 100 | event.x = e.x; | ||
| 101 | event.y = e.y; | ||
| 102 | crossCompilerGroup.getParent().notifyListeners(SWT.Selection, event); | ||
| 103 | } | ||
| 104 | }; | ||
| 105 | |||
| 106 | fModifyListener= new ModifyListener() { | ||
| 107 | public void modifyText(ModifyEvent e) { | ||
| 108 | controlModified(e.widget); | ||
| 109 | relayEvent(e); | ||
| 110 | } | ||
| 111 | |||
| 112 | private void relayEvent(ModifyEvent e) { | ||
| 113 | Event event = new Event(); | ||
| 114 | event.data = e.data; | ||
| 115 | event.display = e.display; | ||
| 116 | event.time = e.time; | ||
| 117 | event.widget = e.widget; | ||
| 118 | crossCompilerGroup.getParent().notifyListeners(SWT.Modify, event); | ||
| 119 | } | ||
| 120 | }; | ||
| 121 | } | ||
| 122 | |||
| 123 | private Control addControls(Control fControl, final String sKey, String sValue) | ||
| 124 | { | ||
| 125 | fControl.setData(new String[]{sKey,sValue}); | ||
| 126 | return fControl; | ||
| 127 | } | ||
| 128 | |||
| 129 | private Control addRadioButton(Composite parent, String label, String key, boolean bSelected) { | ||
| 130 | GridData gd= new GridData(SWT.FILL, SWT.CENTER, true, false); | ||
| 131 | String sValue; | ||
| 132 | Button button= new Button(parent, SWT.RADIO); | ||
| 133 | |||
| 134 | gd.horizontalSpan= 2; | ||
| 135 | button.setText(label); | ||
| 136 | button.setLayoutData(gd); | ||
| 137 | button.setSelection(bSelected); | ||
| 138 | |||
| 139 | if (bSelected) | ||
| 140 | sValue = IPreferenceStore.TRUE; | ||
| 141 | else | ||
| 142 | sValue = IPreferenceStore.FALSE; | ||
| 143 | return addControls((Control)button, key, sValue); | ||
| 144 | |||
| 145 | } | ||
| 146 | |||
| 147 | private Control addTextControl(final Composite parent, String key, String value) { | ||
| 148 | final Text text; | ||
| 149 | |||
| 150 | text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER); | ||
| 151 | text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| 152 | text.setText(value); | ||
| 153 | text.setSize(10, 150); | ||
| 154 | |||
| 155 | return addControls((Control)text, key, value); | ||
| 156 | } | ||
| 157 | |||
| 158 | private Button addFileSelectButton(final Composite parent, final Text text, final String key) { | ||
| 159 | Button button = new Button(parent, SWT.PUSH | SWT.LEAD); | ||
| 160 | button.setText(InputUIElement.BROWSELABEL); | ||
| 161 | button.addSelectionListener(new SelectionAdapter() { | ||
| 162 | @Override | ||
| 163 | public void widgetSelected(SelectionEvent event) { | ||
| 164 | String dirName; | ||
| 165 | if (key.equals(PreferenceConstants.TOOLCHAIN_ROOT)|| key.equals(PreferenceConstants.SYSROOT)) | ||
| 166 | dirName = new DirectoryDialog(parent.getShell()).open(); | ||
| 167 | else | ||
| 168 | dirName = new FileDialog(parent.getShell()).open(); | ||
| 169 | if (dirName != null) { | ||
| 170 | text.setText(dirName); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | }); | ||
| 174 | return button; | ||
| 175 | } | ||
| 176 | |||
| 177 | private void createQemuSetup(final Group targetGroup) | ||
| 178 | { | ||
| 179 | //QEMU Setup | ||
| 180 | kernel_label= new Label(targetGroup, SWT.NONE); | ||
| 181 | kernel_label.setText("Kernel: "); | ||
| 182 | kernel_label.setAlignment(SWT.RIGHT); | ||
| 183 | |||
| 184 | Composite textContainer = new Composite(targetGroup, SWT.NONE); | ||
| 185 | textContainer.setLayout(new GridLayout(2, false)); | ||
| 186 | textContainer.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false)); | ||
| 187 | textKernelLoc= (Text)addTextControl(textContainer, PreferenceConstants.QEMU_KERNEL, yoctoUIElement.getStrQemuKernelLoc()); | ||
| 188 | btnKernelLoc = addFileSelectButton(textContainer, textKernelLoc, PreferenceConstants.QEMU_KERNEL); | ||
| 189 | |||
| 190 | |||
| 191 | option_label = new Label(targetGroup, SWT.NONE); | ||
| 192 | option_label.setText("Custom Option: "); | ||
| 193 | option_label.setAlignment(SWT.RIGHT); | ||
| 194 | |||
| 195 | textContainer = new Composite(targetGroup, SWT.NONE); | ||
| 196 | textContainer.setLayout(new GridLayout(2, false)); | ||
| 197 | textContainer.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false)); | ||
| 198 | textQemuOption = (Text)addTextControl(textContainer, PreferenceConstants.QEMU_OPTION, yoctoUIElement.getStrQemuOption()); | ||
| 199 | |||
| 200 | /* | ||
| 201 | rootfs_label= new Label(targetGroup, SWT.NONE); | ||
| 202 | rootfs_label.setText("Root Filesystem: "); | ||
| 203 | rootfs_label.setAlignment(SWT.RIGHT); | ||
| 204 | |||
| 205 | textContainer = new Composite(targetGroup, SWT.NONE); | ||
| 206 | textContainer.setLayout(new GridLayout(2, false)); | ||
| 207 | textContainer.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false)); | ||
| 208 | textRootFSLoc= (Text)addTextControl(textContainer, PreferenceConstants.QEMU_ROOTFS, yoctoUIElement.getStrQemuRootFSLoc()); | ||
| 209 | btnRootFSLoc = addFileSelectButton(textContainer, textRootFSLoc, PreferenceConstants.QEMU_ROOTFS); | ||
| 210 | */ | ||
| 211 | |||
| 212 | } | ||
| 213 | public void createComposite(Composite composite) | ||
| 214 | { | ||
| 215 | GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); | ||
| 216 | GridLayout layout = new GridLayout(2, false); | ||
| 217 | |||
| 218 | crossCompilerGroup = new Group(composite, SWT.NONE); | ||
| 219 | layout= new GridLayout(2, false); | ||
| 220 | crossCompilerGroup.setLayout(layout); | ||
| 221 | gd= new GridData(SWT.FILL, SWT.CENTER, true, false); | ||
| 222 | gd.horizontalSpan= 2; | ||
| 223 | crossCompilerGroup.setLayoutData(gd); | ||
| 224 | crossCompilerGroup.setText("Cross Compiler Options:"); | ||
| 225 | |||
| 226 | if (yoctoUIElement.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) { | ||
| 227 | |||
| 228 | btnSDKRoot = (Button)addRadioButton(crossCompilerGroup, "Standalone pre-built toolchain", PreferenceConstants.SDK_MODE + "_1", true); | ||
| 229 | btnPokyRoot = (Button)addRadioButton(crossCompilerGroup, "Build system derived toolchain", PreferenceConstants.SDK_MODE + "_2", false); | ||
| 230 | } | ||
| 231 | else { | ||
| 232 | btnSDKRoot = (Button)addRadioButton(crossCompilerGroup, "Standalone pre-built toolchain", PreferenceConstants.SDK_MODE + "_1", false); | ||
| 233 | btnPokyRoot = (Button)addRadioButton(crossCompilerGroup, "Build system derived toolchain", PreferenceConstants.SDK_MODE + "_2", true); | ||
| 234 | } | ||
| 235 | |||
| 236 | root_label = new Label(crossCompilerGroup, SWT.NONE); | ||
| 237 | root_label.setText("Toolchain Root Location: "); | ||
| 238 | Composite textContainer = new Composite(crossCompilerGroup, SWT.NONE); | ||
| 239 | textContainer.setLayout(new GridLayout(2, false)); | ||
| 240 | textContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); | ||
| 241 | textRootLoc = (Text)addTextControl(textContainer, | ||
| 242 | PreferenceConstants.TOOLCHAIN_ROOT, yoctoUIElement.getStrToolChainRoot()); | ||
| 243 | btnToolChainLoc = addFileSelectButton(textContainer, textRootLoc, PreferenceConstants.TOOLCHAIN_ROOT); | ||
| 244 | |||
| 245 | sysroot_label= new Label(crossCompilerGroup, SWT.NONE); | ||
| 246 | sysroot_label.setText("Sysroot Location: "); | ||
| 247 | sysroot_label.setAlignment(SWT.RIGHT); | ||
| 248 | |||
| 249 | textContainer = new Composite(crossCompilerGroup, SWT.NONE); | ||
| 250 | textContainer.setLayout(new GridLayout(2, false)); | ||
| 251 | textContainer.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false)); | ||
| 252 | textSysrootLoc= (Text)addTextControl(textContainer, PreferenceConstants.SYSROOT, yoctoUIElement.getStrSysrootLoc()); | ||
| 253 | btnSysrootLoc = addFileSelectButton(textContainer, textSysrootLoc, PreferenceConstants.SYSROOT); | ||
| 254 | |||
| 255 | updateSDKControlState(); | ||
| 256 | targetArchLabel = new Label(crossCompilerGroup, SWT.NONE); | ||
| 257 | targetArchLabel.setText("Target Architecture: "); | ||
| 258 | |||
| 259 | targetArchCombo= new Combo(crossCompilerGroup, SWT.READ_ONLY); | ||
| 260 | if (yoctoUIElement.getStrTargetsArray() != null) | ||
| 261 | { | ||
| 262 | targetArchCombo.setItems(yoctoUIElement.getStrTargetsArray()); | ||
| 263 | targetArchCombo.select(yoctoUIElement.getIntTargetIndex()); | ||
| 264 | } | ||
| 265 | targetArchCombo.setLayout(new GridLayout(2, false)); | ||
| 266 | targetArchCombo.setLayoutData(new GridData(SWT.FILL, SWT.LEFT, true, false)); | ||
| 267 | this.addControls((Control)targetArchCombo, | ||
| 268 | PreferenceConstants.TOOLCHAIN_TRIPLET, String.valueOf(yoctoUIElement.getIntTargetIndex())); | ||
| 269 | |||
| 270 | |||
| 271 | //Target Options | ||
| 272 | GridData gd2= new GridData(SWT.FILL, SWT.LEFT, true, false); | ||
| 273 | gd2.horizontalSpan= 2; | ||
| 274 | Group targetGroup= new Group(composite, SWT.NONE); | ||
| 275 | layout= new GridLayout(); | ||
| 276 | layout.numColumns= 2; | ||
| 277 | targetGroup.setLayout(layout); | ||
| 278 | targetGroup.setLayoutData(gd2); | ||
| 279 | targetGroup.setText("Target Options:"); | ||
| 280 | |||
| 281 | if (yoctoUIElement.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) { | ||
| 282 | btnQemu = (Button)addRadioButton(targetGroup, "QEMU", PreferenceConstants.TARGET_MODE + "_1", true); | ||
| 283 | createQemuSetup(targetGroup); | ||
| 284 | |||
| 285 | btnDevice = (Button)addRadioButton(targetGroup, "External HW", PreferenceConstants.TARGET_MODE + "_2", false); | ||
| 286 | } | ||
| 287 | else { | ||
| 288 | btnQemu = (Button)addRadioButton(targetGroup, "QEMU", PreferenceConstants.TARGET_MODE + "_1", false); | ||
| 289 | createQemuSetup(targetGroup); | ||
| 290 | |||
| 291 | btnDevice = (Button)addRadioButton(targetGroup, "External HW", PreferenceConstants.TARGET_MODE + "_2", true); | ||
| 292 | } | ||
| 293 | |||
| 294 | updateQemuControlState(); | ||
| 295 | |||
| 296 | //we add the listener at the end for avoiding the useless event trigger when control | ||
| 297 | //changed or modified. | ||
| 298 | btnSDKRoot.addSelectionListener(fSelectionListener); | ||
| 299 | btnPokyRoot.addSelectionListener(fSelectionListener); | ||
| 300 | btnQemu.addSelectionListener(fSelectionListener); | ||
| 301 | btnDevice.addSelectionListener(fSelectionListener); | ||
| 302 | targetArchCombo.addSelectionListener(fSelectionListener); | ||
| 303 | textRootLoc.addModifyListener(fModifyListener); | ||
| 304 | textKernelLoc.addModifyListener(fModifyListener); | ||
| 305 | textQemuOption.addModifyListener(fModifyListener); | ||
| 306 | textSysrootLoc.addModifyListener(fModifyListener); | ||
| 307 | } | ||
| 308 | |||
| 309 | //Load all Control values into the YoctoUIElement | ||
| 310 | public YoctoUIElement getCurrentInput() | ||
| 311 | { | ||
| 312 | YoctoUIElement elem = new YoctoUIElement(); | ||
| 313 | if (btnSDKRoot.getSelection()) | ||
| 314 | elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE); | ||
| 315 | else | ||
| 316 | elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE); | ||
| 317 | |||
| 318 | if (btnQemu.getSelection()) | ||
| 319 | { | ||
| 320 | elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE); | ||
| 321 | } | ||
| 322 | else { | ||
| 323 | elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE); | ||
| 324 | } | ||
| 325 | elem.setStrToolChainRoot(textRootLoc.getText()); | ||
| 326 | elem.setIntTargetIndex(targetArchCombo.getSelectionIndex()); | ||
| 327 | elem.setStrTargetsArray(targetArchCombo.getItems()); | ||
| 328 | elem.setStrTarget(targetArchCombo.getText()); | ||
| 329 | elem.setStrQemuKernelLoc(textKernelLoc.getText()); | ||
| 330 | elem.setStrQemuOption(textQemuOption.getText()); | ||
| 331 | elem.setStrSysrootLoc(textSysrootLoc.getText()); | ||
| 332 | return elem; | ||
| 333 | } | ||
| 334 | |||
| 335 | public void setCurrentInput(YoctoUIElement elem){ | ||
| 336 | elem.setStrTargetsArray(getTargetArray(elem)); | ||
| 337 | |||
| 338 | btnSDKRoot.setSelection(false); | ||
| 339 | btnPokyRoot.setSelection(false); | ||
| 340 | if(elem.getEnumPokyMode().equals(YoctoUIElement.PokyMode.POKY_SDK_MODE)){ | ||
| 341 | btnSDKRoot.setSelection(true); | ||
| 342 | } | ||
| 343 | else if(elem.getEnumPokyMode().equals(YoctoUIElement.PokyMode.POKY_TREE_MODE)){ | ||
| 344 | btnPokyRoot.setSelection(true); | ||
| 345 | } | ||
| 346 | |||
| 347 | btnQemu.setSelection(false); | ||
| 348 | btnDevice.setSelection(false); | ||
| 349 | if(elem.getEnumDeviceMode().equals(YoctoUIElement.DeviceMode.QEMU_MODE)){ | ||
| 350 | btnQemu.setSelection(true); | ||
| 351 | } | ||
| 352 | else if(elem.getEnumDeviceMode().equals(YoctoUIElement.DeviceMode.DEVICE_MODE)){ | ||
| 353 | btnDevice.setSelection(true); | ||
| 354 | } | ||
| 355 | |||
| 356 | textRootLoc.setText(elem.getStrToolChainRoot()); | ||
| 357 | targetArchCombo.select(elem.getIntTargetIndex()); | ||
| 358 | if(elem.getStrTargetsArray() == null){ | ||
| 359 | targetArchCombo.setItems(new String[]{}); | ||
| 360 | } | ||
| 361 | else { | ||
| 362 | targetArchCombo.setItems(elem.getStrTargetsArray()); | ||
| 363 | } | ||
| 364 | targetArchCombo.setText(elem.getStrTarget()); | ||
| 365 | textKernelLoc.setText(elem.getStrQemuKernelLoc()); | ||
| 366 | textQemuOption.setText(elem.getStrQemuOption()); | ||
| 367 | textSysrootLoc.setText(elem.getStrSysrootLoc()); | ||
| 368 | } | ||
| 369 | |||
| 370 | public SDKCheckResults validateInput(SDKCheckRequestFrom from, boolean showErrorDialog) { | ||
| 371 | SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(getCurrentInput()); | ||
| 372 | |||
| 373 | //Show Error Message on the Label to help users. | ||
| 374 | if ((result != SDKCheckResults.SDK_PASS) && showErrorDialog) { | ||
| 375 | Display display = Display.getCurrent(); | ||
| 376 | ErrorDialog.openError(display.getActiveShell(), | ||
| 377 | YoctoSDKChecker.SDKCheckRequestFrom.Other.getErrorMessage(), | ||
| 378 | YoctoSDKChecker.getErrorMessage(result, from), | ||
| 379 | new Status(Status.ERROR, YoctoSDKPlugin.PLUGIN_ID, result.getMessage())); | ||
| 380 | |||
| 381 | } | ||
| 382 | |||
| 383 | return result; | ||
| 384 | } | ||
| 385 | |||
| 386 | public void setUIFormEnabledState(boolean isEnabled) { | ||
| 387 | btnSDKRoot.setEnabled(isEnabled); | ||
| 388 | btnPokyRoot.setEnabled(isEnabled); | ||
| 389 | |||
| 390 | root_label.setEnabled(isEnabled); | ||
| 391 | textRootLoc.setEnabled(isEnabled); | ||
| 392 | btnToolChainLoc.setEnabled(isEnabled); | ||
| 393 | |||
| 394 | sysroot_label.setEnabled(isEnabled); | ||
| 395 | textSysrootLoc.setEnabled(isEnabled); | ||
| 396 | btnSysrootLoc.setEnabled(isEnabled); | ||
| 397 | |||
| 398 | targetArchLabel.setEnabled(isEnabled); | ||
| 399 | targetArchCombo.setEnabled(isEnabled); | ||
| 400 | |||
| 401 | btnQemu.setEnabled(isEnabled); | ||
| 402 | |||
| 403 | if(isEnabled) { | ||
| 404 | /* enabling widgets regarding | ||
| 405 | * Kernel and Custom Options | ||
| 406 | * depends on the state of the QEMU button */ | ||
| 407 | kernel_label.setEnabled(isEnabled); | ||
| 408 | option_label.setEnabled(isEnabled); | ||
| 409 | |||
| 410 | if(btnQemu.getSelection()) { | ||
| 411 | textKernelLoc.setEnabled(isEnabled); | ||
| 412 | btnKernelLoc.setEnabled(isEnabled); | ||
| 413 | |||
| 414 | textQemuOption.setEnabled(isEnabled); | ||
| 415 | } | ||
| 416 | } else { | ||
| 417 | /* disable all widgets regarding | ||
| 418 | * Kernel and Custom Options */ | ||
| 419 | kernel_label.setEnabled(isEnabled); | ||
| 420 | textKernelLoc.setEnabled(isEnabled); | ||
| 421 | btnKernelLoc.setEnabled(isEnabled); | ||
| 422 | |||
| 423 | option_label.setEnabled(isEnabled); | ||
| 424 | textQemuOption.setEnabled(isEnabled); | ||
| 425 | } | ||
| 426 | |||
| 427 | btnDevice.setEnabled(isEnabled); | ||
| 428 | } | ||
| 429 | |||
| 430 | private void updateQemuControlState() | ||
| 431 | { | ||
| 432 | boolean bQemuMode = btnQemu.getSelection(); | ||
| 433 | |||
| 434 | textKernelLoc.setEnabled(bQemuMode); | ||
| 435 | //textRootFSLoc.setEnabled(bQemuMode); | ||
| 436 | btnKernelLoc.setEnabled(bQemuMode); | ||
| 437 | //btnRootFSLoc.setEnabled(bQemuMode); | ||
| 438 | textQemuOption.setEnabled(bQemuMode); | ||
| 439 | } | ||
| 440 | |||
| 441 | private void updateSDKControlState() | ||
| 442 | { | ||
| 443 | if (btnSDKRoot.getSelection()) | ||
| 444 | { | ||
| 445 | } | ||
| 446 | else { | ||
| 447 | if (!yoctoUIElement.getStrToolChainRoot().startsWith("/opt/poky")) | ||
| 448 | { | ||
| 449 | textRootLoc.setText(yoctoUIElement.getStrToolChainRoot()); | ||
| 450 | } | ||
| 451 | textRootLoc.setEnabled(true); | ||
| 452 | btnToolChainLoc.setEnabled(true); | ||
| 453 | } | ||
| 454 | } | ||
| 455 | |||
| 456 | private void controlChanged(Widget widget) { | ||
| 457 | |||
| 458 | if (widget == btnSDKRoot || widget == btnPokyRoot) | ||
| 459 | { | ||
| 460 | |||
| 461 | setTargetCombo(targetArchCombo); | ||
| 462 | updateSDKControlState(); | ||
| 463 | } | ||
| 464 | |||
| 465 | if (widget == btnDevice || widget == btnQemu) | ||
| 466 | updateQemuControlState(); | ||
| 467 | } | ||
| 468 | |||
| 469 | private void controlModified(Widget widget) { | ||
| 470 | if (widget == textRootLoc) | ||
| 471 | { | ||
| 472 | setTargetCombo(targetArchCombo); | ||
| 473 | } | ||
| 474 | } | ||
| 475 | |||
| 476 | /* Search current supported Target triplet from the toolchain root | ||
| 477 | * by parsing ENV script file name | ||
| 478 | */ | ||
| 479 | private static ArrayList<String> getTargetTripletList(String strFileName) | ||
| 480 | { | ||
| 481 | File fFile = new File(strFileName); | ||
| 482 | if (!fFile.exists()) | ||
| 483 | return null; | ||
| 484 | |||
| 485 | ArrayList<String> arrTarget = new ArrayList<String>(); | ||
| 486 | String[] strFileArray = fFile.list(); | ||
| 487 | for (int i = 0; i < strFileArray.length; i++) | ||
| 488 | { | ||
| 489 | if (strFileArray[i].startsWith(ENV_SCRIPT_FILE_PREFIX)) { | ||
| 490 | arrTarget.add(strFileArray[i].substring(ENV_SCRIPT_FILE_PREFIX.length())); | ||
| 491 | } | ||
| 492 | } | ||
| 493 | return arrTarget; | ||
| 494 | |||
| 495 | } | ||
| 496 | |||
| 497 | private static String[] getTargetArray(YoctoUIElement elem) | ||
| 498 | { | ||
| 499 | ArrayList<String> arrTarget; | ||
| 500 | String sEnvFilePath = elem.getStrToolChainRoot(); | ||
| 501 | |||
| 502 | if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) | ||
| 503 | { | ||
| 504 | arrTarget = getTargetTripletList(sEnvFilePath); | ||
| 505 | } | ||
| 506 | else | ||
| 507 | { | ||
| 508 | arrTarget = getTargetTripletList(sEnvFilePath + "/tmp"); | ||
| 509 | } | ||
| 510 | if (arrTarget == null || arrTarget.size() <= 0) | ||
| 511 | return null; | ||
| 512 | |||
| 513 | String [] strTargetArray = new String[arrTarget.size()]; | ||
| 514 | for (int i = 0; i < arrTarget.size(); i++) | ||
| 515 | strTargetArray[i] = arrTarget.get(i); | ||
| 516 | |||
| 517 | return strTargetArray; | ||
| 518 | |||
| 519 | } | ||
| 520 | |||
| 521 | private void setTargetCombo(Combo targetCombo) | ||
| 522 | { | ||
| 523 | YoctoUIElement elem = getCurrentInput(); | ||
| 524 | //re-get Combo box items according to latest input! | ||
| 525 | elem.setStrTargetsArray(getTargetArray(elem)); | ||
| 526 | targetCombo.removeAll(); | ||
| 527 | if (elem.getStrTargetsArray() != null) | ||
| 528 | { | ||
| 529 | targetCombo.setItems(elem.getStrTargetsArray()); | ||
| 530 | for (int i = 0; i < targetCombo.getItemCount(); i++) | ||
| 531 | { | ||
| 532 | if(elem.getStrTarget().equalsIgnoreCase(targetCombo.getItem(i))) | ||
| 533 | { | ||
| 534 | targetCombo.select(i); | ||
| 535 | return; | ||
| 536 | } | ||
| 537 | if (elem.getStrTargetsArray().length == 1) | ||
| 538 | targetCombo.select(0); | ||
| 539 | targetCombo.select(-1); | ||
| 540 | } | ||
| 541 | } | ||
| 542 | //prompt user,if he use tree mode, maybe he hasn't bitbake meta-ide-support yet. | ||
| 543 | else if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_TREE_MODE) | ||
| 544 | { | ||
| 545 | if (elem.getStrToolChainRoot().isEmpty()) | ||
| 546 | return; | ||
| 547 | else { | ||
| 548 | File fToolChain = new File(elem.getStrToolChainRoot()); | ||
| 549 | if (!fToolChain.exists()) | ||
| 550 | return; | ||
| 551 | } | ||
| 552 | } | ||
| 553 | |||
| 554 | } | ||
| 555 | } | ||
