Ticket #1245: Update target selection required to avoid yellow warnings on content tab
authorhaismail <hussein.ismail@nokia.com>
Thu, 18 Feb 2010 08:20:36 +0200
changeset 5 d5efbe6c22e8
parent 4 77337b2717f2
child 6 7f60f3388609
Ticket #1245: Update target selection required to avoid yellow warnings on content tab Ticket #1135: As a iMaker plugin user i want to reload available configurations (reload the current configuration)
imakerplugin/com.nokia.s60tools.imaker/doc/change_log_3_0_0.txt
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/IIMakerWrapper.java
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/UIConfiguration.java
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/model/Environment.java
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/DebugTab.java
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
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/wrapper/IMakerWrapper.java
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/wrapper/IMakerWrapperPreferences.java
imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/messages.properties
--- a/imakerplugin/com.nokia.s60tools.imaker/doc/change_log_3_0_0.txt	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/doc/change_log_3_0_0.txt	Thu Feb 18 08:20:36 2010 +0200
@@ -15,6 +15,8 @@
 Ticket #1188: As a Carbide.c++ user I want to modify my .IMP file using iMaker plugin
 Ticket #1137: Rename debug tab in iMaker plugin to something else
 Ticket #1055: As a SW developer I don't want to have temporary files in my Carbide.c++ workspace
+Ticket #1245: Update target selection required to avoid yellow warnings on content tab
+Ticket #1135: As a iMaker plugin user i want to reload available configurations (reload the current configuration)
 
 Enhancements
 License changed from SFL to EPL
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/IIMakerWrapper.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/IIMakerWrapper.java	Thu Feb 18 08:20:36 2010 +0200
@@ -134,5 +134,5 @@
 	 * @param monitor, monitor object
 	 * @return
 	 */
-	public abstract String getTargetSteps(String target,String makefile, IProgressMonitor monitor);
+	public abstract String getTargetSteps(String target,String makefile, IProgressMonitor monitor) throws IMakerCoreExecutionException;
 }
\ No newline at end of file
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/UIConfiguration.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/UIConfiguration.java	Thu Feb 18 08:20:36 2010 +0200
@@ -321,6 +321,11 @@
 		return null;
 	}
 
+	public void reload() throws Throwable {
+		loaded = false;
+		load();
+	}
+	
 	public void load() throws Throwable {
 		if(loaded ) {
 			return;
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/model/Environment.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/model/Environment.java	Thu Feb 18 08:20:36 2010 +0200
@@ -189,7 +189,11 @@
 //				@Override
 				public void run(IProgressMonitor monitor) throws InvocationTargetException,
 						InterruptedException {
-					targetSteps = wrapper.getTargetSteps(target, getCurrentProduct().getFilePath(), monitor);
+					try {
+						targetSteps = wrapper.getTargetSteps(target, getCurrentProduct().getFilePath(), monitor);
+					} catch (IMakerCoreExecutionException e) {
+						throw new InvocationTargetException(e);
+					}
 				}
 			});
 		} catch (InvocationTargetException e) {
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/DebugTab.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/DebugTab.java	Thu Feb 18 08:20:36 2010 +0200
@@ -18,6 +18,7 @@
 package com.nokia.s60tools.imaker.internal.viewers;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -335,9 +336,8 @@
 						}
 					}
 				}
-				String message = Messages.getString("DebugTab.0");
-				entry.setStatusMessage(message.replace("xxx", location.substring(1)));
-				return true;
+				mainTab.addTarget(entry.getLocation().getName());
+				return false;
 			}
 
 			private boolean isError(Object element) {
@@ -463,7 +463,9 @@
 	 */
 	public void addToProperties(ImakerProperties prop) {
 		ImageContent input = getInput();
-		prop.put(IMakerKeyConstants.DEBUGFILES, input.getEntries());			
+		List<IbyEntry> ls = new ArrayList<IbyEntry>();
+		ls.addAll(input.getEntries());
+		prop.put(IMakerKeyConstants.DEBUGFILES, ls);			
 
 	}
 	
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/IMakerTabsViewer.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/IMakerTabsViewer.java	Thu Feb 18 08:20:36 2010 +0200
@@ -76,6 +76,7 @@
 	private IEnvironmentManager environmentManager;
 	private PreferencesTab tabPreferences;
 	private Button fRestoreButton;
+	private Button fReloadButton;
 	private SettingsTab tabSettings;
 	private Combo fConfigWidget;
 	private Button deleteButton;
@@ -257,6 +258,7 @@
 		Composite buttonComp = new Composite(mainComp, SWT.NONE);
 		GridLayout buttonCompLayout = new GridLayout();
 		buttonCompLayout.numColumns = 2;
+		buttonCompLayout.makeColumnsEqualWidth = false;
 		buttonComp.setLayout(buttonCompLayout);
 		gd = new GridData(GridData.FILL_HORIZONTAL);
 		buttonComp.setLayoutData(gd);
@@ -273,6 +275,18 @@
 			}
 		});
 		
