Merge branch 'develop' of ssh://dev.e-taxonomy.eu/var/git/taxeditor into develop
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 16 Nov 2015 15:51:20 +0000 (16:51 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 16 Nov 2015 15:51:20 +0000 (16:51 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/ImportManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/AbcdImportWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/io/wizard/ClassificationChooserWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java

index abdad0532f4d722ea341fd18461b976eb3a0e612..b89c7d84fe624258eafdb8f74ce2d7a6d951bfd9 100644 (file)
@@ -15,6 +15,7 @@ import java.io.InputStream;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.List;
 import java.util.UUID;
 
 import org.apache.commons.io.IOUtils;
@@ -24,6 +25,7 @@ import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
@@ -31,6 +33,7 @@ import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
 import eu.etaxonomy.cdm.io.common.CdmDefaultImport;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
 import eu.etaxonomy.cdm.io.common.IImportConfigurator.SOURCE_TYPE;
+import eu.etaxonomy.cdm.io.common.ImportResult;
 import eu.etaxonomy.cdm.io.excel.taxa.NormalExplicitImportConfigurator;
 import eu.etaxonomy.cdm.io.jaxb.JaxbImportConfigurator;
 import eu.etaxonomy.cdm.io.reference.endnote.in.EndnoteImportConfigurator;
@@ -45,6 +48,7 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
+import eu.etaxonomy.taxeditor.ui.dialog.ReportTextDialog;
 
 /**
  * <p>
@@ -107,9 +111,10 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
                                CdmDefaultImport<IImportConfigurator> importer = new CdmDefaultImport<IImportConfigurator>();
                                importer.setCdmAppController(applicationConfiguration);
                                monitor.worked(5);
-
+                               ImportResult importResult = null;
                                try {
-                                       importer.invoke(configurator);
+                                       importResult = importer.invoke(configurator);
+
                                        monitor.worked(80);
                                } catch (RuntimeException e) {
                                        MessagingUtils.messageDialog(
@@ -125,10 +130,23 @@ public class ImportManager extends AbstractIOManager<IImportConfigurator> implem
                                monitor.worked(5);
                                monitor.done();
 
+
+                               final StringBuilder reportText = new StringBuilder();
+                               if(importResult!=null){
+                                   List<byte[]> reports = importResult.getReports();
+                                   for (byte[] bs : reports) {
+                        reportText.append(new String(bs));
+                    }
+                               }
                                display.asyncExec(new Runnable() {
 
                                        @Override
                                        public void run() {
+                        // display reports with possibility to save
+                        ReportTextDialog dialog = new ReportTextDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+                        dialog.setTitle(configurator.getClass().getSimpleName()+" Report");
+                        dialog.setReportText(reportText.toString());
+                        dialog.open();
                                                CdmStore.getContextManager().notifyContextRefresh();
                                        }
                                });
index 4dc3d410c49d192a04ffa994179649c11a00029d..b9181aba398cfc01b41d083a3f13b6b0da7c04d0 100644 (file)
@@ -62,7 +62,6 @@ public class AbcdImportWizard extends AbstractImportWizard<Abcd206ImportConfigur
            if(classificationChooserWizardPage.getClassification()!=null){
                configurator.setClassificationUuid(classificationChooserWizardPage.getClassification().getUuid());
            }
-           configurator.setReportUri(classificationChooserWizardPage.getReportUri());
 
            if(CdmStore.getCurrentSessionManager().isRemoting()) {
                //Job job = CdmStore.getImportManager().createIOServiceJob(configurator, new File(source), SOURCE_TYPE.INPUTSTREAM);
index 01e47b4a81e2403dc9539031c945f8787e235e59..377ccc84ca04ddff8c37b828424d7fd389f8c892 100644 (file)
 
 package eu.etaxonomy.taxeditor.io.wizard;
 
-import java.io.File;
-import java.net.URI;
-
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.wb.swt.ResourceManager;
 
 import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
 
 /**
@@ -50,17 +43,6 @@ public class ClassificationChooserWizardPage extends WizardPage implements Liste
 
     private Button btnClear;
 
-    //report
-    private FileDialog fileDialogReport;
-    private Text textFileReport;
-
-       /**
-        * <p>Constructor for ImportFromFileDataSourceWizardPage.</p>
-        *
-        * @param title a {@link java.lang.String} object.
-        * @param description a {@link java.lang.String} object.
-        * @param extensions an array of {@link java.lang.String} objects.
-        */
        protected ClassificationChooserWizardPage(String title, String description) {
                super(PAGE_NAME);
 
@@ -70,20 +52,12 @@ public class ClassificationChooserWizardPage extends WizardPage implements Liste
 
        }
 
-       /**
-        * <p>XML</p>
-        *
-        * @return a {@link eu.etaxonomy.taxeditor.io.wizard.ClassificationChooserWizardPage} object.
-        */
        protected static ClassificationChooserWizardPage createPage(){
                return new ClassificationChooserWizardPage("Configure import destinations", "Note: Selecting no classification will create a default one.");
        }
 
 
 
-       /* (non-Javadoc)
-        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
-        */
        /** {@inheritDoc} */
        @Override
     public void createControl(Composite parent) {
@@ -106,45 +80,9 @@ public class ClassificationChooserWizardPage extends WizardPage implements Liste
                btnClear.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/trash.gif"));
                btnClear.addListener(SWT.Selection, this);
 
-               if(!CdmStore.getCurrentSessionManager().isRemoting()) {
-                   //report
-                   Label labelReportFile = new Label(composite, SWT.NONE);
-                   labelReportFile.setText("Report File");
-
-                   fileDialogReport = new FileDialog(parent.getShell());
-
-                   fileDialogReport.setFilterExtensions(new String[]{"*.*"});
-
-                   textFileReport = new Text(composite, SWT.BORDER);
-                   textFileReport.setEditable(false);
-                   textFileReport.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
-
-
-                   Button buttonReport = new Button(composite, SWT.PUSH);
-                   buttonReport.setText("Browse...");
-
-                   buttonReport.addSelectionListener(new SelectionAdapter(){
-
-                       /* (non-Javadoc)
-                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
-                        */
-                       @Override
-                       public void widgetSelected(SelectionEvent e) {
-                           String path = fileDialogReport.open();
-                           if(path!=null){
-                               textFileReport.setText(path);
-                               setPageComplete(true);
-                           }
-                       }
-
-                   });
-               }
                setControl(composite);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
-        */
        @Override
        public void handleEvent(Event event) {
            if(event.widget==btnBrowseClassification){
@@ -166,14 +104,4 @@ public class ClassificationChooserWizardPage extends WizardPage implements Liste
         return classification;
     }
 
-    public URI getReportUri(){
-        if(textFileReport == null) {
-            return null;
-        }
-        String text = textFileReport.getText();
-        if(text==null || text.isEmpty()){
-            return null;
-        }
-        return new File(text).toURI();
-    }
 }
index 1ba3c42ddd294369dc0a52e99c0d03b21d291030..f4c50280380f55a993ee86f56a449465172302bd 100644 (file)
@@ -1555,8 +1555,8 @@ public class CdmFormFactory extends FormToolkit {
         return section;
     }
 
-    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style){
-        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, style);
+    public NonViralNameDetailSection createNonViralNameDetailSection(ConversationHolder conversation, ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style){
+        NonViralNameDetailSection section = new NonViralNameDetailSection(this, conversation, parentElement, selectionProvider, nameChoosable, style);
         addAndAdaptSection(parentElement, section);
         return section;
     }
index 4f4c09e06ef72de7927395d69682a0d90195c6d6..9a02d8f98d514b01315b30a4767b272ca9265ea9 100644 (file)
@@ -44,6 +44,7 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
                implements ITaxonBaseDetailSection {
 
        private TaxonBase taxonBase;
+       boolean nameChoosable = false;
 
        /**
         * <p>Constructor for NonViralNameDetailSection.</p>
@@ -52,41 +53,45 @@ public class NonViralNameDetailSection extends AbstractCdmDetailSection<NonViral
         * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
         * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
         * @param selectionProvider a {@link org.eclipse.jface.viewers.ISelectionProvider} object.
+        * @param nameChoosable if <code>true</code> adds a button to choose the displayed name
         * @param style a int.
         */
        public NonViralNameDetailSection(CdmFormFactory formFactory, ConversationHolder conversation,
-                       ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
+                       ICdmFormElement parentElement, ISelectionProvider selectionProvider, boolean nameChoosable, int style) {
                super(formFactory, conversation, parentElement, selectionProvider, style);
+               this.nameChoosable = nameChoosable;
        }
 
        @Override
        protected Control createToolbar() {
-               ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
-
-               //choose name
-               Action chooseNameAction = new Action("Choose Name", IAction.AS_PUSH_BUTTON){
-                   @Override
-                   public void run() {
-                       TaxonNameBase taxonName = NameSelectionDialog.select(getShell(), getConversationHolder(), null);
-                       if(taxonName!=null){
-                           if(taxonName.isInstanceOf(NonViralName.class)){
-                               CdmStore.getService(ITaxonNodeService.class).list(TaxonNode.class, null, null, null, null);
-                               NonViralName nonViralName = HibernateProxyHelper.deproxy(taxonName, NonViralName.class);
-                               taxonBase.setName(nonViralName);
-                               //                                      taxonBase.getTitleCache();
-                               setEntity(nonViralName);
-                               firePropertyChangeEvent(NonViralNameDetailSection.this);
-                           }
-                           else{
-                               MessagingUtils.warningDialog("Invalid name", this, "The selected name can not be used for this taxon.");
-                           }
-                       }
-                   }
-               };
-               chooseNameAction.setToolTipText("Choose name for this taxon");
-               chooseNameAction.setImageDescriptor(ImageResources.getImageDescriptor(ImageResources.BROWSE_ICON));
-
-               toolBarManager.add(chooseNameAction);
+               ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+
+               if(nameChoosable){
+                   //choose name
+                   Action chooseNameAction = new Action("Choose Name", IAction.AS_PUSH_BUTTON){
+                       @Override
+                       public void run() {
+                           TaxonNameBase taxonName = NameSelectionDialog.select(getShell(), getConversationHolder(), null);
+                           if(taxonName!=null){
+                               if(taxonName.isInstanceOf(NonViralName.class)){
+                                   CdmStore.getService(ITaxonNodeService.class).list(TaxonNode.class, null, null, null, null);
+                                   NonViralName nonViralName = HibernateProxyHelper.deproxy(taxonName, NonViralName.class);
+                                   taxonBase.setName(nonViralName);
+                                   //                                  taxonBase.getTitleCache();
+                                   setEntity(nonViralName);
+                                   firePropertyChangeEvent(NonViralNameDetailSection.this);
+                               }
+                               else{
+                                   MessagingUtils.warningDialog("Invalid name", this, "The selected name can not be used for this taxon.");
+                               }
+                           }
+                       }
+                   };
+                   chooseNameAction.setToolTipText("Choose name for this taxon");
+                   chooseNameAction.setImageDescriptor(ImageResources.getImageDescriptor(ImageResources.BROWSE_ICON));
+
+                   toolBarManager.add(chooseNameAction);
+           }
 
                //clone
                if(getEntity() != null && checkForMultipleNameUsages(getEntity())){
index aa63bfbf3d72737b1f8391c9cc22ac56d375d9a4..db2f1e3ec1d952baee4344d05a142995286305ad 100644 (file)
@@ -369,8 +369,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
                        ExpandableComposite.TWISTIE     | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        NonViralNameDetailSection nonViralNameSection = formFactory
+                .createNonViralNameDetailSection(getConversationHolder(), parent, this, true,
+                        ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,
@@ -406,8 +407,9 @@ public class DetailsViewer extends AbstractCdmDataViewer {
 
     private void createNameSections(RootElement parent) {
         destroySections();
-        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(getConversationHolder(), parent, this,
-                       ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
+        NonViralNameDetailSection nonViralNameSection = formFactory.createNonViralNameDetailSection(
+                getConversationHolder(), parent, this, false, ExpandableComposite.TWISTIE
+                        | ExpandableComposite.EXPANDED);
         formFactory.createHorizontalSeparator(parent, SWT.BORDER);
 
         NomenclaturalReferenceDetailSection referenceDetailSection = formFactory.createNomenclaturalReferenceDetailSection(getConversationHolder(), parent, this,