Revision 21a1bf2d
Added by Cherian Mathew almost 9 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/component/EditConceptRelationshipComposite.java | ||
---|---|---|
170 | 170 |
this.window = window; |
171 | 171 |
} |
172 | 172 |
|
173 |
public boolean canCreateRelationship() { |
|
174 |
return presenter.canCreateRelationship(fromTaxonIun.getUuid()); |
|
175 |
} |
|
176 |
|
|
173 | 177 |
private void initFromTaxon() { |
174 | 178 |
if(fromTaxonIun != null) { |
175 | 179 |
fromTaxonTextField.setReadOnly(false); |
... | ... | |
401 | 405 |
|
402 | 406 |
private static void showInDialog(String windowTitle, |
403 | 407 |
EditConceptRelationshipComposite ecrc) { |
408 |
//FIXME : hack for the moment to demonstrate checking of concept relationship rules |
|
409 |
if(!ecrc.canCreateRelationship()) { |
|
410 |
Notification.show("Cannot create relationship for a taxon which is already congruent to another taxon", Type.WARNING_MESSAGE); |
|
411 |
return; |
|
412 |
} |
|
404 | 413 |
Window dialog = new Window(windowTitle); |
405 | 414 |
dialog.setModal(false); |
406 | 415 |
dialog.setClosable(false); |
src/main/java/eu/etaxonomy/cdm/vaadin/component/NewTaxonBaseComposite.java | ||
---|---|---|
77 | 77 |
|
78 | 78 |
|
79 | 79 |
private final Window dialog; |
80 |
private final IdUuidName accTaxonIdUuid;
|
|
81 |
private final IdUuidName classificationIdUuid;
|
|
80 |
private final IdUuidName accTaxonIun;
|
|
81 |
private final IdUuidName classificationIun;
|
|
82 | 82 |
|
83 | 83 |
private static final Logger logger = Logger.getLogger(NewTaxonBaseComposite.class); |
84 | 84 |
|
85 |
private static final String CHOOSE_SECUNDUM_PROMPT = "Choose Secundum ...."; |
|
86 |
|
|
85 | 87 |
/** |
86 | 88 |
* The constructor should first build the main layout, set the |
87 | 89 |
* composition root and then do any custom initialization. |
... | ... | |
91 | 93 |
*/ |
92 | 94 |
public NewTaxonBaseComposite(Window dialog, |
93 | 95 |
INewTaxonBaseComponentListener listener, |
94 |
IdUuidName accTaxonIdUuid,
|
|
96 |
IdUuidName accTaxonIun,
|
|
95 | 97 |
String accTaxonName, |
96 |
IdUuidName classificationIdUuid) {
|
|
98 |
IdUuidName classificationIun) {
|
|
97 | 99 |
buildMainLayout(); |
98 | 100 |
setCompositionRoot(mainLayout); |
99 | 101 |
|
100 | 102 |
this.listener = listener; |
101 | 103 |
this.dialog = dialog; |
102 |
this.accTaxonIdUuid = accTaxonIdUuid;
|
|
103 |
this.classificationIdUuid = classificationIdUuid;
|
|
104 |
this.accTaxonIun = accTaxonIun;
|
|
105 |
this.classificationIun = classificationIun;
|
|
104 | 106 |
|
105 | 107 |
addUIListeners(); |
106 | 108 |
|
... | ... | |
124 | 126 |
secComboBox.setImmediate(true); |
125 | 127 |
if(listener != null) { |
126 | 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()); |
|
134 |
} else { |
|
135 |
selectedSecItemId = listener.getAcceptedTaxonRefId(accTaxonIun.getUuid()); |
|
136 |
} |
|
137 |
|
|
138 |
if(selectedSecItemId != null) { |
|
139 |
secComboBox.setValue(selectedSecItemId); |
|
140 |
} else { |
|
141 |
secComboBox.setInputPrompt(CHOOSE_SECUNDUM_PROMPT); |
|
142 |
} |
|
127 | 143 |
} |
128 | 144 |
} |
129 | 145 |
|
... | ... | |
154 | 170 |
public boolean execute() { |
155 | 171 |
setProgress("Saving Taxon " + nameTextField.getValue()); |
156 | 172 |
IdUuidName taxonBaseIdUuid; |
157 |
if(accTaxonIdUuid == null) {
|
|
158 |
taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),secComboBox.getValue(), classificationIdUuid.getUuid());
|
|
173 |
if(accTaxonIun == null) {
|
|
174 |
taxonBaseIdUuid = listener.newTaxon(nameTextField.getValue(),secComboBox.getValue(), classificationIun.getUuid());
|
|
159 | 175 |
} else { |
160 |
taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),secComboBox.getValue(), accTaxonIdUuid.getUuid());
|
|
176 |
taxonBaseIdUuid = listener.newSynonym(nameTextField.getValue(),secComboBox.getValue(), accTaxonIun.getUuid());
|
|
161 | 177 |
} |
162 | 178 |
Object rowId = new RowId(taxonBaseIdUuid.getId()); |
163 | 179 |
registerDelayedEvent(new CdmChangeEvent(Action.Create, Arrays.asList(rowId), NewTaxonBaseComposite.class)); |
src/main/java/eu/etaxonomy/cdm/vaadin/component/StatusComposite.java | ||
---|---|---|
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
|
181 |
// public void setTaxaTableEnabled(boolean enabled) { |
|
182 |
// taxaTreeTable.setEnabled(enabled); |
|
183 |
// } |
|
184 |
// |
|
185 |
// public void setTaxaTableSelectable(boolean isTaxaTableSelectable) { |
|
186 |
// taxaTreeTable.setSelectable(isTaxaTableSelectable); |
|
187 |
// } |
|
188 |
|
|
189 | 181 |
public TreeTable getTaxaTreeTable() { |
190 | 182 |
return taxaTreeTable; |
191 | 183 |
} |
... | ... | |
235 | 227 |
if(source.getItem(itemId) == null) { |
236 | 228 |
return null; |
237 | 229 |
} |
238 |
Property hasSynProperty = source.getItem(itemId).getItemProperty(LeafNodeTaxonContainer.HAS_SYN_ID); |
|
239 |
if(hasSynProperty == null) { |
|
230 |
if(listener.isSynonym(itemId)) { |
|
240 | 231 |
// this is a synonym, so we activate the corresponding css class |
241 | 232 |
return "synonym"; |
233 |
} else { |
|
234 |
return "taxon"; |
|
242 | 235 |
} |
243 |
return null; |
|
236 |
|
|
244 | 237 |
} |
245 | 238 |
}); |
246 | 239 |
|
247 |
|
|
240 |
taxaTreeTable.setSortContainerPropertyId(LeafNodeTaxonContainer.NAME_ID); |
|
248 | 241 |
|
249 | 242 |
// NOTE : Not really sure why we need to refresh the container here. |
250 | 243 |
// in the case of 'Table' this is not required |
... | ... | |
426 | 419 |
public void itemClick(ItemClickEvent event) { |
427 | 420 |
Object itemId = event.getItemId(); |
428 | 421 |
if(taxaTreeTable.isSelectable()) { |
429 |
if(!listener.isSynonym(itemId)) { |
|
422 |
if(!CdmVaadinUtilities.isSelected(taxaTreeTable, itemId) && !listener.isSynonym(itemId)) {
|
|
430 | 423 |
UUID taxonUuid = listener.getCurrentLeafNodeTaxonContainer().getUuid(itemId); |
431 | 424 |
String taxonName = (String)listener.getCurrentLeafNodeTaxonContainer().getProperty(itemId, LeafNodeTaxonContainer.NAME_ID).getValue(); |
432 | 425 |
Object idUuidName = new IdUuidName(itemId, taxonUuid, taxonName); |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/EditConceptRelationshipPresenter.java | ||
---|---|---|
138 | 138 |
return relTypeToTaxonIunMap; |
139 | 139 |
} |
140 | 140 |
|
141 |
public boolean canCreateRelationship(UUID fromTaxonUuid) { |
|
142 |
TransactionStatus tx = app.startTransaction(); |
|
143 |
Taxon fromTaxon = CdmBase.deproxy(taxonService.load(fromTaxonUuid), Taxon.class); |
|
144 |
boolean canCreateRelationship = true; |
|
145 |
Set<TaxonRelationship> trList = fromTaxon.getRelationsFromThisTaxon(); |
|
146 |
for(TaxonRelationship tr : trList) { |
|
147 |
if(tr.getType() != null && tr.getType().equals(TaxonRelationshipType.CONGRUENT_TO())) { |
|
148 |
canCreateRelationship = false; |
|
149 |
break; |
|
150 |
} |
|
151 |
} |
|
152 |
app.commitTransaction(tx); |
|
153 |
return canCreateRelationship; |
|
154 |
} |
|
155 |
|
|
141 | 156 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/presenter/NewTaxonBasePresenter.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.presenter; |
11 | 11 |
|
12 | 12 |
import java.sql.SQLException; |
... | ... | |
16 | 16 |
|
17 | 17 |
import org.springframework.transaction.TransactionStatus; |
18 | 18 |
|
19 |
import com.vaadin.data.util.sqlcontainer.RowId; |
|
20 |
|
|
19 | 21 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
20 | 22 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
21 | 23 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
... | ... | |
84 | 86 |
NonViralName name = parser.parseFullName(scientificName); |
85 | 87 |
name.setTitleCache(scientificName, true); |
86 | 88 |
Taxon newTaxon = Taxon.NewInstance(name, sec); |
89 |
newTaxon.setUnplaced(true); |
|
87 | 90 |
List<String> CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String []{ |
88 | 91 |
"rootNode.childNodes" |
89 | 92 |
}); |
... | ... | |
118 | 121 |
} |
119 | 122 |
|
120 | 123 |
|
124 |
@Override |
|
125 |
public Object getAcceptedTaxonRefId(UUID accTaxonUuid) { |
|
126 |
Taxon accTaxon = CdmBase.deproxy(taxonService.load(accTaxonUuid), Taxon.class); |
|
127 |
if(accTaxon.getSec() != null) { |
|
128 |
int refId = accTaxon.getSec().getId(); |
|
129 |
RowId itemId = new RowId(refId); |
|
130 |
return itemId; |
|
131 |
} |
|
132 |
return null; |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public Object getClassificationRefId(UUID classificationUuid) { |
|
137 |
Classification classification = CdmBase.deproxy(classificationService.load(classificationUuid), Classification.class); |
|
138 |
if(classification.getReference() != null) { |
|
139 |
int refId = classification.getReference().getId(); |
|
140 |
RowId itemId = new RowId(refId); |
|
141 |
return itemId; |
|
142 |
} |
|
143 |
return null; |
|
144 |
} |
|
145 |
|
|
146 |
|
|
147 |
|
|
121 | 148 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmVaadinUtilities.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.util; |
11 | 11 |
|
12 | 12 |
import java.util.Iterator; |
13 | 13 |
import java.util.List; |
14 |
import java.util.Set; |
|
14 | 15 |
|
16 |
import com.vaadin.ui.AbstractSelect; |
|
15 | 17 |
import com.vaadin.ui.Component; |
16 | 18 |
import com.vaadin.ui.HasComponents; |
17 | 19 |
import com.vaadin.ui.UI; |
... | ... | |
82 | 84 |
} |
83 | 85 |
} |
84 | 86 |
|
87 |
public static boolean isSelected(AbstractSelect select, Object itemId) { |
|
88 |
if(select.getValue() != null) { |
|
89 |
if(select.isMultiSelect()) { |
|
90 |
Set<Object> selectedItemIds = (Set<Object>)select.getValue(); |
|
91 |
for(Object selectedItemId : selectedItemIds) { |
|
92 |
if(selectedItemId.equals(itemId)) { |
|
93 |
return true; |
|
94 |
} |
|
95 |
} |
|
96 |
} else { |
|
97 |
return (select.getValue().equals(itemId)); |
|
98 |
} |
|
99 |
} |
|
100 |
return false; |
|
101 |
} |
|
102 |
|
|
85 | 103 |
|
86 | 104 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/view/ConceptRelationshipView.java | ||
---|---|---|
40 | 40 |
import eu.etaxonomy.cdm.vaadin.session.IBasicEventListener; |
41 | 41 |
import eu.etaxonomy.cdm.vaadin.session.SelectionEvent; |
42 | 42 |
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinSessionUtilities; |
43 |
import eu.etaxonomy.cdm.vaadin.util.CdmVaadinUtilities; |
|
43 | 44 |
|
44 | 45 |
/** |
45 | 46 |
* @author cmathew |
... | ... | |
180 | 181 |
toTaxonIun = new IdUuidName(targetItemId, |
181 | 182 |
targetContainer.getUuid(targetItemId), |
182 | 183 |
toName); |
183 |
CdmVaadinSessionUtilities.getCurrentSelectionService() |
|
184 |
if(!CdmVaadinUtilities.isSelected(sourceTable, sourceItemId)) { |
|
185 |
CdmVaadinSessionUtilities.getCurrentSelectionService() |
|
184 | 186 |
.fireSelectionEvent(new SelectionEvent(Arrays.asList(fromTaxonIun, sourceSc.getSelectedClassificationUuid()), StatusComposite.class), false); |
187 |
} |
|
188 |
sourceTable.setValue(Arrays.asList(sourceItemId)); |
|
185 | 189 |
EditConceptRelationshipComposite.showInDialog(ConceptRelationshipComposite.CREATE_NEW_CR_TITLE, |
186 | 190 |
fromTaxonIun, |
187 | 191 |
null, |
src/main/java/eu/etaxonomy/cdm/vaadin/view/INewTaxonBaseComponentListener.java | ||
---|---|---|
43 | 43 |
public IdUuidName newSynonym(String scientificName, Object secRefItemId, UUID accTaxonUuid); |
44 | 44 |
|
45 | 45 |
|
46 |
/** |
|
47 |
* @param accTaxonUuid |
|
48 |
* @return |
|
49 |
*/ |
|
50 |
public Object getAcceptedTaxonRefId(UUID accTaxonUuid); |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* @param classificationUuid |
|
55 |
* @return |
|
56 |
*/ |
|
57 |
public Object getClassificationRefId(UUID classificationUuid); |
|
58 |
|
|
59 |
|
|
46 | 60 |
|
47 | 61 |
|
48 | 62 |
|
src/main/resources/eu/etaxonomy/cdm/vaadin/jscomponent/lib/d3.conceptrelationshiptree_connector.js | ||
---|---|---|
35 | 35 |
"rightleft": { |
36 | 36 |
size: [height, width], |
37 | 37 |
x: function(d) { return width - d.y; }, |
38 |
y: function(d) { return d.x; } |
|
38 |
y: function(d) { return d.x; }, |
|
39 |
xend: function(d) { return d.y; }, |
|
39 | 40 |
}, |
40 | 41 |
"bottomtop": { |
41 | 42 |
size: [width, height], |
... | ... | |
45 | 46 |
"leftright": { |
46 | 47 |
size: [height, width], |
47 | 48 |
x: function(d) { return d.y; }, |
48 |
y: function(d) { return d.x; } |
|
49 |
y: function(d) { return d.x; }, |
|
50 |
xend: function(d) { return width - d.y; }, |
|
49 | 51 |
} |
50 | 52 |
}; |
51 | 53 |
// default setting is left-right |
... | ... | |
133 | 135 |
// Transition exiting nodes to the parent's new position. |
134 | 136 |
var nodeExit = node.exit().transition() |
135 | 137 |
.duration(duration) |
136 |
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
|
|
138 |
.attr("transform", function(d) { return "translate(" + orientation.xend(source) + "," + orientation.y(source) + ")"; })
|
|
137 | 139 |
.remove(); |
138 | 140 |
|
139 | 141 |
nodeExit.select("circle") |
... | ... | |
146 | 148 |
var link = svg.selectAll("path.link") |
147 | 149 |
.data(links, function(d) { return d.target.id; }); |
148 | 150 |
|
149 |
// Transition exiting nodes to the parent's new position. |
|
150 |
link.exit().transition() |
|
151 |
.duration(duration) |
|
152 |
.attr("d", function(d) { |
|
153 |
var o = {x: source.x, y: source.y}; |
|
154 |
return diagonal({source: o, target: o}); |
|
155 |
}) |
|
156 |
.remove(); |
|
151 |
// Remove links without transition |
|
152 |
link.exit().remove(); |
|
157 | 153 |
|
158 | 154 |
// Enter any new links at the parent's previous position. |
159 | 155 |
link.enter().insert("path", "g") |
src/main/webapp/VAADIN/themes/edit/edit.scss | ||
---|---|---|
37 | 37 |
/* Style specifically for the row header cells. */ |
38 | 38 |
.v-table-cell-content-synonym { |
39 | 39 |
font-style: italic; |
40 |
text-indent: 10px |
|
40 |
text-indent: 10px |
|
41 |
} |
|
42 |
|
|
43 |
.v-table-cell-content-taxon { |
|
44 |
font-style: italic; |
|
41 | 45 |
} |
42 | 46 |
|
43 | 47 |
.cr-arrow .v-icon { |
src/main/webapp/VAADIN/themes/edit/styles.css | ||
---|---|---|
5898 | 5898 |
text-indent: 10px; |
5899 | 5899 |
} |
5900 | 5900 |
|
5901 |
.edit .v-table-cell-content-taxon { |
|
5902 |
font-style: italic; |
|
5903 |
} |
|
5904 |
|
|
5901 | 5905 |
.edit .cr-arrow .v-icon { |
5902 | 5906 |
color: #006666; |
5903 | 5907 |
font-size: 30px; |
Also available in: Unified diff
EditConceptRelationshipComposite, EditConceptRelationshipPresenter : hack for checking relationship rules (currently only for congruence)
INewTaxonBaseComponentListener, NewTaxonBaseComposite, NewTaxonBasePresenter : Setting default secundum when addin taxon / synonym
StatusComposite, ConceptRelationshipView : added check for already selected item in taxon table
CdmVaadinUtilities : added utility method to check if given item is selected
d3.conceptrelationshiptree_connector.js : cleaned up transition for nodes + removed transition for links
edit.scss, styles.css : added italics also for taxon