Project

General

Profile

Download (22.1 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2015 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
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.
9
 */
10
package eu.etaxonomy.cdm.vaadin.component;
11

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

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

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

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

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

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

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

    
96

    
97
    private final EditConceptRelationshipPresenter presenter;
98

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

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

    
106

    
107
    private Action action;
108
    private Direction direction;
109

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

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

    
119
    }
120

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

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

    
133
    }
134

    
135

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

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

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

    
154

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

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

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

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

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

    
186
    private void initDirectionComponents() {
187

    
188
        initTaxonComponents();
189

    
190
        leftLabel.addStyleName("cr-arrow");
191
        leftLabel.setContentMode(ContentMode.HTML);
192

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

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

    
221
        rightTaxonTextField.setReadOnly(true);
222
        leftTaxonTextField.setReadOnly(true);
223

    
224
        horizontalLayout.addComponent(leftTaxonComponent,0);
225
        horizontalLayout.setComponentAlignment(leftTaxonComponent, new Alignment(48));
226

    
227

    
228
        horizontalLayout.addComponent(rightTaxonComponent);
229
        horizontalLayout.setComponentAlignment(rightTaxonComponent, new Alignment(48));
230

    
231
        leftLabel.setSizeUndefined();
232
        rightLabel.setSizeUndefined();
233

    
234
    }
235

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

    
251
        if(action == Action.Delete) {
252
            conceptRComboBox.setReadOnly(true);
253
            saveButton.setCaption("ok");
254
        }
255
    }
256

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

    
263
        // init right taxon layout
264
        rightTaxonLabel = new Label();
265
        rightTaxonTextField = new TextField();
266
        rightTaxonComponent = buildTaxonVLayout(rightTaxonLabel, rightTaxonTextField);
267
    }
