Fixed invalid imp file selection problem
authorhaismail <hussein.ismail@nokia.com>
Thu, 11 Feb 2010 10:37:13 +0200
changeset 3 9b808d6f55be
parent 2 a91cb670dd8e
child 4 77337b2717f2
Fixed invalid imp file selection problem
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/IMakerTabsViewer.java
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/PreferencesTab.java
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/IMakerTabsViewer.java	Tue Feb 09 17:10:58 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/IMakerTabsViewer.java	Thu Feb 11 10:37:13 2010 +0200
@@ -413,5 +413,10 @@
 	public Button getFRevertButton() {
 		return fRevertButton;
 	}
+	
+	public void restoreSelection()
+	{
+		fConfigWidget.select(0);
+	}
 
 }
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/PreferencesTab.java	Tue Feb 09 17:10:58 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/PreferencesTab.java	Thu Feb 11 10:37:13 2010 +0200
@@ -699,8 +699,12 @@
 		}
 
 		if (!found) {
-			IStatus status = new Status(Status.WARNING,IMakerPlugin.PLUGIN_ID,"Unable to fill dialog ui, because product: "+targetProduct+" not found!");
+			IStatus status = new Status(Status.ERROR,IMakerPlugin.PLUGIN_ID,"Unable to fill dialog ui, because product: "+targetProduct+" not found!");
 			IMakerPlugin.getDefault().getLog().log(status);			
+			clearWidgets();
+			StatusHandler.handle(IStatus.ERROR,"Unable to fill dialog ui, because product: "+targetProduct+" not found!",null);	
+			tabsViewer.restoreSelection();
+			loadImakerFile(ProjectManager.NEW_ITEM);
 			return;
 		}
 		
@@ -900,6 +904,28 @@
 			if(file!=null) {
 				ImakerProperties prop = null;
 				prop = ImakerProperties.createFromFile(file);
+				
+				if (prop.isEmpty())
+				{
+					StatusHandler.handle(IStatus.ERROR,"Unable to load preferences from file "+file.getName()+". Invalid or corrupted IMP file.",null);	
+					tabsViewer.restoreSelection();
+					loadImakerFile(ProjectManager.NEW_ITEM);
+					return;
+				}
+				if (!prop.containsKey(IMakerKeyConstants.PRODUCT))
+				{
+					StatusHandler.handle(IStatus.ERROR,"Unable to load product from file "+file.getName()+". Invalid or corrupted IMP file.",null);	
+					tabsViewer.restoreSelection();
+					loadImakerFile(ProjectManager.NEW_ITEM);
+					return;
+				}
+				if (!prop.containsKey(IMakerKeyConstants.TYPE))
+				{
+					StatusHandler.handle(IStatus.ERROR,"Unable to load image type from file "+file.getName()+". Invalid or corrupted IMP file.",null);	
+					tabsViewer.restoreSelection();
+					loadImakerFile(ProjectManager.NEW_ITEM);
+					return;
+				}
 				fillUIForm(prop);				
 			}
 		} else {