Project

General

Profile

« Previous | Next » 

Revision 84a43ef0

Added by U-BGBM\k.luther over 8 years ago

fixing #5150

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
1 1
/**
2
 * 
2
 *
3 3
 */
4 4
package eu.etaxonomy.taxeditor.ui.dialog.selection;
5 5

  
......
31 31
 * @author p.ciardelli
32 32
 * @version $Id: $
33 33
 */
34
public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNode> implements SelectionListener{	
35
	
34
public class TaxonNodeSelectionDialog extends AbstractFilteredCdmResourceSelectionDialog<TaxonNode> implements SelectionListener{
35

  
36 36
	/**
37 37
	 * <p>select</p>
38 38
	 *
......
44 44
	 * @return a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
45 45
	 */
46 46
	public static TaxonNode select(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, TaxonNode node, Classification classification) {
47
		TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell, 
47
		TaxonNodeSelectionDialog dialog = new TaxonNodeSelectionDialog(shell,
48 48
				conversation,
49 49
				title,
50 50
				excludeTaxa,
......
57 57
	private Combo classificationSelectionCombo;
58 58

  
59 59
	private List<Classification> classifications;
60
	
61
	private Classification selectedClassification;	
60

  
61
	private Classification selectedClassification;
62 62

  
63 63
	/**
64 64
	 * <p>Constructor for FilteredTaxonNodeSelectionDialog.</p>
......
72 72
	 */
73 73
	protected TaxonNodeSelectionDialog(Shell shell, ConversationHolder conversation, String title, List<UUID> excludeTaxa, boolean multi, TaxonNode node, Classification classification) {
74 74
		super(shell, conversation, title, multi, TaxonNodeSelectionDialog.class.getCanonicalName(), node);
75
		
75

  
76 76
		ILabelProvider labelProvider = new FilteredCdmResourceLabelProvider();
77 77

  
78 78
		setListLabelProvider(labelProvider);
79 79
		setDetailsLabelProvider(labelProvider);
80
		
80

  
81 81
		if(classification != null){
82 82
			selectedClassification = classification;
83 83
		}
......
92 92
	protected Control createExtendedContentArea(Composite parent) {
93 93
		return createClassificationSelectionCombo(parent);
94 94
	}
95
	
95

  
96 96
	/*
97 97
	 * currently disabled tree selection composite
98 98
	 */
99 99
	private Control createClassificationSelectionCombo(Composite parent){
100 100
//		classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
101
		
101

  
102 102
		Composite classificationSelection = new Composite(parent, SWT.NULL);
103 103
		classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
104
		
104

  
105 105
		GridLayout layout = new GridLayout();
106 106
		classificationSelection.setLayout(layout);
107
		
107

  
108 108
		Label label = new Label(classificationSelection, SWT.NULL);
109 109
		// TODO not working is not really true but leave it here to remind everyone that this is under construction
110
		label.setText("Select Classification (experimental)");
110
		label.setText("Select Classification");
111 111
		classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
112 112
		classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
113
		
113

  
114 114
		for(Classification tree : classifications){
115 115
			classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
116

  
116 117
		}
117
		
118

  
118 119
		classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
119
		
120

  
120 121
		// TODO remember last selection
121 122
		classificationSelectionCombo.addSelectionListener(this);
122
		
123
		
124
		
123

  
124

  
125

  
125 126
		return classificationSelection;
126 127
	}
127 128

  
......
131 132
		if(taxonNode != null && taxonNode.getTaxon() != null){
132 133
			return taxonNode.getTaxon().getTitleCache();
133 134
		}
134
		
135

  
135 136
		return "";
136 137
	}
137
	
138

  
138 139
	/* (non-Javadoc)
139 140
	 * @see eu.etaxonomy.taxeditor.dialogs.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
140 141
	 */
......
150 151
	/** {@inheritDoc} */
151 152
	@Override
152 153
	protected void initModel() {
153
		// default to first tree 
154
		// TODO this will be problematic and can only be seen as workaround 
155
		
156
		
154
		// default to first tree
155
		// TODO this will be problematic and can only be seen as workaround
156

  
157

  
157 158
		if(classifications == null){
158 159
			classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
159 160
			selectedClassification = classifications.iterator().next();
160 161
		}
161
		
162

  
162 163
		model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification);
163 164
	}
164 165

  
......
173 174
	protected String getNewWizardLinkText() {
174 175
		return null;
175 176
	}
176
	
177

  
177 178
	/** {@inheritDoc} */
178
	public void widgetSelected(SelectionEvent e) {
179
	@Override
180
    public void widgetSelected(SelectionEvent e) {
179 181
		selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
180
		
182

  
181 183
//		refresh();
182 184
		setPattern(null);
183 185
	}
184 186

  
185 187
	/** {@inheritDoc} */
186
	public void widgetDefaultSelected(SelectionEvent e) {}
188
	@Override
189
    public void widgetDefaultSelected(SelectionEvent e) {}
187 190

  
188 191

  
189 192
}

Also available in: Unified diff