Revision e11bc05e
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractCdmDetailElement.java | ||
---|---|---|
47 | 47 |
* @author n.hoffmann |
48 | 48 |
* @created Feb 26, 2010 |
49 | 49 |
*/ |
50 |
public abstract class AbstractCdmDetailElement<T> extends AbstractCdmFormElement implements ICdmDetailElement<T>, Observer, IEnableableFormElement{
|
|
50 |
public abstract class AbstractCdmDetailElement<T> extends AbstractCdmFormElement implements ICdmDetailElement<T>, Observer{ |
|
51 | 51 |
|
52 | 52 |
private T entity; |
53 | 53 |
|
... | ... | |
106 | 106 |
removeElements(); |
107 | 107 |
createControls(this, entity, SWT.NONE); |
108 | 108 |
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true); |
109 |
|
|
110 | 109 |
updateControlStates(); |
111 | 110 |
} |
112 | 111 |
|
... | ... | |
215 | 214 |
ICdmFormElement eventElement = (ICdmFormElement) eventSource; |
216 | 215 |
ICdmFormElement eventElementContainer = eventElement |
217 | 216 |
.getParentElement(); |
218 |
|
|
217 |
ICdmFormElement parent = this.getParentElement(); |
|
219 | 218 |
if (eventElementContainer == this) { |
220 | 219 |
if (event instanceof CdmPropertyChangeEvent) { |
221 | 220 |
if (((CdmPropertyChangeEvent) event).hasException()) { |
... | ... | |
311 | 310 |
this.warnForReferencedObjects = warnForReferencedObjects; |
312 | 311 |
} |
313 | 312 |
|
314 |
public void setWarnForReferencingObjects(ICdmFormElement formElement){ |
|
313 |
public void setWarnForReferencingObjects(ICdmFormElement formElement, int defaultReferencingObjects){
|
|
315 | 314 |
if (getEntity() instanceof CdmBase){ |
316 | 315 |
CdmBase cdmBase = (CdmBase) getEntity(); |
317 | 316 |
if (cdmBase.getId() != 0){ |
318 | 317 |
long referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(cdmBase); |
319 | 318 |
|
320 |
if (referencingObjectsCount > 1){
|
|
319 |
if (referencingObjectsCount > defaultReferencingObjects){
|
|
321 | 320 |
setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The "+ cdmBase.getUserFriendlyTypeName()+" is referenced by " + referencingObjectsCount+ " objects, if you change it, it is changed for all these objects"))); |
322 | 321 |
getWarnForReferencedObjects().setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
323 | 322 |
getWarnForReferencedObjects().setLayout(LayoutConstants.FILL(2, 3)); |
... | ... | |
328 | 327 |
} |
329 | 328 |
} |
330 | 329 |
|
330 |
public void setWarnForReferencingObjects(ICdmFormElement formElement){ |
|
331 |
setWarnForReferencingObjects(formElement, 1); |
|
332 |
} |
|
333 |
|
|
331 | 334 |
public void setWarnForReferencingObjectsVisible(boolean isVisible){ |
332 | 335 |
if (getWarnForReferencedObjects() != null){ |
333 | 336 |
getWarnForReferencedObjects().setVisible(isVisible); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java | ||
---|---|---|
16 | 16 |
import org.eclipse.swt.graphics.Color; |
17 | 17 |
import org.eclipse.swt.widgets.Button; |
18 | 18 |
import org.eclipse.swt.widgets.Composite; |
19 |
import org.eclipse.swt.widgets.Display; |
|
19 | 20 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
20 | 21 |
|
21 | 22 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
22 | 23 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; |
24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
23 | 26 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap; |
24 | 27 |
import eu.etaxonomy.taxeditor.model.ImageResources; |
28 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
25 | 29 |
import eu.etaxonomy.taxeditor.ui.element.AbstractCdmFormElement; |
26 | 30 |
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection; |
27 | 31 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
28 | 32 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
29 | 33 |
import eu.etaxonomy.taxeditor.ui.element.IEntityElement; |
30 | 34 |
import eu.etaxonomy.taxeditor.ui.element.ISelectable; |
35 |
import eu.etaxonomy.taxeditor.ui.element.LabelElement; |
|
31 | 36 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
32 | 37 |
|
33 | 38 |
/** |
... | ... | |
57 | 62 |
|
58 | 63 |
private Color backgroundColor; |
59 | 64 |
|
65 |
private LabelElement warnForReferencedObjects; |
|
66 |
|
|
60 | 67 |
public AbstractEntityCollectionElement(CdmFormFactory formFactory, |
61 | 68 |
AbstractFormSection section, ENTITY entity, SelectionListener removeListener, |
62 | 69 |
Color backgroundColor, int style) { |
... | ... | |
218 | 225 |
@Override |
219 | 226 |
public void update(CdmDataChangeMap changeEvents) { |
220 | 227 |
} |
228 |
|
|
229 |
public void setWarnForReferencedObjects(LabelElement warnForReferencedObjects) { |
|
230 |
this.warnForReferencedObjects = warnForReferencedObjects; |
|
231 |
} |
|
232 |
|
|
233 |
public void setWarnForReferencingObjects(ICdmFormElement formElement, int defaultReferencingObjects){ |
|
234 |
if (entity instanceof CdmBase){ |
|
235 |
CdmBase cdmBase = (CdmBase)entity; |
|
236 |
if (cdmBase.getId() != 0){ |
|
237 |
long referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(cdmBase); |
|
238 |
|
|
239 |
if (referencingObjectsCount > defaultReferencingObjects){ |
|
240 |
setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The "+ cdmBase.getUserFriendlyTypeName()+" is referenced by more than one object, if you change it, it is changed for all these objects"))); |
|
241 |
warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
242 |
warnForReferencedObjects.setLayout(LayoutConstants.FILL(2, 3)); |
|
243 |
warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
244 |
} |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
public void setWarnForReferencingObjects(ICdmFormElement formElement){ |
|
250 |
setWarnForReferencingObjects(formElement, 1); |
|
251 |
} |
|
252 |
|
|
253 |
public void setWarnForReferencingObjectsVisible(boolean isVisible){ |
|
254 |
if (warnForReferencedObjects != null){ |
|
255 |
warnForReferencedObjects.setVisible(isVisible); |
|
256 |
} |
|
257 |
} |
|
221 | 258 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractIdentifiableEntityDetailElement.java | ||
---|---|---|
6 | 6 |
import java.util.Arrays; |
7 | 7 |
import java.util.EnumSet; |
8 | 8 |
|
9 |
import org.eclipse.swt.SWT; |
|
10 |
import org.eclipse.swt.widgets.Display; |
|
11 |
|
|
12 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
13 | 9 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
14 | 10 |
import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; |
15 | 11 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD; |
... | ... | |
18 | 14 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
19 | 15 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
20 | 16 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
21 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
22 | 17 |
import eu.etaxonomy.taxeditor.ui.element.ToggleableTextElement; |
23 | 18 |
|
24 | 19 |
/** |
... | ... | |
42 | 37 |
|
43 | 38 |
} |
44 | 39 |
|
40 |
|
|
45 | 41 |
public void updateToggleableCacheField() { |
46 | 42 |
if (toggleable_cache != null){ |
47 | 43 |
if (!getEntity().isProtectedTitleCache()) { |
... | ... | |
79 | 75 |
} |
80 | 76 |
} |
81 | 77 |
|
82 |
|
|
78 |
|
|
83 | 79 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import java.util.Map; |
7 | 7 |
|
8 |
import org.eclipse.swt.SWT; |
|
9 | 8 |
import org.eclipse.swt.events.SelectionListener; |
10 |
import org.eclipse.swt.widgets.Display; |
|
11 | 9 |
|
12 | 10 |
import eu.etaxonomy.cdm.common.CdmUtils; |
13 | 11 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
14 | 12 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
15 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
16 | 13 |
import eu.etaxonomy.cdm.model.common.Language; |
17 | 14 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
18 | 15 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
... | ... | |
24 | 21 |
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory; |
25 | 22 |
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement; |
26 | 23 |
import eu.etaxonomy.taxeditor.ui.element.ISelectableElement; |
27 |
import eu.etaxonomy.taxeditor.ui.element.LabelElement; |
|
28 | 24 |
import eu.etaxonomy.taxeditor.ui.element.LanguageStringWithLabelElement; |
29 |
import eu.etaxonomy.taxeditor.ui.element.LayoutConstants; |
|
30 | 25 |
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator; |
31 | 26 |
import eu.etaxonomy.taxeditor.ui.element.TimePeriodElement; |
32 | 27 |
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection; |
... | ... | |
46 | 41 |
private MediaDetailElement mediaDetailElement; |
47 | 42 |
private TimePeriodElement mediaCreated; |
48 | 43 |
private SelectionArbitrator selectionArbitrator; |
49 |
private LabelElement warnForReferencedObjects; |
|
44 |
|
|
50 | 45 |
|
51 | 46 |
public MediaMetaElement(CdmFormFactory cdmFormFactory, |
52 | 47 |
AbstractFormSection<?> formElement, Media element, |
... | ... | |
155 | 150 |
return selectionArbitrator; |
156 | 151 |
} |
157 | 152 |
|
158 |
public void setWarnForReferencedObjects(LabelElement warnForReferencedObjects) { |
|
159 |
this.warnForReferencedObjects = warnForReferencedObjects; |
|
160 |
} |
|
161 |
|
|
162 |
public void setWarnForReferencingObjects(ICdmFormElement formElement, int defaultReferencingObjects){ |
|
163 |
if (getEntity() instanceof CdmBase){ |
|
164 |
CdmBase cdmBase = getEntity(); |
|
165 |
if (cdmBase.getId() != 0){ |
|
166 |
long referencingObjectsCount = CdmStore.getCommonService().getReferencingObjectsCount(cdmBase); |
|
167 |
|
|
168 |
if (referencingObjectsCount > defaultReferencingObjects){ |
|
169 |
setWarnForReferencedObjects(formFactory.createLabel(formElement, CdmUtils.Nz("The "+ cdmBase.getUserFriendlyTypeName()+" is referenced by more than one object, if you change it, it is changed for all these objects"))); |
|
170 |
warnForReferencedObjects.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
171 |
warnForReferencedObjects.setLayout(LayoutConstants.FILL(2, 3)); |
|
172 |
warnForReferencedObjects.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
178 |
public void setWarnForReferencingObjects(ICdmFormElement formElement){ |
|
179 |
setWarnForReferencingObjects(formElement, 1); |
|
180 |
} |
|
181 | 153 |
|
182 |
public void setWarnForReferencingObjectsVisible(boolean isVisible){ |
|
183 |
if (warnForReferencedObjects != null){ |
|
184 |
warnForReferencedObjects.setVisible(isVisible); |
|
185 |
} |
|
186 |
} |
|
187 | 154 |
|
188 | 155 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NameRelationshipDetailElement.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
53 | 53 |
NameRelationship entity, SelectionListener removeListener, int style) { |
54 | 54 |
super(cdmFormFactory, formElement, entity, removeListener, style); |
55 | 55 |
} |
56 |
|
|
56 |
|
|
57 | 57 |
/* (non-Javadoc) |
58 | 58 |
* @see eu.etaxonomy.taxeditor.forms.entitysections.AbstractEntitySetElementComposite#createControls(org.eclipse.swt.widgets.Composite, int) |
59 | 59 |
*/ |
... | ... | |
61 | 61 |
@Override |
62 | 62 |
public void createControls(ICdmFormElement element, int style) { |
63 | 63 |
label = formFactory.createLabel(element, null); |
64 |
|
|
64 |
|
|
65 | 65 |
text_ruleConsidered = formFactory.createTextWithLabelElement(element, "Rule Considered", null, SWT.NULL); |
66 |
|
|
66 |
|
|
67 | 67 |
super.createControls(element, style); |
68 | 68 |
} |
69 |
|
|
69 |
|
|
70 | 70 |
/** {@inheritDoc} */ |
71 | 71 |
@Override |
72 | 72 |
public void setEntity(NameRelationship entity) { |
73 | 73 |
String text = entity.getFromName().getTitleCache() + " is " + entity.getType().getLabel() + " " + entity.getToName().getTitleCache(); |
74 |
|
|
74 |
|
|
75 | 75 |
label.setText(text); |
76 | 76 |
text_ruleConsidered.setText(entity.getRuleConsidered()); |
77 |
|
|
78 |
super.setEntity(entity);
|
|
77 |
|
|
78 |
super.setEntity(entity); |
|
79 | 79 |
} |
80 |
|
|
80 |
|
|
81 | 81 |
/** {@inheritDoc} */ |
82 | 82 |
@Override |
83 | 83 |
public void handleEvent(Object eventSource) { |
... | ... | |
97 | 97 |
getEntity().setCitationMicroReference(text_referenceDetail.getText()); |
98 | 98 |
} |
99 | 99 |
} |
100 |
|
|
100 |
|
|
101 | 101 |
/** {@inheritDoc} */ |
102 | 102 |
@Override |
103 | 103 |
public void setBackground(Color color) { |
104 |
if(label != null) |
|
105 |
label.setBackground(color); |
|
104 |
if(label != null) { |
|
105 |
label.setBackground(color); |
|
106 |
} |
|
106 | 107 |
super.setBackground(color); |
107 | 108 |
} |
108 | 109 |
|
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/ReferenceDetailElement.java | ||
---|---|---|
103 | 103 |
@Override |
104 | 104 |
protected void createControls(ICdmFormElement formElement, |
105 | 105 |
Reference entity, int style) { |
106 |
if (isWizard){ |
|
107 |
setWarnForReferencingObjects(formElement); |
|
108 |
} |
|
109 |
|
|
106 |
setWarnForReferencingObjects(formElement); |
|
110 | 107 |
toggleable_cache = formFactory.createToggleableTextField(formElement, |
111 | 108 |
"Reference Cache", entity.getTitleCache(), |
112 | 109 |
entity.isProtectedTitleCache(), style); |
Also available in: Unified diff
add warning for referencing objects in details view and code cleaning