]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.template2d.ui/src/org/simantics/modeling/template2d/ui/export/DrawingTemplateExporter.java
Add progress monitoring for copying resources on desktop
[simantics/platform.git] / bundles / org.simantics.modeling.template2d.ui / src / org / simantics / modeling / template2d / ui / export / DrawingTemplateExporter.java
index 2a60f8095b812820e3b59d9f58c793db6c75a50a..e3ae930349052d7c66d52df821857c4761486050 100644 (file)
@@ -6,6 +6,7 @@ import java.util.List;
 import java.util.Set;
 
 import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
 import org.osgi.service.prefs.Preferences;
 import org.simantics.databoard.binding.mutable.Variant;
 import org.simantics.databoard.type.RecordType;
@@ -61,9 +62,10 @@ public class DrawingTemplateExporter implements ExportClass {
                        ) throws ExportException {
                                
                final TransferableGraphWriter writer = (TransferableGraphWriter) writer_;
-               
+               SubMonitor ss = SubMonitor.convert(monitor, 2);
         try {
                List<Resource> resources = context.session.syncRequest( ExportQueries.toResources2(contents) );
+               SubMonitor subMonitor = ss.split(resources.size());
                for ( final Resource model : resources ) {
                    // TODO: figure out a way to make the TG go directly into a file
                    // instead of having it all in memory at once.
@@ -72,13 +74,15 @@ public class DrawingTemplateExporter implements ExportClass {
                        public SimanticsClipboard perform(ReadGraph graph) throws DatabaseException {
                            CopyHandler ch = graph.adapt( model, CopyHandler.class );
                            SimanticsClipboardImpl clipboard = new SimanticsClipboardImpl();
-                           ch.copyToClipboard(graph, clipboard);
+                           ch.copyToClipboard(graph, clipboard, subMonitor.split(1));
                            return clipboard;
                        }
                    });
+                   SubMonitor subMonitor2 = ss.split(resources.size());
                    for (Set<Representation> object : clipboard.getContents()) {
                        TransferableGraph1 tg = ClipboardUtils.accept(object, SimanticsKeys.KEY_TRANSFERABLE_GRAPH);                    
                        writer.writeFile(TransferableGraph1.BINDING, tg);
+                       subMonitor2.worked(1);
                    }
                }