Project

General

Profile

« Previous | Next » 

Revision f4fd193c

Added by Niels Hoffmann about 13 years ago

Improving polytomous key handling

View differences:

.gitattributes
346 346
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditor.java -text
347 347
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyEditorInput.java -text
348 348
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyLabelProvider.java -text
349
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyRelationship.java -text
350 349
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/CreateNodeHandler.java -text
351 350
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/handler/DeleteNodeHandler.java -text
352 351
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/CreateNodeOperation.java -text
......
788 787
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MultiLanguageText.java -text
789 788
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/NameHelper.java -text
790 789
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/NomenclaturalCodeHelper.java -text
790
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/PolytomousKeyRelationship.java -text
791 791
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxeditorPartService.java -text
792 792
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TaxonTransfer.java -text
793 793
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/TextHelper.java -text
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/AbstractKeyEditor.java
30 30
import org.eclipse.zest.core.widgets.ZestStyles;
31 31
import org.eclipse.zest.layouts.LayoutAlgorithm;
32 32
import org.eclipse.zest.layouts.LayoutStyles;
33
import org.eclipse.zest.layouts.algorithms.CompositeLayoutAlgorithm;
34
import org.eclipse.zest.layouts.algorithms.HorizontalShift;
33 35
import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;
34 36

  
35 37
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
......
151 153

  
152 154
			@Override
153 155
			public void controlResized(ControlEvent e) {
154
				applyLayout();
156
				// applyLayout();
155 157
			}
156 158

  
157 159
			@Override
......
203 205

  
204 206
	public void refresh() {
205 207
		graphViewer.refresh();
206
		graphViewer.applyLayout();
208
		// graphViewer.applyLayout();
207 209
	}
208 210

  
209 211
	@Override
