Project

General

Profile

« Previous | Next » 

Revision 4c8f9801

Added by Alex Theys almost 12 years ago

AT: commiting latest changes to the Palm Use data extension

View differences:

.gitattributes
481 481
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseHandler.java -text
482 482
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/CreateUseRecordHandler.java -text
483 483
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DeleteUseHandler.java -text
484
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DynamicFeatureMenu.java -text
485 484
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateTaxonUseOperation.java -text
486 485
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/CreateUseRecordOperation.java -text
487 486
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/operation/DeleteTaxonUseOperation.java -text
......
1263 1262
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailElement.java -text
1264 1263
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailSection.java -text
1265 1264
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/user/UserDetailWizardPage.java -text
1265
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java -text
1266
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java -text
1266 1267
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/AbstractTermBaseDetailElement.java -text
1267 1268
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailElement.java -text
1268 1269
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/vocabulary/DefinedTermDetailSection.java -text
eu.etaxonomy.taxeditor.editor/plugin.xml
478 478
               commandId="eu.etaxonomy.taxeditor.editor.use.createUseRecord"
479 479
               label="New Use Record"
480 480
               style="push">
481
         </command>
482
         <separator
483
               name="eu.etaxonomy.taxeditor.usesEditor.separator3"
484
               visible="true">
485
         </separator>
486
         <menu
487
               label="New">
488
            <dynamic
489
                  class="eu.etaxonomy.taxeditor.editor.view.uses.handler.DynamicFeatureMenu"
490
                  id="eu.etaxonomy.taxeditor.uses.dynamicFeatureMenu">
491
            </dynamic>
492 481
            <visibleWhen
493 482
                  checkEnabled="true">
494 483
               <or>
......
503 492
                  </reference>
504 493
               </or>
505 494
            </visibleWhen>
506
         </menu>
495
         </command>
496
         <separator
497
               name="eu.etaxonomy.taxeditor.usesEditor.separator3"
498
               visible="true">
499
         </separator>
507 500
         <separator
508 501
               name="taxeditor-editor.separator1"
509 502
               visible="true">
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/handler/DynamicFeatureMenu.java
1
package eu.etaxonomy.taxeditor.editor.view.uses.handler;
2

  
3
//$Id$
4
/**
5
* Copyright (C) 2007 EDIT
6
* European Distributed Institute of Taxonomy 
7
* http://www.e-taxonomy.eu
8
* 
9
* The contents of this file are subject to the Mozilla Public License Version 1.1
10
* See LICENSE.TXT at the top of this package for the full license terms.
11
*/
12

  
13
import org.eclipse.jface.action.ContributionItem;
14
import org.eclipse.jface.action.IContributionItem;
15
import org.eclipse.jface.viewers.ISelection;
16
import org.eclipse.jface.viewers.IStructuredSelection;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionListener;
19
import org.eclipse.swt.widgets.Event;
20
import org.eclipse.swt.widgets.Menu;
21
import org.eclipse.swt.widgets.MenuItem;
22
import org.eclipse.ui.ISelectionService;
23
import org.eclipse.ui.actions.CompoundContributionItem;
24
import org.eclipse.ui.handlers.IHandlerService;
25

  
26
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
27
import eu.etaxonomy.cdm.model.description.DescriptionBase;
28
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
29
import eu.etaxonomy.cdm.model.description.Feature;
30
import eu.etaxonomy.cdm.model.description.FeatureNode;
31
import eu.etaxonomy.cdm.model.description.FeatureTree;
32
import eu.etaxonomy.cdm.model.description.TaxonDescription;
33
import eu.etaxonomy.taxeditor.editor.EditorUtil;
34
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
35
import eu.etaxonomy.taxeditor.editor.view.uses.UsesViewPart;
36
import eu.etaxonomy.taxeditor.editor.view.uses.operation.CreateTaxonUseOperation;
37
import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
38
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
39
import eu.etaxonomy.taxeditor.store.CdmStore;
40
import eu.etaxonomy.taxeditor.store.TermStore;
41

  
42
/**
43
 * <p>DynamicFeatureMenu class.</p>
44
 *
45
 * @author n.hoffmann
46
 * @created 17.04.2009
47
 * @version 1.0
48
 */
