Project

General

Profile

« Previous | Next » 

Revision 4736d50c

Added by Katja Luther over 5 years ago

ref #3767: add DOI to reference detail element

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
116 116
    public static String UriWithLabelElement_INVALID_URL;
117 117
    public static String UriWithLabelElement_OPEN_EXTERNAL_BROWSER;
118 118
    public static String UriWithLabelElement_URL_NOT_SAVED;
119
    public static String DoiWithLabelElement_DOI_NOT_SAVED;
120

  
119 121
	public static String CdmStoreConnector_AUTHENTICATING_USER;
120 122
	public static String CdmStoreConnector_CHECK_IF_EDITOR_IS_COMPATIBLE;
121 123
	public static String CdmStoreConnector_CHECK_IF_NON_EMPTY;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
52 52
UriWithLabelElement_INVALID_URL=Invalid URI
53 53
UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Open in external browser
54 54

  
55
DoiWithLabelElement_DOI_NOT_SAVED=DOI won't be saved\!
56

  
55 57
ChangeConnectionHandler_ALREADY_CONNECTING=Already creating data model
56 58
ChangeConnectionHandler_CURRENTLY_CONNECTING_ALREADY=You are currently creating a data model for a datasource already.
57 59
ChangeConnectionHandler_DATASOURCE_NOT_AVAILABLE=Chosen datasource is not available
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
52 52
UriWithLabelElement_INVALID_URL=Ung\u00FCltige URI
53 53
UriWithLabelElement_OPEN_EXTERNAL_BROWSER=Im Browser ?ffnen 
54 54

  
55
DoiWithLabelElement_DOI_NOT_SAVED=DOI wird nicht gespeichert\!
56

  
55 57
ChangeConnectionHandler_ALREADY_CONNECTING=Datenmodell wird erstellt
56 58
ChangeConnectionHandler_CURRENTLY_CONNECTING_ALREADY=Es wird schon das Datenmodell f?r eine Datenquelle erstellt
57 59
ChangeConnectionHandler_DATASOURCE_NOT_AVAILABLE=Gew?hlte Datenquelle ist nicht verf?gbar
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
49 49

  
50 50
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
51 51
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
52
import eu.etaxonomy.cdm.common.DOI;
52 53
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
53 54
import eu.etaxonomy.cdm.model.agent.Person;
54 55
import eu.etaxonomy.cdm.model.agent.Team;
......
821 822
    }
822 823

  
823 824

  
825
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
826
            DOI initialDoi, int style) {
827
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, null, style);
828
        adapt(element);
829
        parentElement.addElement(element);
830
        return element;
831
    }
832
    public DoiWithLabelElement createDoiWithLabelElement(ICdmFormElement parentElement, String labelString,
833
            DOI initialDoi,Integer textHeight, int style) {
834
        DoiWithLabelElement element = new DoiWithLabelElement(this, parentElement, labelString, initialDoi, textHeight, style);
835
        adapt(element);
836
        parentElement.addElement(element);
837
        return element;
838
    }
839

  
824 840
    /**
825 841
     * @param element
826 842
     * @param string
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/DoiWithLabelElement.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.ui.element;
10

  
11
import org.eclipse.jface.resource.JFaceResources;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Display;
15
import org.eclipse.ui.forms.widgets.TableWrapLayout;
16

  
17
import eu.etaxonomy.cdm.common.DOI;
18
import eu.etaxonomy.taxeditor.l10n.Messages;
19

  
20
/**
21
 * @author k.luther
22
 * @since 27.11.2018
23
 *
24
 */
25
public class DoiWithLabelElement extends AbstractUriWithExceptionLabelElement<DOI> {
26

  
27
    /**
28
     * @param formFactory
29
     * @param parentElement
30
     * @param labelString
31
     * @param initialObject
32
     * @param textHeight
33
     * @param style
34
     */
35
    protected DoiWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
36
            DOI initialObject, Integer textHeight, int style) {
37
        super(formFactory, parentElement, labelString, initialObject, textHeight, style);
38
        // TODO Auto-generated constructor stub
39
    }
40

  
41
    /**
42
     * {@inheritDoc}
43
     */
