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;
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;
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;
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>
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(
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();
}
});
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);
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;
/**
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);
}
- /**
- * <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) {
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){
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();
- }
}
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;
}
implements ITaxonBaseDetailSection {
private TaxonBase taxonBase;
+ boolean nameChoosable = false;
/**
* <p>Constructor for NonViralNameDetailSection.</p>
* @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())){
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,
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,