Implemented MobotOpenUrl UI
authorn.hoffmann <n.hoffmann@localhost>
Fri, 4 Feb 2011 16:06:06 +0000 (16:06 +0000)
committern.hoffmann <n.hoffmann@localhost>
Fri, 4 Feb 2011 16:06:06 +0000 (16:06 +0000)
21 files changed:
.gitattributes
taxeditor-cdmlib/META-INF/MANIFEST.MF
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/CdmFormFactory.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/ImageElement.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/IOpenUrlEnabled.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlContentProvider.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlLabelProvider.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlReferencePage.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlResultPage.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorElement.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorWizard.java [new file with mode: 0644]
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/section/name/ProtologueElement.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/section/reference/ReferenceDetailElement.java
taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/section/supplemental/ImageFileElement.java
taxeditor-store/plugin.xml
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/model/AbstractUtility.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/MobotOpenUrlPreferences.java [new file with mode: 0644]
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/TaxonomicEditorGeneralPreferences.java

index 587665351ee34027318286b5837fee3142f76dfe..895763d8e6c85ad5b9fc6d6b7721e5a91cfa8977 100644 (file)
@@ -532,6 +532,13 @@ taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/TextWithLabelElement
 taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/TimePeriodElement.java -text
 taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/ToggleableTextElement.java -text
 taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/UriWithLabelElement.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/IOpenUrlEnabled.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlContentProvider.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlLabelProvider.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlReferencePage.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlResultPage.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorElement.java -text
+taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorWizard.java -text
 taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/selection/AbstractSelectionElement.java -text
 taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/selection/AgentSelectionElement.java -text
 taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/selection/ClassificationSelectionElement.java -text
@@ -1100,6 +1107,7 @@ taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/InitNomenclaturalCodePrefDialog.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/LanguagePreferencePage.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/MatchingPreferences.java -text
+taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/MobotOpenUrlPreferences.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/NomenclaturalCodePreferences.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencePropertyTester.java -text
 taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java -text
index 37f39ca8542c138684c0d6f2d75fa41d18a0ecb6..2e1989ad92fb36bb7409c811356c1d980e46204c 100644 (file)
@@ -226,6 +226,7 @@ Export-Package: com.google.api,
  eu.etaxonomy.cdm.ext.dc,
  eu.etaxonomy.cdm.ext.geo,
  eu.etaxonomy.cdm.ext.ipni,
+ eu.etaxonomy.cdm.ext.openurl,
  eu.etaxonomy.cdm.ext.sru,
  eu.etaxonomy.cdm.hibernate;uses:="org.hibernate.search.bridge",
  eu.etaxonomy.cdm.io.berlinModel;
index cc5f95fbdbe07a12360223effae774cfa067ddea..1ff1238a43e6b43e32038c720a5ffcfe3225371c 100644 (file)
@@ -20,7 +20,6 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
 import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
index 5d76b0d0cba79d577d53532437574c2f9f341825..b638ea58cb0eb4e8a3edda6ceb92f346b2388ea0 100644 (file)
@@ -121,6 +121,8 @@ import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.strategy.parser.ParserProblem;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.forms.openurl.IOpenUrlEnabled;
+import eu.etaxonomy.taxeditor.forms.openurl.OpenUrlSelectorElement;
 import eu.etaxonomy.taxeditor.forms.selection.AbstractSelectionElement;
 import eu.etaxonomy.taxeditor.forms.selection.AgentSelectionElement;
 import eu.etaxonomy.taxeditor.forms.selection.ClassificationSelectionElement;
@@ -633,6 +635,21 @@ public class CdmFormFactory extends FormToolkit{
                return element;
        }
        
+       /**
+        * @param element
+        * @param string
+        * @param uri
+        * @param style
+        * @return
+        */
+       public OpenUrlSelectorElement createOpenUrlSelectorElement(
+                       ICdmFormElement parentElement, String labelString, IOpenUrlEnabled openUrlEnabled, int style) {
+               OpenUrlSelectorElement element = new OpenUrlSelectorElement(this, parentElement, labelString, openUrlEnabled, style);
+               adapt(element);
+               parentElement.addElement(element);
+               return element;
+       }
+       
        /**
         * <p>createIntegerTextWithLabelElement</p>
         *
index 5806912a2d20f6c5d5687d81a98ab423479851e1..9db80d123cd8bbcbb711c1fb3a35e7582ef508b2 100644 (file)
@@ -17,14 +17,15 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
+import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.swt.events.PaintEvent;
 import org.eclipse.swt.events.PaintListener;
+import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
 import org.eclipse.ui.forms.widgets.TableWrapData;
 
 import eu.etaxonomy.cdm.common.UriUtils;
@@ -37,7 +38,7 @@ import eu.etaxonomy.taxeditor.editor.EditorUtil;
  * @created Sep 24, 2010
  * @version 1.0
  */
