From: jsimomaa Date: Thu, 26 Oct 2017 09:15:24 +0000 (+0300) Subject: Progress monitoring to users Pgraph compilation X-Git-Tag: v1.31.0~62 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F1181%2F7;p=simantics%2Fplatform.git Progress monitoring to users Pgraph compilation refs #7576 Change-Id: I98004732bb8d3e1171dbd846bd2c476e00fd9f72 --- diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphsAction.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphsAction.java index 783244a61..eda0228f9 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphsAction.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/actions/CompilePGraphsAction.java @@ -2,6 +2,10 @@ package org.simantics.modeling.ui.actions; import java.io.IOException; +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.MessageDialog; import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.layout.GridLayoutFactory; @@ -16,6 +20,7 @@ import org.simantics.db.layer0.adapter.ActionFactory; import org.simantics.graph.compiler.CompilationResult; import org.simantics.ltk.Problem; import org.simantics.modeling.CompilePGraphs; +import org.simantics.modeling.ui.Activator; import org.simantics.utils.ui.ExceptionUtils; /** @@ -28,11 +33,21 @@ public class CompilePGraphsAction implements ActionFactory { if (!(target instanceof Resource)) return null; return () -> { - try { - CompilePGraphs.compilePGraphs((Resource) target, new CompileUserAgent()); - } catch (IOException | DatabaseException e) { - ExceptionUtils.logAndShowError(e); - } + Job job = new Job("Compile PGraphs") { + @Override + protected IStatus run(IProgressMonitor monitor) { + try { + CompilePGraphs.compilePGraphs((Resource) target, new CompileUserAgent(), monitor); + return Status.OK_STATUS; + } catch (IOException | DatabaseException e) { + ExceptionUtils.logAndShowError(e); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage()); + } finally { + monitor.done(); + } + } + }; + job.schedule(); }; } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java index 10e23c65b..7f7171dca 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/CompilePGraphs.java @@ -16,6 +16,8 @@ import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; import org.osgi.framework.Bundle; import org.simantics.Simantics; import org.simantics.databoard.Bindings; @@ -86,6 +88,10 @@ public class CompilePGraphs { } public static void compilePGraphs(Resource r, UserAgent userAgent) throws IOException, DatabaseException { + compilePGraphs(r, userAgent, new NullProgressMonitor()); + } + + public static void compilePGraphs(Resource r, UserAgent userAgent, IProgressMonitor monitor) throws IOException, DatabaseException { final Collection sources = new ArrayList<>(); Collection dependencies = new ArrayList<>(); @@ -249,6 +255,9 @@ public class CompilePGraphs { } }); } + + // Delete index to get rid of floating old instances of the same ontology +// DatabaseIndexing.deleteAllIndexes(); } private static File extractLib(URL libURL, String libName) throws FileNotFoundException, IOException {