Project

General

Profile

Download (22.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2015 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.cdm.vaadin.component;
10

    
11
import java.sql.SQLException;
12
import java.util.Arrays;
13
import java.util.Map;
14
import java.util.UUID;
15

    
16
import com.vaadin.annotations.AutoGenerated;
17
import com.vaadin.data.Container.Hierarchical;
18
import com.vaadin.data.Validator.EmptyValueException;
19
import com.vaadin.data.util.sqlcontainer.RowId;
20
import com.vaadin.event.Transferable;
21
import com.vaadin.event.dd.DragAndDropEvent;
22
import com.vaadin.event.dd.DropHandler;
23
import com.vaadin.event.dd.acceptcriteria.AcceptAll;
24
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
25
import com.vaadin.server.FontAwesome;
26
import com.vaadin.server.Page;
27
import com.vaadin.shared.ui.label.ContentMode;
28
import com.vaadin.ui.Alignment;
29
import com.vaadin.ui.Button;
30
import com.vaadin.ui.Button.ClickEvent;
31
import com.vaadin.ui.Button.ClickListener;
32
import com.vaadin.ui.ComboBox;
33
import com.vaadin.ui.Component;
34
import com.vaadin.ui.CustomComponent;
35
import com.vaadin.ui.DragAndDropWrapper;
36
import com.vaadin.ui.HorizontalLayout;
37
import com.vaadin.ui.Label;
38
import com.vaadin.ui.Notification;
39
import com.vaadin.ui.Notification.Type;
40
import com.vaadin.ui.TextField;
41
import com.vaadin.ui.TreeTable;
42
import com.vaadin.ui.UI;
43
import com.vaadin.ui.VerticalLayout;
44
import com.vaadin.ui.Window;
45

    
46
import eu.etaxonomy.cdm.vaadin.container.IdUuidName;
47
import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer;
48
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction;
49
import eu.etaxonomy.cdm.vaadin.presenter.EditConceptRelationshipPresenter;
50
import eu.etaxonomy.cdm.vaadin.session.BasicEvent;
51
import eu.etaxonomy.cdm.vaadin.session.CdmChangeEvent;
52
import eu.etaxonomy.cdm.vaadin.session.CdmChangeEvent.Action;
53
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinOperation;
54
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinSessionUtilities;
55
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinUtilities;
56
;
57

    
58
/**
59
 * @author cmathew
60
 * @date 13 Apr 2015
61
 *
62
 */
63
public class EditConceptRelationshipComposite extends CustomComponent {
64

    
65
    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
66

    
67
    @AutoGenerated
68
    private VerticalLayout mainLayout;
69
    @AutoGenerated
70
    private CdmProgressComponent cdmProgressComponent;
71
    @AutoGenerated
72
    private HorizontalLayout saveCancelHLayout;
73
    @AutoGenerated
74
    private Button cancelButton;
75
    @AutoGenerated
76
    private Button saveButton;
77
    @AutoGenerated
78
    private HorizontalLayout horizontalLayout;
79
    @AutoGenerated
80
    private Label rightLabel;
81
    @AutoGenerated
82
    private VerticalLayout typeVLayout;
83
    @AutoGenerated
84
    private ComboBox conceptRComboBox;
85
    @AutoGenerated
86
    private Label typeLabel;
87
    @AutoGenerated
88
    private Label leftLabel;
89
    private TextField leftTaxonTextField, rightTaxonTextField;
90

    
91
    private Component leftTaxonComponent, rightTaxonComponent;
92
    private TextField fromTaxonTextField, toTaxonTextField;
93
    private Label leftTaxonLabel, rightTaxonLabel;
94

    
95

    
96
    private final EditConceptRelationshipPresenter presenter;
97

    
98
    private IdUuidName fromTaxonIun, taxonRTypeIun, toTaxonIun;
99
    private UUID relUuid;
100
    private Window window;
101

    
102
    private final static String CHOOSE_TREL_TYPE = "Choose Type ...";
103
    private final static String DRAG_TAXON_HINT = "Drag Taxon here ...";
104

    
105

    
106
    private Action action;
107
    private Direction direction;
108

    
109
    public EditConceptRelationshipComposite(IdUuidName fromTaxonIdUuidName,
110
            IdUuidName taxonRTypeIdUuidName,
111
            IdUuidName toTaxonIdUuidName,
112
            Action action,
113
            Direction direction) {
114
        this(direction);
115

    
116
        init(fromTaxonIdUuidName, taxonRTypeIdUuidName, toTaxonIdUuidName, action);
117

    
118
    }
119

    
120
    public EditConceptRelationshipComposite(IdUuidName fromTaxonIun,
121
            UUID relUuid,
122
            Action action,
123
            Direction direction) {
124
        this(direction);
125
        this.relUuid = relUuid;
126

    
127
        Map<String, IdUuidName> map = presenter.getRelTypeToTaxonIunMap(fromTaxonIun.getUuid(), relUuid);
128
        taxonRTypeIun = map.get(EditConceptRelationshipPresenter.REL_TYPE_KEY);
129
        toTaxonIun = map.get(EditConceptRelationshipPresenter.TO_TAXON_KEY);
130
        init(fromTaxonIun, taxonRTypeIun, toTaxonIun, action);
131

    
132
    }
133

    
134

    
135
    /**
136
     * The constructor should first build the main layout, set the
137
     * composition root and then do any custom initialization.
138
     *
139
     * The constructor will not be automatically regenerated by the
140
     * visual editor.
141
     */
142
    private EditConceptRelationshipComposite(Direction direction) {
143
        this.direction = direction;
144

    
145
        buildMainLayout();
146
        initDirectionComponents();
147
        setCompositionRoot(mainLayout);
148

    
149
        this.presenter = new EditConceptRelationshipPresenter();
150
        addUIListeners();
151
    }
152

    
153

    
154
    public void init(IdUuidName fromTaxonIdUuidName,
155
            IdUuidName taxonRTypeIdUuidName,
156
            IdUuidName toTaxonIdUuidName,
157
            Action action) {
158

    
159
        this.fromTaxonIun = fromTaxonIdUuidName;
160
        this.taxonRTypeIun = taxonRTypeIdUuidName;
161
        this.toTaxonIun = toTaxonIdUuidName;
162
        this.action = action;
163

    
164
        initFromTaxon();
165
        initConceptRComboBox();
166
    }
167

    
168
    public void setWindow(Window window) {
169
        this.window = window;
170
    }
171

    
172
    public boolean canCreateRelationship() {
173
        return presenter.canCreateRelationship(fromTaxonIun.getUuid());
174
    }
175

    
176
    private void initFromTaxon() {
177
        if(fromTaxonIun != null) {
178
            fromTaxonTextField.setReadOnly(false);
179
            fromTaxonTextField.setValue(fromTaxonIun.getName());
180
            fromTaxonTextField.setReadOnly(true);
181
        }
182
        if(toTaxonIun != null) {
183
            toTaxonTextField.setReadOnly(false);
184
            toTaxonTextField.setValue(toTaxonIun.getName());
185
            toTaxonTextField.setReadOnly(true);
186
        }
187
    }
188

    
189
    private void initDirectionComponents() {
190

    
191
        initTaxonComponents();
192

    
193
        leftLabel.addStyleName("cr-arrow");
194
        leftLabel.setContentMode(ContentMode.HTML);
195

    
196
        rightLabel.addStyleName("cr-arrow");
197
        rightLabel.setContentMode(ContentMode.HTML);
198

    
199
        rightTaxonTextField.setReadOnly(false);
200
        leftTaxonTextField.setReadOnly(false);
201
        switch(direction) {
202
        case LEFT_RIGHT:
203
            leftLabel.setValue(FontAwesome.CARET_RIGHT.getHtml());
204
            rightLabel.setValue(FontAwesome.CARET_RIGHT.getHtml());
205
            leftTaxonLabel.setValue("From Taxon");
206
            rightTaxonLabel.setValue("To Taxon");
207
            fromTaxonTextField = leftTaxonTextField;
208
            toTaxonTextField = rightTaxonTextField;
209
            rightTaxonTextField.setValue(DRAG_TAXON_HINT);
210
            rightTaxonComponent = intiDragDropWrapper(rightTaxonComponent, rightTaxonTextField);
211
            break;
212
        case RIGHT_LEFT:
213
            leftLabel.setValue(FontAwesome.CARET_LEFT.getHtml());
214
            rightLabel.setValue(FontAwesome.CARET_LEFT.getHtml());
215
            leftTaxonLabel.setValue("To Taxon");
216
            rightTaxonLabel.setValue("From Taxon");
217
            leftTaxonTextField.setValue(DRAG_TAXON_HINT);
218
            fromTaxonTextField = rightTaxonTextField;
219
            toTaxonTextField = leftTaxonTextField;
220
            leftTaxonComponent = intiDragDropWrapper(leftTaxonComponent, leftTaxonTextField);
221
            break;
222
        }
223

    
224
        rightTaxonTextField.setReadOnly(true);
225
        leftTaxonTextField.setReadOnly(true);
226

    
227
        horizontalLayout.addComponent(leftTaxonComponent,0);
228
        horizontalLayout.setComponentAlignment(leftTaxonComponent, new Alignment(48));
229

    
230

    
231
        horizontalLayout.addComponent(rightTaxonComponent);
232
        horizontalLayout.setComponentAlignment(rightTaxonComponent, new Alignment(48));
233

    
234
        leftLabel.setSizeUndefined();
235
        rightLabel.setSizeUndefined();
236

    
237
    }
238

    
239
    private void initConceptRComboBox() {
240
        conceptRComboBox.setImmediate(true);
241
        conceptRComboBox.setItemCaptionPropertyId("titleCache");
242
        try {
243
            conceptRComboBox.setContainerDataSource(presenter.loadTaxonRelationshipTypeContainer());
244
        } catch (SQLException e) {
245
            // TODO Auto-generated catch block
246
            e.printStackTrace();
247
        }
248
        if(taxonRTypeIun == null) {
249
            conceptRComboBox.setInputPrompt(CHOOSE_TREL_TYPE);
250
        } else {
251
            conceptRComboBox.setValue(new RowId(taxonRTypeIun.getId()));
252
        }
253

    
254
        if(action == Action.Delete) {
255
            conceptRComboBox.setReadOnly(true);
256
            saveButton.setCaption("ok");
257
        }
258
    }
259

    
260
    private void initTaxonComponents() {
261
        // init left taxon layout
262
        leftTaxonLabel = new Label();
263
        leftTaxonTextField = new TextField();
264
        leftTaxonComponent = buildTaxonVLayout(leftTaxonLabel, leftTaxonTextField);
265

    
266
        // init right taxon layout
267
        rightTaxonLabel = new Label();
268
        rightTaxonTextField = new TextField();
269
        rightTaxonComponent = buildTaxonVLayout(rightTaxonLabel, rightTaxonTextField);
270
    }
271

    
272
    private DragAndDropWrapper intiDragDropWrapper(Component toTaxonLayout, final TextField toTaxonTextField) {
273

    
274
        DragAndDropWrapper toTaxonLayoutWrapper = new DragAndDropWrapper(toTaxonLayout);
275
        toTaxonLayoutWrapper.setImmediate(false);
276
        toTaxonLayoutWrapper.setWidth("-1px");
277
        toTaxonLayoutWrapper.setHeight("-1px");
278

    
279
        toTaxonLayoutWrapper.setDropHandler(new DropHandler() {
280

    
281
            @Override
282
            public AcceptCriterion getAcceptCriterion() {
283
                return AcceptAll.get();
284
            }
285

    
286
            @Override
287
            public void drop(DragAndDropEvent event) {
288
                // Wrapper for the object that is dragged
289
                Transferable t = event.getTransferable();
290

    
291
                // Make sure the drag source is a status composite tree table
292
                if (action != Action.Delete && t.getSourceComponent() instanceof TreeTable) {
293
                    TreeTable table = (TreeTable)t.getSourceComponent();
294
                    Hierarchical containerDataSource = table.getContainerDataSource();
295
                    if(containerDataSource instanceof LeafNodeTaxonContainer) {
296
                        LeafNodeTaxonContainer lntc = (LeafNodeTaxonContainer)containerDataSource;
297
                        Object sourceItemId = t.getData("itemId");
298
                        String toName = (String)lntc.getProperty(sourceItemId, LeafNodeTaxonContainer.NAME_ID).getValue();
299
                        toTaxonIun = new IdUuidName(sourceItemId,
300
                                lntc.getUuid(sourceItemId),
301
                                toName);
302
                        toTaxonTextField.setReadOnly(false);
303
                        toTaxonTextField.setValue(toName);
304
                        toTaxonTextField.setReadOnly(true);
305
                    }
306
                }
307
            }
308
        });
309
        return toTaxonLayoutWrapper;
310

    
311
    }
312

    
313

    
314
    private void addUIListeners() {
315
        addSaveButtonListener();
316
        addCancelButtonListener();
317

    
318
    }
319

    
320
    private void addSaveButtonListener() {
321
        saveButton.addClickListener(new ClickListener() {
322

    
323
            @Override
324
            public void buttonClick(ClickEvent event) {
325

    
326

    
327
                try {
328
                    conceptRComboBox.validate();
329
                    rightTaxonTextField.validate();
330
                    if(toTaxonIun == null) {
331
                        // FIXME: Not efficient - figure out a way
332
                        // of validation including the null check
333
                        throw new EmptyValueException("");
334
                    }
335
                } catch (EmptyValueException e) {
336
                    Notification notification = new Notification("Invalid input", "Neither Relationship Type nor To Taxon can be empty", Type.WARNING_MESSAGE);
337
                    notification.setDelayMsec(2000);
338
                    notification.show(Page.getCurrent());
339
                    return;
340
                }
341

    
342
                CdmVaadinUtilities.setEnabled(mainLayout, false, null);
343

    
344
                try {
345
                    CdmVaadinUtilities.exec(new CdmVaadinOperation(1000, cdmProgressComponent) {
346
                        @Override
347
                        public boolean execute() {
348
                            UUID relTypeUuid = presenter.getTaxonRTypeContainer().getUuid(conceptRComboBox.getValue());
349
                            switch(action) {
350
                            case Create:
351
                                setProgress("Saving New Concept Relationship");
352
                                presenter.createRelationship(fromTaxonIun.getUuid(), relTypeUuid, toTaxonIun.getUuid());
353
                                registerDelayedEvent(new CdmChangeEvent(Action.Create, Arrays.asList((Object)relTypeUuid), EditConceptRelationshipComposite.class));
354
                                break;
355
                            case Update:
356
                                setProgress("Update Concept Relationship");
357
                                presenter.updateRelationship(fromTaxonIun.getUuid(), relUuid, relTypeUuid, toTaxonIun.getUuid());
358
                                registerDelayedEvent(new CdmChangeEvent(Action.Update, Arrays.asList((Object)relTypeUuid), EditConceptRelationshipComposite.class));
359
                                break;
360
                            case Delete:
361
                                setProgress("Deleting Concept Relationship");
362
                                presenter.deleteRelationship(fromTaxonIun.getUuid(), relUuid);
363
                                registerDelayedEvent(new CdmChangeEvent(Action.Delete, Arrays.asList((Object)relTypeUuid), EditConceptRelationshipComposite.class));
364
                                break;
365
                            default:
366

    
367
                            }
368
                            return true;
369
                        }
370

    
371
                        @Override
372
                        public void postOpUIUpdate(boolean success) {
373
                            if(success) {
374
                                if(window != null) {
375
                                    UI.getCurrent().removeWindow(window);
376
                                }
377
                            } else {
378
                                CdmVaadinUtilities.setEnabled(mainLayout, true, null);
379
                            }
380
                        }
381
                    });
382
                } finally {
383
                    CdmVaadinSessionUtilities.getCurrentBasicEventService()
384
                    .fireBasicEvent(new BasicEvent(ConceptRelationshipComposite.UPDATE_END_ID, EditConceptRelationshipComposite.class), false);
385
                }
386
            }
387
        });
388
    }
389

    
390
    private void addCancelButtonListener() {
391
        cancelButton.addClickListener(new ClickListener() {
392

    
393
            @Override
394
            public void buttonClick(ClickEvent event) {
395
                if(window != null) {
396
                    UI.getCurrent().removeWindow(window);
397
                }
398
                CdmVaadinSessionUtilities.getCurrentBasicEventService()
399
                .fireBasicEvent(new BasicEvent(ConceptRelationshipComposite.UPDATE_END_ID, EditConceptRelationshipComposite.class), true);
400
            }
401
        });
402
    }
403

    
404

    
405
    private static void showInDialog(String windowTitle,
406
            EditConceptRelationshipComposite ecrc) {
407
        //FIXME : hack for the moment to demonstrate checking of concept relationship rules
408
        if(ecrc.action.equals(Action.Create) && !ecrc.canCreateRelationship()) {
409
            Notification.show("Cannot create relationship for a taxon which is already congruent to another taxon", Type.WARNING_MESSAGE);
410
            return;
411
        }
412
        Window dialog = new Window(windowTitle);
413
        dialog.setModal(false);
414
        dialog.setClosable(false);
415
        dialog.setResizable(false);
416
        UI.getCurrent().addWindow(dialog);
417
        ecrc.setWindow(dialog);
418
        dialog.setContent(ecrc);
419
        CdmVaadinSessionUtilities.getCurrentBasicEventService()
420
        .fireBasicEvent(new BasicEvent(ConceptRelationshipComposite.UPDATE_START_ID, ConceptRelationshipComposite.class), false);
421
    }
422

    
423
    public static void showInDialog(String windowTitle,
424
            IdUuidName fromTaxonIun,
425
            IdUuidName taxonRTypeIun,
426
            IdUuidName toTaxonIun,
427
            Action action,
428
            Direction direction) {
429
        EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, taxonRTypeIun, toTaxonIun,action, direction);
430
        showInDialog(windowTitle, ecrc);
431
    }
432

    
433
    public static void showInDialog(String windowTitle,
434
            IdUuidName fromTaxonIun,
435
            UUID relUuid,
436
            Action action,
437
            Direction direction) {
438
        EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, relUuid, action, direction);
439
        showInDialog(windowTitle, ecrc);
440
    }