-public class ImageElement extends AbstractCdmFormElement implements PaintListener, ControlListener{
+public class ImageElement extends AbstractCdmFormElement implements PaintListener{
 
        private URI imageUri;
        private Image image;
@@ -57,11 +58,11 @@ public class ImageElement extends AbstractCdmFormElement implements PaintListene
                super(formFactory, parentElement);
                
                setImageUri(imageUri);
+               loadImage();
                
                container = new Composite(getLayoutComposite(), style);
                container.setLayoutData(CdmFormFactory.FILL(2, 1));
                
-               container.addControlListener(this);
                container.addPaintListener(this);
        }
        
@@ -83,36 +84,84 @@ public class ImageElement extends AbstractCdmFormElement implements PaintListene
         */
        public void setImageUri(URI uri) {
                this.imageUri = uri;
-               
-               if(imageUri != null){
-                       
-                       final Display display = Display.getCurrent();
-                       Job job = new Job("Loading image: " + imageUri){
+       }
+       
+       
+       /**
+        * <p>Getter for the field <code>imageUri</code>.</p>
+        *
+        * @return the imageUri
+        */
+       public URI getImageUri() {
+               return imageUri;
+       }
+       
+       public void loadImage(){
+               loadImage(null);
+       }
+       
+       public void loadImage(final Runnable postRunnable){
+               if(getImageUri() != null){
+                       Job job = new Job("Loading image") {
+                               
                                @Override
                                protected IStatus run(IProgressMonitor monitor) {
-                                       try {                                           
-                                               InputStream imageStream = UriUtils.getInputStream(imageUri);
-                                               
-                                               image = new Image(Display.getCurrent(), imageStream);
-                                               
-                                               display.asyncExec(new Runnable(){
-                                                       @Override
-                                                       public void run() {
-                                                               EditorUtil.reflowDetailsViewer();
-//                                                             getLayoutComposite().layout();
-                                                       }
-                                               });
-                                               return Status.OK_STATUS;
-                                       }catch (Exception e) {
-                                               EditorUtil.errorDialog("Could not load image", getClass(), e.getMessage(), e);
-                                       } 
-                                       return Status.CANCEL_STATUS;
-                               }                                       
+                                       IRunnableWithProgress runnable = getLoadImageRunnable(postRunnable);
+                                       try {
+                                               runnable.run(monitor);
+                                       } catch (Exception e) {
+                                               EditorUtil.errorDialog("Could not load image", getClass(), e.getMessage()  + ": " +  getImageUri(), e);
+                                       }
+                                       
+                                       return Status.OK_STATUS;
+                               }
                        };
-                       
                        job.schedule();
                }
        }
+       
+       public IRunnableWithProgress getLoadImageRunnable(final Runnable postRunnable){
+               
+               final Display display = getLayoutComposite().getDisplay(); 
+               
+               IRunnableWithProgress runnable = new IRunnableWithProgress(){
+                       
+                       @Override
+                       public void run(IProgressMonitor monitor) {
+                               try {   
+                                       monitor.beginTask("Loading: " + getImageUri(), IProgressMonitor.UNKNOWN);
+                                       InputStream imageStream = UriUtils.getInputStream(imageUri);
+                                       
+                                       image = new Image(Display.getCurrent(), imageStream);
+                                       
+                                       // redraw the image container
+                                       display.asyncExec(new Runnable(){
+                                               @Override
+                                               public void run() {
+                                                       if(! getLayoutComposite().isDisposed()){
+                                                               Event untypedEvent = new Event();
+                                                               untypedEvent.widget = container;
+                                                               PaintEvent event = new PaintEvent(untypedEvent);
+                                                               event.gc = new GC(container);
+                                                               paintControl(event);
+                                                               getLayoutComposite().layout();
+                                                       }
+                                               }
+                                       });
+                                       
+                                       // execute the external runnable
+                                       if(postRunnable != null){
+                                               display.asyncExec(postRunnable);
+                                       }
+                                       monitor.done();                                 
+                               }catch (Exception e) {
+                                       EditorUtil.errorDialog("Could not load image", getClass(), e.getMessage()  + ": " + imageUri , e);
+                               } 
+                       }                                       
+               };
+               
+               return runnable;
+       }
 
        private void calculateImageBounds(){
                Rectangle imageBounds = image.getBounds();
@@ -127,15 +176,7 @@ public class ImageElement extends AbstractCdmFormElement implements PaintListene
                
                imageMaxBounds = new Rectangle(containerBounds.x, containerBounds.y, width, height.intValue());
        }
-       
-       /**
-        * <p>Getter for the field <code>imageUri</code>.</p>
-        *
-        * @return the imageUri
-        */
-       public URI getImageUri() {
-               return imageUri;
-       }
+
 
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
@@ -150,27 +191,7 @@ public class ImageElement extends AbstractCdmFormElement implements PaintListene
                        layoutData.heightHint = imageMaxBounds.height;
                        composite.setLayoutData(layoutData);
                        e.gc.drawImage(image, 0, 0, image.getBounds().width, image.getBounds().height, 0, 0, imageMaxBounds.width, imageMaxBounds.height);
+                       e.gc.dispose();
                }               
        }
