Project

General

Profile

« Previous | Next » 

Revision ffeb89d3

Added by Katja Luther almost 4 years ago

fix #9035: fix NPE in reference details

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/DoiWithLabelElement.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.ui.element;
10 10

  
11
import java.io.IOException;
12
import java.net.URL;
13

  
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
11 16
import org.eclipse.jface.resource.JFaceResources;
12 17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.SelectionAdapter;
19
import org.eclipse.swt.events.SelectionEvent;
13 20
import org.eclipse.swt.widgets.Button;
14 21
import org.eclipse.swt.widgets.Composite;
15 22
import org.eclipse.swt.widgets.Display;
......
17 24

  
18 25
import eu.etaxonomy.cdm.common.DOI;
19 26
import eu.etaxonomy.taxeditor.l10n.Messages;
27
import eu.etaxonomy.taxeditor.model.ImageResources;
28
import eu.etaxonomy.taxeditor.model.MessagingUtils;
29
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
30
import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
20 31

  
21 32
/**
22 33
 * @author k.luther
......
69 80

  
70 81
        //label
71 82
        initLabel(formFactory, labelString, false, getLayoutComposite());
72
        //uri text
73
        initText(formFactory, null, textHeight, null, false, style, getLayoutComposite());
74

  
75
//        Composite textAndButton = formFactory.createComposite(getLayoutComposite(), style);
76
//        addControl(textAndButton);
77
//        textAndButton.setLayout(LayoutConstants.LAYOUT(2, false));
78
//        textAndButton.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
79
//      //button
80
//        btnOpenBrowser = formFactory.createButton(textAndButton, "", SWT.NONE); //$NON-NLS-1$
81
//        btnOpenBrowser.setImage(ImageResources.getImage(ImageResources.WEB));
82
//        btnOpenBrowser.setToolTipText(Messages.UriWithLabelElement_OPEN_EXTERNAL_BROWSER);
83
//        btnOpenBrowser.addSelectionListener(new SelectionAdapter() {
84
//            @Override
85
//            public void widgetSelected(SelectionEvent e) {
86
//                String errorTitle = Messages.UriWithLabelElement_INVALID_URL;
87
//                String errorText = Messages.UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
88
//
89
//                DOI doi= parseText();
90
//                if(doi!=null){
91
//                    try {
92
//                        WorkbenchUtility.openWebpage(new URL(doi.asURI()));
93
//                    } catch (IOException pie) {
94
//                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, pie));
95
//                    } catch (IllegalArgumentException iae) {
96
//                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, iae));
97
//                    }
98
//                }
99
//                else{
100
//                    MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, null));
101
//                }
102
//            }
103
//        });
104
//        btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
83

  
84

  
85

  
86
        Composite textAndButton = formFactory.createComposite(getLayoutComposite(), style);
87
        addControl(textAndButton);
88
        textAndButton.setLayout(LayoutConstants.LAYOUT(2, false));
89
        textAndButton.setLayoutData(LayoutConstants.FILL_HORIZONTALLY());
90
      //uri text
91
        initText(formFactory, null, textHeight, null, false, style, textAndButton);
92

  
93
      //button
94
        btnOpenBrowser = formFactory.createButton(textAndButton, "", SWT.NONE); //$NON-NLS-1$
95
        btnOpenBrowser.setImage(ImageResources.getImage(ImageResources.WEB));
96
        btnOpenBrowser.setToolTipText(Messages.UriWithLabelElement_OPEN_EXTERNAL_BROWSER);
97
        btnOpenBrowser.addSelectionListener(new SelectionAdapter() {
98
            @Override
99
            public void widgetSelected(SelectionEvent e) {
100
                String errorTitle = Messages.UriWithLabelElement_INVALID_URL;
101
                String errorText = Messages.UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
102

  
103
                DOI doi= parseText();
104
                if(doi!=null){
105
                    try {
106
                        WorkbenchUtility.openWebpage(new URL(doi.asURI()));
107
                    } catch (IOException pie) {
108
                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, pie));
109
                    } catch (IllegalArgumentException iae) {
110
                        MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, iae));
111
                    }
112
                }
113
                else{
114
                    MessagingUtils.informationDialog(errorTitle, new Status(IStatus.WARNING, TaxeditorStorePlugin.PLUGIN_ID, errorText, null));
115
                }
116
            }
117
        });
118
        btnOpenBrowser.setLayoutData(LayoutConstants.RIGHT());
105 119
        initExceptionLabel(getLayoutComposite(), formFactory, initialObject);
106 120
    }
107 121

  

Also available in: Unified diff