441

    
442

    
443
    private VerticalLayout buildTaxonVLayout(Label taxonDirLabel, TextField taxonTextField) {
444
        // common part: create layout
445
        VerticalLayout vLayout = new VerticalLayout();
446
        vLayout.setImmediate(false);
447
        vLayout.setWidth("-1px");
448
        vLayout.setHeight("-1px");
449
        vLayout.setMargin(false);
450
        vLayout.setSpacing(true);
451

    
452

    
453
        taxonDirLabel.setImmediate(false);
454
        taxonDirLabel.setWidth("-1px");
455
        taxonDirLabel.setHeight("-1px");
456

    
457
        vLayout.addComponent(taxonDirLabel);
458
        vLayout.setComponentAlignment(taxonDirLabel, new Alignment(48));
459

    
460

    
461
        taxonTextField.setImmediate(false);
462
        taxonTextField.setWidth("-1px");
463
        taxonTextField.setHeight("-1px");
464
        taxonTextField.setInvalidAllowed(false);
465
        taxonTextField.setRequired(true);
466
        taxonTextField.setReadOnly(true);
467
        vLayout.addComponent(taxonTextField);
468
        vLayout.setComponentAlignment(taxonTextField, new Alignment(48));
469

    
470
        return vLayout;
471
    }
472

    
473
    @AutoGenerated