+		fReloadButton = new Button(buttonComp, SWT.PUSH);
+		fReloadButton.setText(Messages.getString("IMakerTabsViewer.12")); //$NON-NLS-1$
+		fReloadButton.setToolTipText(Messages.getString("IMakerTabsViewer.13")); //$NON-NLS-1$
+		gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
+		fReloadButton.setLayoutData(gd);
+		SWTFactory.setButtonWidthHint(fReloadButton);
+		fReloadButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent evt) {
+				handleReloadPressed();
+			}
+		});
+		
         Dialog.applyDialogFont(parent);
 	}
 
@@ -287,12 +301,14 @@
 		tabPreferences.restore();
 	}
 		
+	private void handleReloadPressed() {
+		tabPreferences.reload(getSelectedItem());
+	}
+	
 	protected void handleRevertPressed() {
 		if(fTabFolder.getSelection() == tabSettings) {
 			tabPreferences.refreshSettingsTab(null);
-		} else {
-//			tabPreferences.revert();
-		}
+		} else {}
 	}
 
 	/**
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/PreferencesTab.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/viewers/PreferencesTab.java	Thu Feb 18 08:20:36 2010 +0200
@@ -393,9 +393,12 @@
 			
 //			@Override
 			public void widgetSelected(SelectionEvent se) {
-				String item = listTarget.getItem(listTarget.getSelectionIndex());
-				UIConfiguration p = activeEnvironment.getCurrentProduct();
-				listTarget.setToolTipText(p.getTarget(item).getDescription());
+				int index = listTarget.getSelectionIndex();
+				if(index!=-1) {
+					String item = listTarget.getItem(index);
+					UIConfiguration p = activeEnvironment.getCurrentProduct();
+					listTarget.setToolTipText(p.getTarget(item).getDescription());					
+				}
 			}
 			
 //			@Override
@@ -493,7 +496,7 @@
 			UITarget tr = pr.getTarget(target);
 			if(tr.getSteps()==null) {
 				String targetSteps = activeEnvironment.getTargetSteps(target);
-				tr.setSteps(targetSteps);				
+				tr.setSteps(targetSteps);
 			}
 		}
 	}
@@ -543,7 +546,7 @@
 		List<UIConfiguration> configs;
 		try {
 			configs = activeEnvironment.getConfigurations();
-			UIConfiguration ret = null;
+			UIConfiguration ret = getSelectedProduct();
 			for (UIConfiguration config : configs) {
 				if(config.isDefaultConfig()) {
 					ret = config;
@@ -640,7 +643,7 @@
 		}
 	}
 
-	private Properties getUIValues() {
+	private ImakerProperties getUIValues() {
 		ImakerProperties prop = new ImakerProperties();
 		try {
 			UIConfiguration config = (UIConfiguration) textProduct.getData();
@@ -1001,4 +1004,28 @@
 	public UIConfiguration getSelectedProduct() {
 		return activeEnvironment.getCurrentProduct();
 	}
+
+
+	/**
+	 * Add the given target to the list of selected targets if
+	 * it is not already there
+	 * @param name
+	 */
+	public void addTarget(String newTarget) {
+		addToListTarget(new String[]{newTarget.toLowerCase()});
+	}
+
+
+	public void reload(String selection) {
+		if(ProjectManager.NEW_ITEM.equals(selection)) {
+			try {
+				ImakerProperties ui = getUIValues();
+				getSelectedProduct().reload();
+				fillUIForm(ui);
+			} catch (Throwable e) {
+				StatusHandler.handle(IStatus.ERROR,"An error has occurred while executing iMaker Core.",e);
+				return;
+			}
+		}
+	}
 }
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/wrapper/IMakerWrapper.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/wrapper/IMakerWrapper.java	Thu Feb 18 08:20:36 2010 +0200
@@ -816,10 +816,21 @@
 		return this.tool;
 	}
 
