--- /dev/null
+/**
+* Copyright (C) 2019 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.ui.element;
+
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+import eu.etaxonomy.cdm.model.agent.ORCID;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
+/**
+ * @author k.luther
+ * @since 11.11.2019
+ */
+public class OrcidWithLabelElement extends AbstractUriWithExceptionLabelElement<ORCID> {
+
+ /**
+ * @param formFactory
+ * @param parentElement
+ * @param labelString
+ * @param initialObject
+ * @param textHeight
+ * @param style
+ */
+ protected OrcidWithLabelElement(CdmFormFactory formFactory, ICdmFormElement parentElement, String labelString,
+ ORCID initialObject, Integer textHeight, int style) {
+ super(formFactory, parentElement, labelString, initialObject, textHeight, style);
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setParsedText(ORCID object) {
+ if(object != null){
+ super.setText(object.toString());
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ORCID getParsedText() throws Exception {
+ String orcidText = super.getText();
+ if(orcidText!=null){
+ return ORCID.fromString(super.getText());
+ }
+ return null;
+ }
+
+ @Override
+ protected void init(CdmFormFactory formFactory, String labelString, ORCID initialObject, Integer textHeight, int style) {
+
+ //label
+ initLabel(formFactory, labelString, false, getLayoutComposite());
+ //uri text
+ initText(formFactory, null, textHeight, null, false, style, getLayoutComposite());
+ initExceptionLabel(getLayoutComposite(), formFactory, initialObject);
+ }
+
+ @Override
+ protected void initExceptionLabel(Composite parent, CdmFormFactory formFactory, ORCID initialObject) {
+ labelException = formFactory.createLabel(parent, "", SWT.WRAP); //$NON-NLS-1$
+ int numColumns = AbstractFormSection.DEFAULT_NUM_COLUMNS;
+ if(parent.getLayout() instanceof TableWrapLayout){
+ numColumns = ((TableWrapLayout)parent.getLayout()).numColumns;
+ }
+ labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(numColumns, 1));
+ labelException.setBackground(getPersistentBackground());
+ addControl(labelException);
+ setParsedText(initialObject);
+ }
+ @Override
+ public ORCID parseText(){
+ try {
+ labelException.setFont(JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT));
+ labelException.setForeground(getPersistentBackground());
+ labelException.setText(""); //$NON-NLS-1$
+ return getParsedText();
+ } catch (Exception e) {
+ labelException.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
+ labelException.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
+ labelException.setText(Messages.OrcidWithLabelElement_DOI_NOT_SAVED+e.getLocalizedMessage());
+ return null;
+ }
+ }
+
+}
+
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+import eu.etaxonomy.taxeditor.ui.element.OrcidWithLabelElement;
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
import eu.etaxonomy.taxeditor.ui.section.AbstractIdentifiableEntityDetailElement;
private TextWithLabelElement text_prefix;
private TextWithLabelElement text_suffix;
private TextWithLabelElement text_initials;
+ private OrcidWithLabelElement text_orcid;
private Collection<Object> excludeFromIrrelevantToggleableObjects;
"Initials", entity.getInitials(), SWT.NULL);
text_prefix = formFactory.createTextWithLabelElement(formElement,
"Prefix", entity.getPrefix(), SWT.NULL);
- text_suffix = formFactory.createTextWithLabelElement(formElement,
- "Suffix", entity.getSuffix(), SWT.NULL);
+ text_orcid = formFactory.createOrcidWithLabelElement(formElement, "ORCID", entity.getOrcid(), SWT.NULL);
+
}
/** {@inheritDoc} */
getEntity().setPrefix(text_prefix.getText());
} else if (eventSource == text_suffix) {
getEntity().setSuffix(text_suffix.getText());
- }
+ }else if (eventSource == text_orcid) {
+ getEntity().setOrcid(text_orcid.parseText());
+ }
//if (eventSource != toggleable_cache) {
if (!getEntity().isProtectedTitleCache()){