474
    private VerticalLayout buildMainLayout() {
475
        // common part: create layout
476
        mainLayout = new VerticalLayout();
477
        mainLayout.setImmediate(false);
478
        mainLayout.setWidth("740px");
479
        mainLayout.setHeight("170px");
480
        mainLayout.setMargin(false);
481
        mainLayout.setSpacing(true);
482

    
483
        // top-level component properties
484
        setWidth("740px");
485
        setHeight("170px");
486

    
487
        // horizontalLayout
488
        horizontalLayout = buildHorizontalLayout();
489
        mainLayout.addComponent(horizontalLayout);
490
        mainLayout.setExpandRatio(horizontalLayout, 1.0f);
491
        mainLayout.setComponentAlignment(horizontalLayout, new Alignment(48));
492

    
493
        // saveCancelHLayout
494
        saveCancelHLayout = buildSaveCancelHLayout();
495
        mainLayout.addComponent(saveCancelHLayout);
496
        mainLayout.setComponentAlignment(saveCancelHLayout, new Alignment(48));
497

    
498
        // cdmProgressComponent
499
        cdmProgressComponent = new CdmProgressComponent();
500
        cdmProgressComponent.setImmediate(false);
501
        cdmProgressComponent.setWidth("-1px");
502
        cdmProgressComponent.setHeight("-1px");
503
        mainLayout.addComponent(cdmProgressComponent);
504
        mainLayout.setComponentAlignment(cdmProgressComponent, new Alignment(48));
505

    
506
        return mainLayout;
507
    }
