3 * Copyright (C) 2016 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.element
;
12 import org
.eclipse
.jface
.window
.Window
;
13 import org
.eclipse
.jface
.wizard
.WizardDialog
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.events
.SelectionAdapter
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
18 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
19 import eu
.etaxonomy
.cdm
.model
.common
.TermBase
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.vocabulary
.TermTranslationWizard
;
28 public class TranslatableRepresentationElement
extends RepresentationElement
{
33 * @param representation
37 * @param isTranslationWizard
39 public TranslatableRepresentationElement(CdmFormFactory formFactory
, ICdmFormElement formElement
,
40 Representation representation
, TermBase term
, Integer textHeight
, int style
) {
41 super(formFactory
, formElement
, representation
, term
, textHeight
, style
);
47 * @param cdmFormFactory
48 * @param parentElement
53 public TranslatableRepresentationElement(CdmFormFactory cdmFormFactory
, ICdmFormElement parentElement
,
54 TermBase term
, int textHeight
, int style
) {
55 super(cdmFormFactory
, parentElement
, term
, textHeight
, style
);
59 private class OpenTranslationWizard
extends SelectionAdapter
{
61 public OpenTranslationWizard() {
69 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
70 * .swt.events.SelectionEvent)
73 public void widgetSelected(SelectionEvent e
) {
74 TermBase term
= getTerm();
77 MessagingUtils
.warningDialog("No term to translate", getClass(), "The term is empty and therefore can not be translated");
80 TermTranslationWizard wizard
= new TermTranslationWizard(term
);
81 WizardDialog dialog
= new WizardDialog(getLayoutComposite()
84 if (dialog
.open() == Window
.OK
) {
85 combo_language
.setTerms(getLanguages());
92 protected void createRepresentationEditingElements(ICdmFormElement formElement
, int style
) {
93 super.createRepresentationEditingElements(formElement
, style
);
94 button
= formFactory
.createButton(getLayoutComposite(),
95 "Open In Translation Editor", SWT
.PUSH
);
97 button
.setLayoutData(LayoutConstants
.RIGHT());
98 button
.addSelectionListener(new OpenTranslationWizard());
106 button
.setEnabled(false);
115 protected void updateControls() {
116 super.updateControls();
117 button
.setEnabled(true);
118 combo_language
.setTerms(getLanguages());
119 combo_language
.setSelection(selectedRepresentation
.getLanguage());