Project

General

Profile

« Previous | Next » 

Revision 29aeffbe

Added by Cherian Mathew almost 9 years ago

EditConceptRelationshipComposite : show notification only when creating concept relationship
NewTaxonBaseComposite : added second sec. combobox for the case of creating synonyms
INewTaxonBaseComponentListener, NewTaxonBasePresenter : creating separate containers for acc. taxon and synonym references
NewTaxonBasePresenter, NewTaxonBasePresenterTest : updated new synonym method to include acc. taxon sec in input
StatusComposite : added move / change actions to context menu

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/component/NewTaxonBaseComposite.java
62 62
    @AutoGenerated
63 63
    private GridLayout gridLayout;
64 64
    @AutoGenerated
65
    private Label accTaxonNameValue;
65
    private ComboBox synComboBox;
66
    @AutoGenerated
67
    private Label synSecLabel;
66 68
    @AutoGenerated
67
    private ComboBox secComboBox;
69
    private ComboBox accTaxonSecComboBox;
68 70
    @AutoGenerated
69
    private Label secLabel;
71
    private Label accTaxonSecLabel;
70 72
    @AutoGenerated
71 73
    private TextField nameTextField;
72 74
    @AutoGenerated
73 75
    private Label nameLabel;
74 76
    @AutoGenerated
77
    private Label accTaxonNameValue;
78
    @AutoGenerated
75 79
    private Label accTaxonLabel;
76 80
    private INewTaxonBaseComponentListener listener;
77 81

  
......
107 111
        addUIListeners();
108 112

  
109 113
        if(accTaxonName == null || accTaxonName.isEmpty()) {
114
            // this is the case where we create a new taxon
110 115
            accTaxonLabel.setVisible(false);
111 116
            accTaxonNameValue.setVisible(false);
117
            synSecLabel.setVisible(false);
118
            synComboBox.setVisible(false);
112 119
        } else {
120
            // this is the case where we create a new synonym
113 121
            accTaxonNameValue.setValue(accTaxonName);
114 122
        }
115 123
        init();
116 124
    }
117 125

  
118 126
    public void init() {
119
        initSecComboBox();
127
        initAccTaxonSecComboBox();
128
        if(accTaxonIun != null) {
129
            initSynSecComboBox();
130
        }
120 131
    }
121 132

  
122
    private void initSecComboBox() {
123

  
124
        secComboBox.setNullSelectionAllowed(false);
125
        secComboBox.setItemCaptionPropertyId("titleCache");
126
        secComboBox.setImmediate(true);
133
    private void  initAccTaxonSecComboBox() {
134
        accTaxonSecComboBox.setNullSelectionAllowed(false);
135
        accTaxonSecComboBox.setItemCaptionPropertyId("titleCache");
136
        accTaxonSecComboBox.setImmediate(true);
127 137
        if(listener != null) {
128
            secComboBox.setContainerDataSource(listener.getSecRefContainer());
129
            Object selectedSecItemId = null;
130
            // if accTaxonIun is null then we are creating a new taxon
131
            // else a new synonym
132
            if(accTaxonIun == null) {
133
                selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
138
            accTaxonSecComboBox.setContainerDataSource(listener.getAccTaxonSecRefContainer());
139
            Object selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
140
            if(selectedSecItemId != null) {
141
                accTaxonSecComboBox.setValue(selectedSecItemId);
134 142
            } else {
135
                selectedSecItemId = listener.getAcceptedTaxonRefId(accTaxonIun.getUuid());
143
                accTaxonSecComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
136 144
            }
145
        }
146
    }
137 147

  
148
    private void initSynSecComboBox() {
149
        synComboBox.setNullSelectionAllowed(false);
150
        synComboBox.setItemCaptionPropertyId("titleCache");
151
        synComboBox.setImmediate(true);
152
        if(listener != null) {
153
            synComboBox.setContainerDataSource(listener.getSynSecRefContainer());
154
            Object selectedSecItemId = listener.getClassificationRefId(classificationIun.getUuid());
138 155
            if(selectedSecItemId != null) {
139
                secComboBox.setValue(selectedSecItemId);
156
                synComboBox.setValue(selectedSecItemId);
140 157
            } else {
141
                secComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
158
                synComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT);
142 159
            }
143 160
        }
144 161
    }
145 162

  
163

  
164

  
146 165
    private void addUIListeners() {
147 166
        addSaveButtonListener();
148 167
        addCancelButtonListener();
......
155 174
            public void buttonClick(ClickEvent event) {
156 175
                try {
157 176
                    nameTextField.validate();
158
                    secComboBox.validate();
177
                    accTaxonSecComboBox.validate();
178
                    if(accTaxonIun != null) {
179
                        synComboBox.validate();
180
                    }
159 181
                } catch (EmptyValueException e) {
160 182
                    Notification notification = new Notification("Invalid input", "Neither Name or Secundum can be empty", Type.WARNING_MESSAGE);
161 183
                    notification.setDelayMsec(2000);
......
171 193
                        setProgress("Saving Taxon " + nameTextField.getValue());
172 194
                        IdUuidName taxonBaseIdUuid;
173 195
                        if(accTaxonIun == null) {
174
                            taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),secComboBox.getValue(), classificationIun.getUuid());
196
                            taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),accTaxonSecComboBox.getValue(), classificationIun.getUuid());
175 197
                        } else {
176
                            taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),secComboBox.getValue(), accTaxonIun.getUuid());
198
                            taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),
199
                                    accTaxonSecComboBox.getValue(),
200
                                    accTaxonSecComboBox.getValue(),