508

    
509
    @AutoGenerated
510
    private HorizontalLayout buildHorizontalLayout() {
511
        // common part: create layout
512
        horizontalLayout = new HorizontalLayout();
513
        horizontalLayout.setImmediate(false);
514
        horizontalLayout.setWidth("-1px");
515
        horizontalLayout.setHeight("-1px");
516
        horizontalLayout.setMargin(true);
517
        horizontalLayout.setSpacing(true);
518

    
519
        // leftLabel
520
        leftLabel = new Label();
521
        leftLabel.setImmediate(false);
522
        leftLabel.setWidth("-1px");
523
        leftLabel.setHeight("30px");
524
        leftLabel.setValue("Label");
525
        horizontalLayout.addComponent(leftLabel);
526
        horizontalLayout.setComponentAlignment(leftLabel, new Alignment(24));
527

    
528
        // typeVLayout
529
        typeVLayout = buildTypeVLayout();
530
        horizontalLayout.addComponent(typeVLayout);
531
        horizontalLayout.setExpandRatio(typeVLayout, 1.0f);
532
        horizontalLayout.setComponentAlignment(typeVLayout, new Alignment(48));
533

    
534
        // rightLabel
535
        rightLabel = new Label();
536
        rightLabel.setImmediate(false);
537
        rightLabel.setWidth("-1px");
538
        rightLabel.setHeight("30px");
539
        rightLabel.setValue("Label");
540
        horizontalLayout.addComponent(rightLabel);
541
        horizontalLayout.setComponentAlignment(rightLabel, new Alignment(24));
542

    
543
        return horizontalLayout;
544
    }