268

    
269
    private DragAndDropWrapper intiDragDropWrapper(Component toTaxonLayout, final TextField toTaxonTextField) {
270

    
271
        DragAndDropWrapper toTaxonLayoutWrapper = new DragAndDropWrapper(toTaxonLayout);
272
        toTaxonLayoutWrapper.setImmediate(false);
273
        toTaxonLayoutWrapper.setWidth("-1px");
274
        toTaxonLayoutWrapper.setHeight("-1px");
275

    
276
        toTaxonLayoutWrapper.setDropHandler(new DropHandler() {
277

    
278
            @Override
279
            public AcceptCriterion getAcceptCriterion() {
280
                return AcceptAll.get();
281
            }
282

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

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

    
308
    }
309

    
310

    
311
    private void addUIListeners() {
312
        addSaveButtonListener();
313
        addCancelButtonListener();
314

    
315
    }
316

    
317
    private void addSaveButtonListener() {
318
        saveButton.addClickListener(new ClickListener() {
319

    
320
            @Override
321
            public void buttonClick(ClickEvent event) {
322

    
323

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

    
339
                CdmVaadinUtilities.setEnabled(mainLayout, false, null);
340

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

    
364
                            }
365
                            return true;
366
                        }
367

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

    
387
    private void addCancelButtonListener() {
388
        cancelButton.addClickListener(new ClickListener() {
389

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

    
401

    
402
    private static void showInDialog(String windowTitle,
403
            EditConceptRelationshipComposite ecrc) {
404
        Window dialog = new Window(windowTitle);
405
        dialog.setModal(false);
406
        dialog.setClosable(false);
407
        dialog.setResizable(false);
408
        UI.getCurrent().addWindow(dialog);
409
        ecrc.setWindow(dialog);
410
        dialog.setContent(ecrc);
411
        CdmVaadinSessionUtilities.getCurrentBasicEventService()
412
        .fireBasicEvent(new BasicEvent(ConceptRelationshipComposite.UPDATE_START_ID, ConceptRelationshipComposite.class), false);
413
    }
414

    
415
    public static void showInDialog(String windowTitle,
416
            IdUuidName fromTaxonIun,
417
            IdUuidName taxonRTypeIun,
418
            IdUuidName toTaxonIun,
419
            Action action,
420
            Direction direction) {
421
        EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, taxonRTypeIun, toTaxonIun,action, direction);
422
        showInDialog(windowTitle, ecrc);
423
    }
424

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

    
434

    
435
    private VerticalLayout buildTaxonVLayout(Label taxonDirLabel, TextField taxonTextField) {
436
        // common part: create layout
437
        VerticalLayout vLayout = new VerticalLayout();
438
        vLayout.setImmediate(false);
439
        vLayout.setWidth("-1px");
440
        vLayout.setHeight("-1px");
441
        vLayout.setMargin(false);
442
        vLayout.setSpacing(true);
443

    
444

    
445
        taxonDirLabel.setImmediate(false);
446
        taxonDirLabel.setWidth("-1px");
447
        taxonDirLabel.setHeight("-1px");
448

    
449
        vLayout.addComponent(taxonDirLabel);
450
        vLayout.setComponentAlignment(taxonDirLabel, new Alignment(48));
451

    
452

    
453
        taxonTextField.setImmediate(false);
454
        taxonTextField.setWidth("-1px");
455
        taxonTextField.setHeight("-1px");
456
        taxonTextField.setInvalidAllowed(false);
457
        taxonTextField.setRequired(true);
458
        taxonTextField.setReadOnly(true);
459
        vLayout.addComponent(taxonTextField);
460
        vLayout.setComponentAlignment(taxonTextField, new Alignment(48));
461

    
462
        return vLayout;
463
    }
464

    
465
    @AutoGenerated
466
    private VerticalLayout buildMainLayout() {
467
        // common part: create layout
468
        mainLayout = new VerticalLayout();
469
        mainLayout.setImmediate(false);
470
        mainLayout.setWidth("740px");
471
        mainLayout.setHeight("170px");
472
        mainLayout.setMargin(false);
473
        mainLayout.setSpacing(true);
474

    
475
        // top-level component properties
476
        setWidth("740px");
477
        setHeight("170px");
478

    
479
        // horizontalLayout
480
        horizontalLayout = buildHorizontalLayout();
481
        mainLayout.addComponent(horizontalLayout);
482
        mainLayout.setExpandRatio(horizontalLayout, 1.0f);
483
        mainLayout.setComponentAlignment(horizontalLayout, new Alignment(48));
484

    
485
        // saveCancelHLayout
486
        saveCancelHLayout = buildSaveCancelHLayout();
487
        mainLayout.addComponent(saveCancelHLayout);
488
        mainLayout.setComponentAlignment(saveCancelHLayout, new Alignment(48));
489

    
490
        // cdmProgressComponent
491
        cdmProgressComponent = new CdmProgressComponent();
492
        cdmProgressComponent.setImmediate(false);
493
        cdmProgressComponent.setWidth("-1px");
494
        cdmProgressComponent.setHeight("-1px");
495
        mainLayout.addComponent(cdmProgressComponent);
496
        mainLayout.setComponentAlignment(cdmProgressComponent, new Alignment(48));
497

    
498
        return mainLayout;
499
    }
500

    
501
    @AutoGenerated
502
    private HorizontalLayout buildHorizontalLayout() {
503
        // common part: create layout
504
        horizontalLayout = new HorizontalLayout();
505
        horizontalLayout.setImmediate(false);
506
        horizontalLayout.setWidth("-1px");
507
        horizontalLayout.setHeight("-1px");
508
        horizontalLayout.setMargin(true);
509
        horizontalLayout.setSpacing(true);
510

    
511
        // leftLabel
512
        leftLabel = new Label();
513
        leftLabel.setImmediate(false);
514
        leftLabel.setWidth("-1px");
515
        leftLabel.setHeight("30px");
516
        leftLabel.setValue("Label");
517
        horizontalLayout.addComponent(leftLabel);
518
        horizontalLayout.setComponentAlignment(leftLabel, new Alignment(24));
519

    
520
        // typeVLayout
521
        typeVLayout = buildTypeVLayout();
522
        horizontalLayout.addComponent(typeVLayout);
523
        horizontalLayout.setExpandRatio(typeVLayout, 1.0f);
524
        horizontalLayout.setComponentAlignment(typeVLayout, new Alignment(48));
525

    
526
        // rightLabel
527
        rightLabel = new Label();
528
        rightLabel.setImmediate(false);
529
        rightLabel.setWidth("-1px");
530
        rightLabel.setHeight("30px");
531
        rightLabel.setValue("Label");
532
        horizontalLayout.addComponent(rightLabel);
533
        horizontalLayout.setComponentAlignment(rightLabel, new Alignment(24));
534

    
535
        return horizontalLayout;
536
    }
537

    
538
    @AutoGenerated
539
    private VerticalLayout buildTypeVLayout() {
540
        // common part: create layout
541
        typeVLayout = new VerticalLayout();
542
        typeVLayout.setImmediate(false);
543
        typeVLayout.setWidth("-1px");
544
        typeVLayout.setHeight("-1px");
545
        typeVLayout.setMargin(false);
546
        typeVLayout.setSpacing(true);
547

    
548
        // typeLabel
549
        typeLabel = new Label();
550
        typeLabel.setImmediate(false);
551
        typeLabel.setWidth("-1px");
552
        typeLabel.setHeight("-1px");
553
        typeLabel.setValue("Type");
554
        typeVLayout.addComponent(typeLabel);
555
        typeVLayout.setComponentAlignment(typeLabel, new Alignment(48));
556

    
557
        // conceptRComboBox
558
        conceptRComboBox = new ComboBox();
559
        conceptRComboBox.setImmediate(false);
560
        conceptRComboBox.setWidth("260px");
561
        conceptRComboBox.setHeight("-1px");
562
        conceptRComboBox.setRequired(true);
563
        typeVLayout.addComponent(conceptRComboBox);
564
        typeVLayout.setExpandRatio(conceptRComboBox, 1.0f);
565
        typeVLayout.setComponentAlignment(conceptRComboBox, new Alignment(48));
566

    
567
        return typeVLayout;
568
    }
569

    
570
    @AutoGenerated
571
    private HorizontalLayout buildSaveCancelHLayout() {
572
        // common part: create layout
573
        saveCancelHLayout = new HorizontalLayout();
574
        saveCancelHLayout.setImmediate(false);
575
        saveCancelHLayout.setWidth("-1px");
576
        saveCancelHLayout.setHeight("-1px");
577
        saveCancelHLayout.setMargin(false);
578
        saveCancelHLayout.setSpacing(true);
579

    
580
        // saveButton
581
        saveButton = new Button();
582
        saveButton.setCaption("save");
583
        saveButton.setImmediate(true);
584
        saveButton.setWidth("-1px");
585
        saveButton.setHeight("-1px");
586
        saveCancelHLayout.addComponent(saveButton);
587

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

    
596
        return saveCancelHLayout;
597
    }
598

    
599
}
(3-3/6)