201
                                    accTaxonIun.getUuid());
177 202
                        }
178 203
                        Object rowId = new RowId(taxonBaseIdUuid.getId());
179 204
                        registerDelayedEvent(new CdmChangeEvent(Action.Create, Arrays.asList(rowId), NewTaxonBaseComposite.class));
......
218 243
        // common part: create layout
219 244
        mainLayout = new VerticalLayout();
220 245
        mainLayout.setImmediate(false);
221
        mainLayout.setWidth("340px");
222
        mainLayout.setHeight("200px");
246
        mainLayout.setWidth("420px");
247
        mainLayout.setHeight("240px");
223 248
        mainLayout.setMargin(true);
224 249

  
225 250
        // top-level component properties
226
        setWidth("340px");
227
        setHeight("200px");
251
        setWidth("420px");
252
        setHeight("240px");
228 253

  
229 254
        // gridLayout
230 255
        gridLayout = buildGridLayout();
......
253 278
        gridLayout = new GridLayout();
254 279
        gridLayout.setImmediate(false);
255 280
        gridLayout.setWidth("-1px");
256
        gridLayout.setHeight("-1px");
281
        gridLayout.setHeight("140px");
257 282
        gridLayout.setMargin(false);
258 283
        gridLayout.setSpacing(true);
259 284
        gridLayout.setColumns(2);
......
268 293
        gridLayout.addComponent(accTaxonLabel, 0, 0);
269 294
        gridLayout.setComponentAlignment(accTaxonLabel, new Alignment(34));
270 295

  
296
        // accTaxonNameValue
297
        accTaxonNameValue = new Label();
298
        accTaxonNameValue.setImmediate(false);
299
        accTaxonNameValue.setWidth("-1px");
300
        accTaxonNameValue.setHeight("-1px");
301
        accTaxonNameValue.setValue("Taxon Name");
302
        gridLayout.addComponent(accTaxonNameValue, 1, 0);
303
        gridLayout.setComponentAlignment(accTaxonNameValue, new Alignment(33));
304

  
271 305
        // nameLabel
272 306
        nameLabel = new Label();
273 307
        nameLabel.setImmediate(false);
......
287 321
        gridLayout.addComponent(nameTextField, 1, 1);
288 322
        gridLayout.setComponentAlignment(nameTextField, new Alignment(33));
289 323

  
290
        // secLabel
291
        secLabel = new Label();
292
        secLabel.setImmediate(false);
293
        secLabel.setWidth("-1px");
294
        secLabel.setHeight("-1px");
295
        secLabel.setValue("Secundum : ");
296
        gridLayout.addComponent(secLabel, 0, 2);
297
        gridLayout.setComponentAlignment(secLabel, new Alignment(34));
298

  
299
        // secComboBox
300
        secComboBox = new ComboBox();
301
        secComboBox.setImmediate(false);
302
        secComboBox.setWidth("190px");
303
        secComboBox.setHeight("-1px");
304
        secComboBox.setInvalidAllowed(false);
305
        secComboBox.setRequired(true);
306
        gridLayout.addComponent(secComboBox, 1, 2);
307
        gridLayout.setComponentAlignment(secComboBox, new Alignment(33));
308

  
309
        // accTaxonNameValue
310
        accTaxonNameValue = new Label();
311
        accTaxonNameValue.setImmediate(false);
312
        accTaxonNameValue.setWidth("-1px");
313
        accTaxonNameValue.setHeight("-1px");
314
        accTaxonNameValue.setValue("Taxon Name");
315
        gridLayout.addComponent(accTaxonNameValue, 1, 0);
316
        gridLayout.setComponentAlignment(accTaxonNameValue, new Alignment(33));
324
        // accTaxonSecLabel
325
        accTaxonSecLabel = new Label();
326
        accTaxonSecLabel.setImmediate(false);
327
        accTaxonSecLabel.setWidth("-1px");
328
        accTaxonSecLabel.setHeight("-1px");
329
        accTaxonSecLabel.setValue("Acc. Taxon Secundum : ");
330
        gridLayout.addComponent(accTaxonSecLabel, 0, 2);
331
        gridLayout.setComponentAlignment(accTaxonSecLabel, new Alignment(34));
332

  
333
        // accTaxonSecComboBox
334
        accTaxonSecComboBox = new ComboBox();
335
        accTaxonSecComboBox.setImmediate(false);
336
        accTaxonSecComboBox.setWidth("190px");
337
        accTaxonSecComboBox.setHeight("-1px");
338
        accTaxonSecComboBox.setInvalidAllowed(false);
339
        accTaxonSecComboBox.setRequired(true);
340
        gridLayout.addComponent(accTaxonSecComboBox, 1, 2);
341
        gridLayout.setComponentAlignment(accTaxonSecComboBox, new Alignment(33));
342

  
343
        // synSecLabel
344
        synSecLabel = new Label();
345
        synSecLabel.setImmediate(false);
346
        synSecLabel.setWidth("-1px");
347
        synSecLabel.setHeight("-1px");
348
        synSecLabel.setValue("Synonym Secundum : ");
349
        gridLayout.addComponent(synSecLabel, 0, 3);
350

  
351
        // synComboBox
352
        synComboBox = new ComboBox();
353
        synComboBox.setImmediate(false);
354
        synComboBox.setWidth("190px");
355
        synComboBox.setHeight("-1px");
356
        synComboBox.setInvalidAllowed(false);
357
        synComboBox.setRequired(true);
358
        gridLayout.addComponent(synComboBox, 1, 3);
317 359

  
318 360
        return gridLayout;
319 361
    }

Also available in: Unified diff