]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.team.ui/src/org/simantics/team/ui/handlers/StageEditHandler.java
Removed contact application support prints
[simantics/platform.git] / bundles / org.simantics.team.ui / src / org / simantics / team / ui / handlers / StageEditHandler.java
index 87281fa1e579845fd3f379498a4864d0b218f42e..3a8f025737d6a17ccaa9045759655e22c7e22088 100644 (file)
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.team.ui.handlers;\r
-\r
-import java.io.File;\r
-import java.nio.charset.Charset;\r
-\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.ServerReference;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.LifecycleSupport;\r
-import org.simantics.team.Activator;\r
-import org.simantics.team.internal.StagingLauncher;\r
-import org.simantics.team.internal.StagingLauncher.Config;\r
-import org.simantics.team.internal.StagingLauncher.StagingResult;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.ui.workbench.handler.AbstractPreferenceHandler;\r
-import org.simantics.utils.FileUtils;\r
-import org.simantics.utils.ui.ErrorLogger;\r
-import org.simantics.utils.ui.dialogs.ShowError;\r
-\r
-public class StageEditHandler extends AbstractPreferenceHandler {\r
-\r
-    public StageEditHandler() {\r
-        super(Activator.getDefault());\r
-    }\r
-    private void showError(String msg, Throwable t) {\r
-        String title = "Staging failed!";\r
-        ShowError.showError(title, msg, t);\r
-    }\r
-    @Override\r
-    public Object execute(ExecutionEvent event) throws ExecutionException {\r
-        System.out.println("DEBUG: EditStageHandler");\r
-        try {\r
-            Session session = SimanticsUI.getSession();\r
-            File wsFolder = new File(Platform.getInstanceLocation().getURL().getFile());\r
-            File stFolder = new File(wsFolder, "staging");\r
-            if (!stFolder.isDirectory())\r
-                throw new DatabaseException("Folder must exist. path=" + stFolder.getAbsolutePath());\r
-            show(session, stFolder);\r
-        } catch (Throwable t) {\r
-            showError("Staging failed:", t);\r
-        } finally {\r
-        }\r
-        return null;\r
-    }\r
-    private void show(Session session, File stFolder) {\r
-        final IProgressMonitor monitor = new NullProgressMonitor();\r
-        try {\r
-            monitor.beginTask("begin", 1300);\r
-            LifecycleSupport lfs = session.getService(LifecycleSupport.class);\r
-            ServerReference sref = lfs.getSessionReference().getServerReference();\r
-//            SerialisationSupport ss = session.getService(SerialisationSupport.class);\r
-            String randomAccessId = "target"; // String.valueOf(ss.getRandomAccessId(target));\r
-            Resource targetLibrary = null;\r
-            final Config config = new Config(session, targetLibrary, stFolder, null);\r
-            StagingResult result = StagingLauncher.launch(config, sref.toString(), randomAccessId);\r
-            if (result.getExitValue() != 0) {\r
-                String msg = "";\r
-                if (result.getLogFile().exists()) {\r
-                    byte[] data = FileUtils.readFile(result.getLogFile());\r
-                    msg = new String(data, Charset.defaultCharset());\r
-                }\r
-                if (msg.isEmpty() || msg.matches(" *"))\r
-                    msg = "Staging crashed. Contact application support.";\r
-                ShowError.showError("Staging failed, errorcode="+result.getExitValue(), msg, new Exception());\r
-            }\r
-            if (result.getMessageLog() != null) {\r
-                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),\r
-                        "Staging failed",\r
-                        result.getMessageLog());\r
-            }\r
-            } catch (Exception e) {\r
-                ErrorLogger.defaultLogError(e);\r
-            } finally {\r
-                monitor.done();\r
-            }\r
-    }\r
-//    private String openInitDialog()\r
-//    throws DatabaseException {\r
-//        final Display display = PlatformUI.getWorkbench().getDisplay();\r
-//        final StageInitDialog.Data data = new StageInitDialog.Data();\r
-//        display.syncExec(new Runnable() {\r
-//            @Override\r
-//            public void run() {\r
-//                data.comment = "Help!";\r
-//                StageInitDialog d =  new StageInitDialog(display.getActiveShell(), data);\r
-//                if (Dialog.OK != d.open())\r
-//                    data.comment = null;\r
-//            }});\r
-//        return data.comment;\r
-//    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * 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:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.team.ui.handlers;
+
+import java.io.File;
+import java.nio.charset.Charset;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.PlatformUI;
+import org.simantics.db.Resource;
+import org.simantics.db.ServerReference;
+import org.simantics.db.Session;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.LifecycleSupport;
+import org.simantics.team.Activator;
+import org.simantics.team.internal.StagingLauncher;
+import org.simantics.team.internal.StagingLauncher.Config;
+import org.simantics.team.internal.StagingLauncher.StagingResult;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.ui.workbench.handler.AbstractPreferenceHandler;
+import org.simantics.utils.FileUtils;
+import org.simantics.utils.ui.ErrorLogger;
+import org.simantics.utils.ui.dialogs.ShowError;
+
+public class StageEditHandler extends AbstractPreferenceHandler {
+
+    public StageEditHandler() {
+        super(Activator.getDefault());
+    }
+    private void showError(String msg, Throwable t) {
+        String title = "Staging failed!";
+        ShowError.showError(title, msg, t);
+    }
+    @Override
+    public Object execute(ExecutionEvent event) throws ExecutionException {
+        System.out.println("DEBUG: EditStageHandler");
+        try {
+            Session session = SimanticsUI.getSession();
+            File wsFolder = new File(Platform.getInstanceLocation().getURL().getFile());
+            File stFolder = new File(wsFolder, "staging");
+            if (!stFolder.isDirectory())
+                throw new DatabaseException("Folder must exist. path=" + stFolder.getAbsolutePath());
+            show(session, stFolder);
+        } catch (Throwable t) {
+            showError("Staging failed:", t);
+        } finally {
+        }
+        return null;
+    }
+    private void show(Session session, File stFolder) {
+        final IProgressMonitor monitor = new NullProgressMonitor();
+        try {
+            monitor.beginTask("begin", 1300);
+            LifecycleSupport lfs = session.getService(LifecycleSupport.class);
+            ServerReference sref = lfs.getSessionReference().getServerReference();
+//            SerialisationSupport ss = session.getService(SerialisationSupport.class);
+            String randomAccessId = "target"; // String.valueOf(ss.getRandomAccessId(target));
+            Resource targetLibrary = null;
+            final Config config = new Config(session, targetLibrary, stFolder, null);
+            StagingResult result = StagingLauncher.launch(config, sref.toString(), randomAccessId);
+            if (result.getExitValue() != 0) {
+                String msg = "";
+                if (result.getLogFile().exists()) {
+                    byte[] data = FileUtils.readFile(result.getLogFile());
+                    msg = new String(data, Charset.defaultCharset());
+                }
+                if (msg.isEmpty() || msg.matches(" *"))
+                    msg = "Staging crashed.";
+                ShowError.showError("Staging failed, errorcode="+result.getExitValue(), msg, new Exception());
+            }
+            if (result.getMessageLog() != null) {
+                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(),
+                        "Staging failed",
+                        result.getMessageLog());
+            }
+            } catch (Exception e) {
+                ErrorLogger.defaultLogError(e);
+            } finally {
+                monitor.done();
+            }
+    }
+//    private String openInitDialog()
+//    throws DatabaseException {
+//        final Display display = PlatformUI.getWorkbench().getDisplay();
+//        final StageInitDialog.Data data = new StageInitDialog.Data();
+//        display.syncExec(new Runnable() {
+//            @Override
+//            public void run() {
+//                data.comment = "Help!";
+//                StageInitDialog d =  new StageInitDialog(display.getActiveShell(), data);
+//                if (Dialog.OK != d.open())
+//                    data.comment = null;
+//            }});
+//        return data.comment;
+//    }
+}