[Esbox-commits] r2070 - in trunk/org.maemo.esbox.cpp.project: . META-INF src/org/maemo/esbox/internal/cpp/project/core

eswartz at garage.maemo.org eswartz at garage.maemo.org
Tue Sep 1 19:46:51 EEST 2009


Author: eswartz
Date: 2009-09-01 19:46:51 +0300 (Tue, 01 Sep 2009)
New Revision: 2070

Added:
   trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ApplyDoctoolsFixMarkerResolutionGenerator.java
Modified:
   trunk/org.maemo.esbox.cpp.project/META-INF/MANIFEST.MF
   trunk/org.maemo.esbox.cpp.project/plugin.xml
   trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ConvertCppProjectMarkerResolutionGenerator.java
Log:
Merge revs 2062:2069 from work_Ed branch

Modified: trunk/org.maemo.esbox.cpp.project/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.maemo.esbox.cpp.project/META-INF/MANIFEST.MF	2009-09-01 15:59:16 UTC (rev 2069)
+++ trunk/org.maemo.esbox.cpp.project/META-INF/MANIFEST.MF	2009-09-01 16:46:51 UTC (rev 2070)
@@ -23,6 +23,9 @@
  org.eclipse.cdt.core;bundle-version="5.0.2",
  org.maemo.esbox.maemosdk.ui;bundle-version="2.0.0",
  org.maemo.mica.maemosdk.core;bundle-version="2.0.0",
- org.maemo.mica.cpp.project.builder.make;bundle-version="2.0.0"
+ org.maemo.mica.cpp.project.builder.make;bundle-version="2.0.0",
+ org.maemo.mica.cpp.project.builder.autotools;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.sb1;bundle-version="2.0.0",
+ org.maemo.esbox.scratchbox.core;bundle-version="2.0.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy

Modified: trunk/org.maemo.esbox.cpp.project/plugin.xml
===================================================================
--- trunk/org.maemo.esbox.cpp.project/plugin.xml	2009-09-01 15:59:16 UTC (rev 2069)
+++ trunk/org.maemo.esbox.cpp.project/plugin.xml	2009-09-01 16:46:51 UTC (rev 2070)
@@ -170,6 +170,10 @@
             class="org.maemo.esbox.internal.cpp.project.core.ConvertCppProjectMarkerResolutionGenerator"
             markerType="org.eclipse.core.resources.problemmarker">
       </markerResolutionGenerator>
+     <markerResolutionGenerator
+            class="org.maemo.esbox.internal.cpp.project.core.ApplyDoctoolsFixMarkerResolutionGenerator"
+            markerType="org.maemo.mica.cpp.project.builder.autotools.autotoolsProblemMarker">
+      </markerResolutionGenerator>
    </extension>
          
   <extension

