Project

General

Profile

« Previous | Next » 

Revision a06ac8f6

Added by Patrick Plitzner over 3 years ago

ref #8147 Enable "Finish" only if any data is present

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/RepresentationElement.java
22 22
import org.eclipse.swt.SWT;
23 23
import org.eclipse.swt.events.SelectionAdapter;
24 24
import org.eclipse.swt.events.SelectionEvent;
25
import org.eclipse.swt.events.SelectionListener;
26 25
import org.eclipse.swt.widgets.Button;
27 26

  
28 27
import eu.etaxonomy.cdm.model.common.Language;
......
36 35
import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
37 36

  
38 37

  
39
public class RepresentationElement  extends AbstractCdmFormElement implements
40
SelectionListener{
38
public class RepresentationElement extends AbstractCdmFormElement {
41 39

  
42 40
        protected TermComboElement<Language> combo_language;
43 41

  
......
93 91
            combo_language = formFactory.createDefinedTermComboElement(TermType.Language, formElement,
94 92
                            "", null, false, style);
95 93

  
96
            combo_language.addSelectionListener(this);
97

  
98 94
       }
99 95

  
100 96
        public List<Language> getLanguages() {
......
109 105
            return languageList;
110 106
        }
111 107

  
112
        @Override
113
        public void widgetSelected(SelectionEvent e) {
114
            Language selectedLanguage = combo_language.getSelection();
115
            if (selectedLanguage != null) {
116
                selectedRepresentation = getTerm().getRepresentation(
117
                        selectedLanguage);
118
                if (selectedRepresentation == null){
119
                    selectedRepresentation = Representation.NewInstance("", "", "", selectedLanguage);
120
                }
121
                element_Label.setText(selectedRepresentation.getLabel());
122
                element_abbrevLabel.setText(selectedRepresentation.getAbbreviatedLabel());
123
                element_plural.setText(selectedRepresentation.getPlural());
124
                element_text.setText(selectedRepresentation.getDescription());
125

  
126
            }else {
127
                setEnabledControls(false);
128
            }
129

  
130
        }
131

  
132
        @Override
133
        public void widgetDefaultSelected(SelectionEvent e) {
134
        }
135

  
136 108
        public void setTerm(
137 109
                TermBase term, boolean update) {
138 110
            this.term = term;
......
215 187
            } else if (eventSource == button){
216 188
            	firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
217 189
            } else if (eventSource == combo_language){
218
            	if (combo_language.getSelection() != null){
219
            	    setEnabledControls(true);
220
            		 boolean removePossible = term.getRepresentations().size() > 1 ;
221
                     removeRepresentation.setEnabled(removePossible);
222
            	} else{
223
            	    setEnabledControls(false);
224
                     removeRepresentation.setEnabled(false);
225
            	}
226
            	firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
190
                if (combo_language.getSelection() != null){
191
                    setEnabledControls(true);
192
                    boolean removePossible = term.getRepresentations().size() > 1 ;
193
                    removeRepresentation.setEnabled(removePossible);
194

  
195
                    Language selectedLanguage = combo_language.getSelection();
196
                    if (selectedLanguage != null) {
197
                        selectedRepresentation = getTerm().getRepresentation(selectedLanguage);
198
                        if (selectedRepresentation == null){
199
                            selectedRepresentation = Representation.NewInstance("", "", "", selectedLanguage);
200
                        }
201
                        element_Label.setText(selectedRepresentation.getLabel());
202
                        element_abbrevLabel.setText(selectedRepresentation.getAbbreviatedLabel());
203
                        element_plural.setText(selectedRepresentation.getPlural());
204
                        element_text.setText(selectedRepresentation.getDescription());
205

  
206
                    }else {
207
                        setEnabledControls(false);
208
                    }
209
                } else{
210
                    setEnabledControls(false);
211
                    removeRepresentation.setEnabled(false);
212
                }
213
                firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
227 214
            }
228 215
        }
229 216

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/TermTranslationWizard.java
66 66

  
67 67
        return true;
68 68
    }
69

  
70
    /**
71
     * {@inheritDoc}
72
     */
73
    @Override
74
    public boolean canFinish() {
75
        Representation representation = page.getTargetRepresentation();
76
        if (representation==null || representation.getLanguage() == null){
77
            return false;
78
        }
79
        return CdmUtils.isNotBlank(representation.getText())
80
                || CdmUtils.isNotBlank(representation.getLabel())
81
                || CdmUtils.isNotBlank(representation.getAbbreviatedLabel())
82
                || CdmUtils.isNotBlank(representation.getPlural());
83
    }
69 84
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/translation/TermTranslationWizardPage.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.ui.translation;
10 10

  
11
/**
12
 * @author k.luther
13
 * @date 22.06.2016
14
 *
15
 */
16

  
17
import java.beans.PropertyChangeEvent;
18
import java.beans.PropertyChangeListener;
19

  
20
import org.apache.commons.lang.StringUtils;
11
import org.eclipse.jface.util.IPropertyChangeListener;
21 12
import org.eclipse.jface.wizard.WizardPage;
22 13
import org.eclipse.swt.SWT;
23 14
import org.eclipse.swt.widgets.Composite;
......
35 26
import eu.etaxonomy.taxeditor.ui.element.RepresentationElement;
36 27
import eu.etaxonomy.taxeditor.ui.element.RootElement;
37 28

  
38
public class TermTranslationWizardPage extends WizardPage implements PropertyChangeListener{
29
/**
30
 * @author k.luther
31
 * @date 22.06.2016
32
 *
33
 */
34
public class TermTranslationWizardPage extends WizardPage implements IPropertyChangeListener{
39 35

  
40 36

  
41 37
        private static int TEXT_HEIGHT = 200;
......
61 57
            setTitle("Add or edit translations.");
62 58
            this.term = term;
63 59
            formFactory = new CdmFormFactory(Display.getCurrent());
60
            formFactory.addPropertyChangeListener(this);
64 61
            setPageComplete(false);
65 62
        }
66 63

  
......
129 126
         */
130 127
        private void createRightControls(ICdmFormElement element){
131 128
            text_target = formFactory.createRepresentationElement(element, null, term, TEXT_HEIGHT, SWT.NULL, false);
132
            
129

  
133 130
        }
134 131

  
135 132

  
......
152 149
            return text_target.getSelectedRepresentation();
153 150
        }
154 151

  
155
        /* (non-Javadoc)
156
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
157
         */
152
        /**
153
        * {@inheritDoc}
154
        */
158 155
        @Override
159
        public void propertyChange(PropertyChangeEvent evt) {
160
            if (evt.getSource() == text_target){
161
                if (!StringUtils.isBlank(text_target.getSelectedRepresentation().getAbbreviatedLabel()) ||
162
                        !StringUtils.isBlank(text_target.getSelectedRepresentation().getLabel()) || !StringUtils.isBlank(text_target.getSelectedRepresentation().getText())){
163
                    setPageComplete(true);
164
                }
156
        public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
157
            if (event.getSource() == text_target){
158
                getWizard().getContainer().updateButtons();
165 159
            }
166

  
167 160
        }
168 161

  
169

  
170

  
171

  
172 162
}

Also available in: Unified diff