......
218 220

  
219 221
	private LayoutAlgorithm getLayoutAlgoritm() {
220 222
		if (layoutAlgoritm == null) {
221
			layoutAlgoritm = new TreeLayoutAlgorithm(
222
					LayoutStyles.NO_LAYOUT_NODE_RESIZING);
223
			layoutAlgoritm.setEntityAspectRatio(2.5);
223
			layoutAlgoritm = new CompositeLayoutAlgorithm(
224
					LayoutStyles.NO_LAYOUT_NODE_RESIZING,
225
					new LayoutAlgorithm[] {
226
							new TreeLayoutAlgorithm(
227
									LayoutStyles.NO_LAYOUT_NODE_RESIZING),
228
							new HorizontalShift(
229
									LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
230

  
231
			// layoutAlgoritm = new TreeLayoutAlgorithm(
232
			// LayoutStyles.NO_LAYOUT_NODE_RESIZING);
233
			// layoutAlgoritm.setEntityAspectRatio(2.5);
224 234
		}
225 235
		return layoutAlgoritm;
226 236
	}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyContentProvider.java
18 18

  
19 19
import eu.etaxonomy.cdm.model.description.PolytomousKey;
20 20
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
21
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
21 22

  
22 23
/**
23 24
 * 
......
56 57
		if (parent instanceof PolytomousKeyNode) {
57 58
			children = ((PolytomousKeyNode) parent).getChildren();
58 59
		} else if (parent instanceof PolytomousKey) {
59
			children = ((PolytomousKey) parent).getRoot().getChildren();
60
			children = new ArrayList<PolytomousKeyNode>();
61
			children.add(((PolytomousKey) parent).getRoot());
60 62
		} else {
61 63
			throw new RuntimeException(
62 64
					"Parent element has to be PolytomousKeyNode or PolytomousKey, but was: "
......
71 73

  
72 74
	@Override
73 75
	public Object getSource(Object relationship) {
74
		return ((PolytomousKeyRelationship) relationship).source;
76
		return ((PolytomousKeyRelationship) relationship).getSource();
75 77
	}
76 78

  
77 79
	@Override
78 80
	public Object getDestination(Object relationship) {
79
		return ((PolytomousKeyRelationship) relationship).destination;
81
		return ((PolytomousKeyRelationship) relationship).getDestination();
80 82
	}
81 83

  
82 84
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyLabelProvider.java
11 11
package eu.etaxonomy.taxeditor.editor.key.polytomous;
12 12

  
13 13
import org.apache.commons.lang.StringUtils;
14
import org.eclipse.draw2d.IFigure;
14 15
import org.eclipse.jface.viewers.LabelProvider;
16
import org.eclipse.swt.graphics.Color;
17
import org.eclipse.zest.core.viewers.IEntityStyleProvider;
15 18

  
16
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
17 19
import eu.etaxonomy.cdm.model.common.Language;
18 20
import eu.etaxonomy.cdm.model.description.KeyStatement;
19 21
import eu.etaxonomy.cdm.model.description.PolytomousKey;
20 22
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
23
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
21 24
import eu.etaxonomy.taxeditor.store.CdmStore;
22 25

  
23 26
/**
......
26 29
 * @created Mar 30, 2011
27 30
 * @version 1.0
28 31
 */
29
class PolytomousKeyLabelProvider extends LabelProvider {
32
class PolytomousKeyLabelProvider extends LabelProvider implements
33
		IEntityStyleProvider {
30 34

  
31 35
	public static final String LEAF_BUT_NO_TAXON = "leaf but no taxon";
32 36
	public static final String NO_NODE_NUMBER = "No node number set";
......
50 54
				String statementLabel = "";
51 55
				String nodeNumber = keyNode.getNodeNumber().toString();
52 56

  
53
				KeyStatement statement = keyNode.getStatement();
57
				KeyStatement question = keyNode.getQuestion();
54 58

  
55
				if (statement != null) {
59
				if (question != null) {
56 60
					statementLabel += " "
57
							+ statement.getLabelText(CdmStore
61
							+ question.getLabelText(CdmStore
58 62
									.getDefaultLanguage());
59 63
				}
60 64

  
......
64 68
			}
65 69
		} else if (element instanceof PolytomousKeyRelationship) {
66 70
			PolytomousKeyRelationship relationship = (PolytomousKeyRelationship) element;
67
			if (relationship.source instanceof PolytomousKeyNode) {
68
				PolytomousKeyNode sourceNode = (PolytomousKeyNode) relationship.source;
71
			if (relationship.getSource() instanceof PolytomousKeyNode) {
72
				PolytomousKeyNode destinationNode = (PolytomousKeyNode) relationship
73
						.getDestination();
69 74

  
70
				KeyStatement question = (KeyStatement) HibernateProxyHelper
71
						.deproxy(sourceNode.getQuestion());
75
				KeyStatement statement = destinationNode.getStatement();
72 76

  
73
				if (question != null) {
77
				if (statement != null) {
74 78
					Language language = CdmStore.getDefaultLanguage();
75
					String questionLabel = sourceNode.getQuestion()
76
							.getLabelText(language);
79
					String statementLabel = statement.getLabelText(language);
77 80

  
78
					return StringUtils.isEmpty(questionLabel) ? EMPTY
79
							: questionLabel;
81
					return StringUtils.isEmpty(statementLabel) ? EMPTY
82
							: statementLabel;
80 83
				}
81 84
			}
82 85
		}
83 86
		return EMPTY;
84 87
	}
88

  
89
	/*
90
	 * (non-Javadoc)
91
	 * 
92
	 * @see
93
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#fisheyeNode(java.lang
94
	 * .Object)
95
	 */
96
	@Override
97
	public boolean fisheyeNode(Object arg0) {
98
		// TODO Auto-generated method stub
99
		return false;
100
	}
101

  
102
	/*
103
	 * (non-Javadoc)
104
	 * 
105
	 * @see
106
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getBackgroundColour
107
	 * (java.lang.Object)
108
	 */
109
	@Override
110
	public Color getBackgroundColour(Object arg0) {
111
		// TODO Auto-generated method stub
112
		return null;
113
	}
114

  
115
	/*
116
	 * (non-Javadoc)
117
	 * 
118
	 * @see
119
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderColor(java
120
	 * .lang.Object)
121
	 */
122
	@Override
123
	public Color getBorderColor(Object arg0) {
124
		// TODO Auto-generated method stub
125
		return null;
126
	}
127

  
128
	/*
129
	 * (non-Javadoc)
130
	 * 
131
	 * @see
132
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderHighlightColor
133
	 * (java.lang.Object)
134
	 */
135
	@Override
136
	public Color getBorderHighlightColor(Object arg0) {
137
		// TODO Auto-generated method stub
138
		return null;
139
	}
140

  
141
	/*
142
	 * (non-Javadoc)
143
	 * 
144
	 * @see
145
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getBorderWidth(java
146
	 * .lang.Object)
147
	 */
148
	@Override
149
	public int getBorderWidth(Object arg0) {
150
		return 0;
151
	}
152

  
153
	/*
154
	 * (non-Javadoc)
155
	 * 
156
	 * @see
157
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getForegroundColour
158
	 * (java.lang.Object)
159
	 */
160
	@Override
161
	public Color getForegroundColour(Object arg0) {
162
		// TODO Auto-generated method stub
163
		return null;
164
	}
165

  
166
	/*
167
	 * (non-Javadoc)
168
	 * 
169
	 * @see
170
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getNodeHighlightColor
171
	 * (java.lang.Object)
172
	 */
173
	@Override
174
	public Color getNodeHighlightColor(Object arg0) {
175
		// TODO Auto-generated method stub
176
		return null;
177
	}
178

  
179
	/*
180
	 * (non-Javadoc)
181
	 * 
182
	 * @see
183
	 * org.eclipse.zest.core.viewers.IEntityStyleProvider#getTooltip(java.lang
184
	 * .Object)
185
	 */
186
	@Override
187
	public IFigure getTooltip(Object arg0) {
188
		return null;
189
	}
85 190
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/PolytomousKeyRelationship.java
1
// $Id$
2
/**
3
 * Copyright (C) 2007 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

  
11
package eu.etaxonomy.taxeditor.editor.key.polytomous;
12

  
13
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
14

  
15
/**
16
 * 
17
 * @author n.hoffmann
18
 * @created Mar 30, 2011
19
 * @version 1.0
20
 */
21
class PolytomousKeyRelationship {
22
	Object destination;
23
	Object source;
24

  
25
	PolytomousKeyRelationship(Object source, Object destination) {
26
		this.source = HibernateProxyHelper.deproxy(source);
27
		this.destination = HibernateProxyHelper.deproxy(destination);
28
	}
29
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/PolytomousKeyRelationship.java
1
// $Id$
2
/**
3
 * Copyright (C) 2007 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

  
11
package eu.etaxonomy.taxeditor.model;
12

  
13
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
14

  
15
/**
16
 * 
17
 * @author n.hoffmann
18
 * @created Mar 30, 2011
19
 * @version 1.0
20
 */
21
public class PolytomousKeyRelationship {
22
	private Object destination;
23
	private Object source;
24

  
25
	public PolytomousKeyRelationship(Object source, Object destination) {
26
		this.source = HibernateProxyHelper.deproxy(source);
27
		this.destination = HibernateProxyHelper.deproxy(destination);
28
	}
29

  
30
	/**
31
	 * @param destination
32
	 *            the destination to set
33
	 */
34
	public void setDestination(Object destination) {
35
		this.destination = destination;
36
	}
37

  
38
	/**
39
	 * @return the destination
40
	 */
41
	public Object getDestination() {
42
		return destination;
43
	}
44

  
45
	/**
46
	 * @param source
47
	 *            the source to set
48
	 */
49
	public void setSource(Object source) {
50
		this.source = source;
51
	}
52

  
53
	/**
54
	 * @return the source
55
	 */
56
	public Object getSource() {
57
		return source;
58
	}
59
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/PointElement.java
1 1
// $Id$
2 2
/**
3
* Copyright (C) 2007 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) 2007 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

  
11 11
package eu.etaxonomy.taxeditor.ui.forms;
12 12

  
13 13
import java.text.ParseException;
14 14

  
15 15
import org.eclipse.jface.util.PropertyChangeEvent;
16
import org.eclipse.swt.widgets.Label;
16 17

  
17 18
import eu.etaxonomy.cdm.model.location.Point;
18 19
import eu.etaxonomy.taxeditor.preference.Resources;
......
20 21
import eu.etaxonomy.taxeditor.ui.term.ReferenceSystemComboElement;
21 22

  
22 23
/**
23
 * <p>PointElement class.</p>
24
 *
24
 * <p>
25
 * PointElement class.
26
 * </p>
27
 * 
25 28
 * @author n.hoffmann
26 29
 * @created Oct 15, 2010
27 30
 * @version 1.0
28 31
 */
29
public class PointElement extends AbstractCdmFormElement implements IEntityElement<Point>{
32
public class PointElement extends AbstractCdmFormElement implements
33
		IEntityElement<Point> {
30 34

  
31 35
	private Point point;
32
	
33
	private ReferenceSystemComboElement combo_referenceSystem;
34
	private TextWithLabelElement text_latitude;	
35
	private TextWithLabelElement text_longitude;	
36
	private NumberWithLabelElement number_errorRadius;
37
	
36

  
37
	private final ReferenceSystemComboElement combo_referenceSystem;
38
	private final TextWithLabelElement text_latitude;
39
	private final TextWithLabelElement text_longitude;
40
	private final NumberWithLabelElement number_errorRadius;
41

  
42
	private final Label label_latitude;
43

  
44
	private final Label label_longitude;
45

  
38 46
	/**
39
	 * <p>Constructor for PointElement.</p>
40
	 *
41
	 * @param formFactory a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory} object.
42
	 * @param formElement a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement} object.
43
	 * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
44
	 * @param style a int.
47
	 * <p>
48
	 * Constructor for PointElement.
49
	 * </p>
50
	 * 
51
	 * @param formFactory
52
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory}
53
	 *            object.
54
	 * @param formElement
55
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement}
56
	 *            object.
57
	 * @param point
58
	 *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
59
	 * @param style
60
	 *            a int.
45 61
	 */
46
	public PointElement(CdmFormFactory formFactory, ICdmFormElement formElement, Point point,  final int style) {
62
	public PointElement(CdmFormFactory formFactory,
63
			ICdmFormElement formElement, Point point, final int style) {
47 64
		super(formFactory, formElement);
48
		
65

  
49 66
		formFactory.addPropertyChangeListener(this);
50
		
51
		text_latitude = formFactory.createTextWithLabelElement(formElement, "Latitude (hexagesimal)", null, style);
52
		text_longitude = formFactory.createTextWithLabelElement(formElement, "Longitude (hexagesimal)", null, style);
53
		number_errorRadius = formFactory.createIntegerTextWithLabelElement(formElement, "Error Radius (m)", null, style);
54
		combo_referenceSystem = (ReferenceSystemComboElement) formFactory.createTermComboElement(TermComboType.REFERENCE_SYSTEM, formElement, "Reference System", null, style);
55
		
67

  
68
		getLayoutComposite().setLayoutData(
69
				CdmFormFactory.FILL_HORIZONTALLY(3, 1));
70

  
71
		text_latitude = formFactory.createTextWithLabelElement(formElement,
72
				"Latitude (hexagesimal)", null, style);
73

  
74
		label_latitude = formFactory.createLabel(getLayoutComposite(), null);
75
		addControl(label_latitude);
76

  
77
		text_longitude = formFactory.createTextWithLabelElement(formElement,
78
				"Longitude (hexagesimal)", null, style);
79

  
80
		label_longitude = formFactory.createLabel(getLayoutComposite(), null);
81
		addControl(label_longitude);
82

  
83
		number_errorRadius = formFactory.createIntegerTextWithLabelElement(
84
				formElement, "Error Radius (m)", null, style);
85
		combo_referenceSystem = (ReferenceSystemComboElement) formFactory
86
				.createTermComboElement(TermComboType.REFERENCE_SYSTEM,
87
						formElement, "Reference System", null, style);
88

  
56 89
		setPoint(point);
57 90
	}
58 91

  
59
	/* (non-Javadoc)
92
	/*
93
	 * (non-Javadoc)
94
	 * 
60 95
	 * @see eu.etaxonomy.taxeditor.forms.ISelectable#setSelected(boolean)
61 96
	 */
62 97
	/** {@inheritDoc} */
63 98
	@Override
64 99
	public void setSelected(boolean selected) {
65
		
100

  
66 101
	}
67
	
68
	/* (non-Javadoc)
69
	 * @see eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
102

  
103
	/*
104
	 * (non-Javadoc)
105
	 * 
106
	 * @see
107
	 * eu.etaxonomy.taxeditor.forms.AbstractCdmFormElement#propertyChange(org
108
	 * .eclipse.jface.util.PropertyChangeEvent)
70 109
	 */
71 110
	/** {@inheritDoc} */
72 111
	@Override
73 112
	public void propertyChange(PropertyChangeEvent event) {
74
		if(event == null){
113
		if (event == null) {
75 114
			return;
76 115
		}
77
		
116

  
78 117
		boolean propagate = false;
79
		
118

  
80 119
		Object eventSource = event.getSource();
81
		if(eventSource == text_latitude){
120
		if (eventSource == text_latitude) {
82 121
			try {
83 122
				getPoint().setLatitudeByParsing(text_latitude.getText());
84
				text_latitude.setText(point.getLatitudeSexagesimal().toString(false));
85
				text_latitude.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
123
				text_latitude.setText(point.getLatitudeSexagesimal().toString(
124
						false));
125
				text_latitude
126
						.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
86 127
				propagate = true;
87 128
			} catch (ParseException e) {
88
				text_latitude.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
129
				text_latitude
130
						.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
89 131
			}
90
		}
91
		else if(eventSource == text_longitude){
132
		} else if (eventSource == text_longitude) {
92 133
			try {
93 134
				getPoint().setLongitudeByParsing(text_longitude.getText());
94
				text_longitude.setText(point.getLongitudeSexagesimal().toString(false));
95
				text_longitude.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
135
				text_longitude.setText(point.getLongitudeSexagesimal()
136
						.toString(false));
137
				text_longitude
138
						.setBackground(getColor(Resources.COLOR_COMPOSITE_BACKGROUND));
96 139
				propagate = true;
97 140
			} catch (ParseException e) {
98
				text_latitude.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
141
				text_latitude
142
						.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
99 143
			}
100
		}
101
		else if(eventSource == number_errorRadius){
144
		} else if (eventSource == number_errorRadius) {
102 145
			getPoint().setErrorRadius(number_errorRadius.getInteger());
103 146
			propagate = true;
104
		}
105
		else if(eventSource == combo_referenceSystem){
147
		} else if (eventSource == combo_referenceSystem) {
106 148
			getPoint().setReferenceSystem(combo_referenceSystem.getSelection());
107 149
			propagate = true;
108
		}	
109
		
110
		if(propagate){
150
		}
151

  
152
		if (propagate) {
111 153
			firePropertyChangeEvent(new CdmPropertyChangeEvent(this, event));
112 154
		}
113 155
	}
114 156

  
115
	/* (non-Javadoc)
157
	/*
158
	 * (non-Javadoc)
159
	 * 
116 160
	 * @see eu.etaxonomy.taxeditor.forms.IEntityElement#getEntity()
117 161
	 */
118 162
	/** {@inheritDoc} */
......
122 166
	}
123 167

  
124 168
	/**
125
	 * <p>setEntity</p>
126
	 *
127
	 * @param point a {@link eu.etaxonomy.cdm.model.location.Point} object.
169
	 * <p>
170
	 * setEntity
171
	 * </p>
172
	 * 
173
	 * @param point
174
	 *            a {@link eu.etaxonomy.cdm.model.location.Point} object.
128 175
	 */
129
	public void setEntity(Point point){
176
	public void setEntity(Point point) {
130 177
		setPoint(point);
131 178
	}
132
	
179

  
133 180
	/**
134
	 * <p>Setter for the field <code>point</code>.</p>
135
	 *
136
	 * @param point the point to set
181
	 * <p>
182
	 * Setter for the field <code>point</code>.
183
	 * </p>
184
	 * 
185
	 * @param point
186
	 *            the point to set
137 187
	 */
138 188
	public void setPoint(Point point) {
139 189
		this.point = point;
140
		if(point != null){
141
			text_latitude.setText(point.getLatitudeSexagesimal() == null ? "" : point.getLatitudeSexagesimal().toString(false));
142
			text_longitude.setText(point.getLongitudeSexagesimal() == null ? "" : point.getLongitudeSexagesimal().toString(false));
190
		if (point != null) {
191
			text_latitude.setText(point.getLatitudeSexagesimal() == null ? ""
192
					: point.getLatitudeSexagesimal().toString(false));
193
			text_longitude.setText(point.getLongitudeSexagesimal() == null ? ""
194
					: point.getLongitudeSexagesimal().toString(false));
143 195
			number_errorRadius.setInteger(point.getErrorRadius());
144 196
			combo_referenceSystem.setSelection(point.getReferenceSystem());
145 197
		}
146 198
	}
147 199

  
148 200
	/**
149
	 * <p>Getter for the field <code>point</code>.</p>
150
	 *
201
	 * <p>
202
	 * Getter for the field <code>point</code>.
203
	 * </p>
204
	 * 
151 205
	 * @return the point
152 206
	 */
153 207
	public Point getPoint() {
154
		if(point == null){
208
		if (point == null) {
155 209
			point = Point.NewInstance();
156 210
		}
157
		
211

  
158 212
		return point;
159 213
	}
160 214

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/key/PolytomousKeyNodeDetailElement.java
49 49
			number_nodeNumber.setEnabled(false);
50 50
		}
51 51

  
52
		element_statement = formFactory.createKeyStatementElement(formElement,
53
				"Statement", entity.getStatement(), 50, style);
52
		element_question = formFactory.createKeyStatementElement(formElement,
53
				"Question", entity.getQuestion(), 50, style);
54 54

  
55 55
		selection_feature = (FeatureSelectionElement) formFactory
56 56
				.createSelectionElement(SelectionType.FEATURE,
......
81 81
		formFactory.createMultiLanguageTextElement(formElement,
82 82
				"Modifying Text", entity.getModifyingText(), 50, style);
83 83

  
84
		element_question = formFactory.createKeyStatementElement(formElement,
85
				"Question", entity.getQuestion(), 50, style);
84
		element_statement = formFactory.createKeyStatementElement(formElement,
85
				"Statement", entity.getStatement(), 50, style);
86 86
	}
87 87

  
88 88
	/*
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/CdmSectionPart.java
1 1
// $Id$
2 2
/**
3
* Copyright (C) 2007 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) 2007 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

  
11 11
package eu.etaxonomy.taxeditor.view.detail;
12 12

  
......
19 19
import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
20 20
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
21 21
import eu.etaxonomy.taxeditor.model.IElementHasDetails;
22
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
22 23
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
23 24
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 25
import eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection;
......
27 28
import eu.etaxonomy.taxeditor.ui.section.occurrence.IDerivedUnitFacadeDetailSection;
28 29

  
29 30
/**
30
 * <p>CdmSectionPart class.</p>
31
 *
31
 * <p>
32
 * CdmSectionPart class.
33
 * </p>
34
 * 
32 35
 * @author n.hoffmann
33 36
 * @created Feb 8, 2010
34 37
 * @version 1.0
35 38
 */
36
public class CdmSectionPart<T> extends SectionPart implements IPropertyChangeListener{
37
	
38
	private AbstractFormSection<T> formSection;
39
	
39
public class CdmSectionPart<T> extends SectionPart implements
40
		IPropertyChangeListener {
41

  
42
	private final AbstractFormSection<T> formSection;
43

  
40 44
	/**
41
	 * <p>Constructor for CdmSectionPart.</p>
42
	 *
43
	 * @param section a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection} object.
44
	 * @param <T> a T object.
45
	 * <p>
46
	 * Constructor for CdmSectionPart.
47
	 * </p>
48
	 * 
49
	 * @param section
50
	 *            a {@link eu.etaxonomy.taxeditor.ui.forms.AbstractFormSection}
51
	 *            object.
52
	 * @param <T>
53
	 *            a T object.
45 54
	 */
46 55
	public CdmSectionPart(AbstractFormSection<T> section) {
47 56
		super(section);
48 57
		formSection = section;
49 58
	}
50
	
59

  
51 60
	/** {@inheritDoc} */
52 61
	@Override
53 62
	public boolean setFormInput(Object input) {
54
		if(input instanceof IElementHasDetails){
63
		if (input instanceof IElementHasDetails) {
55 64
			input = ((IElementHasDetails) input).getData();
56 65
		}
57
		if((input instanceof TaxonBase) && (formSection instanceof ITaxonBaseDetailSection)){
58
			((ITaxonBaseDetailSection) formSection).setTaxonBase((TaxonBase) input);
66
		if ((input instanceof TaxonBase)
67
				&& (formSection instanceof ITaxonBaseDetailSection)) {
68
			((ITaxonBaseDetailSection) formSection)
69
					.setTaxonBase((TaxonBase) input);
59 70
			return true;
60 71
		}
61
		if((input instanceof DerivedUnitBase) && (formSection instanceof IDerivedUnitFacadeDetailSection)){
62
			
72
		if ((input instanceof DerivedUnitBase)
73
				&& (formSection instanceof IDerivedUnitFacadeDetailSection)) {
74

  
63 75
			try {
64
				input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input, PreferencesUtil.getDerivedUnitConfigurator());
76
				input = DerivedUnitFacade.NewInstance((DerivedUnitBase) input,
77
						PreferencesUtil.getDerivedUnitConfigurator());
65 78
			} catch (DerivedUnitFacadeNotSupportedException e) {
66 79
				StoreUtil.error(getClass(), e);
67 80
			}
68 81
		}
69
		
82
		if (input instanceof PolytomousKeyRelationship) {
83
			input = ((PolytomousKeyRelationship) input).getDestination();
84
		}
85

  
70 86
		formSection.setEntity((T) input);
71
		
87

  
72 88
		return true;
73 89
	}
74
	
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
90

  
91
	/*
92
	 * (non-Javadoc)
93
	 * 
94
	 * @see
95
	 * org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse
96
	 * .jface.util.PropertyChangeEvent)
77 97
	 */
78 98
	/** {@inheritDoc} */
99
	@Override
79 100
	public void propertyChange(PropertyChangeEvent event) {
80
		if (event != null){
81
			
101
		if (event != null) {
102

  
82 103
			Object eventSource = event.getSource();
83
			
84
			if(formSection.equals(eventSource) 
85
					|| (eventSource instanceof ICdmFormElement && formSection.containsFormElement((ICdmFormElement)eventSource))){
104

  
105
			if (formSection.equals(eventSource)
106
					|| (eventSource instanceof ICdmFormElement && formSection
107
							.containsFormElement((ICdmFormElement) eventSource))) {
86 108
				markDirty();
87 109
			}
88 110
		}
89 111
	}
90
	
91
	
92
	
112

  
93 113
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/detail/DetailsViewer.java
33 33
import eu.etaxonomy.cdm.model.reference.Reference;
34 34
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
35 35
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
36
import eu.etaxonomy.taxeditor.model.PolytomousKeyRelationship;
36 37
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
37 38
import eu.etaxonomy.taxeditor.store.StoreUtil;
38 39
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
......
239 240
				createPolytomousKeySection(rootElement);
240 241
				currentViewPart = VIEW_PART.POLYTOMOUS_KEY;
241 242
			}
242
		} else if (getInput() instanceof PolytomousKeyNode) {
243
		} else if ((getInput() instanceof PolytomousKeyNode)
244
				|| (getInput() instanceof PolytomousKeyRelationship)) {
243 245
			if (currentViewPart != VIEW_PART.POLYTOMOUS_KEY_NODE) {
244 246
				createPolytomousKeyNodeSection(rootElement);
245 247
				currentViewPart = VIEW_PART.POLYTOMOUS_KEY_NODE;

Also available in: Unified diff