[Esbox-commits] r1068 - in branches/work_Petr: org.maemo.esbox.maemosdk.tests/src/org/maemo/esbox/scratchbox/tests/commands org.maemo.esbox.scratchbox.sb1 org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1 org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core org.maemo.esbox.scratchbox.ui/src/org/maemo/esbox/internal/api/scratchbox/ui/wizards

eswartz at garage.maemo.org eswartz at garage.maemo.org
Sat Dec 13 01:37:08 EET 2008


Author: eswartz
Date: 2008-12-13 01:37:08 +0200 (Sat, 13 Dec 2008)
New Revision: 1068

Added:
   branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapter.java
   branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapterFactory.java
Removed:
   branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapter.java
   branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapterFactory.java
Modified:
   branches/work_Petr/org.maemo.esbox.maemosdk.tests/src/org/maemo/esbox/scratchbox/tests/commands/BaseTest.java
   branches/work_Petr/org.maemo.esbox.scratchbox.sb1/plugin.xml
   branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java
   branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java
   branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java
   branches/work_Petr/org.maemo.esbox.scratchbox.ui/src/org/maemo/esbox/internal/api/scratchbox/ui/wizards/TargetWizardNamePage.java
Log:
Merge revs 202:209 from trunk, and migrate doctools support to AdaptToTargetsProcess / ITemplateProcessWrapperAdapter.  Also fix inaccurate progress monitoring of template wizard.  Finally, refresh SDKs through factory instead of through ISDK#refresh().

Modified: branches/work_Petr/org.maemo.esbox.maemosdk.tests/src/org/maemo/esbox/scratchbox/tests/commands/BaseTest.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.maemosdk.tests/src/org/maemo/esbox/scratchbox/tests/commands/BaseTest.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.maemosdk.tests/src/org/maemo/esbox/scratchbox/tests/commands/BaseTest.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -20,6 +20,7 @@
 import org.maemo.mica.common.core.machine.IFileSystemAccess;
 import org.maemo.mica.common.core.process.IProcessLauncherFactory;
 import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.core.sdk.SDKFactory;
 import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
 
 import junit.framework.TestCase;
@@ -42,6 +43,7 @@
 	 */
 	@Before
 	public void setUp() throws Exception {
+		SDKFactory.getInstance().waitForRefreshComplete(null);
 		this.sb1Sdk = ScratchboxSDKFacade.getInstance().getScratchboxSDK(IScratchbox1SDK.class).get(0);
 		this.sb1Command = ((Scratchbox1SDK) sb1Sdk).getCommandAbstractor();  
 		this.sb2Sdk = ScratchboxSDKFacade.getInstance().getScratchboxSDK(IScratchbox2SDK.class).get(0);

Modified: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/plugin.xml
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb1/plugin.xml	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb1/plugin.xml	2008-12-12 23:37:08 UTC (rev 1068)
@@ -41,9 +41,9 @@
       </factory>
       <factory
             adaptableType="org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDKTarget"
-            class="org.maemo.esbox.internal.scratchbox.sb1.core.adapters.Sb1TargetConfigurationAdapterFactory">
+            class="org.maemo.esbox.internal.scratchbox.sb1.core.adapters.Sb1TargetLocalizationSupportAdapterFactory">
          <adapter
-               type="org.maemo.mica.common.core.adapters.ITargetConfiguratorAdapter">
+               type="org.maemo.mica.maemosdk.ui.adapters.ITargetLocalizationSupportAdapter">
          </adapter>
       </factory>
    </extension>

Modified: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/Activator.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -14,9 +14,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.*;
 import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.resource.ImageDescriptor;
@@ -153,4 +151,34 @@
 		}
 		return preferenceStore;
 	}
+	
+	/**
+	 * @param object
+	 * @param e
+	 * @return
+	 */
+	public static IStatus createErrorStatus(String msg, Throwable t) {
+		return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
+	}
+
+	/**
+	 * @param warning
+	 * @param format
+	 * @param e
+	 * @return
+	 */
+	public static IStatus createStatus(int severity, String msg,
+			Throwable t) {
+		return new Status(severity, PLUGIN_ID, msg, t);
+	}
+
+	/**
+	 * @param warning
+	 * @param string
+	 * @return
+	 */
+	public static IStatus createStatus(int severity, String string) {
+		return new Status(severity, PLUGIN_ID, string);
+	}
+	
 }

