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.view;
|
11
|
|
12
|
import java.util.UUID;
|
13
|
|
14
|
import com.vaadin.annotations.AutoGenerated;
|
15
|
import com.vaadin.navigator.View;
|
16
|
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
|
17
|
import com.vaadin.ui.Alignment;
|
18
|
import com.vaadin.ui.CustomComponent;
|
19
|
import com.vaadin.ui.HorizontalLayout;
|
20
|
|
21
|
import eu.etaxonomy.cdm.vaadin.component.ConceptRelationshipComposite;
|
22
|
import eu.etaxonomy.cdm.vaadin.component.StatusComposite;
|
23
|
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction;
|
24
|
import eu.etaxonomy.cdm.vaadin.session.BasicEvent;
|
25
|
import eu.etaxonomy.cdm.vaadin.session.IBasicEventListener;
|
26
|
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinSessionUtilities;
|
27
|
|
28
|
/**
|
29
|
* @author cmathew
|
30
|
* @date 9 Apr 2015
|
31
|
*
|
32
|
*/
|
33
|
public class ConceptRelationshipView extends CustomComponent implements View, IBasicEventListener {
|
34
|
|
35
|
/*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
|
36
|
|
37
|
@AutoGenerated
|
38
|
private HorizontalLayout mainLayout;
|
39
|
@AutoGenerated
|
40
|
private StatusComposite statusCompositeRight;
|
41
|
@AutoGenerated
|
42
|
private ConceptRelationshipComposite conceptRelationshipComposite;
|
43
|
@AutoGenerated
|
44
|
private StatusComposite statusCompositeLeft;
|
45
|
|
46
|
private StatusComposite primaryStatusComposite, secondaryStatusComposite;
|
47
|
|
48
|
private Direction direction;
|
49
|
/**
|
50
|
* The constructor should first build the main layout, set the
|
51
|
* composition root and then do any custom initialization.
|
52
|
*
|
53
|
* The constructor will not be automatically regenerated by the
|
54
|
* visual editor.
|
55
|
*/
|
56
|
public ConceptRelationshipView() {
|
57
|
|
58
|
buildMainLayout();
|
59
|
setCompositionRoot(mainLayout);
|
60
|
|
61
|
conceptRelationshipComposite.setView(this);
|
62
|
conceptRelationshipComposite.setSizeFull();
|
63
|
|
64
|
setPrimaryStatusCompositeUuid(statusCompositeLeft.getSelectedClassificationUuid());
|
65
|
direction = Direction.LEFT_RIGHT;
|
66
|
CdmVaadinSessionUtilities.getCurrentBasicEventService().register(this);
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see com.vaadin.navigator.View#enter(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent)
|
71
|
*/
|
72
|
@Override
|
73
|
public void enter(ViewChangeEvent event) {
|
74
|
// TODO Auto-generated method stub
|
75
|
|
76
|
}
|
77
|
|
78
|
public Direction getDirection() {
|
79
|
return direction;
|
80
|
}
|
81
|
|
82
|
public void setPrimaryStatusCompositeUuid(UUID scUuid) {
|
83
|
if(scUuid != null) {
|
84
|
if(scUuid.equals(statusCompositeLeft.getSelectedClassificationUuid())) {
|
85
|
primaryStatusComposite = statusCompositeLeft;
|
86
|
secondaryStatusComposite = statusCompositeRight;
|
87
|
direction = Direction.LEFT_RIGHT;
|
88
|
}
|
89
|
if(scUuid.equals(statusCompositeRight.getSelectedClassificationUuid())) {
|
90
|
secondaryStatusComposite = statusCompositeLeft;
|
91
|
primaryStatusComposite = statusCompositeRight;
|
92
|
direction = Direction.RIGHT_LEFT;
|
93
|
}
|
94
|
secondaryStatusComposite.clearTaxaTableSelections();
|
95
|
}
|
96
|
}
|
97
|
|
98
|
/* (non-Javadoc)
|
99
|
* @see eu.etaxonomy.cdm.vaadin.session.IBasicEventListener#onAction(eu.etaxonomy.cdm.vaadin.session.BasicEvent)
|
100
|
*/
|
101
|
@Override
|
102
|
public void onAction(BasicEvent event) {
|
103
|
if(event.getEventId().equals(ConceptRelationshipComposite.UPDATE_START_ID)) {
|
104
|
primaryStatusComposite.setTaxaTableEnabled(false);
|
105
|
secondaryStatusComposite.setTaxaTableSelectable(false);
|
106
|
}
|
107
|
if(event.getEventId().equals(ConceptRelationshipComposite.UPDATE_END_ID)) {
|
108
|
primaryStatusComposite.setTaxaTableEnabled(true);
|
109
|
secondaryStatusComposite.setTaxaTableSelectable(true);
|
110
|
}
|
111
|
}
|
112
|
|
113
|
@AutoGenerated
|
114
|
private HorizontalLayout buildMainLayout() {
|
115
|
// common part: create layout
|
116
|
mainLayout = new HorizontalLayout();
|
117
|
mainLayout.setImmediate(false);
|
118
|
mainLayout.setWidth("100%");
|
119
|
mainLayout.setHeight("100%");
|
120
|
mainLayout.setMargin(true);
|
121
|
|
122
|
// top-level component properties
|
123
|
setWidth("100.0%");
|
124
|
setHeight("100.0%");
|
125
|
|
126
|
// statusCompositeLeft
|
127
|
statusCompositeLeft = new StatusComposite();
|
128
|
statusCompositeLeft.setImmediate(false);
|
129
|
statusCompositeLeft.setWidth("-1px");
|
130
|
statusCompositeLeft.setHeight("-1px");
|
131
|
mainLayout.addComponent(statusCompositeLeft);
|
132
|
|
133
|
// conceptRelationshipComposite
|
134
|
conceptRelationshipComposite = new ConceptRelationshipComposite();
|
135
|
conceptRelationshipComposite.setImmediate(false);
|
136
|
conceptRelationshipComposite.setWidth("-1px");
|
137
|
conceptRelationshipComposite.setHeight("-1px");
|
138
|
mainLayout.addComponent(conceptRelationshipComposite);
|
139
|
mainLayout.setExpandRatio(conceptRelationshipComposite, 1.0f);
|
140
|
mainLayout.setComponentAlignment(conceptRelationshipComposite, new Alignment(20));
|
141
|
|
142
|
// statusCompositeRight
|
143
|
statusCompositeRight = new StatusComposite();
|
144
|
statusCompositeRight.setImmediate(false);
|
145
|
statusCompositeRight.setWidth("-1px");
|
146
|
statusCompositeRight.setHeight("-1px");
|
147
|
mainLayout.addComponent(statusCompositeRight);
|
148
|
|
149
|
return mainLayout;
|
150
|
}
|
151
|
|
152
|
|
153
|
}
|