Project

General

Profile

« Previous | Next » 

Revision b0ce5b17

Added by Patrick Plitzner over 10 years ago

merged trunk into branch

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/DescriptionElementDetailSection.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
*/
......
22 22
import eu.etaxonomy.taxeditor.store.CdmStore;
23 23
import eu.etaxonomy.taxeditor.store.StoreUtil;
24 24
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
25
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory.DetailType;
26 25
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
26
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
27 27
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
28 28
import eu.etaxonomy.taxeditor.ui.section.description.operation.ChangeDescriptionElementType;
29 29

  
......
36 36
 */
37 37
public class DescriptionElementDetailSection extends
38 38
		AbstractCdmDetailSection<DescriptionElementBase> {
39
	
39

  
40 40
	/**
41 41
	 * <p>Constructor for DescriptionElementDetailSection.</p>
42 42
	 *
......
50 50
			ICdmFormElement parentElement, ISelectionProvider selectionProvider, int style) {
51 51
		super(cdmFormFactory, conversation, parentElement, selectionProvider, style);
52 52
	}
53
	
54
	
55
	protected Control createToolbar() {
53

  
54

  
55
	@Override
56
    protected Control createToolbar() {
56 57
		if(! hasSpecificElement()){
57 58
			return null;
58 59
		}
59
		
60

  
60 61
		ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
61
		
62

  
62 63
		final String destinationString = (getEntity() instanceof TextData) ? "the specific element" : "free text";
63
		
64
		final String label = "Change to " + destinationString; 
65
		
64

  
65
		final String label = "Change to " + destinationString;
66

  
66 67
		Action addAction = new Action("Change Type", Action.AS_PUSH_BUTTON) {
67 68
			/* (non-Javadoc)
68 69
			 * @see org.eclipse.jface.action.Action#run()
......
73 74
						+ destinationString + "? Current data will be lost.");
74 75
				if (confirmed) {
75 76
					// FIXME
76
					ChangeDescriptionElementType operation = new ChangeDescriptionElementType(label, 
77
					ChangeDescriptionElementType operation = new ChangeDescriptionElementType(label,
77 78
							getEntity(), StoreUtil.getDetailsView(), StoreUtil.getUndoContext());
78 79
					StoreUtil.executeOperation(operation);
79 80
				}
80 81
			}
81 82
		};
82
		// TODO enable this once a proper icon has been found 
83
		// TODO enable this once a proper icon has been found
83 84
//		addAction.setImageDescriptor(new ImageDescriptor() {
84
//			
85
//
85 86
//			@Override
86 87
//			public ImageData getImageData() {
87 88
//				return ImageResources.getImage(ImageResources.ADD_ICON).getImageData();
88 89
//			}
89 90
//		});
90 91
		addAction.setToolTipText(label);
91
		
92

  
92 93
		toolBarManager.add(addAction);
93
		
94

  
94 95
		return toolBarManager.createControl(this);
95 96
	}
96
	
97

  
97 98
	/** {@inheritDoc} */
98 99
	@Override
99 100
	public String getHeading() {
100 101
		return "Description Element";
101 102
	}
102 103

  
103
	/** {@inheritDoc} */
104
	@Override
105
	protected DetailType getDetailType() {
106
		return DetailType.DESCRIPTIONELEMENT;
107
	}
108
	
109 104
	/** {@inheritDoc} */
110 105
	@Override
111 106
	protected void setSectionTitle() {
112 107
		this.setText(getHeading() + ": " + getEntity().getFeature().getLabel(CdmStore.getDefaultLanguage()));
113 108
		setTextClient(createToolbar());
114 109
	}
115
	
110

  
116 111
	private boolean hasSpecificElement(){
117
		return  getEntity().getFeature().isSupportsCategoricalData() 
112
		return  getEntity().getFeature().isSupportsCategoricalData()
118 113
				|| getEntity().getFeature().isSupportsCommonTaxonName()
119 114
				|| getEntity().getFeature().isSupportsDistribution()
120 115
				|| getEntity().getFeature().isSupportsIndividualAssociation()
121 116
				|| getEntity().getFeature().isSupportsQuantitativeData()
122 117
				|| getEntity().getFeature().isSupportsTaxonInteraction();
123 118
	}
119

  
120
	/* (non-Javadoc)
121
	 * @see eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection#createCdmDetailElement(eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection, int)
122
	 */
123
	@Override
124
	protected AbstractCdmDetailElement<DescriptionElementBase> createCdmDetailElement(AbstractCdmDetailSection<DescriptionElementBase> parentElement, int style) {
125
	    return formFactory.createDescriptionElementDetailElement(parentElement, style);
126
	}
124 127
}

Also available in: Unified diff