Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2013-10-21 04:53:17 -0400
committerEd Merks2013-10-21 04:53:17 -0400
commitf208f0fbe78d5b0da584586fa19e4e029783ad73 (patch)
tree649ccce46459741a004c1db398cce7dcee566d2f
parent0dcd43b2e700939bfcce670e238c65ce54a1aff8 (diff)
downloadcdo-f208f0fbe78d5b0da584586fa19e4e029783ad73.tar.gz
cdo-f208f0fbe78d5b0da584586fa19e4e029783ad73.tar.xz
cdo-f208f0fbe78d5b0da584586fa19e4e029783ad73.zip
Improve setup related models
Change-Id: I849125cd8e1d67e684ed056f061eb6b1079b1b6e Signed-off-by: Ed Merks <ed.merks@gmail.com>
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/ProgressLogDialog.java78
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/impl/P2TaskImpl.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/util/log/ProgressLog.java4
4 files changed, 101 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java
index c4ff4eac78..2294a185e5 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/SetupTaskPerformer.java
@@ -36,6 +36,7 @@ import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
@@ -58,7 +59,7 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
{
private static final String RELENG_URL = System.getProperty("releng.url",
"http://download.eclipse.org/modeling/emf/cdo/updates/integration").replace('\\', '/');
-
+
private static boolean NEEDS_PATH_SEPARATOR_CONVERSION = File.pathSeparatorChar == '\\';
private static final ComposedAdapterFactory ADAPTER_FACTORY = new ComposedAdapterFactory(
@@ -133,6 +134,11 @@ public class SetupTaskPerformer extends HashMap<Object, Object> implements Setup
}
}
+ public void log(IStatus status)
+ {
+ log(ProgressLogDialog.toString(status));
+ }
+
public boolean isCancelled()
{
if (progress != null)
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/ProgressLogDialog.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/ProgressLogDialog.java
index 9195b96369..d6c9487ca2 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/ProgressLogDialog.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/internal/setup/ui/ProgressLogDialog.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.releng.setup.util.log.ProgressLogRunnable;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
@@ -41,10 +42,12 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.progress.ProgressManager;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -244,6 +247,11 @@ public class ProgressLogDialog extends TitleAreaDialog implements ProgressLog
});
}
+ public void log(IStatus status)
+ {
+ log(toString(status));
+ }
+
public void setFinished()
{
Job.getJobManager().setProgressProvider(ProgressManager.getInstance());
@@ -363,4 +371,74 @@ public class ProgressLogDialog extends TitleAreaDialog implements ProgressLog
Activator.log(ex);
}
}
+
+ public static String toString(IStatus status)
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ PrintStream printStream;
+ try
+ {
+ printStream = new PrintStream(out, false, "UTF-8");
+ deeplyPrint(status, printStream, 0);
+ printStream.close();
+ return new String(out.toByteArray(), "UTF-8");
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ return status.getMessage();
+ }
+ }
+
+ private static void deeplyPrint(IStatus status, PrintStream strm, int level)
+ {
+ appendLevelPrefix(strm, level);
+ String msg = status.getMessage();
+ strm.println(msg);
+ Throwable cause = status.getException();
+ if (cause != null)
+ {
+ strm.print("Caused by: ");
+ if (!(msg.equals(cause.getMessage()) || msg.equals(cause.toString())))
+ {
+ deeplyPrint(cause, strm, level);
+ }
+ }
+
+ if (status.isMultiStatus())
+ {
+ IStatus[] children = status.getChildren();
+ for (int i = 0; i < children.length; i++)
+ {
+ deeplyPrint(children[i], strm, level + 1);
+ }
+ }
+ }
+
+ private static void deeplyPrint(Throwable t, PrintStream strm, int level)
+ {
+ if (t instanceof CoreException)
+ {
+ deeplyPrint(t, strm, level);
+ }
+ else
+ {
+ appendLevelPrefix(strm, level);
+ strm.println(t.toString());
+ Throwable cause = t.getCause();
+ if (cause != null)
+ {
+ strm.print("Caused by: "); //$NON-NLS-1$
+ deeplyPrint(cause, strm, level);
+ }
+ }
+ }
+
+ private static void appendLevelPrefix(PrintStream strm, int level)
+ {
+ for (int idx = 0; idx < level; ++idx)
+ {
+ strm.print(' ');
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/impl/P2TaskImpl.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/impl/P2TaskImpl.java
index f02f8be70d..8ec6a1e0fe 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/impl/P2TaskImpl.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/impl/P2TaskImpl.java
@@ -29,9 +29,11 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.director.app.DirectorApplication;
import org.eclipse.equinox.internal.p2.director.app.ILog;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
@@ -416,7 +418,8 @@ public class P2TaskImpl extends SetupTaskImpl implements P2Task
}
else
{
- context.log(status.toString());
+ context.log(status);
+ throw new CoreException(Status.CANCEL_STATUS);
}
}
}
@@ -492,7 +495,7 @@ public class P2TaskImpl extends SetupTaskImpl implements P2Task
public void log(IStatus status)
{
- log(status.getMessage());
+ context.log(status);
}
public void close()
@@ -500,9 +503,15 @@ public class P2TaskImpl extends SetupTaskImpl implements P2Task
}
});
- app.run(args);
+ Object exitCode = app.run(args);
+ if (EXIT_ERROR.equals(exitCode))
+ {
+ throw new CoreException(Status.CANCEL_STATUS);
+ }
}
+ private static final Integer EXIT_ERROR = 13;
+
private String makeList(SetupTaskContext context, EList<? extends EObject> objects, EAttribute attribute)
{
StringBuilder builder = new StringBuilder();
diff --git a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/util/log/ProgressLog.java b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/util/log/ProgressLog.java
index 3123c0f59f..78432050dd 100644
--- a/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/util/log/ProgressLog.java
+++ b/plugins/org.eclipse.emf.cdo.releng.setup/src/org/eclipse/emf/cdo/releng/setup/util/log/ProgressLog.java
@@ -10,6 +10,8 @@
*/
package org.eclipse.emf.cdo.releng.setup.util.log;
+import org.eclipse.core.runtime.IStatus;
+
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -22,4 +24,6 @@ public interface ProgressLog
public boolean isCancelled();
public void log(String line);
+
+ public void log(IStatus status);
}

Back to the top