49
public class DynamicFeatureMenu extends CompoundContributionItem {
50
	
51
	private ISelectionService selectionService = EditorUtil.getActivePart().getSite().getWorkbenchWindow().getSelectionService();
52
	private IHandlerService handlerService = (IHandlerService) EditorUtil.getService(IHandlerService.class);
53
	
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
56
	 */
57
	/** {@inheritDoc} */
58
	@Override
59
	protected IContributionItem[] getContributionItems() {
60
		
61
		return new IContributionItem[] {
62
				new ContributionItem() {
63
					public void fill(Menu menu, int index){
64
								
65
						ISelection selection = selectionService.getSelection(UsesViewPart.ID);
66
						
67
						if(selection instanceof IStructuredSelection){
68
							IStructuredSelection structuredSelection = (IStructuredSelection) selection;
69
							Object selectedElement = structuredSelection.getFirstElement();
70
							
71
							if(selectedElement instanceof TaxonDescription){
72
								FeatureTree featureTree = getFeatureTree((TaxonDescription) selectedElement);
73
								
74
								for(FeatureNode childNode : featureTree.getRootChildren()){
75
									createMenuItem(menu, childNode.getFeature());
76
								}
77
							}
78
							else if(selectedElement instanceof FeatureNodeContainer){
79
								FeatureNode featureNode = ((FeatureNodeContainer) selectedElement).getFeatureNode();
80
								
81
								// add the feature to the menu
82
								createMenuItem(menu, featureNode.getFeature());
83
								
84
								// add possible children to the menu
85
								for(FeatureNode childNode : featureNode.getChildren()){
86
									createMenuItem(menu, childNode.getFeature());
87
								}
88
							}
89
							else if(selectedElement instanceof DescriptionElementBase){
90
								Feature feature = ((DescriptionElementBase) selectedElement).getFeature();
91
								createMenuItem(menu, feature);
92
							}
93
						}	
94
					}
95
				}
96
		};
97
	}	
98
	
99
	private void createMenuItem(Menu menu, final Feature feature) {
100
		MenuItem menuItem = new MenuItem(menu, -1);
101
		final Feature deproxiedFeature = (Feature) HibernateProxyHelper.deproxy(feature);
102
		menuItem.setText(deproxiedFeature.getLabel());
103
		menuItem.addSelectionListener(new SelectionListener(){
104

  
105
			public void widgetDefaultSelected(SelectionEvent e) {}
106

  
107
			public void widgetSelected(SelectionEvent ev) {
108
				Event event = new Event();
109
				event.data = deproxiedFeature;
110
				try {
111
					//handlerService.executeCommand(CreateTaxonUseOperation.ID, event);
112
				} catch (Exception e) {
113
					EditorUtil.error(getClass(), e);
114
				}
115
			}				
116
		});
117
	}
118
	
119
	/**
120
	 * Retrieves the feature tree associated with the given description
121
	 * 
122
	 * TODO as of now this is always the same thing because feature trees may not be associated 
123
	 * to descriptions yet.
124
	 * 
125
	 * @param description
126
	 * @return
127
	 */
128
	private FeatureTree getFeatureTree(DescriptionBase description){
129
		FeatureTree featureTree = null;
130
		
131
		// TODO change this to the feature tree associated with this taxon description
132
		if (description.hasStructuredData()){					
133
			featureTree = PreferencesUtil.getDefaultFeatureTreeForStructuredDescription();
134
		}else{
135
			featureTree = PreferencesUtil.getDefaultFeatureTreeForTextualDescription();
136
		}
137
		
138
		if(featureTree == null){
139
			//featureTree = FeatureTree.NewInstance(CdmStore.getTermManager().getPreferredFeatures());
140
			featureTree = FeatureTree.NewInstance(CdmStore.getTermManager().getPreferredTerms(Feature.class));
141
		}
142
		
143
		return featureTree;
144
	}
145
}
146

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/forms/CdmFormFactory.java
257 257
import eu.etaxonomy.taxeditor.ui.section.user.GroupsByUserDetailSection;
258 258
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailElement;
259 259
import eu.etaxonomy.taxeditor.ui.section.user.UserDetailSection;
260
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailElement;
261
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
260 262
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailElement;
261 263
import eu.etaxonomy.taxeditor.ui.section.vocabulary.DefinedTermDetailSection;
262 264
import eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailSection;
......
433 435
			return true;
