13 |
13 |
import java.util.List;
|
14 |
14 |
import java.util.Set;
|
15 |
15 |
|
|
16 |
import org.apache.commons.lang.StringUtils;
|
16 |
17 |
import org.eclipse.core.runtime.Assert;
|
17 |
18 |
import org.eclipse.jface.dialogs.Dialog;
|
18 |
19 |
import org.eclipse.jface.text.IDocument;
|
... | ... | |
47 |
48 |
|
48 |
49 |
import eu.etaxonomy.cdm.common.CdmUtils;
|
49 |
50 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
|
51 |
import eu.etaxonomy.cdm.model.common.CdmBase;
|
50 |
52 |
import eu.etaxonomy.cdm.model.name.INonViralName;
|
51 |
53 |
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
52 |
54 |
import eu.etaxonomy.cdm.model.name.TaxonName;
|
... | ... | |
90 |
92 |
* @author p.ciardelli
|
91 |
93 |
* @author n.hoffmann
|
92 |
94 |
* @created 02.06.2008
|
93 |
|
* @version 1.0
|
94 |
95 |
*/
|
95 |
96 |
abstract public class AbstractGroupedContainer<T extends TaxonBase> implements
|
96 |
97 |
IFormPart, IContainerConstants, IElementHasDetails {
|
... | ... | |
314 |
315 |
*/
|
315 |
316 |
public void showAnnotations() {
|
316 |
317 |
|
317 |
|
if (getName().hasProblem()) {
|
|
318 |
if (getName() != null && getName().hasProblem()) {
|
318 |
319 |
showParsingProblems();
|
319 |
320 |
}
|
320 |
321 |
|
... | ... | |
340 |
341 |
private void showParsingProblems() {
|
341 |
342 |
String text = getNameViewer().getTextWidget().getText();
|
342 |
343 |
|
343 |
|
List<ParserProblem> parsingProblems = getName().getParsingProblems();
|
|
344 |
TaxonName name = getName();
|
|
345 |
if (name == null){
|
|
346 |
return;
|
|
347 |
}
|
|
348 |
|
|
349 |
List<ParserProblem> parsingProblems = name.getParsingProblems();
|
344 |
350 |
|
345 |
351 |
for (ParserProblem problem : parsingProblems) {
|
346 |
352 |
getNameViewer().addAnnotation(new EditorAnnotation(problem),
|
... | ... | |
351 |
357 |
private Position getParsingProblemPosition() {
|
352 |
358 |
String text = getNameViewer().getTextWidget().getText();
|
353 |
359 |
|
354 |
|
if (getName().hasProblem() && text.length() > 0) {
|
|
360 |
if (getName() != null && getName().hasProblem() && text.length() > 0) {
|
355 |
361 |
int start = getName().getProblemStarts();
|
356 |
362 |
int length = getName().getProblemEnds() - start;
|
357 |
363 |
|
... | ... | |
450 |
456 |
* @return
|
451 |
457 |
*/
|
452 |
458 |
private boolean isFreetextEditingAllowed() {
|
453 |
|
INonViralName name = (INonViralName) HibernateProxyHelper
|
454 |
|
.deproxy(getName());
|
455 |
459 |
boolean enableFreetext = true;
|
456 |
460 |
|
457 |
461 |
enableFreetext |= isNameUsedMultipleTimes();
|
... | ... | |
468 |
472 |
*/
|
469 |
473 |
private boolean isNameUsedMultipleTimes() {
|
470 |
474 |
|
471 |
|
Set<TaxonBase> taxonBases = getName().getTaxonBases();
|
472 |
|
Iterator<TaxonBase> tbItr = taxonBases.iterator();
|
473 |
|
int nonOrphanedTaxonBaseCount = taxonBases.size();
|
474 |
|
|
475 |
|
while(tbItr.hasNext()) {
|
476 |
|
TaxonBase tb = tbItr.next();
|
477 |
|
if(tb.isOrphaned()) {
|
478 |
|
nonOrphanedTaxonBaseCount--;
|
|
475 |
TaxonName name = getName();
|
|
476 |
if (name != null){
|
|
477 |
Set<TaxonBase> taxonBases = name.getTaxonBases();
|
|
478 |
Iterator<TaxonBase> tbItr = taxonBases.iterator();
|
|
479 |
int nonOrphanedTaxonBaseCount = taxonBases.size();
|
|
480 |
|
|
481 |
while(tbItr.hasNext()) {
|
|
482 |
TaxonBase<?> tb = tbItr.next();
|
|
483 |
if(tb.isOrphaned()) {
|
|
484 |
nonOrphanedTaxonBaseCount--;
|
|
485 |
}
|
|
486 |
}
|
|
487 |
if(nonOrphanedTaxonBaseCount > 1) {
|
|
488 |
return true;
|
479 |
489 |
}
|
480 |
|
}
|
481 |
|
if(nonOrphanedTaxonBaseCount > 1) {
|
482 |
|
return true;
|
483 |
490 |
}
|
484 |
491 |
return false;
|
485 |
492 |
}
|
486 |
493 |
|
487 |
494 |
private boolean isNameParsable() {
|
488 |
495 |
TaxonName name = getName();
|
|
496 |
if (name == null){
|
|
497 |
return false;
|
|
498 |
}
|
489 |
499 |
|
490 |
500 |
boolean isParsable = true;
|
491 |
|
isParsable &= CdmUtils.isEmpty(name.getAppendedPhrase()); // taxonFieldsEmpty();
|
|
501 |
isParsable &= StringUtils.isBlank(name.getAppendedPhrase()); // taxonFieldsEmpty();
|
492 |
502 |
|
493 |
503 |
isParsable &= !name.isProtectedAuthorshipCache();
|
494 |
504 |
isParsable &= !name.isProtectedNameCache();
|
... | ... | |
526 |
536 |
* @return a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
|
527 |
537 |
*/
|
528 |
538 |
public TaxonName getName() {
|
529 |
|
return HibernateProxyHelper.deproxy(getTaxonBase()
|
530 |
|
.getName());
|
|
539 |
return CdmBase.deproxy(getTaxonBase().getName());
|
531 |
540 |
}
|
532 |
541 |
|
533 |
542 |
/**
|
handle some more cases for taxa without name and add some invalid name types to use invalid icon