44
    @Override
45
    public void setParsedText(DOI object) {
46
        if(object != null){
47
            super.setText(object.toString());
48
        }
49

  
50
    }
51

  
52
    /**
53
     * {@inheritDoc}
54
     */
55
    @Override
56
    protected DOI getParsedText() throws Exception {
57
        String doiText = super.getText();
58
        if(doiText!=null){
59
            return DOI.fromString(super.getText());
60
        }
61
        return null;
62
    }
63

  
64
    @Override
65
    protected void init(CdmFormFactory formFactory, String labelString, DOI initialObject, Integer textHeight, int style) {
66

  
67
        //label
68
        initLabel(formFactory, labelString, false, getLayoutComposite());
69
        //uri text
70
        initText(formFactory, null, textHeight, null, false, style, getLayoutComposite());
71
        initExceptionLabel(getLayoutComposite(), formFactory, initialObject);
72
    }
73

  
74
    @Override
75
    protected void initExceptionLabel(Composite parent, CdmFormFactory formFactory, DOI initialObject) {
76
        labelException = formFactory.createLabel(parent, "", SWT.WRAP); //$NON-NLS-1$
77
        int numColumns = AbstractFormSection.DEFAULT_NUM_COLUMNS;
78
        if(parent.getLayout() instanceof TableWrapLayout){
79
            numColumns = ((TableWrapLayout)parent.getLayout()).numColumns;
80
        }
81
        labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(numColumns, 1));
82
        labelException.setBackground(getPersistentBackground());
83
        addControl(labelException);
84
        setParsedText(initialObject);
85
    }
86
    @Override
87
    public DOI parseText(){
88
        try {
89
            labelException.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));
90
            labelException.setForeground(getPersistentBackground());
91
            labelException.setText(""); //$NON-NLS-1$
92
            return getParsedText();
93
        } catch (Exception e) {
94
            labelException.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
95
            labelException.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
96
            labelException.setText(Messages.DoiWithLabelElement_DOI_NOT_SAVED+e.getLocalizedMessage());
97
            return null;
98
        }
99
    }
100

  
101
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java
28 28
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
29 29
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
30 30
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
31
import eu.etaxonomy.taxeditor.ui.element.DoiWithLabelElement;
31 32
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
32 33
import eu.etaxonomy.taxeditor.ui.element.IErrorIntolerableElement;
33 34
import eu.etaxonomy.taxeditor.ui.element.IExceptionHandler;
......
68 69
	private TextWithLabelElement text_volume;
69 70
	private TextWithLabelElement text_abbrevTitle;
70 71
	private TextWithLabelElement text_title;
72
	private DoiWithLabelElement text_doi;
71 73
	private UriWithLabelElement text_uri;
72 74
	private DateElement text_accessed;
73 75
	private EntitySelectionElement<AgentBase> selection_authorTeam;
......
164 166
		// date published
165 167
		element_timePeriod = formFactory.createVerbatimTimePeriodElement(formElement,
166 168
				"Date Published", entity.getDatePublished(), style);
167

  
169
		text_doi = formFactory.createDoiWithLabelElement(formElement, "DOI", entity.getDoi(), style);
168 170
		createUriAndAbstract(this, entity, SWT.NULL);
171

  
169 172
		handleToggleableAbbrevTitleField();
170 173
		handleToggleableCacheField();
171 174
	}
......
468 471
			getEntity().setUri(text_uri.parseText());
469 472
		} else if (eventSource == text_volume) {
470 473
			getEntity().setVolume(text_volume.getText());
471
		}else if (eventSource == text_accessed.getController()) {
472
			getEntity().setAccessed(text_accessed.getController().getDateTime());
473
		}
474
		}else if (eventSource == text_doi) {
475
            getEntity().setDoi(text_doi.parseText());
476
        }else if (eventSource == text_accessed.getController()) {
477
            getEntity().setAccessed(text_accessed.getController().getDateTime());
478
        }
474 479

  
475 480
		if (eventSource != text_title && eventSource != text_abbrevTitle) {
476 481
		    // set abbrev title cache to null to force new generation

Also available in: Unified diff