Deleted: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapter.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapter.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapter.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Nokia Corporation
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Petr Baranov (Nokia) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.scratchbox.sb1.core.adapters;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.maemo.esbox.internal.scratchbox.sb1.Activator;
-import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDKTarget;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.adapters.ITargetConfiguratorAdapter;
-
-public class Sb1TargetConfigurationAdapter implements
-		ITargetConfiguratorAdapter {
-	private final IScratchbox1SDKTarget target;
-
-	public Sb1TargetConfigurationAdapter(IScratchbox1SDKTarget target) {
-		this.target = target;
-	}
-
-	public void addDevkits(List<String> newDevkit) {
-		try {
-			target.addDevkits(newDevkit);
-		} catch (MicaException e) {
-			Activator.getErrorLogger().log(IStatus.WARNING,
-					"Template requires nonexisting devkit.", e);
-		}
-	}
-
-	public boolean isTargetDevkit(String devkit) {
-		try {
-			return target.getDevkit().contains(devkit);
-		} catch (MicaException e) {
-			Activator.getErrorLogger().log(IStatus.WARNING,
-					"Template requires nonexisting devkit.", e);
-		}
-		return false;
-	}
-
-}

Deleted: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapterFactory.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapterFactory.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapterFactory.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Nokia Corporation
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *    Petr Baranov (Nokia) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.scratchbox.sb1.core.adapters;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDKTarget;
-import org.maemo.mica.common.core.adapters.ITargetConfiguratorAdapter;
-
-public class Sb1TargetConfigurationAdapterFactory implements IAdapterFactory {
-
-	public Object getAdapter(Object adaptableObject, Class adapterType) {
-		if (adapterType.equals(ITargetConfiguratorAdapter.class)) {
-			if (adaptableObject instanceof IScratchbox1SDKTarget) {
-				return new Sb1TargetConfigurationAdapter(
-						(IScratchbox1SDKTarget) adaptableObject);
-			}
-		}
-		return null;
-	}
-
-	public Class[] getAdapterList() {
-		return new Class[] { ITargetConfiguratorAdapter.class };
-	}
-
-}

Copied: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapter.java (from rev 1059, branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapter.java)
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapter.java	                        (rev 0)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapter.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.core.adapters;
+
+import com.nokia.carbide.template.engine.ITemplate;
+import com.nokia.carbide.templatewizard.process.*;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.maemo.esbox.internal.scratchbox.sb1.Activator;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDKTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.maemosdk.ui.adapters.ITargetLocalizationSupportAdapter;
+
+/**
+ * For scratchbox 1, enable "doctools" in a project
+ * @author baranov
+ * @author eswartz
+ *
+ */
+public class Sb1TargetLocalizationSupportAdapter extends AbstractProcess implements ITargetLocalizationSupportAdapter {
+	private final IScratchbox1SDKTarget target;
+
+	public Sb1TargetLocalizationSupportAdapter(IScratchbox1SDKTarget target) {
+		this.target = target;
+	}
+
+	/* (non-Javadoc)
+	 * @see com.nokia.carbide.templatewizard.process.AbstractProcess#getPlugin()
+	 */
+	@Override
+	protected Plugin getPlugin() {
+		return Activator.getDefault();
+	}
+	
+	/* (non-Javadoc)
+	 * @see com.nokia.carbide.templatewizard.process.AbstractProcess#process(com.nokia.carbide.template.engine.ITemplate, java.util.List, org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	@Override
+	public void process(ITemplate template, List<IParameter> parameters,
+			IProgressMonitor monitor) throws CoreException {
+		
+		// parameters aren't needed here
+		
+		monitor.beginTask("", 1);
+		monitor.subTask("Checking for doctools...");
+		
+		try {
+			if (target.getDevkit().contains("doctools"))
+				return;
+		} catch (MicaException e) {
+			throw new CoreException(Activator.createErrorStatus("Failed to detect doctools", e));
+		}
+		
+		// ask user...
+		final boolean[] permission = { false };
+		Display.getDefault().syncExec(new Runnable() {
+
+			public void run() {
+				permission[0] = MessageDialog.openQuestion(null,
+						"Target change needed",
+						MessageFormat.format(
+								"The target ''{0}'' needs the ''doctools'' devkit to properly build this project.\n\nAdd it now?",
+								target.getName()));
+			}
+			
+		});
+
+		if (permission[0]) {
+			try {
+				target.addDevkit("doctools");
+			} catch (MicaException e) {
+				throw new CoreException(Activator.createErrorStatus("Failed to add doctools support", e));
+			}
+		}
+		
+	}
+
+	/* (non-Javadoc)
+	 * @see com.nokia.carbide.templatewizard.process.AbstractProcess#init(com.nokia.carbide.template.engine.ITemplate, java.util.List)
+	 */
+	@Override
+	protected void init(ITemplate template, List<IParameter> parameters)
+			throws CoreException {
+		
+	}
+
+}


