Beautifying print publishing plugin
authorn.hoffmann <n.hoffmann@localhost>
Tue, 21 Sep 2010 11:45:53 +0000 (11:45 +0000)
committern.hoffmann <n.hoffmann@localhost>
Tue, 21 Sep 2010 11:45:53 +0000 (11:45 +0000)
taxeditor-printpublisher/META-INF/MANIFEST.MF
taxeditor-printpublisher/plugin.xml
taxeditor-printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/handler/GeneratePdfHandler.java
taxeditor-printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/wizard/AbstractPublishWizard.java
taxeditor-printpublisher/src/main/java/eu/etaxonomy/taxeditor/printpublisher/wizard/SelectFeatureTreeWizardPage.java

index d2cc1b1f55e4f80ab0bbf4160d5d05c70c2e7033..18479a8be57852c12623f4868749038b22992395 100644 (file)
@@ -10,6 +10,7 @@ Require-Bundle: org.eclipse.osgi;bundle-version="3.5.2",
  eu.etaxonomy.taxeditor.store;bundle-version="2.1.0"
 Import-Package: org.apache.log4j,
  org.eclipse.core.runtime;version="3.4.0",
+ org.eclipse.core.runtime.jobs,
  org.osgi.framework;version="1.5.0"
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: EDIT
index d2fa494ae9a3a6599367462453a671fbde13dfe0..298486ec7a3d6b13b203075f46f506667b749051 100644 (file)
@@ -7,29 +7,29 @@
             id="print-publisher.category"
             name="Print Publishing">
       </category>
-      <wizard
-            category="print-publisher.category"
-            class="eu.etaxonomy.taxeditor.printpublisher.wizard.PublishWizardXML"
-            id="print-publisher.wizardXml"
-            name="CDM-XML">
-      </wizard>
       <wizard
             category="print-publisher.category"
             class="eu.etaxonomy.taxeditor.printpublisher.wizard.PublishWizardODF"
             id="print-publisher.wizardOdf"
-            name="ODF">
+            name="Open Document Format (ODF) - edit in openoffice.org">
       </wizard>
       <wizard
             category="print-publisher.category"
             class="eu.etaxonomy.taxeditor.printpublisher.wizard.PublishWizardPDF"
             id="print-publisher.wizardPdf"
-            name="PDF">
+            name="Portable Document Format (PDF) - choose from pre-defined layout templates">
       </wizard>
       <wizard
             category="print-publisher.category"
             class="eu.etaxonomy.taxeditor.printpublisher.wizard.PublishWizardTaxPub"
             id="print-publisher.wizardTaxPub"
-            name="TaxPub">
+            name="TaxPub (experimental)">
+      </wizard>
+      <wizard
+            category="print-publisher.category"
+            class="eu.etaxonomy.taxeditor.printpublisher.wizard.PublishWizardXML"
+            id="print-publisher.wizardXml"
+            name="CDM-XML – raw XML data">
       </wizard>
    </extension>
    <extension
index 737e2aecf37920e6c5cf35244fa34e0493f60def..0bfdc77581e8b607f889dbe35b56728b906edac9 100644 (file)
@@ -72,11 +72,11 @@ public class GeneratePdfHandler extends AbstractHandler {
                
                int result = dialog.open();
                
-               if(result != Status.OK || result != Status.CANCEL){
+               if(result == Status.OK || result == Status.CANCEL){
+                       return null;
+               }else{
                        throw new RuntimeException("An error occurred during print publishing.");
                }
-               
-               return null;
        }
        
        private Element getTaxonNodeElement(IEditorPart editor){
index a4b344a3db2b2551a633ed906d7bd7056321854d..2f382a8bda09c9eaa4f7515efd9eeb0aaec724c8 100644 (file)
@@ -3,11 +3,11 @@
  */
 package eu.etaxonomy.taxeditor.printpublisher.wizard;
 
-import java.lang.reflect.InvocationTargetException;
-
 import org.apache.log4j.Logger;
 import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.ui.IExportWizard;
@@ -58,37 +58,32 @@ public class AbstractPublishWizard extends Wizard implements IExportWizard{
        @Override
        public boolean performFinish() {
                
-               IRunnableWithProgress runnable = new IRunnableWithProgress() {
+               Job job = new Job("Running Print Publisher") {
 
-                       public void run(final IProgressMonitor monitor)
-                                       throws InvocationTargetException, InterruptedException {
-                               monitor.beginTask("Exporting Printable Output", getConfigurator().calculateNumberOfNodes() + 1);
-                               try{
+                       @Override
+                       protected IStatus run(IProgressMonitor monitor) {
+                               monitor.beginTask("Print Publisher", getConfigurator().calculateNumberOfNodes() + 1);
+                               ConversationHolder conversation = null;
+                               try{                                    
                                        getConfigurator().setProgressMonitor(new CdmProgressMonitorAdapter(monitor));
                                        
+                                       if(getConfigurator().isLocal()){
+                                               conversation= CdmStore.createConversation();
+                                       }
+                                       
                                        Publisher.publish(getConfigurator());
+                                       
                                }finally{
                                        monitor.done();
+                                       if(conversation != null) conversation.close();
                                }
-                               
-                       }                       
-               };
-               
-               ConversationHolder conversation = null;
-               
-               try {
-                       if(getConfigurator().isLocal()){
-                               conversation= CdmStore.createConversation();
+                               return Status.OK_STATUS;
                        }
-                       getContainer().run(false, true, runnable);
                        
-               } catch (InvocationTargetException e) {
-                       e.printStackTrace();
-               } catch (InterruptedException e) {
-                       e.printStackTrace();
-               }finally{
-                       if(conversation != null) conversation.close();
-               }
+               };
+               
+               job.setPriority(Job.BUILD);
+               job.schedule();
                
                return true;
        }
index f0e55e060c340a906f03c5cb35cf3576ead0dbad..573ef6057200852150665201f8933610d619f6f9 100644 (file)
@@ -110,6 +110,7 @@ public class SelectFeatureTreeWizardPage extends AbstractPublishWizardPage imple
                        UUID featureTreeUuid = XMLHelper.getUuid(featureTreeElement);
                        
                        getConfigurator().setFeatureTree(featureTreeUuid);
+                       setErrorMessage(null);
                }else if(selection.size() > 1){
                        setErrorMessage("Please select only one feature tree.");
                }