-	public String getTargetSteps(String target, String makefile, IProgressMonitor monitor) {
+	public String getTargetSteps(String target, String makefile, IProgressMonitor monitor) throws IMakerCoreExecutionException {
 		if (monitor != null) {
-			monitor.beginTask(Messages.getString("IMakerWrapper.24"),2);
-			monitor.subTask(Messages.getString("IMakerWrapper.25"));
+			monitor.beginTask(Messages.getString("IMakerWrapper.29"),10);
+		}
+		String ret = getTargetSteps2(target, makefile, monitor,false); 
+		if(monitor!=null) {
+			monitor.done();
+		}
+		return ret;
+	}
+
+	private String getTargetSteps2(String target, String makefile,
+			IProgressMonitor monitor, boolean isRestart) throws IMakerCoreExecutionException {
+		if(monitor!=null) {
+			monitor.subTask(Messages.getString("IMakerWrapper.30")+ target);
 		}
 		Pattern pattern = Pattern.compile(".*\\s*=\\s*.(.*).");
 		List<String> cmd = new ArrayList<String>();
@@ -827,37 +838,54 @@
 		cmd.add(makefile);
 		cmd.add(target);
 		cmd.add(IMakerWrapperPreferences.TARGET_STEPS);
-		try {
-			if(monitor!=null) {
-				monitor.worked(1);
-				monitor.subTask(Messages.getString("IMakerWrapper.26"));
+		if(isRestart) {
+			cmd.add(IMakerWrapperPreferences.TARGET_STEPS_RESTARTS);
+		}
+		StringBuilder sb = new StringBuilder();
+		List<String> ret = executeCommand(cmd,null);
+		for (String str : ret) {
+			Matcher matcher = pattern.matcher(str);
+			if(matcher.find()) {
+				int end = matcher.end(1);
+				int start = matcher.start(1);
+				String retValue = str.substring(start,end);
+				if(retValue.contains(" RESTART")) {
+					String subRet = getTargetSteps2(target,makefile,monitor,true);
+					if(subRet!=null) sb.append(subRet);
+				} else {
+					String[] parts = retValue.split(" ");
+					
+					for (int i = 0; i < parts.length; i++) {
+						String p = parts[i];
+						if(isTarget(p)) {
+							String subRet = getTargetSteps2(p,makefile,monitor, false); 
+							if(subRet!=null) sb.append(subRet);
+						} else {
+							sb.append(p);
+							sb.append(" ");							
+						}
+					}
+				}
+				break;
 			}
-			StringBuilder sb = new StringBuilder();
-			List<String> ret = executeCommand(cmd,null);
-			for (String str : ret) {
-				Matcher matcher = pattern.matcher(str);
-				if(matcher.find()) {
-					int end = matcher.end(1);
-					int start = matcher.start(1);
-					String retValue = str.substring(start,end);
-					if(monitor!=null) {
-						monitor.worked(1);
-						monitor.done();
-					}
-					sb.append(retValue);
-					sb.append(" ");
-				}
-			}
-			String str = sb.toString();
-			if(str.equals("")) {
-				return null;
-			} else {
-				return str;
-			}
-		} catch (IMakerCoreExecutionException e) {
-			e.printStackTrace();
+		}
+		String str = sb.toString();
+		if(monitor!=null) {
+			monitor.worked(1);
 		}
-		return null;
+		if(str.equals("")) {
+			return null;
+		} else {
+			return str;
+		}
+	}
+
+	private boolean isTarget(String p) {
+		if(p!=null) {
+			String pl = p.toLowerCase();
+			return pl.equals(p);
+		}
+		return false;
 	}
 
 	public boolean buildImage(File impFile, OutputStream out)
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/wrapper/IMakerWrapperPreferences.java	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/internal/wrapper/IMakerWrapperPreferences.java	Thu Feb 18 08:20:36 2010 +0200
@@ -62,4 +62,5 @@
 	public static final String PLATSIM_STEP 			        = "step-PLATBLD";
 	public static final String USE_PLATSIM 			        	= "USE_PLATSIM";
 	public static final String TARGET_STEPS 			      	= "print-IMAKER_STEPS";
+	public static final String TARGET_STEPS_RESTARTS 	    	= "IMAKER_MKRESTARTS=1";
 }
--- a/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/messages.properties	Thu Feb 11 10:40:36 2010 +0200
+++ b/imakerplugin/com.nokia.s60tools.imaker/src/com/nokia/s60tools/imaker/messages.properties	Thu Feb 18 08:20:36 2010 +0200
@@ -36,6 +36,8 @@
 IMakerTabsViewer.9=PlatSim
 IMakerTabsViewer.10=Configure PlatSim instance settings
 IMakerTabsViewer.11=Restore default configuration 
+IMakerTabsViewer.12=Reload
+IMakerTabsViewer.13=Reload selected configuration 
 Flashmenu.0=iMaker plugin preferences doesn't contain valid information. Please verify the preferences you provided.
 Flashmenu.1=Build preferences are not set. Set build preferences by selecting 'Preferences...' from iMaker Plugin's menu.
 Flashmenu.4=TYPE=prd
@@ -82,6 +84,8 @@
 IMakerWrapper.26=Getting target information from iMaker...please wait. 
 IMakerWrapper.27=Make sure that iMaker cmd (xxx) exists. 
 IMakerWrapper.28=command: 
+IMakerWrapper.29=Fetching target steps please wait...
+IMakerWrapper.30=Processing...
 SettingsTable.header0=Parameter
 SettingsTable.header1=Value
 SettingsTable.header2=Value format