Property changes on: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapter.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Copied: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapterFactory.java (from rev 1059, branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetConfigurationAdapterFactory.java)
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapterFactory.java	                        (rev 0)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapterFactory.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.scratchbox.sb1.core.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDKTarget;
+import org.maemo.mica.maemosdk.ui.adapters.ITargetLocalizationSupportAdapter;
+
+public class Sb1TargetLocalizationSupportAdapterFactory implements IAdapterFactory {
+
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(ITargetLocalizationSupportAdapter.class)) {
+			if (adaptableObject instanceof IScratchbox1SDKTarget) {
+				return new Sb1TargetLocalizationSupportAdapter(
+						(IScratchbox1SDKTarget) adaptableObject);
+			}
+		}
+		return null;
+	}
+
+	public Class[] getAdapterList() {
+		return new Class[] { ITargetLocalizationSupportAdapter.class };
+	}
+
+}


Property changes on: branches/work_Petr/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/adapters/Sb1TargetLocalizationSupportAdapterFactory.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Modified: branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/command/CreateMaemoRootstrapSb2Command.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -19,6 +19,7 @@
 import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
 import org.maemo.mica.common.core.process.ProcessLauncherUtils;
 import org.maemo.mica.common.core.sdk.ISDK;
+import org.maemo.mica.common.core.sdk.SDKFactory;
 import org.maemo.mica.common.core.sdk.commands.ICommandAbstractor;
 
 import java.util.ArrayList;
@@ -83,7 +84,7 @@
 				null, "Installing rootstrap " + targetName));
 		doPerformCommand(params, envBlock, 0);
 
-		sdk.refresh();
+		SDKFactory.getInstance().refresh(false);
 
 		return true;
 	}

Modified: branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/core/Scratchbox2SDKTarget.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -34,7 +34,6 @@
 public class Scratchbox2SDKTarget extends AbstractScratchboxSDKTarget implements IScratchbox2SDKTarget{
 	private IPath targetRoot;
 	private IPath rootstrapRoot;
-	private String session = null;
 	
 	public Scratchbox2SDKTarget(Scratchbox2SDK sdk, ISDKPlatform platform,
 			String architecture, String target, IPath targetRoot) throws MicaException {
@@ -50,10 +49,7 @@
 	
 	
 	public String getSession() throws MicaException {
-		if (session == null) {
-			session = Activator.getDefault().findOrCreateSession(this);
-		}
-		return session;
+		return Activator.getDefault().findOrCreateSession(this);
 	}
 
 	/*

Modified: branches/work_Petr/org.maemo.esbox.scratchbox.ui/src/org/maemo/esbox/internal/api/scratchbox/ui/wizards/TargetWizardNamePage.java
===================================================================
--- branches/work_Petr/org.maemo.esbox.scratchbox.ui/src/org/maemo/esbox/internal/api/scratchbox/ui/wizards/TargetWizardNamePage.java	2008-12-12 22:18:34 UTC (rev 1067)
+++ branches/work_Petr/org.maemo.esbox.scratchbox.ui/src/org/maemo/esbox/internal/api/scratchbox/ui/wizards/TargetWizardNamePage.java	2008-12-12 23:37:08 UTC (rev 1068)
@@ -21,6 +21,7 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.*;
 import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDK;
+import org.maemo.mica.common.core.sdk.SDKFactory;
 import org.maemo.mica.internal.api.maemosdk.ui.wizards.IValidatePage;
 import org.maemo.mica.internal.api.maemosdk.ui.wizards.TargetListener;
 
@@ -138,6 +139,6 @@
 	 * new targets.
 	 */
 	private void updateTargetList() {
-		sdk.refresh();
+		SDKFactory.getInstance().refresh(false);
 	}
 }
\ No newline at end of file



More information about the Esbox-commits mailing list