Copied: trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ApplyDoctoolsFixMarkerResolutionGenerator.java (from rev 2069, branches/work_Ed/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ApplyDoctoolsFixMarkerResolutionGenerator.java)
===================================================================
--- trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ApplyDoctoolsFixMarkerResolutionGenerator.java	                        (rev 0)
+++ trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ApplyDoctoolsFixMarkerResolutionGenerator.java	2009-09-01 16:46:51 UTC (rev 2070)
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.cpp.project.core;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolution2;
+import org.eclipse.ui.IMarkerResolutionGenerator2;
+import org.maemo.esbox.internal.cpp.project.Activator;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDKTarget;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.project.core.ProjectManager;
+import org.maemo.mica.common.ui.dialogs.DialogUtils;
+import org.maemo.mica.cpp.project.builder.autotools.MicaAutotoolsConstants;
+import org.maemo.mica.internal.api.common.core.sdk.BaseSDKTarget;
+
+/**
+ * Apply a "quick fix" for detected errors about intltool being out of date.
+ * This really means, you need to add the "doctools" devkit.
+ * @author eswartz
+ *
+ */
+public class ApplyDoctoolsFixMarkerResolutionGenerator implements
+		IMarkerResolutionGenerator2 {
+
+	private static class FixupDoctoolsMarkerResolution implements
+			IMarkerResolution2 {
+		public String getDescription() {
+			return "Add the doctools devkit to your Scratchbox target.  This provides the approved version of intltool (don't install it inside the target).";
+		}
+
+		public Image getImage() {
+			return null;
+		}
+
+		public String getLabel() {
+			return "Add doctools devkit to target";
+		}
+
+		public void run(final IMarker marker) {
+			ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
+			try {
+				dialog.run(true, true, new IRunnableWithProgress() {
+
+					public void run(IProgressMonitor monitor)
+							throws InvocationTargetException,
+							InterruptedException {
+						monitor.beginTask("Adding devkit...", IProgressMonitor.UNKNOWN);
+						addDoctoolsDevkit(marker);
+						monitor.worked(1);
+						monitor.done();
+					}
+					
+				});
+				
+			} catch (InvocationTargetException e) {
+				Activator.getErrorLogger().logError("Unexpected error fixing marker", e.getCause());
+				return;
+			} catch (InterruptedException e) {
+				return;
+			}
+			
+			boolean build = DialogUtils.showQuestionDialog(null,
+					"Updated target", 
+					"Added the 'doctools' devkit to the target.\n \nDo you want to rebuild now?");
+			if (build) {
+				Job buildJob = new Job("Rebuild project") {
+
+					@Override
+					protected IStatus run(IProgressMonitor monitor) {
+						try {
+							marker.getResource().getProject().build(IncrementalProjectBuilder.FULL_BUILD,
+									monitor);
+							return Status.OK_STATUS;
+							
+						} catch (CoreException e) {
+							return e.getStatus();
+						}
+					}
+					
+				};
+				buildJob.schedule();
+					
+			}
+			
+		}
+		
+		/**
+		 * @param marker
+		 */
+		private void addDoctoolsDevkit(final IMarker marker) {
+			try {
+				// already checked
+				IResource rsrc = marker.getResource();
+				ISDKTarget target = ProjectManager.getInstance().getSDKTarget(rsrc.getProject());
+				// in case it changed...
+				if (target instanceof IScratchbox1SDKTarget) {
+					IScratchbox1SDKTarget sb1Target = (IScratchbox1SDKTarget) target;
+					// in case out of date
+					((BaseSDKTarget) sb1Target).clearCache();
+					sb1Target.addDevkit("doctools");
+					marker.delete();
+					
+				}
+			} catch (MicaException e) {
+				Activator.getErrorLogger().logAndShowError("Error updating devkits", e);
+			} catch (CoreException e) {
+				Activator.getErrorLogger().logError("Failed to fix marker", e);
+			}
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.IMarkerResolutionGenerator2#hasResolutions(org.eclipse.core.resources.IMarker)
+	 */
+	public boolean hasResolutions(IMarker marker) {
+		try {
+			if (marker.getType().equals(MicaAutotoolsConstants.AUTOTOOLS_PROBLEM_MARKER_TYPE)) {
+				Object message = marker.getAttribute(IMarker.MESSAGE);
+				if (message != null && message.toString().contains("Your intltool is too old")) {
+					// make sure doctools is not already present
+					IResource rsrc = marker.getResource();
+					if (rsrc != null) {
+						ISDKTarget target = ProjectManager.getInstance().getSDKTarget(rsrc.getProject());
+						if (target instanceof IScratchbox1SDKTarget) {
+							return true;
+						}
+					}
+				}
+			}
+		} catch (CoreException e) {
+			// marker bugs
+		} catch (MicaException e) {
+			// not a Mica project
+		}
+		return false;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker)
+	 */
+	public IMarkerResolution[] getResolutions(IMarker marker) {
+		return new IMarkerResolution[] {
+			new FixupDoctoolsMarkerResolution()
+		};
+	}
+
+	
+
+}

Modified: trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ConvertCppProjectMarkerResolutionGenerator.java
===================================================================
--- trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ConvertCppProjectMarkerResolutionGenerator.java	2009-09-01 15:59:16 UTC (rev 2069)
+++ trunk/org.maemo.esbox.cpp.project/src/org/maemo/esbox/internal/cpp/project/core/ConvertCppProjectMarkerResolutionGenerator.java	2009-09-01 16:46:51 UTC (rev 2070)
@@ -25,6 +25,7 @@
 import org.maemo.mica.internal.api.common.project.core.IOldFormatProjectBuilder;
 
 /**
+ * Apply a "quick fix" support for the problem generated by the old-format project builder.
  * @author eswartz
  *
  */



More information about the Esbox-commits mailing list