545

    
546
    @AutoGenerated
547
    private VerticalLayout buildTypeVLayout() {
548
        // common part: create layout
549
        typeVLayout = new VerticalLayout();
550
        typeVLayout.setImmediate(false);
551
        typeVLayout.setWidth("-1px");
552
        typeVLayout.setHeight("-1px");
553
        typeVLayout.setMargin(false);
554
        typeVLayout.setSpacing(true);
555

    
556
        // typeLabel
557
        typeLabel = new Label();
558
        typeLabel.setImmediate(false);
559
        typeLabel.setWidth("-1px");
560
        typeLabel.setHeight("-1px");
561
        typeLabel.setValue("Type");
562
        typeVLayout.addComponent(typeLabel);
563
        typeVLayout.setComponentAlignment(typeLabel, new Alignment(48));
564

    
565
        // conceptRComboBox
566
        conceptRComboBox = new ComboBox();
567
        conceptRComboBox.setImmediate(false);
568
        conceptRComboBox.setWidth("260px");
569
        conceptRComboBox.setHeight("-1px");
570
        conceptRComboBox.setRequired(true);
571
        typeVLayout.addComponent(conceptRComboBox);
572
        typeVLayout.setExpandRatio(conceptRComboBox, 1.0f);
573
        typeVLayout.setComponentAlignment(conceptRComboBox, new Alignment(48));
574

    
575
        return typeVLayout;
576
    }
577

    
578
    @AutoGenerated
579
    private HorizontalLayout buildSaveCancelHLayout() {
580
        // common part: create layout
581
        saveCancelHLayout = new HorizontalLayout();
582
        saveCancelHLayout.setImmediate(false);
583
        saveCancelHLayout.setWidth("-1px");
584
        saveCancelHLayout.setHeight("-1px");
585
        saveCancelHLayout.setMargin(false);
586
        saveCancelHLayout.setSpacing(true);
587

    
588
        // saveButton
589
        saveButton = new Button();
590
        saveButton.setCaption("save");
591
        saveButton.setImmediate(true);
592
        saveButton.setWidth("-1px");
593
        saveButton.setHeight("-1px");
594
        saveCancelHLayout.addComponent(saveButton);
595

    
596
        // cancelButton
597
        cancelButton = new Button();
598
        cancelButton.setCaption("cancel");
599
        cancelButton.setImmediate(true);
600
        cancelButton.setWidth("-1px");
601
        cancelButton.setHeight("-1px");
602
        saveCancelHLayout.addComponent(cancelButton);
603

    
604
        return saveCancelHLayout;
605
    }
606

    
607
}
(4-4/7)