-
-
-       /* (non-Javadoc)
-        * @see org.eclipse.swt.events.ControlListener#controlMoved(org.eclipse.swt.events.ControlEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void controlMoved(ControlEvent e) {
-               // TODO Auto-generated method stub
-               
-       }
-
-
-       /* (non-Javadoc)
-        * @see org.eclipse.swt.events.ControlListener#controlResized(org.eclipse.swt.events.ControlEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public void controlResized(ControlEvent e) {
-               EditorUtil.reflowDetailsViewer();
-       }
 }
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/IOpenUrlEnabled.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/IOpenUrlEnabled.java
new file mode 100644 (file)
index 0000000..2a219e1
--- /dev/null
@@ -0,0 +1,36 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import java.net.URI;
+
+import eu.etaxonomy.cdm.model.reference.Reference;
+
+/**
+ * @author n.hoffmann
+ * @created Feb 3, 2011
+ * @version 1.0
+ */
+public interface IOpenUrlEnabled {
+
+       public void setOpenUrl(URI uri);
+
+       /**
+        * @return
+        */
+       public Reference getReference();
+
+       /**
+        * @return
+        */
+       public String getDetail();
+       
+}
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlContentProvider.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlContentProvider.java
new file mode 100644 (file)
index 0000000..46c99cf
--- /dev/null
@@ -0,0 +1,58 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+import eu.etaxonomy.cdm.ext.openurl.OpenUrlReference;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 31, 2011
+ * @version 1.0
+ */
+public class OpenUrlContentProvider implements IStructuredContentProvider {
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+        */
+       @Override
+       public void dispose() {
+               // TODO Auto-generated method stub
+
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+        */
+       @Override
+       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+               // TODO Auto-generated method stub
+
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+        */
+       @Override
+       public Object[] getElements(Object inputElement) {
+               if(inputElement instanceof List){
+                       return ((List) inputElement).toArray();
+               }
+               
+               
+               return new Object[]{};
+       }
+
+}
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlLabelProvider.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlLabelProvider.java
new file mode 100644 (file)
index 0000000..af539e6
--- /dev/null
@@ -0,0 +1,24 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 31, 2011
+ * @version 1.0
+ */
+public class OpenUrlLabelProvider extends LabelProvider implements
+               IBaseLabelProvider {
+
+}
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlReferencePage.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlReferencePage.java
new file mode 100644 (file)
index 0000000..9b1bd8e
--- /dev/null
@@ -0,0 +1,183 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import java.net.URI;
+import java.util.List;
+
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Label;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+import eu.etaxonomy.cdm.ext.openurl.OpenUrlReference;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
+import eu.etaxonomy.taxeditor.forms.ImageElement;
+import eu.etaxonomy.taxeditor.forms.RootElement;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 31, 2011
+ * @version 1.0
+ */
+public class OpenUrlReferencePage extends WizardPage implements SelectionListener {
+
+       public static final String NAME = "OpenUrlReferencePage";
+
+       private static final int NEXT = 1;
+       private static final int PREVIOUS = -1; 
+       
+       private ImageElement imageElement;
+       private RootElement rootElement;
+       private ScrolledForm scrolledForm;
+       private Button button_next;
+       private Button button_previous;
+
+       private OpenUrlReference reference;
+
+       private Composite container;
+
+       private Label label_pageNumber; 
+       
+       /**
+        * @param pageName
+        */
+       protected OpenUrlReferencePage() {
+               super(NAME);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               container = getWizard().getFormFactory().createComposite(parent, SWT.NULL);
+               
+               container.setLayout(new GridLayout());
+               container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               scrolledForm = getWizard().getFormFactory().createScrolledForm(container);
+               scrolledForm.getBody().setLayout(CdmFormFactory.LAYOUT(3, false));
+               scrolledForm.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+               
+               Composite buttonContainer = getWizard().getFormFactory().createComposite(container);
+               buttonContainer.setLayout(new GridLayout(3, true));
+               buttonContainer.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, false));
+               
+               button_previous = getWizard().getFormFactory().createButton(buttonContainer, "Previous", SWT.PUSH);
+               button_previous.addSelectionListener(this);
+               button_previous.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, false));
+               
+               label_pageNumber = getWizard().getFormFactory().createLabel(buttonContainer, "              "); 
+               
+               button_next = getWizard().getFormFactory().createButton(buttonContainer, "Next", SWT.PUSH);
+               button_next.addSelectionListener(this);
+               button_next.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, false));
+               
+               scrolledForm.getBody().setLayoutData(CdmFormFactory.FILL());
+               
+               rootElement = new RootElement(getWizard().getFormFactory(), scrolledForm.getBody());
+               
+               imageElement = getWizard().getFormFactory().createImageElement(rootElement, null, SWT.BORDER);
+               
+               setControl(container);
+       }
+
+       public OpenUrlSelectorWizard getWizard(){
+               return (OpenUrlSelectorWizard) super.getWizard();
+       }
+
+       /**
+        * @param jpegImage
+        */
+       public void displayImage() {
+               URI imageUri = getWizard().getOpenUrlReferenceImageUri();
+               imageElement.setImageUri(imageUri);
+               
+               IRunnableWithProgress runnable = imageElement.getLoadImageRunnable(new Runnable(){
+                       /* (non-Javadoc)
+                        * @see java.lang.Runnable#run()
+                        */
+                       @Override
+                       public void run() {
+                               container.layout();
+                               
+                               configurePageBar();
+                       }
+               });
+               
+               try {
+                       getWizard().getContainer().run(true, false, runnable);
+               } catch (Exception e) {
+                       EditorUtil.errorDialog("Could not load image", getClass(), e.getMessage()  + ": " + imageUri , e);
+               }
+       }
+
+       /**
+        * 
+        */
+       private void configurePageBar() {
+               setTitle(getWizard().getOpenUrlReference().getTitleCache());
+               String pageNumber = getWizard().getOpenUrlReference().getPages();
+               label_pageNumber.setText(pageNumber);
+               button_previous.setEnabled(canPage(PREVIOUS));
+               button_next.setEnabled(canPage(NEXT));
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+        */
+       @Override
+       public void widgetSelected(SelectionEvent e) {
+               if(e.getSource() == button_next){
+                       pageResult(NEXT);
+               }else{
+                       pageResult(PREVIOUS);
+               }
+       }
+       
+       private void pageResult(int direction){
+               try {
+                       List<OpenUrlReference> referenceList = getWizard().getOpenUrlServiceWrapper().doPage(getWizard().getOpenUrlReference(), direction);
+                       OpenUrlReference openUrlReference = referenceList.iterator().next();
+                       getWizard().setOpenUrlReference(openUrlReference);
+                       displayImage();
+                       setErrorMessage(null);
+               } catch (IllegalArgumentException e) {
+                       setErrorMessage(String.format("Could not page: %s", e.getLocalizedMessage()));
+               } catch (Exception e) {
+                       EditorUtil.error(getClass(), e);
+               }
+       }
+       
+       private boolean canPage(int direction){
+               try{
+                       getWizard().getOpenUrlServiceWrapper().doPage(getWizard().getOpenUrlReference(), direction);
+               }catch (IllegalArgumentException e) {
+                       return false;
+               }
+               return true;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+        */
+       @Override
+       public void widgetDefaultSelected(SelectionEvent e) {}
+}
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlResultPage.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlResultPage.java
new file mode 100644 (file)
index 0000000..25b3936
--- /dev/null
@@ -0,0 +1,113 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+import eu.etaxonomy.cdm.ext.openurl.OpenUrlReference;
+
+
+/**
+ * @author n.hoffmann
+ * @created Jan 31, 2011
+ * @version 1.0
+ */
+public class OpenUrlResultPage extends WizardPage {
+
+       public static final String NAME = "OpenUrlResultPage"; 
+       
+       private TableViewer viewer;
+       
+       /**
+        * @param pageName
+        */
+       protected OpenUrlResultPage() {
+               super(NAME);
+               setTitle("Choose from results");
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               setPageComplete(false);
+               
+               Composite container = getWizard().getFormFactory().createComposite(parent);
+               
+               container.setLayout(new GridLayout());
+               container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               viewer = new TableViewer(container);
+               viewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+               
+               viewer.setContentProvider(new OpenUrlContentProvider());
+               viewer.setLabelProvider(new OpenUrlLabelProvider());
+               
+               List<OpenUrlReference> results = getWizard().getResult();
+               
+               if(results == null || results.isEmpty()){
+                       setMessage("No results for the given reference", WizardPage.WARNING);
+               }
+               viewer.setInput(results);
+               
+               viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+                       
+                       @Override
+                       public void selectionChanged(SelectionChangedEvent event) {
+                               IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+                               
+                               OpenUrlReference reference = (OpenUrlReference) selection.getFirstElement();
+                               
+                               getWizard().setOpenUrlReference(reference);
+                               
+                               
+                               ((OpenUrlReferencePage) getNextPage()).displayImage();
+                               
+                               setPageComplete(true);
+                       }
+               });
+               
+               setControl(container);
+               
+       }
+       
+       public OpenUrlSelectorWizard getWizard(){
+               return (OpenUrlSelectorWizard) super.getWizard();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.WizardPage#canFlipToNextPage()
+        */
+       @Override
+       public boolean canFlipToNextPage() {
+               return super.canFlipToNextPage();
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
+        */
+       @Override
+       public boolean isPageComplete() {
+               return super.isPageComplete();
+       }
+
+}
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorElement.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorElement.java
new file mode 100644 (file)
index 0000000..946e92d
--- /dev/null
@@ -0,0 +1,110 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement;
+import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
+import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 31, 2011
+ * @version 1.0
+ */
+public class OpenUrlSelectorElement extends AbstractCdmFormElement implements SelectionListener{
+
+       private Button button;
+       
+       private Reference reference;
+       
+       private String referenceDetail;
+
+       private IOpenUrlEnabled openUrlEnabled;
+       
+       /**
+        * @param formFactory
+        * @param parentElement
+        * @param labelString
+        * @param initialUri
+        * @param textHeight
+        * @param style
+        */
+       public OpenUrlSelectorElement(CdmFormFactory formFactory,
+                       ICdmFormElement parentElement, String labelString, IOpenUrlEnabled openUrlEnabled, int style) {
+               super(formFactory, parentElement);
+               this.openUrlEnabled = openUrlEnabled;
+               button = formFactory.createButton(getLayoutComposite(), "Browse", SWT.PUSH);
+               addControl(button);
+               button.addSelectionListener(this);
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+        */
+       @Override
+       public void widgetSelected(SelectionEvent e) {
+               OpenUrlSelectorWizard wizard = new OpenUrlSelectorWizard(openUrlEnabled.getReference(), openUrlEnabled.getDetail());
+               
+               WizardDialog dialog = new WizardDialog(EditorUtil.getShell(), wizard);
+               
+               if(dialog.open() == IStatus.OK){
+                       openUrlEnabled.setOpenUrl(wizard.getOpenUrlReferenceImageUri());
+               }
+       }
+
+       /**
+        * @return
+        */
+       private String getDetail() {
+               return referenceDetail;
+       }
+       
+       public void setDetail(String referenceDetail){
+               this.referenceDetail = referenceDetail;
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+        */
+       @Override
+       public void widgetDefaultSelected(SelectionEvent e) {}
+
+       /**
+        * @param reference the reference to set
+        */
+       public void setReference(Reference reference) {
+               this.reference = reference;
+       }
+
+       /**
+        * @return the reference
+        */
+       public Reference getReference() {
+               return reference;
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.forms.ISelectable#setSelected(boolean)
+        */
+       @Override
+       public void setSelected(boolean selected) {
+               // pass
+       }
+}
diff --git a/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorWizard.java b/taxeditor-editor/src/main/java/eu/etaxonomy/taxeditor/forms/openurl/OpenUrlSelectorWizard.java
new file mode 100644 (file)
index 0000000..ca1822a
--- /dev/null
@@ -0,0 +1,143 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.forms.openurl;
+
+import java.net.URI;
+import java.util.List;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.swt.widgets.Display;
+
+import eu.etaxonomy.cdm.ext.openurl.MobotOpenUrlQuery;
+import eu.etaxonomy.cdm.ext.openurl.MobotOpenUrlServiceWrapper;
+import eu.etaxonomy.cdm.ext.openurl.MobotOpenUrlServiceWrapper.ReferenceType;
+import eu.etaxonomy.cdm.ext.openurl.OpenUrlReference;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
+import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+
+/**
+ * @author n.hoffmann
+ * @created Jan 31, 2011
+ * @version 1.0
+ */
+public class OpenUrlSelectorWizard extends Wizard {
+       
+       private MobotOpenUrlServiceWrapper openUrlServiceWrapper;
+
+       private MobotOpenUrlQuery query;
+       
+       private OpenUrlReference openUrlReference;
+       
+       private CdmFormFactory formFactory;
+
+       private URI openUrlReferenceImageUri;
+       
+       
+       
+       /**
+        * @param openUrlSelectorElement 
+        * @param reference
+        */
+       public OpenUrlSelectorWizard(Reference reference, String referenceDetail) {
+               setWindowTitle("Mobot Open Url");
+               setNeedsProgressMonitor(true);
+               
+               formFactory = new CdmFormFactory(Display.getDefault());
+               
+               openUrlServiceWrapper = new MobotOpenUrlServiceWrapper();
+               openUrlServiceWrapper.setBaseUrl(PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.OPENURL_ACCESS_POINT));
+               
+               query  = new MobotOpenUrlQuery();
+               
+               query.refType = ReferenceType.getReferenceType(reference);
+               query.authorName = reference.getAuthorTeam().getTitleCache();
+               query.bookTitle = reference.getTitle();
+               if(reference.getInReference() != null){
+                       query.journalTitle = reference.getInReference().getTitle();
+               }
+               query.ISBN = reference.getIsbn();
+               query.ISSN = reference.getIssn();
+               if(reference.getDatePublished() != null){
+                       query.publicationDate = reference.getDatePublished().toString();
+               }
+               query.publicationPlace = reference.getPlacePublished();
+               query.publisherName = reference.getPublisher();
+               query.volume = reference.getVolume();
+               
+               query.startPage = referenceDetail;
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#addPages()
+        */
+       @Override
+       public void addPages() {
+               
+               addPage(new OpenUrlResultPage());
+               addPage(new OpenUrlReferencePage());
+               
+               super.addPages();
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.wizard.Wizard#performFinish()
+        */
+       @Override
+       public boolean performFinish() {
+               return true;
+       }
+
+       /**
+        * @param openUrlReference the openUrlReference to set
+        */
+       public void setOpenUrlReference(OpenUrlReference openUrlReference) {
+               this.openUrlReference = openUrlReference;
+               this.openUrlReferenceImageUri = openUrlReference.getJpegImage(PreferencesUtil.getPreferenceStore().getInt(IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH)
+                               , PreferencesUtil.getPreferenceStore().getInt(IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT));
+       }
+
+       /**
+        * @return the openUrlReference
+        */
+       public OpenUrlReference getOpenUrlReference() {
+               return openUrlReference;
+       }
+
+       /**
+        * @return
+        */
+       public List<OpenUrlReference> getResult() {
+               return openUrlServiceWrapper.doResolve(query);
+       }
+
+       /**
+        * @return the formFactory
+        */
+       public CdmFormFactory getFormFactory() {
+               return formFactory;
+       }
+
+       /**
+        * @return the openUrlServiceWrapper
+        */
+       public MobotOpenUrlServiceWrapper getOpenUrlServiceWrapper() {
+               return openUrlServiceWrapper;
+       }
+
+       /**
+        * @return
+        */
+       public URI getOpenUrlReferenceImageUri() {
+               return openUrlReferenceImageUri;
+       }
+}
index 8be83cb87c39a67a78f18ec3f042e91bfe6722b3..852419b249d2a6c4d08a3d0c6e085a76a55ff595 100644 (file)
@@ -16,16 +16,22 @@ import java.net.URISyntaxException;
 import org.eclipse.swt.events.SelectionListener;
 
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
 import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
 import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
+import eu.etaxonomy.cdm.model.name.TaxonNameBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.forms.AbstractFormSection;
 import eu.etaxonomy.taxeditor.forms.CdmFormFactory;
+import eu.etaxonomy.taxeditor.forms.CdmPropertyChangeEvent;
 import eu.etaxonomy.taxeditor.forms.ICdmFormElement;
 import eu.etaxonomy.taxeditor.forms.ISelectableElement;
 import eu.etaxonomy.taxeditor.forms.SelectionArbitrator;
 import eu.etaxonomy.taxeditor.forms.TextWithLabelElement;
+import eu.etaxonomy.taxeditor.forms.openurl.IOpenUrlEnabled;
+import eu.etaxonomy.taxeditor.forms.openurl.OpenUrlSelectorElement;
 import eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement;
 
 /**
@@ -35,7 +41,7 @@ import eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement;
  * @created Nov 5, 2009
  * @version 1.0
  */
-public class ProtologueElement extends AbstractEntityCollectionElement<DescriptionElementBase> implements ISelectableElement{
+public class ProtologueElement extends AbstractEntityCollectionElement<DescriptionElementBase> implements ISelectableElement, IOpenUrlEnabled{
 
        private SelectionArbitrator selectionArbitrator;
 
@@ -44,6 +50,8 @@ public class ProtologueElement extends AbstractEntityCollectionElement<Descripti
        private Media media;
        private MediaRepresentation mediaRepresentation;
 
+       private OpenUrlSelectorElement element_openUrl;
+
        /**
         * <p>Constructor for ProtologueElement.</p>
         *
@@ -66,6 +74,8 @@ public class ProtologueElement extends AbstractEntityCollectionElement<Descripti
        @Override
        public void createControls(ICdmFormElement element, int style) {
                protologueUriText = formFactory.createTextWithLabelElement(this, "Protologue URI", "", style);
+
+               element_openUrl = formFactory.createOpenUrlSelectorElement(element, "URI", this, style);
        }
 
        /* (non-Javadoc)
@@ -75,13 +85,12 @@ public class ProtologueElement extends AbstractEntityCollectionElement<Descripti
        @Override
        public void setEntity(DescriptionElementBase element) {
                this.entity = element;
-               
+                               
                if(element.getMedia().size() == 0){
                        element.addMedia(Media.NewInstance());
                }
                media = element.getMedia().iterator().next();
                
-               
                if(media.getRepresentations().size() == 0){
                        media.addRepresentation(MediaRepresentation.NewInstance());
                }               
@@ -125,4 +134,37 @@ public class ProtologueElement extends AbstractEntityCollectionElement<Descripti
                        }
                }       
        }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.forms.openurl.IOpenUrlEnabled#setOpenUrl(java.net.URI)
+        */
+       @Override
+       public void setOpenUrl(URI uri) {
+               protologueUriText.setText(uri.toString());
+               firePropertyChangeEvent(new CdmPropertyChangeEvent(protologueUriText, null));
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.forms.openurl.IOpenUrlEnabled#getReference()
+        */
+       @Override
+       public Reference getReference() {
+               return (Reference) getName().getNomenclaturalReference();
+       }
+
+       /* (non-Javadoc)
+        * @see eu.etaxonomy.taxeditor.forms.openurl.IOpenUrlEnabled#getDetail()
+        */
+       @Override
+       public String getDetail() {
+               return getName().getNomenclaturalMicroReference();
+       }
+       
+       private TaxonNameBase getName(){
+               TaxonNameDescription description = (TaxonNameDescription) entity.getInDescription();
+               
+               TaxonNameBase taxonName = description.getTaxonName();
+               
+               return taxonName;
+       }
 }
index 1ca02232113a7a2268b05154b9290a18a590214b..15a192d6f0df76e59f3d5848d727929c39e75a2c 100644 (file)
@@ -35,6 +35,7 @@ import eu.etaxonomy.taxeditor.forms.TextWithLabelElement;
 import eu.etaxonomy.taxeditor.forms.TimePeriodElement;
 import eu.etaxonomy.taxeditor.forms.ToggleableTextElement;
 import eu.etaxonomy.taxeditor.forms.UriWithLabelElement;
+import eu.etaxonomy.taxeditor.forms.openurl.OpenUrlSelectorElement;
 import eu.etaxonomy.taxeditor.forms.selection.AbstractSelectionElement;
 import eu.etaxonomy.taxeditor.forms.selection.ReferenceSelectionElement;
 import eu.etaxonomy.taxeditor.forms.term.ReferenceTypeComboElement;
@@ -71,7 +72,7 @@ public class ReferenceDetailElement extends AbstractCdmDetailElement<Reference>
        private AbstractSelectionElement<Reference> selection_inReference;
        private AbstractSelectionElement<Institution> selection_institution;
        private ReferenceTypeComboElement combo_referenceType;
-
+       
        private ReferenceSelectionElement selection_inSeries;
 
        
index 93f50e376c2db14b77ea62b9bace53be9b01cd26..59454fcb84ff9d8f259297744bfb4bfabbee9230 100644 (file)
@@ -116,6 +116,13 @@ public class ImageFileElement extends AbstractMediaRepresentationPartElement<Ima
                                
                                element_image.setImageUri(uri);
                                
+                               element_image.loadImage(new Runnable(){
+                                       public void run() {
+                                               getLayoutComposite().layout();
+                                               EditorUtil.reflowDetailsViewer();
+                                       }
+                               });
+                               
                        } catch (IOException e) {
                                EditorUtil.error(getClass(), e);
                        }
index 1915742e22bd9fe20d7b0ba86134c8a76b3015cc..7a4d2175c607066edadb5b410b036062fb9bc683 100644 (file)
             id="eu.etaxonomy.taxeditor.preferences.language"
             name="Language">
       </page>
+      <page
+            category="eu.etaxonomy.taxeditor.preferences.general"
+            class="eu.etaxonomy.taxeditor.preference.MobotOpenUrlPreferences"
+            id="eu.etaxonomy.taxeditor.preferences.mobotOpenUrl"
+            name="Mobot Open Url">
+      </page>
    </extension>
    <extension
          point="org.eclipse.ui.views">
index aa66420a0a9a56bae224fa0337d467721890a887..b2cfe084a22091ff50f717ef128a00ae31f8a03b 100644 (file)
@@ -300,7 +300,14 @@ public abstract class AbstractUtility {
         * @param status a {@link org.eclipse.core.runtime.IStatus} object.
         */
        public static void errorDialog(final String title, final Object source, final IStatus status){
-               
+               Display.getDefault().asyncExec(new Runnable(){
+
+                       public void run() {
+                               MessageDialog.openError(getShell(), title, status.getMessage());
+                               Class<? extends Object> clazz = source != null ? source.getClass() : this.getClass();
+                               error(clazz, status.getMessage(), status.getException());
+                       }
+               });
        }
 
        /**
index 925084e764c275d662501a96751afcc8a6a5c5eb..f9e5e09172fb490abeda16c1828278bd9dda5b8e 100644 (file)
@@ -99,4 +99,10 @@ public interface IPreferenceKeys {
        public static final String GLOBAL_LANGUAGE_UUID = "eu.etaxonomy.taxeditor.globalLanguage";
 
        public static final String SHOW_EXPERIMENTAL_FEATURES = "eu.etaxonomy.taxeditor.showExperimentalFeatures";
+
+       public static final String OPENURL_ACCESS_POINT = "eu.etaxonomy.taxeditor.openUrlAccessPoint";
+
+       public static final String OPENURL_IMAGE_MAX_WIDTH = "eu.etaxonomy.taxeditor.openUrlImageMaxWidth";
+
+       public static final String OPENURL_IMAGE_MAX_HEIGHT = "eu.etaxonomy.taxeditor.openUrlImageMaxHeight";
 }
diff --git a/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/MobotOpenUrlPreferences.java b/taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/preference/MobotOpenUrlPreferences.java
new file mode 100644 (file)
index 0000000..77b9350
--- /dev/null
@@ -0,0 +1,133 @@
+// $Id$
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy 
+* http://www.e-taxonomy.eu
+* 
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.preference;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * @author n.hoffmann
+ * @created Feb 4, 2011
+ * @version 1.0
+ */
+public class MobotOpenUrlPreferences extends PreferencePage implements
+               IWorkbenchPreferencePage {
+
+
+       private String openUrlServiceAccessPoint;
+       private String openUrlImageMaxWidth;
+       private String openUrlImageMaxHeight;
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+        */
+       @Override
+       public void init(IWorkbench workbench) {
+               setPreferenceStore(PreferencesUtil.getPreferenceStore());
+       }
+
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       protected Control createContents(Composite parent) {
+               Composite container = new Composite(parent, SWT.NULL);
+               final GridLayout gridLayout = new GridLayout();
+               container.setLayout(gridLayout);
+               
+               creatOpenUrlServiceAccessPoint(container);
+               
+               createOpenUrlImageSize(container);
+               
+               return container;
+       }
+       
+       /**
+        * @param container
+        */
+       private void createOpenUrlImageSize(Composite container) {
+               openUrlImageMaxWidth = getPreferenceStore().getString(IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH);
+               openUrlImageMaxHeight = getPreferenceStore().getString(IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT);
+               
+               Composite composite = new Composite(container, SWT.NULL);
+               final GridLayout gridLayout = new GridLayout(2, false);
+               composite.setLayout(gridLayout);
+               
+               final CLabel labelWidth = new CLabel(composite, SWT.NULL);
+               labelWidth.setText("Image Maximum Width: ");
+               
+               final Text textWidth = new Text(composite, SWT.BORDER);
+               textWidth.setText(openUrlImageMaxWidth);
+               textWidth.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               
+               textWidth.addModifyListener(new ModifyListener() {
+                       
+                       public void modifyText(ModifyEvent e) {
+                               openUrlImageMaxWidth = textWidth.getText();
+                       }
+               });
+               
+               final CLabel labelHeight = new CLabel(composite, SWT.NULL);
+               labelHeight.setText("Image Maximum Height: ");
+               
+               final Text textHeight = new Text(composite, SWT.BORDER);
+               textHeight.setText(openUrlImageMaxHeight);
+               textHeight.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               
+               textHeight.addModifyListener(new ModifyListener() {
+                       
+                       public void modifyText(ModifyEvent e) {
+                               openUrlImageMaxHeight = textHeight.getText();
+                       }
+               });
+       }
+
+       private void creatOpenUrlServiceAccessPoint(Composite composite) {
+               openUrlServiceAccessPoint = getPreferenceStore().getString(IPreferenceKeys.OPENURL_ACCESS_POINT);
+               
+               final CLabel label = new CLabel(composite, SWT.NULL);
+               label.setText("Mobot Open Url Service Access Point:");
+               
+               final Text text = new Text(composite, SWT.BORDER);
+               text.setText(openUrlServiceAccessPoint);
+               text.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               
+               text.addModifyListener(new ModifyListener() {
+                       
+                       public void modifyText(ModifyEvent e) {
+                               openUrlServiceAccessPoint = text.getText();
+                       }
+               });
+       }
+       
+       /* (non-Javadoc)
+        * @see org.eclipse.jface.preference.PreferencePage#performOk()
+        */
+       @Override
+       public boolean performOk() {
+               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_ACCESS_POINT, openUrlServiceAccessPoint);
+               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_IMAGE_MAX_WIDTH, openUrlImageMaxWidth);
+               getPreferenceStore().setValue(IPreferenceKeys.OPENURL_IMAGE_MAX_HEIGHT, openUrlImageMaxHeight);
+               
+               return super.performOk();
+       }
+
+}
index 33323b602c19e8320c2991f2571773adcd3fb1ed..310ee58a367152e4f5f8046eae9de0b3cbdb01df 100644 (file)
@@ -298,6 +298,9 @@ public class PreferencesUtil implements IPreferenceKeys{
                getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS, true);
                getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT, "http://edit.br.fgov.be/edit_wp5/v1/areas.php");
                getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, true);       
+               getPreferenceStore().setDefault(OPENURL_ACCESS_POINT, "http://www.biodiversitylibrary.org/openurl");
+               getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
+               getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
        }
 
        /**
index 78c0f8ad7ffb5b850d985f2bc1155dafb3d67bc2..c7d11ba6485c2225f29da757e3a9ccb9a1eb0996 100644 (file)
@@ -46,6 +46,7 @@ public class TaxonomicEditorGeneralPreferences extends PreferencePage implements
        private boolean shouldExpandSectionWhenDataAvailable;
 
        private boolean shouldShowExperimentalFeatures;
+
        
        /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
@@ -106,6 +107,8 @@ public class TaxonomicEditorGeneralPreferences extends PreferencePage implements
                        }
                });
        }
+       
+
 
        private void createShowUuidInSupplementalView(Composite parent){
                showUuidInSupplementalView = getPreferenceStore().getBoolean(PreferencesUtil.SHOW_DEBUG_INFORMATION);
@@ -206,7 +209,7 @@ public class TaxonomicEditorGeneralPreferences extends PreferencePage implements
                getPreferenceStore().setValue(IPreferenceKeys.SHOULD_CONNECT_AT_STARTUP, shouldConnectAtStartup);
                getPreferenceStore().setValue(IPreferenceKeys.SHOULD_EXPAND_SECTION_WHEN_DATA_AVAILABLE, shouldExpandSectionWhenDataAvailable);
                getPreferenceStore().setValue(IPreferenceKeys.SHOW_EXPERIMENTAL_FEATURES, shouldShowExperimentalFeatures);
-               
+                               
                return super.performOk();
        }