Revision b0ce5b17
Added by Patrick Plitzner over 10 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailSection.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
11 | 11 |
package eu.etaxonomy.taxeditor.ui.section.name; |
12 | 12 |
|
13 | 13 |
import org.eclipse.jface.action.Action; |
14 |
import org.eclipse.jface.action.IAction; |
|
14 | 15 |
import org.eclipse.jface.action.ToolBarManager; |
15 | 16 |
import org.eclipse.jface.viewers.ISelectionProvider; |
16 | 17 |
import org.eclipse.swt.SWT; |
... | ... | |
20 | 21 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
21 | 22 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
22 | 23 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
23 |
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
|
24 |
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
|
24 | 25 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
25 | 26 |
import eu.etaxonomy.taxeditor.ui.element.CdmPropertyChangeEvent; |
26 | 27 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
27 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
|
|
28 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
|
|
28 | 29 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
29 | 30 |
import eu.etaxonomy.taxeditor.ui.section.ITaxonBaseDetailSection; |
30 | 31 |
|
... | ... | |
53 | 54 |
ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) { |
54 | 55 |
super(formFactory, conversation, parentElement, selectionProvider, style); |
55 | 56 |
} |
56 |
|
|
57 |
|
|
57 | 58 |
/* (non-Javadoc) |
58 | 59 |
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#createToolbar() |
59 | 60 |
*/ |
60 | 61 |
@Override |
61 | 62 |
protected Control createToolbar() { |
62 | 63 |
ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); |
63 |
|
|
64 |
|
|
64 | 65 |
if(getEntity() != null && checkForMultipleNameUsages(getEntity())){ |
65 |
|
|
66 |
Action cloneAction = new Action("Clone", Action.AS_PUSH_BUTTON){ |
|
67 |
public void run() { |
|
68 |
boolean confirm = StoreUtil.confirmDialog("Confirm cloning", "Do you really want to clone the name?"); |
|
69 |
|
|
66 |
|
|
67 |
Action cloneAction = new Action("Clone", IAction.AS_PUSH_BUTTON){ |
|
68 |
@Override |
|
69 |
public void run() { |
|
70 |
boolean confirm = AbstractUtility.confirmDialog("Confirm cloning", "Do you really want to clone the name?"); |
|
71 |
|
|
70 | 72 |
if(confirm){ |
71 | 73 |
NonViralName clonedName; |
72 | 74 |
clonedName = (NonViralName) getEntity().clone(); |
... | ... | |
76 | 78 |
// EditorUtil.getActiveMultiPageTaxonEditor().r |
77 | 79 |
firePropertyChangeEvent(new CdmPropertyChangeEvent(NonViralNameDetailSection.this, null)); |
78 | 80 |
} |
79 |
|
|
81 |
|
|
80 | 82 |
}; |
81 | 83 |
}; |
82 |
|
|
84 |
|
|
83 | 85 |
cloneAction.setToolTipText("Clone the name if you do not want to edit the shared instance"); |
84 |
|
|
86 |
|
|
85 | 87 |
toolBarManager.add(cloneAction); |
86 |
|
|
88 |
|
|
87 | 89 |
} |
88 | 90 |
return toolBarManager.createControl(this); |
89 | 91 |
} |
90 |
|
|
92 |
|
|
91 | 93 |
|
92 | 94 |
/** |
93 |
* @param nonViralName
|
|
94 |
*
|
|
95 |
* @param nonViralName |
|
96 |
* |
|
95 | 97 |
*/ |
96 | 98 |
private boolean checkForMultipleNameUsages(NonViralName nonViralName) { |
97 | 99 |
return nonViralName.getTaxonBases().size() != 1; |
98 | 100 |
} |
99 |
|
|
100 |
/* (non-Javadoc) |
|
101 |
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getDetailType() |
|
102 |
*/ |
|
103 |
/** {@inheritDoc} */ |
|
104 |
@Override |
|
105 |
protected DetailType getDetailType() { |
|
106 |
return DetailType.NONVIRALNAME; |
|
107 |
} |
|
108 | 101 |
|
109 | 102 |
/* (non-Javadoc) |
110 | 103 |
* @see eu.etaxonomy.taxeditor.section.AbstractCdmDetailSection#getHeading() |
... | ... | |
119 | 112 |
* @see eu.etaxonomy.taxeditor.section.ITaxonDetailSection#setTaxon(eu.etaxonomy.cdm.model.taxon.TaxonBase) |
120 | 113 |
*/ |
121 | 114 |
/** {@inheritDoc} */ |
122 |
public void setTaxonBase(TaxonBase taxon) { |
|
115 |
@Override |
|
116 |
public void setTaxonBase(TaxonBase taxon) { |
|
123 | 117 |
taxonBase = taxon; |
124 | 118 |
NonViralName name = (NonViralName) HibernateProxyHelper.deproxy(taxon.getName()); |
125 | 119 |
setEntity(name); |
... | ... | |
132 | 126 |
public TaxonBase getTaxonBase() { |
133 | 127 |
return taxonBase; |
134 | 128 |
} |
129 |
|
|
130 |
/* (non-Javadoc) |
|
131 |
* @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int) |
|
132 |
*/ |
|
133 |
@Override |
|
134 |
protected AbstractCdmDetailElement<NonViralName> createCdmDetailElement(AbstractCdmDetailSection<NonViralName> parentElement, int style) { |
|
135 |
return formFactory.createNonViralNameDetailElement(parentElement); |
|
136 |
} |
|
135 | 137 |
} |
Also available in: Unified diff
merged trunk into branch