ref #8233: add pref stable identifier field in duplicate type designation wizard
authorKatja Luther <k.luther@bgbm.org>
Mon, 12 Apr 2021 14:15:37 +0000 (16:15 +0200)
committerKatja Luther <k.luther@bgbm.org>
Mon, 12 Apr 2021 14:16:47 +0000 (16:16 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/type/CloneTypeWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/type/CloneTypeWizardComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/type/CloneTypeWizardPage.java

index 2c2427bedff622cca08048bedfb2ec5a1e403729..5d2bdaccc25933030793bf6cc650c1c019102bc5 100644 (file)
@@ -8,11 +8,13 @@
 */
 package eu.etaxonomy.taxeditor.ui.section.name.type;
 
+
 import java.util.Collection;
 import java.util.stream.Collectors;
 
 import org.eclipse.jface.wizard.Wizard;
 
+import eu.etaxonomy.cdm.common.URI;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
 import eu.etaxonomy.cdm.model.name.TaxonName;
@@ -42,6 +44,8 @@ public class CloneTypeWizard extends Wizard{
 
     private SpecimenTypeDesignationStatus typeStatus;
 
+    private URI stableIdentifier;
+
     public CloneTypeWizard(TaxonName taxonName) {
         this.taxonName = taxonName;
         this.typeDesignations = taxonName.getTypeDesignations().stream()
@@ -65,6 +69,7 @@ public class CloneTypeWizard extends Wizard{
         this.catalogNumber = page.getCatalogNumber();
         this.collection = page.getCollection();
         this.typeStatus = page.getTypeStatus();
+        this.stableIdentifier = page.getStableIdentifier();
         return true;
     }
 
@@ -96,4 +101,12 @@ public class CloneTypeWizard extends Wizard{
         return typeStatus;
     }
 
+    public URI getStableIdentifier() {
+        return stableIdentifier;
+    }
+
+    public void setStableIdentifier(URI stableIdentifier) {
+        this.stableIdentifier = stableIdentifier;
+    }
+
 }
index d32861ef20dcc18b3419f1b9ef3fd8128408ce04..d4e4887067380c60de7f965fa04c2a56743cb4e6 100644 (file)
@@ -8,17 +8,23 @@
  */
 package eu.etaxonomy.taxeditor.ui.section.name.type;
 
+import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.viewers.ComboViewer;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
+import eu.etaxonomy.cdm.common.URI;
 import eu.etaxonomy.cdm.model.term.TermType;
+import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.ui.combo.term.TermUuidComboViewer;
 
@@ -27,7 +33,7 @@ import eu.etaxonomy.taxeditor.ui.combo.term.TermUuidComboViewer;
  * @since Mar 13, 2019
  *
  */
-public class CloneTypeWizardComposite extends Composite {
+public class CloneTypeWizardComposite extends Composite implements ModifyListener{
     private Text txtAccNumber;
     private Text txtCollection;
     private Button btnBrowseCollection;
@@ -35,6 +41,9 @@ public class CloneTypeWizardComposite extends Composite {
     private ComboViewer comboViewerBaseType;
     private Text textBarcode;
     private Text textCatalogNumber;
+    private Text textStableIdentifier;
+    private Label labelException;
+    private URI stableIdentifier;
 
     /**
      * Create the composite.
@@ -93,6 +102,16 @@ public class CloneTypeWizardComposite extends Composite {
         comboTypeStatus.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
         comboTypeStatus.setInput(TermType.SpecimenTypeDesignationStatus);
 
+        Label lblNewLabel_stableIdentifier = new Label(this, SWT.NONE);
+        lblNewLabel_stableIdentifier.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblNewLabel_stableIdentifier.setText("Stable Identifier");
+
+        textStableIdentifier = new Text(this, SWT.BORDER);
+        textStableIdentifier.setEnabled(true);
+        textStableIdentifier.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+        textStableIdentifier.addModifyListener(this);
+
+
     }
 
     @Override
@@ -121,4 +140,34 @@ public class CloneTypeWizardComposite extends Composite {
     public Text getTextCatalogNumber() {
         return textCatalogNumber;
     }
+
+    public URI getStableIdentifier() {
+        return stableIdentifier;
+    }
+
+
+    @Override
+    public void modifyText(ModifyEvent e) {
+        if (e.getSource().equals(textStableIdentifier)){
+            try{
+                stableIdentifier = URI.create(textStableIdentifier.getText());
+                if (labelException != null){
+                    labelException.setText("");
+                }
+            }catch(IllegalArgumentException ex){
+                if (labelException == null){
+                    labelException = new Label(this, SWT.WRAP); //$NON-NLS-1$
+                    labelException.setBackground(this.getBackground());
+                    labelException.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
+                    labelException.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+                    labelException.requestLayout();
+                    labelException.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+                }
+                labelException.setText(Messages.UriWithLabelElement_URL_NOT_SAVED + ex.getLocalizedMessage());
+
+                stableIdentifier = null;
+            }
+        }
+
+    }
 }
index 872feba22427562f76990c23469bddc44385a549..fcf6b9919d08b9fbb20c11cc1b4ef16f3b79b06e 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.widgets.Composite;
 
+import eu.etaxonomy.cdm.common.URI;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.CollectionSelectionDialog;
@@ -133,4 +134,11 @@ public class CloneTypeWizardPage extends WizardPage implements ISelectionChanged
         return (SpecimenTypeDesignationStatus) composite.getComboTypeStatus().getSelection();
     }
 
+    /**
+     * @return
+     */
+    public URI getStableIdentifier() {
+        return composite.getStableIdentifier();
+    }
+
 }