Fixing bugs in open url dialog
authorn.hoffmann <n.hoffmann@localhost>
Thu, 17 Feb 2011 17:42:55 +0000 (17:42 +0000)
committern.hoffmann <n.hoffmann@localhost>
Thu, 17 Feb 2011 17:42:55 +0000 (17:42 +0000)
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlResultPage.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorElement.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorWizard.java

index 25b39364858fd6798da611a51fbd765426b254eb..69fe0a4f3c2d950cc7828eba533b48dc335841e3 100644 (file)
@@ -65,7 +65,8 @@ public class OpenUrlResultPage extends WizardPage {
                List<OpenUrlReference> results = getWizard().getResult();
                
                if(results == null || results.isEmpty()){
-                       setMessage("No results for the given reference", WizardPage.WARNING);
+                       String nomenclaturalCitation = getWizard().getReference().getNomenclaturalCitation(getWizard().getReferenceDetail());
+                       setMessage("No results for the given reference: " + nomenclaturalCitation, WizardPage.WARNING);
                }
                viewer.setInput(results);
                
index 7cbafcb332588b30082bf823b152143cfc247897..0a1ece659dc49d3f32ba01b40a110a34e245318b 100644 (file)
@@ -66,12 +66,16 @@ public class OpenUrlSelectorElement extends AbstractCdmFormElement implements Se
         */
        @Override
        public void widgetSelected(SelectionEvent e) {
+               if(openUrlEnabled.getReference() == null){
+                       EditorUtil.warningDialog("No reference", getClass(), "The given reference is empty");
+                       return;
+               }
                OpenUrlSelectorWizard wizard = new OpenUrlSelectorWizard(openUrlEnabled.getReference(), openUrlEnabled.getDetail());
                
                WizardDialog dialog = new WizardDialog(EditorUtil.getShell(), wizard);
                
                if(dialog.open() == IStatus.OK){
-                       openUrlEnabled.setOpenUrl(wizard.getOpenUrlReferenceImageUri());
+                       openUrlEnabled.setOpenUrl(wizard.getOpenUrlReference().getUri());
                }
        }
 
index ca1822acba046a92e5b59f8b15c8696fc0428d90..d40df1ce60dfcad5f5813dd63ea2fec963038dd3 100644 (file)
@@ -36,11 +36,16 @@ public class OpenUrlSelectorWizard extends Wizard {
 
        private MobotOpenUrlQuery query;
        
+       private Reference reference;
+
+
        private OpenUrlReference openUrlReference;
        
        private CdmFormFactory formFactory;
 
        private URI openUrlReferenceImageUri;
+
+       private String referenceDetail;
        
        
        
@@ -49,6 +54,12 @@ public class OpenUrlSelectorWizard extends Wizard {
         * @param reference
         */
        public OpenUrlSelectorWizard(Reference reference, String referenceDetail) {
+               if(reference == null){
+                       throw new IllegalArgumentException("Reference may not be empty.");
+               }
+               this.reference = reference;
+               this.referenceDetail = referenceDetail;
+               
                setWindowTitle("Mobot Open Url");
                setNeedsProgressMonitor(true);
                
@@ -60,8 +71,11 @@ public class OpenUrlSelectorWizard extends Wizard {
                query  = new MobotOpenUrlQuery();
                
                query.refType = ReferenceType.getReferenceType(reference);
-               query.authorName = reference.getAuthorTeam().getTitleCache();
-               query.bookTitle = reference.getTitle();
+               if(reference.getAuthorTeam() != null){
+                       query.authorName = reference.getAuthorTeam().getTitleCache();
+               }
+               query.abbreviation = reference.getTitle();
+               
                if(reference.getInReference() != null){
                        query.journalTitle = reference.getInReference().getTitle();
                }
@@ -140,4 +154,13 @@ public class OpenUrlSelectorWizard extends Wizard {
        public URI getOpenUrlReferenceImageUri() {
                return openUrlReferenceImageUri;
        }
+       
+       
+       public Reference getReference() {
+               return reference;
+       }
+
+       public String getReferenceDetail() {
+               return referenceDetail;
+       }
 }