434 436
		}
435 437
	};
436
	
438

  
437 439
	private class SelectionMouseHandler extends MouseAdapter {
438 440
		@Override
439 441
		public void mouseDown(MouseEvent e) {
......
953 955
	 * @return a {@link eu.etaxonomy.taxeditor.ui.combo.TermComboElement}
954 956
	 *         object.
955 957
	 */
956
	
958

  
957 959
	public <T extends DefinedTermBase> TermComboElement createTermComboElement(
958 960
			Class<T> termComboType, ICdmFormElement parentElement,
959 961
			String labelString, T selection, int style) {
960
		TermComboElement element = new TermComboElement<T>(this, parentElement, termComboType, labelString, selection, style);
962
		TermComboElement element = new TermComboElement<T>(this, parentElement,
963
				termComboType, labelString, selection, style);
961 964
		adapt(element);
962 965
		parentElement.addElement(element);
963 966
		return element;
......
981 984
	 *         object.
982 985
	 */
983 986
	public <T extends IDefinedTerm> EnumComboElement<T> createEnumComboElement(
984
			Class<T> enumComboType, ICdmFormElement parentElement,
985
			int style) {
986
		EnumComboElement<T> element = new EnumComboElement<T>(this, parentElement, enumComboType, style);
987
			Class<T> enumComboType, ICdmFormElement parentElement, int style) {
988
		EnumComboElement<T> element = new EnumComboElement<T>(this,
989
				parentElement, enumComboType, style);
987 990
		adapt(element);
988 991
		parentElement.addElement(element);
989 992
		return element;
......
1340 1343
	 *            object.
1341 1344
	 */
1342 1345
	public void addPropertyChangeListener(IPropertyChangeListener listener) {
1343
		if(propertyChangeListeners.contains(listener)){
1346
		if (propertyChangeListeners.contains(listener)) {
1344 1347
			return;
1345 1348
		}
1346 1349
		propertyChangeListeners.add(0, listener);
......
1498 1501
	 * 
1499 1502
	 */
1500 1503
	public static enum DetailType {
1501
		NONVIRALNAME, 
1502
		SCIENTIFICNAME, 
1503
		REFERENCEBASE, 
1504
		NOMENCLATURALREFERENCE, 
1505
		TAXONBASE, 
1506
		AUTHORSHIP, 
1507
		TEAM, 
1508
		PERSON, 
1509
		DESCRIPTION, 
1510
		DESCRIPTIONELEMENT, 
1511
		PARSINGMESSAGE, 
1512
		NAMERELATIONSHIP, 
1513
		TEAMORPERSONBASE, 
1514
		MEDIA, 
1515
		FIELD_OBSERVATION, 
1516
		DERIVED_UNIT_FACADE, 
1517
		GATHERING_EVENT, 
1518
		DERIVED_UNIT, 
1519
		NATURAL_LANGUAGE, 
1520
		FEATURE_DISTRIBUTION, 
1521
		CLASSIFICATION, 
1522
		TAXON_NODE, 
1523
		COLLECTION, 
1524
		POLYTOMOUS_KEY, 
1525
		POLYTOMOUS_KEY_NODE, 
1526
		INSTITUTION, 
1527
		DERIVED_UNIT_GENERAL, 
1528
		HYBRID, 
1529
		USER, 
1530
		GROUP, 
1531
		DETERMINATION, 
1532
		TAXON_RELATIONSHIP, 
1533
		REFERENCED_ENTITY, 
1534
		TERM_VOCABULARY,
1535
		NAMED_AREA, 
1536
		NAMED_AREA_LEVEL
1537
	}
1538
	
1539
	public AbstractFormSection createDefinedTermDetailSection(Class definedTermClass,
1540
			ConversationHolder conversation, ICdmFormElement parentElement,
1504
		NONVIRALNAME, SCIENTIFICNAME, REFERENCEBASE, NOMENCLATURALREFERENCE, TAXONBASE, AUTHORSHIP, TEAM, PERSON, DESCRIPTION, DESCRIPTIONELEMENT, PARSINGMESSAGE, NAMERELATIONSHIP, TEAMORPERSONBASE, MEDIA, FIELD_OBSERVATION, DERIVED_UNIT_FACADE, GATHERING_EVENT, DERIVED_UNIT, NATURAL_LANGUAGE, FEATURE_DISTRIBUTION, CLASSIFICATION, TAXON_NODE, COLLECTION, POLYTOMOUS_KEY, POLYTOMOUS_KEY_NODE, INSTITUTION, DERIVED_UNIT_GENERAL, HYBRID, USER, GROUP, DETERMINATION, TAXON_RELATIONSHIP, REFERENCED_ENTITY, TERM_VOCABULARY, NAMED_AREA, NAMED_AREA_LEVEL, USE_RECORD
1505
	}
1506

  
1507
	public AbstractFormSection createDefinedTermDetailSection(
1508
			Class definedTermClass, ConversationHolder conversation,
1509
			ICdmFormElement parentElement,
1541 1510
			ISelectionProvider selectionProvider, int style) {
1542
		
1543
		AbstractFormSection section = new DefinedTermDetailSection(this, definedTermClass, conversation, parentElement, selectionProvider, style);
1544
			
1511

  
1512
		AbstractFormSection section = new DefinedTermDetailSection(this,
1513
				definedTermClass, conversation, parentElement,
1514
				selectionProvider, style);
1515

  
1545 1516
		parentElement.addElement(section);
1546 1517
		adapt(section);
1547 1518
		return section;
1548
		
1519

  
1549 1520
	}
1550
	
1521

  
1551 1522
	/**
1552 1523
	 * @param definedTermClass
1553 1524
	 * @param formElement
......
1558 1529
			Class definedTermClass, AbstractCdmDetailSection parentElement,
1559 1530
			int style) {
1560 1531
		AbstractCdmDetailElement element = null;
1561
		
1562
		if (NamedArea.class.isAssignableFrom(definedTermClass)){
1563
			element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1564
		}
1565
		else {
1532

  
1533
		if (NamedArea.class.isAssignableFrom(definedTermClass)) {
1534
			element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(
1535
					this, parentElement);
1536
		} else {
1566 1537
			element = new DefinedTermDetailElement(this, parentElement);
1567 1538
		}
1568
		
1539

  
1569 1540
		adapt(element);
1570 1541
		parentElement.addElement(element);
1571 1542
		return element;
......
1712 1683
					selectionProvider, style);
1713 1684
			break;
1714 1685
		case DETERMINATION:
1715
			section = new DeterminationDetailSection(this, conversation, parentElement,
1716
					selectionProvider, style);
1686
			section = new DeterminationDetailSection(this, conversation,
1687
					parentElement, selectionProvider, style);
1717 1688
			break;
1718 1689
		case TAXON_RELATIONSHIP:
1719
			section = new TaxonRelationshipDetailSection(this, conversation, parentElement, 
1720
					selectionProvider, style);
1690
			section = new TaxonRelationshipDetailSection(this, conversation,
1691
					parentElement, selectionProvider, style);
1721 1692
			break;
1722 1693
		case REFERENCED_ENTITY:
1723
			section = new ReferencedEntityDetailSection(this, conversation, parentElement, 
1724
					selectionProvider, style);
1694
			section = new ReferencedEntityDetailSection(this, conversation,
1695
					parentElement, selectionProvider, style);
1725 1696
			break;
1726 1697
		case TERM_VOCABULARY:
1727
			section = new TermVocabularyDetailSection(this, conversation, parentElement, 
1728
					selectionProvider, style);
1698
			section = new TermVocabularyDetailSection(this, conversation,
1699
					parentElement, selectionProvider, style);
1729 1700
			break;
1730 1701
		case NAMED_AREA:
1731
			section = new NamedAreaDetailSection(this, conversation, parentElement, 
1732
					selectionProvider, style);
1702
			section = new NamedAreaDetailSection(this, conversation,
1703
					parentElement, selectionProvider, style);
1704
			break;
1705
		case USE_RECORD:
1706
			section = new UseRecordDetailSection(this, conversation,
1707
					parentElement, selectionProvider, style);
1733 1708
			break;
1734 1709
		}
1735 1710

  
......
1743 1718
		return section;
1744 1719
	}
1745 1720

  
1746
	
1747
	
1748 1721
	/**
1749 1722
	 * <p>
1750 1723
	 * createCdmDetailElement
......
1861 1834
			element = new TermVocabularyDetailElement(this, parentElement);
1862 1835
			break;
1863 1836
		case NAMED_AREA:
1864
			element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(this, parentElement);
1837
			element = new eu.etaxonomy.taxeditor.ui.section.vocabulary.NamedAreaDetailElement(
1838
					this, parentElement);
1865 1839
			break;
1866 1840
		case NAMED_AREA_LEVEL:
1867
			element = new DefinedTermDetailElement<NamedAreaLevel>(this, parentElement);
1841
			element = new DefinedTermDetailElement<NamedAreaLevel>(this,
1842
					parentElement);
1868 1843
			break;
1844
		/*case USE_RECORD:
1845
			element = new UseRecordDetailElement(this, parentElement, style);
1846
			break;*/
1869 1847
		}
1870 1848

  
1871 1849
		if (element == null) {
......
1887 1865
	 * @version 1.0
1888 1866
	 */
1889 1867
	public static enum EntityDetailType {
1890
		TEAM, 
1891
		TEAMMEMBER, 
1892
		ANNOTATION, 
1893
		CREDIT, 
1894
		DESCRIPTIONELEMENTSOURCE, 
1895
		EXTENSION, 
1896
		MARKER, 
1897
		MEDIA, 
1898
		DESCRIPTIONELEMENTMEDIA, 
1899
		MEDIAREPRESENTATION, 
1900
		MEDIAREPRESENTATIONPART, 
1901
		MODIFIER, 
1902
		NOMENCLATURALSTATUS, 
1903
		NAME_RELATIONSHIP, 
1904
		PROTOLOG, 
1905
		RIGHTS, 
1906
		SOURCE, 
1907
		SCOPE, 
1908
		DESCRIPTIONSOURCE, 
1909
		TYPEDESIGNATION, 
1910
		STATE_DATA, 
1911
		STATISTICAL_MEASUREMENT_VALUE, 
1912
		DESCRIBED_SPECIMEN, 
1913
		COLLECTING_AREA, 
1914
		DETERMINATION_EVENT, 
1915
		SPECIMEN_COLLECTION, 
1916
		IDENTIFIABLE_SOURCE_COLLECTION, 
1917
		GEOGRAPHICAL_SCOPE, 
1918
		SCOPE_RESTRICTION, 
1919
		MEMBER, 
1920
		GRANTED_AUTHORITY, 
1921
		GROUPS_BY_USER, 
1922
		TAXONOMIC_SCOPE, 
1923
		DETERMINATION_CURRENT, 
1924
		DETERMINATION_HISTORY
1868
		TEAM, TEAMMEMBER, ANNOTATION, CREDIT, DESCRIPTIONELEMENTSOURCE, EXTENSION, MARKER, MEDIA, DESCRIPTIONELEMENTMEDIA, MEDIAREPRESENTATION, MEDIAREPRESENTATIONPART, MODIFIER, NOMENCLATURALSTATUS, NAME_RELATIONSHIP, PROTOLOG, RIGHTS, SOURCE, SCOPE, DESCRIPTIONSOURCE, TYPEDESIGNATION, STATE_DATA, STATISTICAL_MEASUREMENT_VALUE, DESCRIBED_SPECIMEN, COLLECTING_AREA, DETERMINATION_EVENT, SPECIMEN_COLLECTION, IDENTIFIABLE_SOURCE_COLLECTION, GEOGRAPHICAL_SCOPE, SCOPE_RESTRICTION, MEMBER, GRANTED_AUTHORITY, GROUPS_BY_USER, TAXONOMIC_SCOPE, DETERMINATION_CURRENT, DETERMINATION_HISTORY
1925 1869
	}
1926 1870

  
1927 1871
	/**
......
2142 2086
		} else if (entity instanceof ImageFile) {
2143 2087
			element = new ImageFileElement(this, parentElement,
2144 2088
					(ImageFile) entity, removeListener, style);
2145
		} else if (entity instanceof MediaRepresentationPart){
2146
			element = new MediaRepresentationPartElement(this, parentElement, 
2147
					(MediaRepresentationPart) entity, removeListener, style);			
2089
		} else if (entity instanceof MediaRepresentationPart) {
2090
			element = new MediaRepresentationPartElement(this, parentElement,
2091
					(MediaRepresentationPart) entity, removeListener, style);
2148 2092
		} else if (entity instanceof NomenclaturalStatus) {
2149 2093
			element = new NomenclaturalStatusElement(this, parentElement,
2150 2094
					(NomenclaturalStatus) entity, removeListener, style);
......
2484 2428

  
2485 2429
	}
2486 2430

  
2431
	public AbstractDetailedDescriptionDetailElement createUseRecordDetailElement(
2432
			ICdmFormElement parentElement, DescriptionElementBase entity,
2433
			int style) {
2434
		AbstractDetailedDescriptionDetailElement useRecordElement = null;
2435
		if (entity instanceof CategoricalData) {
2436
			useRecordElement = new UseRecordDetailElement(this,
2437
					parentElement, (CategoricalData) entity, style);
2438
		} else {
2439
			throw new IllegalStateException(
2440
					"There is no interface for the given description element");
2441
		}
2442
		adapt(useRecordElement);
2443
		parentElement.addElement(useRecordElement);
2444
		return useRecordElement;
2445
	}
2446

  
2487 2447
	/**
2488 2448
	 * Creates a styled text as a part of the form.
2489 2449
	 * 
......
2506 2466
		return text;
2507 2467
	}
2508 2468

  
2509

  
2510 2469
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailElement.java
1
package eu.etaxonomy.taxeditor.ui.section.userecords;
2

  
3
import org.apache.log4j.Logger;
4
import org.eclipse.ui.forms.widgets.Section;
5

  
6
import eu.etaxonomy.cdm.model.description.CategoricalData;
7
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
8
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
9
import eu.etaxonomy.taxeditor.ui.forms.CheckboxElement;
10
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
11
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.EntityDetailType;
12
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
13
import eu.etaxonomy.taxeditor.ui.section.description.DescriptionElementDetailElement;
14
import eu.etaxonomy.taxeditor.ui.section.description.StateDataSection;
15
import eu.etaxonomy.taxeditor.ui.section.description.detail.AbstractDetailedDescriptionDetailElement;
16

  
17
public class UseRecordDetailElement extends AbstractDetailedDescriptionDetailElement<CategoricalData> {
18
	
19
	private static final Logger logger = Logger
20
			.getLogger(DescriptionElementDetailElement.class);
21
	
22
	private CheckboxElement checkbox_orderRelevant;
23
	private StateDataSection section_stateData;
24
	//private AbstractDetailedDescriptionDetailElement detailElement;
25
	
26
	public UseRecordDetailElement(CdmFormFactory formFactory,
27
			ICdmFormElement formElement, CategoricalData entity, int style) {
28
		super(formFactory, formElement, entity, style);
29
	}
30
	
31
	/** {@inheritDoc} */
32
	@Override
33
	protected void createControls(ICdmFormElement formElement,
34
			CategoricalData entity, int style) {
35
		checkbox_orderRelevant = formFactory.createCheckbox(formElement, "Order Relevant", entity.getOrderRelevant(), style);
36
		section_stateData = (StateDataSection) formFactory.createEntityDetailSection(EntityDetailType.STATE_DATA, getConversationHolder(), formElement, Section.TWISTIE | Section.EXPANDED);
37
		section_stateData.setEntity(entity);
38
		section_stateData.setLayoutData(CdmFormFactory.FILL_HORIZONTALLY(2, 1));
39
	}
40
	
41
	
42
	/** {@inheritDoc} */
43
	@Override
44
	public void handleEvent(Object eventSource) {
45
		if(eventSource == checkbox_orderRelevant){
46
			getEntity().setOrderRelevant(checkbox_orderRelevant.getSelection());
47
		}
48
	}
49

  
50
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/userecords/UseRecordDetailSection.java
1
package eu.etaxonomy.taxeditor.ui.section.userecords;
2

  
3
import org.eclipse.jface.viewers.ISelectionProvider;
4

  
5
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
6
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
7
import eu.etaxonomy.taxeditor.store.CdmStore;
8
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory;
9
import eu.etaxonomy.taxeditor.ui.forms.CdmFormFactory.DetailType;
10
import eu.etaxonomy.taxeditor.ui.forms.ICdmFormElement;
11
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
12

  
13
public class UseRecordDetailSection extends AbstractCdmDetailSection<DescriptionElementBase> {
14
	public UseRecordDetailSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation,
15
			ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
16
		super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
17
	}
18

  
19
	@Override
20
	protected DetailType getDetailType() {
21
		return DetailType.USE_RECORD;
22
	}
23

  
24
	@Override
25
	public String getHeading() {
26
		return "Use Record";
27
	}
28
	
29
	/** {@inheritDoc} */
30
	@Override
31
	protected void setSectionTitle() {
32
		this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage()));
33
		setTextClient(createToolbar());
34
	}
35
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/userecords/UseRecordsViewer.java
30 30
import eu.etaxonomy.taxeditor.ui.section.reference.ReferenceDetailSection;
31 31
import eu.etaxonomy.taxeditor.ui.section.taxon.ParsingMessagesSection;
32 32
import eu.etaxonomy.taxeditor.ui.section.taxon.TaxonBaseDetailSection;
33
import eu.etaxonomy.taxeditor.ui.section.userecords.UseRecordDetailSection;
33 34
import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
34 35
import eu.etaxonomy.taxeditor.view.AbstractCdmViewPart;
35 36

  
......
54 55
				createImageGallerySection(rootElement);
55 56

  
56 57
			} else {
57
				createUseRecordSection(rootElement);
58
				createUseSection(rootElement);
58 59

  
59 60
			}
60 61
		} else if (getInput() instanceof DescriptionElementBase) {
61
			createDescriptionElementSection(rootElement);
62
			createUseRecordSection(rootElement);
62 63

  
63 64
		} 
64 65
		
......
156 157
		addPart(nameRelationshipSection);
157 158
		addPart(parsingMessagesSection);
158 159
	}
159
	private void createDescriptionElementSection(RootElement parent) {
160
	
161
	
162
	private void createUseRecordSection(RootElement parent) {
160 163
		destroySections();
161 164

  
162
		DescriptionElementDetailSection descriptionElementDetailSection = (DescriptionElementDetailSection) formFactory
163
				.createCdmDetailSection(DetailType.DESCRIPTIONELEMENT,
165
		UseRecordDetailSection descriptionUseRecordSection = (UseRecordDetailSection) formFactory
166
				.createCdmDetailSection(DetailType.USE_RECORD,
164 167
						getConversationHolder(), parent, this, Section.TWISTIE
165 168
								| Section.EXPANDED);
166 169

  
167 170
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
168

  
169
		DescriptionElementSourceSection descriptionElementSourceSection = (DescriptionElementSourceSection) formFactory
170
				.createEntityDetailSection(
171
						EntityDetailType.DESCRIPTIONELEMENTSOURCE,
172
						getConversationHolder(), parent, Section.TWISTIE);
173

  
174
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
175

  
176
		DescriptionElementMediaSection descriptionElementMediaSection = (DescriptionElementMediaSection) formFactory
177
				.createEntityDetailSection(
178
						EntityDetailType.DESCRIPTIONELEMENTMEDIA,
179
						getConversationHolder(), parent, Section.TWISTIE);
180

  
181
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
182

  
183
		addPart(descriptionElementDetailSection);
184
		addPart(descriptionElementSourceSection);
185
		addPart(descriptionElementMediaSection);
171
		
172
		addPart(descriptionUseRecordSection);
173
		
174
		
186 175
	}
187 176
	
188
	private void createDescriptionSection(RootElement parent) {
177
	private void createUseSection(RootElement parent) {
189 178
		destroySections();
190 179
		DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory
191 180
				.createCdmDetailSection(DetailType.DESCRIPTION,
......
194 183

  
195 184
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
196 185

  
197
		NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory
186
		/*NaturalLanguageSection naturalLanguageSection = (NaturalLanguageSection) formFactory
198 187
				.createCdmDetailSection(DetailType.NATURAL_LANGUAGE,
199 188
						getConversationHolder(), parent, this, Section.TWISTIE
200 189
								| Section.EXPANDED);
......
205 194
				.createEntityDetailSection(EntityDetailType.DESCRIBED_SPECIMEN,
206 195
						getConversationHolder(), parent, Section.TWISTIE);
207 196

  
208
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
197
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
209 198

  
210 199
		DescriptionSourceSection descriptionSourceSection = (DescriptionSourceSection) formFactory
211 200
				.createEntityDetailSection(EntityDetailType.DESCRIPTIONSOURCE,
212 201
						getConversationHolder(), parent, Section.TWISTIE);
213 202

  
214
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
203
		/*formFactory.createHorizontalSeparator(parent, SWT.BORDER);
215 204

  
216 205
		ScopeSection scopeSection = (ScopeSection) formFactory
217 206
				.createEntityDetailSection(EntityDetailType.SCOPE,
218 207
						getConversationHolder(), parent, Section.TWISTIE);
219 208

  
220
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);
209
		formFactory.createHorizontalSeparator(parent, SWT.BORDER);*/
221 210

  
222 211
		addPart(descriptionDetailSection);
223
		addPart(naturalLanguageSection);
224
		addPart(describedSpecimenSection);
225 212
		addPart(descriptionSourceSection);
226
		addPart(scopeSection);
227
	}
228
	
229
	private void createUseRecordSection(RootElement parent) {
230
		destroySections();
231
		
232 213
		
233 214
	}
234 215
	
216
	
217
	
235 218
	private void createImageGallerySection(RootElement parent) {
236 219
		destroySections();
237 220
		DescriptionDetailSection descriptionDetailSection = (DescriptionDetailSection) formFactory

Also available in: Unified diff