Revision 6f501be5
Added by Cherian Mathew over 8 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/ConceptRelationshipComposite.java | ||
---|---|---|
28 | 28 |
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree; |
29 | 29 |
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction; |
30 | 30 |
import eu.etaxonomy.cdm.vaadin.presenter.ConceptRelationshipPresenter; |
31 |
import eu.etaxonomy.cdm.vaadin.session.BasicEvent; |
|
32 | 31 |
import eu.etaxonomy.cdm.vaadin.session.CdmChangeEvent; |
33 | 32 |
import eu.etaxonomy.cdm.vaadin.session.CdmChangeEvent.Action; |
34 | 33 |
import eu.etaxonomy.cdm.vaadin.session.ICdmChangeListener; |
... | ... | |
123 | 122 |
fromTaxonIun, |
124 | 123 |
null, |
125 | 124 |
null, |
126 |
Action.Create); |
|
127 |
CdmVaadinSessionUtilities.getCurrentBasicEventService() |
|
128 |
.fireBasicEvent(new BasicEvent(UPDATE_START_ID, ConceptRelationshipComposite.class), false); |
|
125 |
Action.Create, |
|
126 |
view.getDirection()); |
|
129 | 127 |
} |
130 | 128 |
}); |
131 | 129 |
} |
... | ... | |
138 | 136 |
EditConceptRelationshipComposite.showInDialog(EDIT_CR_TITLE, |
139 | 137 |
fromTaxonIun, |
140 | 138 |
selectedTaxonRelUuid, |
141 |
Action.Update); |
|
142 |
CdmVaadinSessionUtilities.getCurrentBasicEventService() |
|
143 |
.fireBasicEvent(new BasicEvent(UPDATE_START_ID, ConceptRelationshipComposite.class), false); |
|
139 |
Action.Update, |
|
140 |
view.getDirection()); |
|
144 | 141 |
} |
145 | 142 |
}); |
146 | 143 |
} |
... | ... | |
153 | 150 |
EditConceptRelationshipComposite.showInDialog(DELETE_CR_TITLE, |
154 | 151 |
fromTaxonIun, |
155 | 152 |
selectedTaxonRelUuid, |
156 |
Action.Delete); |
|
157 |
CdmVaadinSessionUtilities.getCurrentBasicEventService() |
|
158 |
.fireBasicEvent(new BasicEvent(UPDATE_START_ID, ConceptRelationshipComposite.class), false); |
|
153 |
Action.Delete, |
|
154 |
view.getDirection()); |
|
159 | 155 |
} |
160 | 156 |
}); |
161 | 157 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/component/EditConceptRelationshipComposite.java | ||
---|---|---|
23 | 23 |
import com.vaadin.event.dd.DropHandler; |
24 | 24 |
import com.vaadin.event.dd.acceptcriteria.AcceptAll; |
25 | 25 |
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; |
26 |
import com.vaadin.server.FontAwesome; |
|
26 | 27 |
import com.vaadin.server.Page; |
28 |
import com.vaadin.shared.ui.label.ContentMode; |
|
27 | 29 |
import com.vaadin.ui.Alignment; |
28 | 30 |
import com.vaadin.ui.Button; |
29 | 31 |
import com.vaadin.ui.Button.ClickEvent; |
... | ... | |
43 | 45 |
|
44 | 46 |
import eu.etaxonomy.cdm.vaadin.container.IdUuidName; |
45 | 47 |
import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer; |
48 |
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction; |
|
46 | 49 |
import eu.etaxonomy.cdm.vaadin.presenter.EditConceptRelationshipPresenter; |
47 | 50 |
import eu.etaxonomy.cdm.vaadin.session.BasicEvent; |
48 | 51 |
import eu.etaxonomy.cdm.vaadin.session.CdmChangeEvent; |
... | ... | |
73 | 76 |
@AutoGenerated |
74 | 77 |
private HorizontalLayout horizontalLayout; |
75 | 78 |
@AutoGenerated |
79 |
private Label rightLabel; |
|
80 |
@AutoGenerated |
|
76 | 81 |
private VerticalLayout typeVLayout; |
77 | 82 |
@AutoGenerated |
78 | 83 |
private ComboBox conceptRComboBox; |
79 | 84 |
@AutoGenerated |
80 | 85 |
private Label typeLabel; |
81 | 86 |
@AutoGenerated |
87 |
private Label leftLabel; |
|
88 |
@AutoGenerated |
|
82 | 89 |
private VerticalLayout fromTaxonVLayout; |
83 | 90 |
@AutoGenerated |
84 | 91 |
private Label fromTaxonValue; |
... | ... | |
100 | 107 |
|
101 | 108 |
|
102 | 109 |
private Action action; |
110 |
private Direction direction; |
|
103 | 111 |
|
104 | 112 |
public EditConceptRelationshipComposite(IdUuidName fromTaxonIdUuidName, |
105 | 113 |
IdUuidName taxonRTypeIdUuidName, |
106 | 114 |
IdUuidName toTaxonIdUuidName, |
107 |
Action action) { |
|
115 |
Action action, |
|
116 |
Direction direction) { |
|
108 | 117 |
this(); |
118 |
this.direction = direction; |
|
109 | 119 |
init(fromTaxonIdUuidName, taxonRTypeIdUuidName, toTaxonIdUuidName, action); |
110 | 120 |
|
111 | 121 |
} |
112 | 122 |
|
113 | 123 |
public EditConceptRelationshipComposite(IdUuidName fromTaxonIun, |
114 | 124 |
UUID relUuid, |
115 |
Action action) { |
|
125 |
Action action, |
|
126 |
Direction direction) { |
|
116 | 127 |
this(); |
117 | 128 |
this.relUuid = relUuid; |
129 |
this.direction = direction; |
|
118 | 130 |
Map<String, IdUuidName> map = presenter.getRelTypeToTaxonIunMap(fromTaxonIun.getUuid(), relUuid); |
119 | 131 |
taxonRTypeIun = map.get(EditConceptRelationshipPresenter.REL_TYPE_KEY); |
120 | 132 |
toTaxonIun = map.get(EditConceptRelationshipPresenter.TO_TAXON_KEY); |
... | ... | |
134 | 146 |
buildToTaxon(); |
135 | 147 |
setCompositionRoot(mainLayout); |
136 | 148 |
|
149 |
direction = Direction.LEFT_RIGHT; |
|
137 | 150 |
this.presenter = new EditConceptRelationshipPresenter(); |
138 | 151 |
addUIListeners(); |
139 | 152 |
|
... | ... | |
152 | 165 |
initFromTaxonLabel(); |
153 | 166 |
initConceptRComboBox(); |
154 | 167 |
initToTaxon(); |
168 |
initDirectionLabels(); |
|
155 | 169 |
} |
156 | 170 |
|
157 | 171 |
public void setWindow(Window window) { |
... | ... | |
161 | 175 |
fromTaxonValue.setValue(fromTaxonIun.getName()); |
162 | 176 |
} |
163 | 177 |
|
178 |
private void initDirectionLabels() { |
|
179 |
|
|
180 |
leftLabel.addStyleName("cr-arrow"); |
|
181 |
leftLabel.setContentMode(ContentMode.HTML); |
|
182 |
|
|
183 |
rightLabel.addStyleName("cr-arrow"); |
|
184 |
rightLabel.setContentMode(ContentMode.HTML); |
|
185 |
|
|
186 |
switch(direction) { |
|
187 |
case LEFT_RIGHT: |
|
188 |
leftLabel.setValue(FontAwesome.LONG_ARROW_RIGHT.getHtml()); |
|
189 |
rightLabel.setValue(FontAwesome.LONG_ARROW_RIGHT.getHtml()); |
|
190 |
break; |
|
191 |
case RIGHT_LEFT: |
|
192 |
leftLabel.setValue(FontAwesome.LONG_ARROW_LEFT.getHtml()); |
|
193 |
rightLabel.setValue(FontAwesome.LONG_ARROW_LEFT.getHtml()); |
|
194 |
break; |
|
195 |
} |
|
196 |
} |
|
197 |
|
|
164 | 198 |
private void initConceptRComboBox() { |
165 | 199 |
conceptRComboBox.setImmediate(true); |
166 | 200 |
conceptRComboBox.setItemCaptionPropertyId("titleCache"); |
... | ... | |
335 | 369 |
UI.getCurrent().addWindow(dialog); |
336 | 370 |
ecrc.setWindow(dialog); |
337 | 371 |
dialog.setContent(ecrc); |
372 |
CdmVaadinSessionUtilities.getCurrentBasicEventService() |
|
373 |
.fireBasicEvent(new BasicEvent(ConceptRelationshipComposite.UPDATE_START_ID, ConceptRelationshipComposite.class), false); |
|
338 | 374 |
} |
339 | 375 |
|
340 | 376 |
public static void showInDialog(String windowTitle, |
341 | 377 |
IdUuidName fromTaxonIun, |
342 | 378 |
IdUuidName taxonRTypeIun, |
343 | 379 |
IdUuidName toTaxonIun, |
344 |
Action action) { |
|
345 |
EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, taxonRTypeIun, toTaxonIun,action); |
|
380 |
Action action, |
|
381 |
Direction direction) { |
|
382 |
EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, taxonRTypeIun, toTaxonIun,action, direction); |
|
346 | 383 |
showInDialog(windowTitle, ecrc); |
347 | 384 |
} |
348 | 385 |
|
349 | 386 |
public static void showInDialog(String windowTitle, |
350 | 387 |
IdUuidName fromTaxonIun, |
351 | 388 |
UUID relUuid, |
352 |
Action action) { |
|
353 |
EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, relUuid,action); |
|
389 |
Action action, |
|
390 |
Direction direction) { |
|
391 |
EditConceptRelationshipComposite ecrc = new EditConceptRelationshipComposite(fromTaxonIun, relUuid, action, direction); |
|
354 | 392 |
showInDialog(windowTitle, ecrc); |
355 | 393 |
} |
356 | 394 |
|
... | ... | |
391 | 429 |
// common part: create layout |
392 | 430 |
mainLayout = new VerticalLayout(); |
393 | 431 |
mainLayout.setImmediate(false); |
394 |
mainLayout.setWidth("602px");
|
|
432 |
mainLayout.setWidth("700px");
|
|
395 | 433 |
mainLayout.setHeight("170px"); |
396 | 434 |
mainLayout.setMargin(false); |
397 | 435 |
mainLayout.setSpacing(true); |
398 | 436 |
|
399 | 437 |
// top-level component properties |
400 |
setWidth("602px");
|
|
438 |
setWidth("700px");
|
|
401 | 439 |
setHeight("170px"); |
402 | 440 |
|
403 | 441 |
// horizontalLayout |
404 | 442 |
horizontalLayout = buildHorizontalLayout(); |
405 | 443 |
mainLayout.addComponent(horizontalLayout); |
444 |
mainLayout.setExpandRatio(horizontalLayout, 1.0f); |
|
445 |
mainLayout.setComponentAlignment(horizontalLayout, new Alignment(48)); |
|
406 | 446 |
|
407 | 447 |
// saveCancelHLayout |
408 | 448 |
saveCancelHLayout = buildSaveCancelHLayout(); |
... | ... | |
425 | 465 |
// common part: create layout |
426 | 466 |
horizontalLayout = new HorizontalLayout(); |
427 | 467 |
horizontalLayout.setImmediate(false); |
428 |
horizontalLayout.setWidth("602px");
|
|
468 |
horizontalLayout.setWidth("-1px");
|
|
429 | 469 |
horizontalLayout.setHeight("-1px"); |
430 | 470 |
horizontalLayout.setMargin(true); |
431 | 471 |
horizontalLayout.setSpacing(true); |
... | ... | |
435 | 475 |
horizontalLayout.addComponent(fromTaxonVLayout); |
436 | 476 |
horizontalLayout.setComponentAlignment(fromTaxonVLayout, new Alignment(48)); |
437 | 477 |
|
478 |
// leftLabel |
|
479 |
leftLabel = new Label(); |
|
480 |
leftLabel.setImmediate(false); |
|
481 |
leftLabel.setWidth("-1px"); |
|
482 |
leftLabel.setHeight("-1px"); |
|
483 |
leftLabel.setValue("Label"); |
|
484 |
horizontalLayout.addComponent(leftLabel); |
|
485 |
horizontalLayout.setComponentAlignment(leftLabel, new Alignment(24)); |
|
486 |
|
|
438 | 487 |
// typeVLayout |
439 | 488 |
typeVLayout = buildTypeVLayout(); |
440 | 489 |
horizontalLayout.addComponent(typeVLayout); |
441 |
horizontalLayout.setExpandRatio(typeVLayout, 1.0f); |
|
442 | 490 |
horizontalLayout.setComponentAlignment(typeVLayout, new Alignment(48)); |
443 | 491 |
|
492 |
// rightLabel |
|
493 |
rightLabel = new Label(); |
|
494 |
rightLabel.setImmediate(false); |
|
495 |
rightLabel.setWidth("-1px"); |
|
496 |
rightLabel.setHeight("-1px"); |
|
497 |
rightLabel.setValue("Label"); |
|
498 |
horizontalLayout.addComponent(rightLabel); |
|
499 |
horizontalLayout.setComponentAlignment(rightLabel, new Alignment(24)); |
|
500 |
|
|
444 | 501 |
return horizontalLayout; |
445 | 502 |
} |
446 | 503 |
|
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java | ||
---|---|---|
19 | 19 |
import org.apache.log4j.Logger; |
20 | 20 |
|
21 | 21 |
import com.vaadin.annotations.AutoGenerated; |
22 |
import com.vaadin.data.Container.Hierarchical; |
|
23 | 22 |
import com.vaadin.data.Item; |
24 | 23 |
import com.vaadin.data.Property; |
25 | 24 |
import com.vaadin.data.Property.ValueChangeEvent; |
... | ... | |
33 | 32 |
import com.vaadin.event.ItemClickEvent.ItemClickListener; |
34 | 33 |
import com.vaadin.event.LayoutEvents.LayoutClickEvent; |
35 | 34 |
import com.vaadin.event.LayoutEvents.LayoutClickListener; |
36 |
import com.vaadin.event.Transferable; |
|
37 |
import com.vaadin.event.dd.DragAndDropEvent; |
|
38 |
import com.vaadin.event.dd.DropHandler; |
|
39 |
import com.vaadin.event.dd.acceptcriteria.AcceptAll; |
|
40 |
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; |
|
41 | 35 |
import com.vaadin.navigator.View; |
42 | 36 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
43 | 37 |
import com.vaadin.server.FontAwesome; |
44 |
import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; |
|
45 | 38 |
import com.vaadin.ui.Alignment; |
46 | 39 |
import com.vaadin.ui.Button; |
47 | 40 |
import com.vaadin.ui.Button.ClickEvent; |
... | ... | |
183 | 176 |
taxaTreeTable.setSelectable(isTaxaTableSelectable); |
184 | 177 |
} |
185 | 178 |
|
179 |
public TreeTable getTaxaTreeTable() { |
|
180 |
return taxaTreeTable; |
|
181 |
} |
|
182 |
|
|
183 |
public LeafNodeTaxonContainer getTaxonContainer() { |
|
184 |
return listener.getCurrentLeafNodeTaxonContainer(); |
|
185 |
} |
|
186 |
|
|
186 | 187 |
public void clearTaxaTableSelections() { |
187 | 188 |
taxaTreeTable.setValue(null); |
188 | 189 |
} |
... | ... | |
233 | 234 |
} |
234 | 235 |
}); |
235 | 236 |
|
236 |
taxaTreeTable.setDropHandler(new DropHandler() { |
|
237 | 237 |
|
238 |
@Override |
|
239 |
public AcceptCriterion getAcceptCriterion() { |
|
240 |
return AcceptAll.get(); |
|
241 |
} |
|
242 |
|
|
243 |
@Override |
|
244 |
public void drop(DragAndDropEvent event) { |
|
245 |
// Wrapper for the object that is dragged |
|
246 |
Transferable t = event.getTransferable(); |
|
247 |
Component source = t.getSourceComponent(); |
|
248 |
|
|
249 |
// This is the case where the source of the dd is another |
|
250 |
// taxon table not the one in this object |
|
251 |
if (source instanceof TreeTable && source != taxaTreeTable) { |
|
252 |
TreeTable table = (TreeTable)t.getSourceComponent(); |
|
253 |
Hierarchical sourceHierachicalContainer = table.getContainerDataSource(); |
|
254 |
|
|
255 |
IdUuidName fromTaxonIun, toTaxonIun; |
|
256 |
if(sourceHierachicalContainer instanceof LeafNodeTaxonContainer) { |
|
257 |
LeafNodeTaxonContainer lntc = (LeafNodeTaxonContainer)sourceHierachicalContainer; |
|
258 |
Object sourceItemId = t.getData("itemId"); |
|
259 |
String fromName = (String)lntc.getProperty(sourceItemId, LeafNodeTaxonContainer.NAME_ID).getValue(); |
|
260 |
|
|
261 |
AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event.getTargetDetails()); |
|
262 |
Object targetItemId = dropData.getItemIdOver(); |
|
263 |
String toName = (String)listener.getCurrentLeafNodeTaxonContainer().getProperty(targetItemId, LeafNodeTaxonContainer.NAME_ID).getValue(); |
|
264 |
|
|
265 |
fromTaxonIun = new IdUuidName(sourceItemId, |
|
266 |
lntc.getUuid(sourceItemId), |
|
267 |
fromName); |
|
268 |
toTaxonIun = new IdUuidName(targetItemId, |
|
269 |
listener.getCurrentLeafNodeTaxonContainer().getUuid(targetItemId), |
|
270 |
toName); |
|
271 |
EditConceptRelationshipComposite.showInDialog(ConceptRelationshipComposite.CREATE_NEW_CR_TITLE, |
|
272 |
fromTaxonIun, |
|
273 |
null, |
|
274 |
toTaxonIun, |
|
275 |
CdmChangeEvent.Action.Create); |
|
276 |
} |
|
277 |
} |
|
278 |
|
|
279 |
|
|
280 |
} |
|
281 |
}); |
|
282 | 238 |
|
283 | 239 |
// NOTE : Not really sure why we need to refresh the container here. |
284 | 240 |
// in the case of 'Table' this is not required |
... | ... | |
444 | 400 |
public void valueChange(ValueChangeEvent event) { |
445 | 401 |
if (classificationComboBox.getValue() != null) { |
446 | 402 |
Object selected = classificationComboBox.getValue(); |
447 |
logger.info("selected : " + selected); |
|
448 | 403 |
int classificationId = (Integer)((RowId)selected).getId()[0]; |
449 | 404 |
initTaxaTable(classificationId); |
450 | 405 |
initFilterTable(); |
... | ... | |
455 | 410 |
} |
456 | 411 |
|
457 | 412 |
private void addTaxaTreeTableListener() { |
413 |
|
|
458 | 414 |
taxaTreeTable.addItemClickListener(new ItemClickListener() { |
459 | 415 |
@Override |
460 | 416 |
public void itemClick(ItemClickEvent event) { |
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmVaadinSessionUtilities.java | ||
---|---|---|
37 | 37 |
|
38 | 38 |
public static void initCdmDataChangeService() { |
39 | 39 |
if(getCurrentCdmDataChangeService() != null) { |
40 |
logger.warn("replacing data change service with new one");
|
|
40 |
logger.info("replacing data change service with new one");
|
|
41 | 41 |
} |
42 | 42 |
setCurrentAttribute(CdmDataChangeService.KEY, new CdmDataChangeService()); |
43 | 43 |
} |
... | ... | |
48 | 48 |
|
49 | 49 |
public static void initSelectionService() { |
50 | 50 |
if(getCurrentSelectionService() != null) { |
51 |
logger.warn("replacing selection service with new one");
|
|
51 |
logger.info("replacing selection service with new one");
|
|
52 | 52 |
} |
53 | 53 |
setCurrentAttribute(SelectionService.KEY, new SelectionService()); |
54 | 54 |
} |
... | ... | |
59 | 59 |
|
60 | 60 |
public static void initBasicEventService() { |
61 | 61 |
if(getCurrentBasicEventService() != null) { |
62 |
logger.warn("replacing basic event service with new one");
|
|
62 |
logger.info("replacing basic event service with new one");
|
|
63 | 63 |
} |
64 | 64 |
setCurrentAttribute(BasicEventService.KEY, new BasicEventService()); |
65 | 65 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/ConceptRelationshipView.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 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 |
*/ |
|
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 | 10 |
package eu.etaxonomy.cdm.vaadin.view; |
11 | 11 |
|
12 |
import java.util.Arrays; |
|
12 | 13 |
import java.util.UUID; |
13 | 14 |
|
14 | 15 |
import com.vaadin.annotations.AutoGenerated; |
16 |
import com.vaadin.data.Container; |
|
17 |
import com.vaadin.event.Transferable; |
|
18 |
import com.vaadin.event.dd.DragAndDropEvent; |
|
19 |
import com.vaadin.event.dd.DropHandler; |
|
20 |
import com.vaadin.event.dd.DropTarget; |
|
21 |
import com.vaadin.event.dd.acceptcriteria.AcceptAll; |
|
22 |
import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; |
|
15 | 23 |
import com.vaadin.navigator.View; |
16 | 24 |
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent; |
25 |
import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails; |
|
17 | 26 |
import com.vaadin.ui.Alignment; |
27 |
import com.vaadin.ui.Component; |
|
18 | 28 |
import com.vaadin.ui.CustomComponent; |
19 | 29 |
import com.vaadin.ui.HorizontalLayout; |
30 |
import com.vaadin.ui.TreeTable; |
|
20 | 31 |
|
21 | 32 |
import eu.etaxonomy.cdm.vaadin.component.ConceptRelationshipComposite; |
33 |
import eu.etaxonomy.cdm.vaadin.component.EditConceptRelationshipComposite; |
|
22 | 34 |
import eu.etaxonomy.cdm.vaadin.component.StatusComposite; |
35 |
import eu.etaxonomy.cdm.vaadin.container.IdUuidName; |
|
36 |
import eu.etaxonomy.cdm.vaadin.container.LeafNodeTaxonContainer; |
|
23 | 37 |
import eu.etaxonomy.cdm.vaadin.jscomponent.D3ConceptRelationshipTree.Direction; |
24 | 38 |
import eu.etaxonomy.cdm.vaadin.session.BasicEvent; |
39 |
import eu.etaxonomy.cdm.vaadin.session.CdmChangeEvent; |
|
25 | 40 |
import eu.etaxonomy.cdm.vaadin.session.IBasicEventListener; |
41 |
import eu.etaxonomy.cdm.vaadin.session.SelectionEvent; |
|
26 | 42 |
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinSessionUtilities; |
27 | 43 |
|
28 | 44 |
/** |
... | ... | |
64 | 80 |
setPrimaryStatusCompositeUuid(statusCompositeLeft.getSelectedClassificationUuid()); |
65 | 81 |
direction = Direction.LEFT_RIGHT; |
66 | 82 |
CdmVaadinSessionUtilities.getCurrentBasicEventService().register(this); |
83 |
|
|
84 |
initDropHandlers(); |
|
67 | 85 |
} |
68 | 86 |
|
69 | 87 |
/* (non-Javadoc) |
... | ... | |
79 | 97 |
return direction; |
80 | 98 |
} |
81 | 99 |
|
100 |
public void initDropHandlers() { |
|
101 |
statusCompositeLeft.getTaxaTreeTable().setDropHandler(new ConceptRelationshipDropHandler(statusCompositeRight)); |
|
102 |
statusCompositeRight.getTaxaTreeTable().setDropHandler(new ConceptRelationshipDropHandler(statusCompositeLeft)); |
|
103 |
} |
|
104 |
|
|
82 | 105 |
public void setPrimaryStatusCompositeUuid(UUID scUuid) { |
83 | 106 |
if(scUuid != null) { |
84 | 107 |
if(scUuid.equals(statusCompositeLeft.getSelectedClassificationUuid())) { |
... | ... | |
100 | 123 |
*/ |
101 | 124 |
@Override |
102 | 125 |
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 |
} |
|
126 |
if(event.getEventId().equals(ConceptRelationshipComposite.UPDATE_START_ID)) {
|
|
127 |
primaryStatusComposite.setTaxaTableEnabled(false);
|
|
128 |
secondaryStatusComposite.setTaxaTableSelectable(false);
|
|
129 |
}
|
|
130 |
if(event.getEventId().equals(ConceptRelationshipComposite.UPDATE_END_ID)) {
|
|
131 |
primaryStatusComposite.setTaxaTableEnabled(true);
|
|
132 |
secondaryStatusComposite.setTaxaTableSelectable(true);
|
|
133 |
}
|
|
111 | 134 |
} |
112 | 135 |
|
113 | 136 |
@AutoGenerated |
... | ... | |
149 | 172 |
return mainLayout; |
150 | 173 |
} |
151 | 174 |
|
175 |
private class ConceptRelationshipDropHandler implements DropHandler { |
|
176 |
|
|
177 |
private StatusComposite sourceSc; |
|
152 | 178 |
|
179 |
|
|
180 |
public ConceptRelationshipDropHandler(StatusComposite sourceSc) { |
|
181 |
this.sourceSc = sourceSc; |
|
182 |
} |
|
183 |
|
|
184 |
@Override |
|
185 |
public AcceptCriterion getAcceptCriterion() { |
|
186 |
return AcceptAll.get(); |
|
187 |
} |
|
188 |
|
|
189 |
@Override |
|
190 |
public void drop(DragAndDropEvent event) { |
|
191 |
// Wrapper for the object that is dragged |
|
192 |
Transferable t = event.getTransferable(); |
|
193 |
Component source = t.getSourceComponent(); |
|
194 |
|
|
195 |
// This is the case where the source of the dd is another |
|
196 |
// taxon table not the one in this object |
|
197 |
if (source instanceof TreeTable && source == sourceSc.getTaxaTreeTable()) { |
|
198 |
TreeTable sourceTable = (TreeTable)t.getSourceComponent(); |
|
199 |
LeafNodeTaxonContainer sourceContainer = (LeafNodeTaxonContainer)sourceTable.getContainerDataSource(); |
|
200 |
|
|
201 |
IdUuidName fromTaxonIun, toTaxonIun; |
|
202 |
|
|
203 |
Object sourceItemId = t.getData("itemId"); |
|
204 |
String fromName = (String)sourceContainer.getProperty(sourceItemId, LeafNodeTaxonContainer.NAME_ID).getValue(); |
|
205 |
|
|
206 |
AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) event.getTargetDetails()); |
|
207 |
DropTarget target = dropData.getTarget(); |
|
208 |
if(target instanceof TreeTable) { |
|
209 |
TreeTable targetTable = (TreeTable)target; |
|
210 |
Container container = targetTable.getContainerDataSource(); |
|
211 |
if(container instanceof LeafNodeTaxonContainer) { |
|
212 |
LeafNodeTaxonContainer targetContainer = (LeafNodeTaxonContainer)container; |
|
213 |
Object targetItemId = dropData.getItemIdOver(); |
|
214 |
String toName = (String)targetContainer.getProperty(targetItemId, LeafNodeTaxonContainer.NAME_ID).getValue(); |
|
215 |
|
|
216 |
fromTaxonIun = new IdUuidName(sourceItemId, |
|
217 |
sourceContainer.getUuid(sourceItemId), |
|
218 |
fromName); |
|
219 |
toTaxonIun = new IdUuidName(targetItemId, |
|
220 |
targetContainer.getUuid(targetItemId), |
|
221 |
toName); |
|
222 |
CdmVaadinSessionUtilities.getCurrentSelectionService() |
|
223 |
.fireSelectionEvent(new SelectionEvent(Arrays.asList(fromTaxonIun, sourceSc.getSelectedClassificationUuid()), StatusComposite.class), false); |
|
224 |
EditConceptRelationshipComposite.showInDialog(ConceptRelationshipComposite.CREATE_NEW_CR_TITLE, |
|
225 |
fromTaxonIun, |
|
226 |
null, |
|
227 |
toTaxonIun, |
|
228 |
CdmChangeEvent.Action.Create, |
|
229 |
direction); |
|
230 |
} |
|
231 |
} |
|
232 |
|
|
233 |
} |
|
234 |
|
|
235 |
} |
|
236 |
|
|
237 |
} |
|
153 | 238 |
} |
src/main/webapp/VAADIN/themes/edit/edit.scss | ||
---|---|---|
39 | 39 |
font-style: italic; |
40 | 40 |
} |
41 | 41 |
|
42 |
.cr-arrow .v-icon { |
|
43 |
color: #006666; |
|
44 |
font-size: 40px; |
|
45 |
} |
|
46 |
|
|
42 | 47 |
} |
src/main/webapp/VAADIN/themes/edit/styles.css | ||
---|---|---|
5895 | 5895 |
|
5896 | 5896 |
.edit .v-table-cell-content-synonym { |
5897 | 5897 |
font-style: italic; |
5898 |
} |
|
5899 |
|
|
5900 |
.edit .cr-arrow .v-icon { |
|
5901 |
color: #006666; |
|
5902 |
font-size: 40px; |
|
5898 | 5903 |
} |
Also available in: Unified diff
ConceptRelationshipComposite : made direction aware
EditConceptRelationshipComposite : made direction aware and added arrows as hints
StatusComposite, ConceptRelationshipView : moved taxon table drop handler from status composite to view
edit.scss, styles.css : added arrow styles