Refactor handling of SDK check errors
cover Refactor handling of SDK check errors
From: Timo Mueller <[email protected]>
Hi,
I tried to display the messages resulting from validating the YoctoUISettings in the message area of the properties/preference pages instead of showing a dialog. This led to some refactoring of the validation functionality and also the messages.
If for example the user entered a SDK toolchain directory that doesn't exist in the global preferences a dialog will show up showing the error and telling him how he can do "IDE-wide settings". As he is currently trying to do "IDE-wide settings" this advice is not really necessary and the dialog can be really annoying.
I split up the messages into a one line error message and an advice. This message can be shown in the page's message area instead of opening a dialog with every configuration error. The advice can still be used when we want to show a dialog to help the user, e.g. when creating a new project.
On a side note I reactivated the YoctoSDKChecker class and moved all the validation code from the utils, getting rid of some duplicated and inconsistent code.
Best regards,
Timo
PS: This patch set is based on "plugins/sdk.ide: Remove profile edit buttons from property page"
Timo Mueller (5):
plugins/sdk.ide: Move SDK check functionality to separate class plugins/sdk.ide: Refactored the construction of mesages with
SDKCheckResults
plugins/sdk.ide: Show SDK check errors in message area plugins/sdk.ide: Removed validation from setCurrentInput plugins/sdk.ide: Use standard error dialog to show SDK check errors
.../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 372 +++++++++++---------- .../org/yocto/sdk/ide/YoctoSDKMessages.properties | 42 ++- .../org/yocto/sdk/ide/YoctoSDKProjectNature.java | 9 +- .../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 255 -------------- .../src/org/yocto/sdk/ide/YoctoUISetting.java | 47 +-- .../ide/preferences/YoctoSDKPreferencePage.java | 84 +++-- .../preferences/YoctoSDKProjectPropertyPage.java | 87 +++-- .../sdk/ide/wizard/NewYoctoCProjectTemplate.java | 18 +- 8 files changed, 344 insertions(+), 570 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/5 plugins/sdk.ide: Move SDK check functionality to separate class
From: Timo Mueller <[email protected]>
The class YoctoSDKChecker provided some unused code for checking a Yocto SDK configuration. Checking of the SDK was done in YoctoSDKUtils. An enum for results was provided in both classes (under the same name) but contained different possible values.
To avoid confusion, reduce duplicate code and to separate the checking functionality from the rest of the utility functions, the checking code has been moved completely to the YoctoSDKChecker.
--- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 361 ++++++++++++--------- .../org/yocto/sdk/ide/YoctoSDKProjectNature.java | 9 +- .../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 255 --------------- .../src/org/yocto/sdk/ide/YoctoUISetting.java | 8 +- .../ide/preferences/YoctoSDKPreferencePage.java | 2 +- .../preferences/YoctoSDKProjectPropertyPage.java | 2 +- .../sdk/ide/wizard/NewYoctoCProjectTemplate.java | 18 +- 7 files changed, 229 insertions(+), 426 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKChecker.java +208 -153
@@ -10,197 +10,252 @@ *******************************************************************************/ package org.yocto.sdk.ide; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; +import java.io.FilenameFilter; +import java.io.IOException; public class YoctoSDKChecker { + public static enum SDKCheckResults { SDK_PASS, + POKY_DEVICE_EMPTY, TOOLCHAIN_LOCATION_EMPTY, - TOOLCHAIN_LOCATION_NON_EXIST, - TARGET_EMPTY, + TOOLCHAIN_LOCATION_NONEXIST, + SDK_TARGET_EMPTY, QEMU_KERNEL_EMPTY, - //QEMU_ROOTFS_EMPTY, - SDK_BIN_NON_EXIST, - SDK_SYSROOT_NON_EXIST, - SDK_PKGCONFIG_NON_EXIST, - QEMU_KERNEL_NON_EXIST, - SYSROOT_NON_EXIST, SYSROOT_EMPTY, - ENV_SETUP_SCRIPT_NON_EXIST + QEMU_KERNEL_NONEXIST, + SYSROOT_NONEXIST, + WRONG_ADT_VERSION, + ENV_SETUP_SCRIPT_NONEXIST, + TOOLCHAIN_NO_SYSROOT, + TOOLCHAIN_HOST_MISMATCH }; public static enum SDKCheckRequestFrom { Wizard, Menu, - Preferences + Preferences, + Other }; - private static final String WIZARD_SDK_LOCATION_EMPTY = "Wizard.SDK.Location.Empty"; - private static final String WIZARD_TOOLCHAIN_LOCATION_NONEXIST = "Wizard.Toolcahin.Location.Nonexist"; - private static final String WIZARD_SDK_TARGET_EMPTY = "Wizard.SDK.Target.Empty"; - private static final String WIZARD_SDK_BIN_NONEXIST = "Wizard.SDK.Bin.Nonexist"; - private static final String WIZARD_SDK_SYSROOT_NONEXIST = "Wizard.SDK.Sysroot.Nonexist"; - private static final String WIZARD_SDK_PKGCONFIG_NONEXIST = "Wizard.SDK.Pkgconfig.Nonexist"; - private static final String WIZARD_QEMU_KERNEL_EMPTY = "Wizard.Qemu.Kernel.Empty"; - private static final String WIZARD_SYSROOT_EMPTY = "Wizard.Sysroot.Empty"; - private static final String WIZARD_QEMU_KERNEL_NONEXIST = "Wizard.Qemu.Kernel.Nonexist"; - private static final String WIZARD_SYSROOT_NONEXIST = "Wizard.Sysroot.Nonexist"; - - private static final String MENU_SDK_LOCATION_EMPTY = "Menu.SDK.Location.Empty"; - private static final String MENU_TOOLCHAIN_LOCATION_NONEXIST = "Menu.Toolchain.Location.Nonexist"; - private static final String MENU_SDK_TARGET_EMPTY = "Menu.SDK.Target.Empty"; - private static final String MENU_SDK_BIN_NONEXIST = "Menu.SDK.Bin.Nonexist"; - private static final String MENU_SDK_SYSROOT_NONEXIST = "Menu.SDK.Sysroot.Nonexist"; - private static final String MENU_SDK_PKGCONFIG_NONEXIST = "Menu.SDK.Pkgconfig.Nonexist"; - private static final String MENU_QEMU_KERNEL_EMPTY = "Menu.Qemu.Kernel.Empty"; - private static final String MENU_SYSROOT_EMPTY = "Menu.Sysroot.Empty"; - private static final String MENU_QEMU_KERNEL_NONEXIST = "Menu.Qemu.Kernel.Nonexist"; - private static final String MENU_SYSROOT_NONEXIST = "Menu.Sysroot.Nonexist"; - - private static final String PREFERENCES_SDK_BIN_NONEXIST = "Preferences.SDK.Bin.Nonexist"; - private static final String PREFERENCES_SDK_SYSROOT_NONEXIST = "Preferences.SDK.Sysroot.Nonexist"; - private static final String PREFERENCES_SDK_PKGCONFIG_NONEXIST = "Preferences.SDK.Pkgconfig.Nonexist"; - - private static final String ENV_SCRIPT_NONEXIST = "Env.Script.Nonexist"; + private static final String POKY_DEVICE_EMPTY = "Poky.SDK.Device.Empty"; + private static final String TOOLCHAIN_LOCATION_EMPTY = "Poky.SDK.Location.Empty"; + private static final String SDK_TARGET_EMPTY = "Poky.SDK.Target.Empty"; + private static final String TOOLCHAIN_LOCATION_NONEXIST = "Poky.SDK.Location.Nonexist"; + private static final String QEMU_KERNEL_EMPTY = "Poky.Qemu.Kernel.Empty"; + private static final String SYSROOT_EMPTY = "Poky.Sysroot.Empty"; + private static final String QEMU_KERNEL_NONEXIST = "Poky.Qemu.Kernel.Nonexist"; + private static final String SYSROOT_NONEXIST = "Poky.Sysroot.Nonexist"; + private static final String WRONG_ADT_VERSION = "Poky.ADT.Sysroot.Wrongversion"; + private static final String ENV_SETUP_SCRIPT_NONEXIST = "Poky.Env.Script.Nonexist"; + private static final String TOOLCHAIN_NO_SYSROOT = "Poky.Toolchain.No.Sysroot"; + private static final String TOOLCHAIN_HOST_MISMATCH = "Poky.Toolchain.Host.Mismatch"; + private static final String[] saInvalidVer = {"1.0", "0.9", "0.9+"}; - private static final String PREFERENCES_TOOLCHAIN_LOCATION_NONEXIST = "Preferences.Toolchain.Location.Nonexist"; - private static final String PREFERENCES_QEMU_KERNEL_EMPTY = "Preferences.Qemu.Kernel.Empty"; - private static final String PREFERENCES_SYSROOT_EMPTY = "Preferences.Sysroot.Empty"; - private static final String PREFERENCES_QEMU_KERNEL_NONEXIST = "Preferences.Qemu.Kernel.Nonexist"; - private static final String PREFERENCES_SYSROOT_NONEXIST = "Preferences.Sysroot.Nonexist"; - - public static SDKCheckResults checkYoctoSDK(String sdkroot, String toolchain_location, String target, String target_qemu, - String qemu_kernel, String sysroot, String ip_addr) { - - if (toolchain_location.isEmpty()) { - return SDKCheckResults.TOOLCHAIN_LOCATION_EMPTY; - } else { - File toolchain = new File(toolchain_location); - if (!toolchain.exists()) - return SDKCheckResults.TOOLCHAIN_LOCATION_NON_EXIST; + private static final String SYSROOTS_DIR = "sysroots"; + + public static SDKCheckResults checkYoctoSDK(YoctoUIElement elem) { + if (elem.getStrToolChainRoot().isEmpty()) + return SDKCheckResults.TOOLCHAIN_LOCATION_EMPTY; + else { + File fToolChain = new File(elem.getStrToolChainRoot()); + if (!fToolChain.exists()) + return SDKCheckResults.TOOLCHAIN_LOCATION_NONEXIST; } - - if (sysroot.isEmpty()) + + if (elem.getStrSysrootLoc().isEmpty()) { return SDKCheckResults.SYSROOT_EMPTY; - else { - File sysroot_dir = new File(sysroot); + } else { + File fSysroot = new File(elem.getStrSysrootLoc()); + if (!fSysroot.exists()) + return SDKCheckResults.SYSROOT_NONEXIST; + } + + if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) { + //Check for SDK compatible with the host arch + String platform = YoctoSDKUtils.getPlatformArch(); + String sysroot_dir_str = elem.getStrToolChainRoot() + "/" + SYSROOTS_DIR; + File sysroot_dir = new File(sysroot_dir_str); if (!sysroot_dir.exists()) - return SDKCheckResults.SYSROOT_NON_EXIST; + return SDKCheckResults.TOOLCHAIN_NO_SYSROOT; + + String toolchain_host_arch = null; + + try { + toolchain_host_arch = findHostArch(sysroot_dir); + } catch(NullPointerException e) { + return SDKCheckResults.TOOLCHAIN_NO_SYSROOT; + } + + if (!toolchain_host_arch.equalsIgnoreCase(platform)) { + if (!platform.matches("i\\d86") || !toolchain_host_arch.matches("i\\d86")) + return SDKCheckResults.TOOLCHAIN_HOST_MISMATCH; + } } - - if (target.isEmpty() || target==null) { - return SDKCheckResults.TARGET_EMPTY; + + if (elem.getIntTargetIndex() < 0 || elem.getStrTarget().isEmpty()) { + //if this is poky tree mode, prompt user whether bitbake meta-ide-support is executed? + if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_TREE_MODE) + return SDKCheckResults.ENV_SETUP_SCRIPT_NONEXIST; + else + return SDKCheckResults.SDK_TARGET_EMPTY; + } else { + String sFileName; + + if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) { + sFileName = elem.getStrToolChainRoot()+"/" + YoctoSDKProjectNature.DEFAULT_ENV_FILE_PREFIX+elem.getStrTarget(); + } else { + //POKY TREE Mode + sFileName = elem.getStrToolChainRoot() + YoctoSDKProjectNature.DEFAULT_TMP_PREFIX + YoctoSDKProjectNature.DEFAULT_ENV_FILE_PREFIX + elem.getStrTarget(); + } + + try { + File file = new File(sFileName); + boolean bVersion = false; + + if (file.exists()) { + BufferedReader input = new BufferedReader(new FileReader(file)); + + try { + String line = null; + + while ((line = input.readLine()) != null) { + if (line.startsWith("export "+ YoctoSDKProjectNature.SDK_VERSION)) { + int beginIndex = 2; + String sVersion = ""; + for (;;) { + char cValue = line.charAt(line.indexOf('=') + beginIndex++); + + if ((cValue != '.') && (!Character.isDigit(cValue)) && (cValue != '+')) + break; + else + sVersion += String.valueOf(cValue); + } + + for (int i = 0; i < saInvalidVer.length; i++) { + if (!sVersion.equals(saInvalidVer[i])) { + bVersion = true; + break; + } + } + + break; + } + } + } finally { + input.close(); + } + + if (!bVersion) + return SDKCheckResults.WRONG_ADT_VERSION; + } + } catch (IOException e) { + e.printStackTrace(); + } } - - if (target_qemu.equals("true")) { - if (qemu_kernel.isEmpty()) + + if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) { + if (elem.getStrQemuKernelLoc().isEmpty()) { return SDKCheckResults.QEMU_KERNEL_EMPTY; - else { - File kernel_file = new File(qemu_kernel); - if (!kernel_file.exists()) - return SDKCheckResults.QEMU_KERNEL_NON_EXIST; + } else { + File fQemuKernel = new File(elem.getStrQemuKernelLoc()); + if (!fQemuKernel.exists()) + return SDKCheckResults.QEMU_KERNEL_NONEXIST; } - } - + return SDKCheckResults.SDK_PASS; } - private static String getWizardErrorMessage(SDKCheckResults result) { - switch (result) { - case TOOLCHAIN_LOCATION_EMPTY: - return YoctoSDKMessages.getString(WIZARD_SDK_LOCATION_EMPTY); - case TOOLCHAIN_LOCATION_NON_EXIST: - return YoctoSDKMessages.getString(WIZARD_TOOLCHAIN_LOCATION_NONEXIST); - case TARGET_EMPTY: - return YoctoSDKMessages.getString(WIZARD_SDK_TARGET_EMPTY); - case QEMU_KERNEL_EMPTY: - return YoctoSDKMessages.getString(WIZARD_QEMU_KERNEL_EMPTY); - case SYSROOT_EMPTY: - return YoctoSDKMessages.getString(WIZARD_SYSROOT_EMPTY); - case QEMU_KERNEL_NON_EXIST: - return YoctoSDKMessages.getString(WIZARD_QEMU_KERNEL_NONEXIST); - case SYSROOT_NON_EXIST: - return YoctoSDKMessages.getString(WIZARD_SYSROOT_NONEXIST); - case SDK_BIN_NON_EXIST: - return YoctoSDKMessages.getString(WIZARD_SDK_BIN_NONEXIST); - case SDK_SYSROOT_NON_EXIST: - return YoctoSDKMessages.getString(WIZARD_SDK_SYSROOT_NONEXIST); - case SDK_PKGCONFIG_NON_EXIST: - return YoctoSDKMessages.getString(WIZARD_SDK_PKGCONFIG_NONEXIST); - default: - return null; - } - } + public static String getErrorMessage(SDKCheckResults result, SDKCheckRequestFrom from) { + String strErrorMsg; - private static String getMenuErrorMessage(SDKCheckResults result) { - switch (result) { - case TOOLCHAIN_LOCATION_EMPTY: - return YoctoSDKMessages.getString(MENU_SDK_LOCATION_EMPTY); - case TOOLCHAIN_LOCATION_NON_EXIST: - return YoctoSDKMessages.getString(MENU_TOOLCHAIN_LOCATION_NONEXIST); - case TARGET_EMPTY: - return YoctoSDKMessages.getString(MENU_SDK_TARGET_EMPTY); - case QEMU_KERNEL_EMPTY: - return YoctoSDKMessages.getString(MENU_QEMU_KERNEL_EMPTY); - //case QEMU_ROOTFS_EMPTY: - // return YoctoSDKMessages.getString(MENU_QEMU_ROOTFS_EMPTY); - case QEMU_KERNEL_NON_EXIST: - return YoctoSDKMessages.getString(MENU_QEMU_KERNEL_NONEXIST); - case SYSROOT_NON_EXIST: - return YoctoSDKMessages.getString(MENU_SYSROOT_NONEXIST); - case SYSROOT_EMPTY: - return YoctoSDKMessages.getString(MENU_SYSROOT_EMPTY); - case SDK_BIN_NON_EXIST: - return YoctoSDKMessages.getString(MENU_SDK_BIN_NONEXIST); - case SDK_SYSROOT_NON_EXIST: - return YoctoSDKMessages.getString(MENU_SDK_SYSROOT_NONEXIST); - case SDK_PKGCONFIG_NON_EXIST: - return YoctoSDKMessages.getString(MENU_SDK_PKGCONFIG_NONEXIST); + switch (from) { + case Wizard: + strErrorMsg = "Yocto Wizard Configuration Error:"; + break; + case Menu: + strErrorMsg = "Yocto Menu Configuration Error!"; + break; + case Preferences: + strErrorMsg = "Yocto Preferences Configuration Error!"; + break; default: - return null; + strErrorMsg = "Yocto Configuration Error!"; + break; } - } - private static String getPreferencesErrorMessage(SDKCheckResults result) { switch (result) { + case POKY_DEVICE_EMPTY: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(POKY_DEVICE_EMPTY); + break; case TOOLCHAIN_LOCATION_EMPTY: - return YoctoSDKMessages.getString(MENU_SDK_LOCATION_EMPTY); - case TOOLCHAIN_LOCATION_NON_EXIST: - return YoctoSDKMessages.getString(PREFERENCES_TOOLCHAIN_LOCATION_NONEXIST); - case TARGET_EMPTY: - return YoctoSDKMessages.getString(MENU_SDK_TARGET_EMPTY); - case SDK_BIN_NON_EXIST: - return YoctoSDKMessages.getString(PREFERENCES_SDK_BIN_NONEXIST); - case SDK_SYSROOT_NON_EXIST: - return YoctoSDKMessages.getString(PREFERENCES_SDK_SYSROOT_NONEXIST); - case SDK_PKGCONFIG_NON_EXIST: - return YoctoSDKMessages.getString(PREFERENCES_SDK_PKGCONFIG_NONEXIST); + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_LOCATION_EMPTY); + break; + case SDK_TARGET_EMPTY: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(SDK_TARGET_EMPTY); + break; + case TOOLCHAIN_LOCATION_NONEXIST: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_LOCATION_NONEXIST); + break; case QEMU_KERNEL_EMPTY: - return YoctoSDKMessages.getString(PREFERENCES_QEMU_KERNEL_EMPTY); + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(QEMU_KERNEL_EMPTY); + break; case SYSROOT_EMPTY: - return YoctoSDKMessages.getString(PREFERENCES_SYSROOT_EMPTY); - case QEMU_KERNEL_NON_EXIST: - return YoctoSDKMessages.getString(PREFERENCES_QEMU_KERNEL_NONEXIST); - case SYSROOT_NON_EXIST: - return YoctoSDKMessages.getString(PREFERENCES_SYSROOT_NONEXIST); - case ENV_SETUP_SCRIPT_NON_EXIST: - return YoctoSDKMessages.getString(ENV_SCRIPT_NONEXIST); + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(SYSROOT_EMPTY); + break; + case QEMU_KERNEL_NONEXIST: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(QEMU_KERNEL_NONEXIST); + break; + case SYSROOT_NONEXIST: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(SYSROOT_NONEXIST); + break; + case WRONG_ADT_VERSION: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(WRONG_ADT_VERSION); + break; + case ENV_SETUP_SCRIPT_NONEXIST: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(ENV_SETUP_SCRIPT_NONEXIST); + break; + case TOOLCHAIN_NO_SYSROOT: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_NO_SYSROOT); + break; + case TOOLCHAIN_HOST_MISMATCH: + strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_HOST_MISMATCH); + break; default: - return null; + break; } + + return strErrorMsg; } - public static String getErrorMessage(SDKCheckResults result, SDKCheckRequestFrom from) { - switch (from) { - case Wizard: - return getWizardErrorMessage(result); - case Menu: - return getMenuErrorMessage(result); - case Preferences: - return getPreferencesErrorMessage(result); - default: - return null; + private static String findHostArch(File sysroot_dir) { + FilenameFilter nativeFilter = new FilenameFilter() { + public boolean accept(File dir, String name) { + if (name.endsWith("sdk-linux")) { + return true; + } else { + return false; + } + } + }; + + File[] files = sysroot_dir.listFiles(nativeFilter); + String arch = null; + + for (File file : files) { + if (file.isDirectory()) { + String path = file.getName(); + String[] subPath = path.split("-"); + arch = subPath[0]; + } else { + continue; + } } - } + + return arch; + } }
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKProjectNature.java +5 -4
@@ -38,7 +38,8 @@ import org.eclipse.debug.core.ILaunchConfigurationType; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.jface.preference.IPreferenceStore; -import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults; @SuppressWarnings("restriction")
@@ -157,9 +158,9 @@ public class YoctoSDKProjectNature implements IProjectNature { YoctoSDKUtils.saveProfilesToProjectPreferences(profileElement, project); IPreferenceStore selecteProfileStore = YoctoSDKPlugin.getProfilePreferenceStore(profileElement.getSelectedProfile()); YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(selecteProfileStore); - YoctoSDKUtils.SDKCheckResults result = YoctoSDKUtils.checkYoctoSDK(elem); - if (result != YoctoSDKUtils.SDKCheckResults.SDK_PASS){ - String strErrorMsg = YoctoSDKUtils.getErrorMessage(result, SDKCheckRequestFrom.Wizard); + SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(elem); + if (result != SDKCheckResults.SDK_PASS){ + String strErrorMsg = YoctoSDKChecker.getErrorMessage(result, SDKCheckRequestFrom.Wizard); throw new YoctoGeneralException(strErrorMsg); } else
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKUtils.java +0 -255
278 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +4 -4
@@ -36,8 +36,8 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Widget; -import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom; -import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckResults; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults; import org.yocto.sdk.ide.preferences.PreferenceConstants; public class YoctoUISetting {
@@ -349,11 +349,11 @@ public class YoctoUISetting { boolean pass = true; String strErrorMessage; - SDKCheckResults result = YoctoSDKUtils.checkYoctoSDK(elem); + SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(elem); //Show Error Message on the Label to help users. if (result != SDKCheckResults.SDK_PASS) { - strErrorMessage = YoctoSDKUtils.getErrorMessage(result, from); + strErrorMessage = YoctoSDKChecker.getErrorMessage(result, from); pass = false; if (bPrompt) {
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +1 -1
@@ -33,7 +33,7 @@ import org.yocto.sdk.ide.YoctoSDKMessages; import org.yocto.sdk.ide.YoctoSDKPlugin; import org.yocto.sdk.ide.YoctoSDKProjectNature; import org.yocto.sdk.ide.YoctoSDKUtils; -import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom; import org.yocto.sdk.ide.YoctoUIElement; import org.yocto.sdk.ide.YoctoUISetting;
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java +1 -1
@@ -24,9 +24,9 @@ import org.yocto.sdk.ide.YoctoGeneralException; import org.yocto.sdk.ide.YoctoProfileElement; import org.yocto.sdk.ide.YoctoProfileSetting; import org.yocto.sdk.ide.YoctoProjectSpecificSetting; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom; import org.yocto.sdk.ide.YoctoSDKPlugin; import org.yocto.sdk.ide.YoctoSDKUtils; -import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom; import org.yocto.sdk.ide.YoctoUIElement; import org.yocto.sdk.ide.YoctoUISetting;
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java +10 -8
@@ -10,15 +10,17 @@ *******************************************************************************/ package org.yocto.sdk.ide.wizard; -import java.util.List; import java.util.LinkedHashMap; +import java.util.List; +import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.templateengine.TemplateCore; import org.eclipse.cdt.core.templateengine.process.ProcessArgument; import org.eclipse.cdt.core.templateengine.process.ProcessFailureException; import org.eclipse.cdt.core.templateengine.process.ProcessRunner; import org.eclipse.cdt.core.templateengine.process.processes.Messages; +import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager; import org.eclipse.cdt.make.core.scannerconfig.IDiscoveredPathManager.IDiscoveredPathInfo;
@@ -36,19 +38,19 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; -import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.preference.IPreferenceStore; import org.yocto.sdk.ide.YoctoGeneralException; import org.yocto.sdk.ide.YoctoProfileElement; +import org.yocto.sdk.ide.YoctoSDKChecker; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom; +import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckResults; import org.yocto.sdk.ide.YoctoSDKEmptyProjectNature; import org.yocto.sdk.ide.YoctoSDKPlugin; import org.yocto.sdk.ide.YoctoSDKProjectNature; import org.yocto.sdk.ide.YoctoSDKUtils; import org.yocto.sdk.ide.YoctoUIElement; -import org.yocto.sdk.ide.YoctoSDKUtils.SDKCheckRequestFrom; @SuppressWarnings("restriction")
@@ -120,9 +122,9 @@ public class NewYoctoCProjectTemplate extends ProcessRunner { YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromDefaultStore(); IPreferenceStore selecteProfileStore = YoctoSDKPlugin.getProfilePreferenceStore(profileElement.getSelectedProfile()); YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(selecteProfileStore); - YoctoSDKUtils.SDKCheckResults result = YoctoSDKUtils.checkYoctoSDK(elem); - if (result != YoctoSDKUtils.SDKCheckResults.SDK_PASS){ - String strErrorMsg = YoctoSDKUtils.getErrorMessage(result, SDKCheckRequestFrom.Wizard); + SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(elem); + if (result != SDKCheckResults.SDK_PASS){ + String strErrorMsg = YoctoSDKChecker.getErrorMessage(result, SDKCheckRequestFrom.Wizard); throw new YoctoGeneralException(strErrorMsg); } AutotoolsNewProjectNature.addAutotoolsNature(project, monitor);
Signature · 1 line
1.7.11.7
PATCH 2/5 plugins/sdk.ide: Refactored the construction of mesages with SDKCheckResults
From: Timo Mueller <[email protected]>
The message keys are now stored with the enum values simplifying the construction of error messages.
Error messages have also been split up into a one line error message and an advice. The one line error message can for example be used in UI Parts with limited space (e.g. message area on property and preference pages). Dialogs or log messages can use the complete message to give the user a hint on what to do in order to fix the error.
--- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 159 +++++++++------------ .../org/yocto/sdk/ide/YoctoSDKMessages.properties | 42 ++++-- 2 files changed, 99 insertions(+), 102 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKChecker.java +70 -89
@@ -1,5 +1,7 @@ /******************************************************************************* * Copyright (c) 2010 Intel Corporation. + * Copyright (c) 2013 BMW Car IT GmbH. + * * 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 +9,7 @@ * * Contributors: * Intel - initial API and implementation + * BMW Car IT - include error and advice messages with check results *******************************************************************************/ package org.yocto.sdk.ide;
@@ -17,45 +20,76 @@ import java.io.FilenameFilter; import java.io.IOException; public class YoctoSDKChecker { + private static final String[] saInvalidVer = {"1.0", "0.9", "0.9+"}; + private static final String SYSROOTS_DIR = "sysroots"; public static enum SDKCheckResults { - SDK_PASS, - POKY_DEVICE_EMPTY, - TOOLCHAIN_LOCATION_EMPTY, - TOOLCHAIN_LOCATION_NONEXIST, - SDK_TARGET_EMPTY, - QEMU_KERNEL_EMPTY, - SYSROOT_EMPTY, - QEMU_KERNEL_NONEXIST, - SYSROOT_NONEXIST, - WRONG_ADT_VERSION, - ENV_SETUP_SCRIPT_NONEXIST, - TOOLCHAIN_NO_SYSROOT, - TOOLCHAIN_HOST_MISMATCH + SDK_PASS("", false), + TOOLCHAIN_LOCATION_EMPTY( + "Poky.SDK.Location.Empty", true), + TOOLCHAIN_LOCATION_NONEXIST( + "Poky.SDK.Location.Nonexist", true), + SDK_TARGET_EMPTY( + "Poky.SDK.Target.Empty", true), + SYSROOT_EMPTY( + "Poky.Sysroot.Empty", true), + SYSROOT_NONEXIST( + "Poky.Sysroot.Nonexist", true), + QEMU_KERNEL_EMPTY( + "Poky.Qemu.Kernel.Empty", true), + QEMU_KERNEL_NONEXIST( + "Poky.Qemu.Kernel.Nonexist", true), + WRONG_ADT_VERSION( + "Poky.ADT.Sysroot.Wrongversion", false), + ENV_SETUP_SCRIPT_NONEXIST( + "Poky.Env.Script.Nonexist", false), + TOOLCHAIN_NO_SYSROOT( + "Poky.Toolchain.No.Sysroot", false), + TOOLCHAIN_HOST_MISMATCH( + "Poky.Toolchain.Host.Mismatch", false); + + private static final String DEFAULT_ADVICE = "Default.Advice"; + private static final String ADVICE_SUFFIX = ".Advice"; + + private final String messageID; + private final boolean addDefaultAdvice; + + private SDKCheckResults(final String messageID, final boolean addDefaultAdvice) { + this.messageID = messageID; + this.addDefaultAdvice = addDefaultAdvice; + } + + public String getMessage() { + return YoctoSDKMessages.getString(messageID); + } + + public String getAdvice() { + String advice = YoctoSDKMessages.getString(messageID + ADVICE_SUFFIX); + + if (addDefaultAdvice) { + advice += YoctoSDKMessages.getString(DEFAULT_ADVICE); + } + + return advice; + } }; public static enum SDKCheckRequestFrom { - Wizard, - Menu, - Preferences, - Other - }; + Wizard("Poky.SDK.Error.Origin.Wizard"), + Menu("Poky.SDK.Error.Origin.Menu"), + Preferences("Poky.SDK.Error.Origin.Preferences"), + Other("Poky.SDK.Error.Origin.Other"); - private static final String POKY_DEVICE_EMPTY = "Poky.SDK.Device.Empty"; - private static final String TOOLCHAIN_LOCATION_EMPTY = "Poky.SDK.Location.Empty"; - private static final String SDK_TARGET_EMPTY = "Poky.SDK.Target.Empty"; - private static final String TOOLCHAIN_LOCATION_NONEXIST = "Poky.SDK.Location.Nonexist"; - private static final String QEMU_KERNEL_EMPTY = "Poky.Qemu.Kernel.Empty"; - private static final String SYSROOT_EMPTY = "Poky.Sysroot.Empty"; - private static final String QEMU_KERNEL_NONEXIST = "Poky.Qemu.Kernel.Nonexist"; - private static final String SYSROOT_NONEXIST = "Poky.Sysroot.Nonexist"; - private static final String WRONG_ADT_VERSION = "Poky.ADT.Sysroot.Wrongversion"; - private static final String ENV_SETUP_SCRIPT_NONEXIST = "Poky.Env.Script.Nonexist"; - private static final String TOOLCHAIN_NO_SYSROOT = "Poky.Toolchain.No.Sysroot"; - private static final String TOOLCHAIN_HOST_MISMATCH = "Poky.Toolchain.Host.Mismatch"; - private static final String[] saInvalidVer = {"1.0", "0.9", "0.9+"}; - - private static final String SYSROOTS_DIR = "sysroots"; + private final String errorMessageID; + + private SDKCheckRequestFrom(final String errorMessageID) { + this.errorMessageID = errorMessageID; + } + + public String getErrorMessage() { + return YoctoSDKMessages.getString(errorMessageID); + } + }; public static SDKCheckResults checkYoctoSDK(YoctoUIElement elem) { if (elem.getStrToolChainRoot().isEmpty())
@@ -172,62 +206,9 @@ public class YoctoSDKChecker { public static String getErrorMessage(SDKCheckResults result, SDKCheckRequestFrom from) { String strErrorMsg; - - switch (from) { - case Wizard: - strErrorMsg = "Yocto Wizard Configuration Error:"; - break; - case Menu: - strErrorMsg = "Yocto Menu Configuration Error!"; - break; - case Preferences: - strErrorMsg = "Yocto Preferences Configuration Error!"; - break; - default: - strErrorMsg = "Yocto Configuration Error!"; - break; - } - - switch (result) { - case POKY_DEVICE_EMPTY: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(POKY_DEVICE_EMPTY); - break; - case TOOLCHAIN_LOCATION_EMPTY: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_LOCATION_EMPTY); - break; - case SDK_TARGET_EMPTY: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(SDK_TARGET_EMPTY); - break; - case TOOLCHAIN_LOCATION_NONEXIST: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_LOCATION_NONEXIST); - break; - case QEMU_KERNEL_EMPTY: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(QEMU_KERNEL_EMPTY); - break; - case SYSROOT_EMPTY: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(SYSROOT_EMPTY); - break; - case QEMU_KERNEL_NONEXIST: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(QEMU_KERNEL_NONEXIST); - break; - case SYSROOT_NONEXIST: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(SYSROOT_NONEXIST); - break; - case WRONG_ADT_VERSION: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(WRONG_ADT_VERSION); - break; - case ENV_SETUP_SCRIPT_NONEXIST: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(ENV_SETUP_SCRIPT_NONEXIST); - break; - case TOOLCHAIN_NO_SYSROOT: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_NO_SYSROOT); - break; - case TOOLCHAIN_HOST_MISMATCH: - strErrorMsg = strErrorMsg + "\n" + YoctoSDKMessages.getString(TOOLCHAIN_HOST_MISMATCH); - break; - default: - break; - } + strErrorMsg = from.getErrorMessage(); + strErrorMsg += "\n" + result.getMessage(); + strErrorMsg += "\n" + result.getAdvice(); return strErrorMsg; }
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +29 -13
48 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 3/5 plugins/sdk.ide: Show SDK check errors in message area
From: Timo Mueller <[email protected]>
If settings made by the user do not pass the SDK check the error message was not shown in eclipse but was printed to system out which was never visible by the user.
The error is now shown in the message area of the property or preference page if the check fails.
--- .../src/org/yocto/sdk/ide/YoctoUISetting.java | 43 ++++------- .../ide/preferences/YoctoSDKPreferencePage.java | 84 ++++++++++----------- .../preferences/YoctoSDKProjectPropertyPage.java | 85 +++++++++++----------- 3 files changed, 97 insertions(+), 115 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +16 -27
@@ -336,40 +336,29 @@ public class YoctoUISetting { textQemuOption.setText(elem.getStrQemuOption()); textSysrootLoc.setText(elem.getStrSysrootLoc()); - try { - validateInput(SDKCheckRequestFrom.Preferences, false); - } catch (YoctoGeneralException e) { + SDKCheckResults result = validateInput(SDKCheckRequestFrom.Preferences, false); + if (result != SDKCheckResults.SDK_PASS) { System.out.println("Have you ever set Yocto Project Reference before?"); - System.out.println(e.getMessage()); + System.out.println(YoctoSDKChecker.getErrorMessage(result, SDKCheckRequestFrom.Other)); } } - public boolean validateInput(SDKCheckRequestFrom from, boolean bPrompt) throws YoctoGeneralException { - YoctoUIElement elem = getCurrentInput(); - boolean pass = true; - String strErrorMessage; - - SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(elem); + public SDKCheckResults validateInput(SDKCheckRequestFrom from, boolean showErrorDialog) { + SDKCheckResults result = YoctoSDKChecker.checkYoctoSDK(getCurrentInput()); //Show Error Message on the Label to help users. - if (result != SDKCheckResults.SDK_PASS) { - strErrorMessage = YoctoSDKChecker.getErrorMessage(result, from); - pass = false; - if (bPrompt) - { - Display display = Display.getCurrent(); - Shell shell = new Shell(display); - MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - msgBox.setText("Yocto Project Configuration Error"); - msgBox.setMessage(strErrorMessage); - msgBox.open(); - if (shell != null) - shell.dispose(); - } - - throw new YoctoGeneralException(strErrorMessage); + if ((result != SDKCheckResults.SDK_PASS) && showErrorDialog) { + Display display = Display.getCurrent(); + Shell shell = new Shell(display); + MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); + msgBox.setText("Yocto Project Configuration Error"); + msgBox.setMessage(YoctoSDKChecker.getErrorMessage(result, from)); + msgBox.open(); + if (shell != null) + shell.dispose(); } - return pass; + + return result; } public void setUIFormEnabledState(boolean isEnabled) {
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +40 -44
124 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java +41 -44
112 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 4/5 plugins/sdk.ide: Removed validation from setCurrentInput
From: Timo Mueller <[email protected]>
The result of the validation did not affect the behaviour of the method. Also an error is not reported back to the caller or the user. Validation of the setting should be handled before setting the input or on save.
--- plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java | 6 ------ 1 file changed, 6 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +0 -6
@@ -335,12 +335,6 @@ public class YoctoUISetting { textKernelLoc.setText(elem.getStrQemuKernelLoc()); textQemuOption.setText(elem.getStrQemuOption()); textSysrootLoc.setText(elem.getStrSysrootLoc()); - - SDKCheckResults result = validateInput(SDKCheckRequestFrom.Preferences, false); - if (result != SDKCheckResults.SDK_PASS) { - System.out.println("Have you ever set Yocto Project Reference before?"); - System.out.println(YoctoSDKChecker.getErrorMessage(result, SDKCheckRequestFrom.Other)); - } } public SDKCheckResults validateInput(SDKCheckRequestFrom from, boolean showErrorDialog) {
Signature · 1 line
1.7.11.7
PATCH 5/5 plugins/sdk.ide: Use standard error dialog to show SDK check errors
From: Timo Mueller <[email protected]>
--- .../src/org/yocto/sdk/ide/YoctoUISetting.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoUISetting.java +7 -9
@@ -14,6 +14,8 @@ import java.io.File; import java.util.ArrayList; import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent;
@@ -32,8 +34,6 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Widget; import org.yocto.sdk.ide.YoctoSDKChecker.SDKCheckRequestFrom;
@@ -343,13 +343,11 @@ public class YoctoUISetting { //Show Error Message on the Label to help users. if ((result != SDKCheckResults.SDK_PASS) && showErrorDialog) { Display display = Display.getCurrent(); - Shell shell = new Shell(display); - MessageBox msgBox = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK); - msgBox.setText("Yocto Project Configuration Error"); - msgBox.setMessage(YoctoSDKChecker.getErrorMessage(result, from)); - msgBox.open(); - if (shell != null) - shell.dispose(); + ErrorDialog.openError(display.getActiveShell(), + "Yocto Project Configuration Error", + YoctoSDKChecker.getErrorMessage(result, from), + new Status(Status.ERROR, YoctoSDKPlugin.PLUGIN_ID, result.getMessage())); + } return result;
Signature · 1 line
1.7.11.7
Hi Timo,
Thanks for initiating the cleanup in this area that I agree definitely need some work. There're couple issues I'm seeing with your patch set that probably need some refinements:
1. After seeing the error message, if I go into the field correct the error, I have to explicit click on "Apply" to make it revalidate, probably we should track the fields change and do automatic re-validation
2. For a scenario that I have 2 toolchains (for different arch, e.g. arm and x86) installed under same directory, which means there're 2 environment setup scripts under the same directory. In this case, the Target Architecture drop down list will contain 2 entries for the arches. In this case, I'm getting an error message for missing environment script file which is not true. By looking at the code, the logic basically checking the elem's target architecture setting, if there's none, report missing environment script. I think for this case, we do need to check the size of the target arch option list to see whether it's empty or not.
3. For the case of Poky.Env.Script.Nonexist, there's Poky.Env.ScriptNoexist.Advise which is more meaningful to user what to do if running into the error. But I don't see that Advice is posted and by looking at code, it seems it's not being used as well?
Thanks,
Jessica
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Timo Mueller
Sent: Wednesday, February 27, 2013 6:37 AM
To: [email protected]
Cc: Timo Mueller
Subject: [yocto] [PATCH 0/5][eclipse-poky] Refactor handling of SDK check errors
From: Timo Mueller <[email protected]>
Hi,
I tried to display the messages resulting from validating the YoctoUISettings in the message area of the properties/preference pages instead of showing a dialog. This led to some refactoring of the validation functionality and also the messages.
If for example the user entered a SDK toolchain directory that doesn't exist in the global preferences a dialog will show up showing the error and telling him how he can do "IDE-wide settings". As he is currently trying to do "IDE-wide settings" this advice is not really necessary and the dialog can be really annoying.
I split up the messages into a one line error message and an advice. This message can be shown in the page's message area instead of opening a dialog with every configuration error. The advice can still be used when we want to show a dialog to help the user, e.g. when creating a new project.
On a side note I reactivated the YoctoSDKChecker class and moved all the validation code from the utils, getting rid of some duplicated and inconsistent code.
Best regards,
Timo
PS: This patch set is based on "plugins/sdk.ide: Remove profile edit buttons from property page"
Timo Mueller (5):
plugins/sdk.ide: Move SDK check functionality to separate class plugins/sdk.ide: Refactored the construction of mesages with
SDKCheckResults
plugins/sdk.ide: Show SDK check errors in message area plugins/sdk.ide: Removed validation from setCurrentInput plugins/sdk.ide: Use standard error dialog to show SDK check errors
.../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 372 +++++++++++---------- .../org/yocto/sdk/ide/YoctoSDKMessages.properties | 42 ++- .../org/yocto/sdk/ide/YoctoSDKProjectNature.java | 9 +- .../src/org/yocto/sdk/ide/YoctoSDKUtils.java | 255 -------------- .../src/org/yocto/sdk/ide/YoctoUISetting.java | 47 +-- .../ide/preferences/YoctoSDKPreferencePage.java | 84 +++-- .../preferences/YoctoSDKProjectPropertyPage.java | 87 +++-- .../sdk/ide/wizard/NewYoctoCProjectTemplate.java | 18 +- 8 files changed, 344 insertions(+), 570 deletions(-)
--
1.7.11.7
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto
Hi Jessica,
Zhang, Jessica wrote, On 27.02.2013 23:04:
Quoted 10 lines
Hi Timo,
Thanks for initiating the cleanup in this area that I agree definitely need some work. There're couple issues I'm seeing with your patch set that probably need some refinements:
1. After seeing the error message, if I go into the field correct the error, I have to explicit click on "Apply" to make it revalidate, probably we should track the fields change and do automatic re-validation
Yes, I agree it can be confusing. I already played around with enabling Listeners on the YoctoUISetting element but stopped because I thought that rechecking the SDK everytime you type in a new character will slow down the ui to much.
One idea I have in mind is, if the settings are changed (on type) we delete the error message and show a message telling the user that the new settings have to be revalidated again. Do you think that would be sufficient?
Nevertheless I will extend the YoctoUISetting to be able to notify registered listeners on change. Then we can decide on how we want to react to this change.
Quoted 11 lines
2. For a scenario that I have 2 toolchains (for different arch, e.g. arm and x86) installed under same directory, which means there're 2 environment setup scripts under the same directory. In this case, the Target Architecture drop down list will contain 2 entries for the arches. In this case, I'm getting an error message for missing environment script file which is not true. By looking at the code, the logic basically checking the elem's target architecture setting, if there's none, report missing environment script. I think for this case, we do need to check the size of the target arch option list to see whether it's empty or not.
True, this calls for a separate error message.
Quoted 5 lines
3. For the case of Poky.Env.Script.Nonexist, there's Poky.Env.ScriptNoexist.Advise which is more meaningful to user what to do if running into the error. But I don't see that Advice is posted and by looking at code, it seems it's not being used as well?
I'll try to rephrase the error message.
Regarding the advice I'm not quite sure if I follow correctly. If you choose "Build system derived toolchain" and the location doesn't contain a toolchain (so the drop-down is empty) the SDK check fails with ENV_SETUP_SCRIPT_NONEXIST. If a dialog pops up showing the error, the advice will also be used and added to the message.
Quoted 30 lines
Thanks, Jessica
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Timo Mueller
Sent: Wednesday, February 27, 2013 6:37 AM To:
[email protected] Cc: Timo Mueller Subject: [yocto] [PATCH 0/5][eclipse-poky] Refactor handling of SDK check errorsFrom: Timo Mueller <[email protected]>
Hi,
I tried to display the messages resulting from validating the YoctoUISettings in the message area of the properties/preference pages instead of showing a dialog. This led to some refactoring of the validation functionality and also the messages.
If for example the user entered a SDK toolchain directory that doesn't exist in the global preferences a dialog will show up showing the error and telling him how he can do "IDE-wide settings". As he is currently trying to do "IDE-wide settings" this advice is not really necessary and the dialog can be really annoying.
I split up the messages into a one line error message and an advice. This message can be shown in the page's message area instead of opening a dialog with every configuration error. The advice can still be used when we want to show a dialog to help the user, e.g. when creating a new project.
Quoted 8 lines
On a side note I reactivated the YoctoSDKChecker class and moved all the validation code from the utils, getting rid of some duplicated and inconsistent code.
Best regards, Timo
PS: This patch set is based on "plugins/sdk.ide: Remove profile edit buttons from property page"
Best regards
Timo
Comments below...
Thanks,
Jessica
-----Original Message-----
From: Timo Müller [mailto:[email protected]]
Sent: Friday, March 01, 2013 1:37 AM
To: Zhang, Jessica
Cc: [email protected]; Timo Mueller
Subject: Re: [yocto] [PATCH 0/5][eclipse-poky] Refactor handling of SDK check errors
Hi Jessica,
Zhang, Jessica wrote, On 27.02.2013 23:04:
Quoted 10 lines
Hi Timo,
Thanks for initiating the cleanup in this area that I agree definitely need some work. There're couple issues I'm seeing with your patch set that probably need some refinements:
1. After seeing the error message, if I go into the field correct the error, I have to explicit click on "Apply" to make it revalidate, probably we should track the fields change and do automatic re-validation
Yes, I agree it can be confusing. I already played around with enabling Listeners on the YoctoUISetting element but stopped because I thought that rechecking the SDK everytime you type in a new character will slow down the ui to much. [JZ] yeah that's my concern too....
One idea I have in mind is, if the settings are changed (on type) we delete the error message and show a message telling the user that the new settings have to be revalidated again. Do you think that would be sufficient? [JZ] this sounds reasonable
Nevertheless I will extend the YoctoUISetting to be able to notify registered listeners on change. Then we can decide on how we want to react to this change.
Quoted 11 lines
2. For a scenario that I have 2 toolchains (for different arch, e.g. arm and x86) installed under same directory, which means there're 2 environment setup scripts under the same directory. In this case, the Target Architecture drop down list will contain 2 entries for the arches. In this case, I'm getting an error message for missing environment script file which is not true. By looking at the code, the logic basically checking the elem's target architecture setting, if there's none, report missing environment script. I think for this case, we do need to check the size of the target arch option list to see whether it's empty or not.
True, this calls for a separate error message.
Quoted 5 lines
3. For the case of Poky.Env.Script.Nonexist, there's Poky.Env.ScriptNoexist.Advise which is more meaningful to user what to do if running into the error. But I don't see that Advice is posted and by looking at code, it seems it's not being used as well?
I'll try to rephrase the error message.
Regarding the advice I'm not quite sure if I follow correctly. If you choose "Build system derived toolchain" and the location doesn't contain a toolchain (so the drop-down is empty) the SDK check fails with ENV_SETUP_SCRIPT_NONEXIST. If a dialog pops up showing the error, the advice will also be used and added to the message.
[JZ] Yes, only for build tree derived toolchain, the mechanism for build the toolchain thus having the environment setup script is via "bitbake meta-ide-support" so we need to explicitly tell people what to do if they run into this error.
Quoted 30 lines
Thanks, Jessica
-----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Timo Mueller
Sent: Wednesday, February 27, 2013 6:37 AM To:
[email protected] Cc: Timo Mueller Subject: [yocto] [PATCH 0/5][eclipse-poky] Refactor handling of SDK check errorsFrom: Timo Mueller <[email protected]>
Hi,
I tried to display the messages resulting from validating the YoctoUISettings in the message area of the properties/preference pages instead of showing a dialog. This led to some refactoring of the validation functionality and also the messages.
If for example the user entered a SDK toolchain directory that doesn't exist in the global preferences a dialog will show up showing the error and telling him how he can do "IDE-wide settings". As he is currently trying to do "IDE-wide settings" this advice is not really necessary and the dialog can be really annoying.
I split up the messages into a one line error message and an advice. This message can be shown in the page's message area instead of opening a dialog with every configuration error. The advice can still be used when we want to show a dialog to help the user, e.g. when creating a new project.
Quoted 8 lines
On a side note I reactivated the YoctoSDKChecker class and moved all the validation code from the utils, getting rid of some duplicated and inconsistent code.
Best regards, Timo
PS: This patch set is based on "plugins/sdk.ide: Remove profile edit buttons from property page"
Best regards
Timo