Révision 3728

TXM/trunk/bundles/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 3728)
5 5
import java.awt.event.ComponentListener;
6 6

  
7 7
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.custom.CLabel;
9 8
import org.eclipse.swt.events.SelectionEvent;
10 9
import org.eclipse.swt.events.SelectionListener;
11
import org.eclipse.swt.graphics.Point;
12
import org.eclipse.swt.graphics.Rectangle;
13 10
import org.eclipse.swt.widgets.Combo;
14 11
import org.eclipse.swt.widgets.Label;
15
import org.eclipse.swt.widgets.Menu;
16
import org.eclipse.swt.widgets.MenuItem;
17 12
import org.eclipse.swt.widgets.Spinner;
18 13
import org.eclipse.swt.widgets.Text;
19 14
import org.eclipse.swt.widgets.ToolItem;
......
31 26
import org.txm.rcp.editors.TXMEditor;
32 27
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
33 28
import org.txm.rcp.swt.GLComposite;
29
import org.txm.rcp.swt.widget.LabeledCombo;
34 30
import org.txm.rcp.swt.widget.ThresholdsGroup;
35 31
import org.txm.rcp.swt.widget.structures.PropertiesComboViewer;
36 32
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
......
160 156
		
161 157
		// Show/hide columns
162 158
		showIndividuals = new ToolItem(this.chartToolBar, SWT.CHECK);
163
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
164
		// showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL);
159
		// FIXME: SJ: keep this for offering an option "large icons" with text in buttons?
160
		//showIndividuals.setText(CAUIMessages.showTheColumns);
165 161
		showIndividuals.setToolTipText(CAUIMessages.showhideTheColumnPoints);
166 162
		showIndividuals.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_columns.png")); //$NON-NLS-1$
167 163
		showIndividuals.addSelectionListener(computeSelectionListener);
168 164
		
169 165
		// Show/hide rows
170 166
		showVariables = new ToolItem(this.chartToolBar, SWT.CHECK);
171
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
172
		// this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL);
167
		// FIXME: SJ: keep this for offering an option "large icons" with text in buttons?
168
		//showVariables.setText(CAUIMessages.showTheRows);
173 169
		showVariables.setToolTipText(CAUIMessages.showhideTheRowPoints);
174 170
		showVariables.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_rows.png")); //$NON-NLS-1$
175 171
		showVariables.addSelectionListener(computeSelectionListener);
......
177 173
		
178 174
		// Show/hide point shapes
179 175
		showPointShapes = new ToolItem(this.chartToolBar, SWT.CHECK);
180
		// FIXME: keep this for offering an option "large icons" with text in buttons ?
181
		// showPointShapes.setText(CAUIMessages.SHOW_HIDE_POINT_SHAPES);
176
		// FIXME: SJ: keep this for offering an option "large icons" with text in buttons?
177
		//showPointShapes.setText(CAUIMessages.showPointShapes);
182 178
		showPointShapes.setToolTipText(CAUIMessages.showhidePointShapes);
183 179
		showPointShapes.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_point_shapes.png")); //$NON-NLS-1$
184 180
		showPointShapes.addSelectionListener(computeSelectionListener);
185 181
		
186 182
		
187
		final ToolItem item = new ToolItem (this.chartToolBar, SWT.PUSH);
188
		final Menu menu = new Menu (this.chartToolBar.getShell(), SWT.POP_UP);
189
		MenuItem item12 = new MenuItem (menu, SWT.PUSH);
190
		item12.setText ("(1,2)"); // , "(1,3)", "(2,3)"
191
		item12.addSelectionListener(new SelectionListener() {
192
			
193
			@Override
194
			public void widgetSelected(SelectionEvent e) {
195
				getResult().setFirstDimension(1);
196
				getResult().setSecondDimension(2);
197
				getResult().setChartDirty();
198
				getResult().setNeedsToResetView(true);
199
				item.setText(CAUIMessages.axesColon+" (1,2)");
200
				compute(true);
201
			}
202

  
203
			@Override
204
			public void widgetDefaultSelected(SelectionEvent e) { }
205
		});
206
		MenuItem item13 = new MenuItem (menu, SWT.PUSH);
207
		item13.setText ("(1,3)"); // "(1,2)", "(1,3)", "(2,3)"
208
		item13.addSelectionListener(new SelectionListener() {
209
			
210
			@Override
211
			public void widgetSelected(SelectionEvent e) {
212
				getResult().setFirstDimension(1);
213
				getResult().setSecondDimension(3);
214
				getResult().setChartDirty();
215
				getResult().setNeedsToResetView(true);
216
				item.setText(CAUIMessages.axesColon+" (1,3)");
217
				compute(true);
218
			}
219

  
220
			@Override
221
			public void widgetDefaultSelected(SelectionEvent e) { }
222
		});
223
		MenuItem item23 = new MenuItem (menu, SWT.PUSH);
224
		item23.setText ("(2,3)"); // "(1,2)", "(1,3)", "(2,3)"
225
		item23.addSelectionListener(new SelectionListener() {
226
			
227
			@Override
228
			public void widgetSelected(SelectionEvent e) {
229
				getResult().setFirstDimension(2);
230
				getResult().setSecondDimension(3);
231
				getResult().setChartDirty();
232
				getResult().setNeedsToResetView(true);
233
				item.setText(CAUIMessages.axesColon+" (2,3)");
234
				compute(true);
235
			}
236

  
237
			@Override
238
			public void widgetDefaultSelected(SelectionEvent e) { }
239
		});
240 183
		
241
		item.setText(CAUIMessages.axesColon+" (1,2)");
242
		item.addListener (SWT.Selection, event -> {
243
//			if (event.detail == SWT.PUSH) {
244
				Rectangle rect = item.getBounds ();
245
				Point pt = new Point (rect.x, rect.y + rect.height);
246
				pt = this.chartToolBar.toDisplay (pt);
247
				menu.setLocation (pt.x, pt.y);
248
				menu.setVisible (true);
184
		// Factors plane selection
185
		//FIXME: SJ: other version with a DropDown item
186
//		final ToolItem item = new ToolItem (this.chartToolBar, SWT.PUSH);
187
//		final Menu menu = new Menu (this.chartToolBar.getShell(), SWT.POP_UP);
188
//		MenuItem item12 = new MenuItem (menu, SWT.PUSH);
189
//		item12.setText ("(1,2)"); // , "(1,3)", "(2,3)"
190
//		item12.addSelectionListener(new SelectionListener() {
191
//			
192
//			@Override
193
//			public void widgetSelected(SelectionEvent e) {
194
//				getResult().setFirstDimension(1);
195
//				getResult().setSecondDimension(2);
196
//				getResult().setChartDirty();
197
//				getResult().setNeedsToResetView(true);
198
//				item.setText(CAUIMessages.axesColon+" (1,2)");
199
//				compute(true);
249 200
//			}
250
		});
251
		
252
//		// Factors plane selection
253
//		ToolItem factorsLabelItem = new ToolItem(this.chartToolBar, SWT.SEPARATOR);
254
//		
255
//		CLabel factorsLabel = new CLabel(this.chartToolBar, SWT.CENTER);
256
//		factorsLabel.setText(CAUIMessages.axesColon);
257
//		
258
//		ToolItem plansComboItem = new ToolItem(this.chartToolBar, SWT.SEPARATOR);
259
//		final Combo plansCombo = new Combo(this.chartToolBar, SWT.READ_ONLY);
260
//		
261
//		// FIXME: commented because the infos panel is not ready to manage more axes
262
//		// ArrayList<String> planes = null;
263
//		// try {
264
//		// int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length;
265
//		// planes = new ArrayList<String>();
266
//		// for(int i = 1 ; i < nbsv ; i ++) {
267
//		// for(int j = i ; j < nbsv ; j++) {
268
//		// if(i != j) {
269
//		// planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
270
//		// }
271
//		// }
272
//		// }
273
//		// }
274
//		// catch (StatException e1) {
275
//		// // TODO Auto-generated catch block
276
//		// org.txm.utils.logger.Log.printStackTrace(e1);
277
//		// }
278
//		// String [] items = planes.toArray(new String[planes.size()]);
279
//		
280
//		String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
281
//		
282
//		// TODO : commented because the infos panel is not ready to manage more axes
283
//		// if(couples != null && couples.size() > 3) {
284
//		// items = couples.toArray(new String[couples.size()]);
285
//		// }
286
//		
287
//		plansCombo.setItems(items);
288
//		
289
//		// Preselect the plan from the CA data
290
//		if (this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
291
//			plansCombo.select(2);
292
//		}
293
//		else if (this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
294
//			plansCombo.select(1);
295
//		}
296
//		else {
297
//			plansCombo.select(0);
298
//		}
299
//		
300
//		//this.chartToolBar.addControl(plansCombo);
301
//		
302
//		// Listeners
303
//		SelectionListener listener = new SelectionListener() {
201
//
202
//			@Override
203
//			public void widgetDefaultSelected(SelectionEvent e) { }
204
//		});
205
//		MenuItem item13 = new MenuItem (menu, SWT.PUSH);
206
//		item13.setText ("(1,3)"); // "(1,2)", "(1,3)", "(2,3)"
207
//		item13.addSelectionListener(new SelectionListener() {
304 208
//			
305 209
//			@Override
306 210
//			public void widgetSelected(SelectionEvent e) {
307
//				
308
//				boolean resetView = false;
309
//				
310
//				// Change factors
311
//				if (e.getSource() == plansCombo) {
312
//					
313
//					Combo plans = (Combo) e.getSource();
314
//					
315
//					int dimension1 = 1;
316
//					int dimension2 = 2;
317
//					
318
//					String str = plans.getItem(plans.getSelectionIndex());
319
//					str = str.substring(1, str.length() - 1); // remove ( and )
320
//					String[] split = str.split(","); // 2 items //$NON-NLS-1$
321
//					dimension1 = Integer.parseInt(split[0]);
322
//					dimension2 = Integer.parseInt(split[1]);
323
//					
324
//					getResult().setFirstDimension(dimension1);
325
//					getResult().setSecondDimension(dimension2);
326
//					
327
//					resetView = true;
328
//				}
211
//				getResult().setFirstDimension(1);
212
//				getResult().setSecondDimension(3);
329 213
//				getResult().setChartDirty();
330
//				getResult().setNeedsToResetView(resetView);
214
//				getResult().setNeedsToResetView(true);
215
//				item.setText(CAUIMessages.axesColon+" (1,3)");
331 216
//				compute(true);
332
//				// forceFocus();
333 217
//			}
218
//
219
//			@Override
220
//			public void widgetDefaultSelected(SelectionEvent e) { }
221
//		});
222
//		MenuItem item23 = new MenuItem (menu, SWT.PUSH);
223
//		item23.setText ("(2,3)"); // "(1,2)", "(1,3)", "(2,3)"
224
//		item23.addSelectionListener(new SelectionListener() {
334 225
//			
335 226
//			@Override
336
//			public void widgetDefaultSelected(SelectionEvent e) {
337
//				// TODO Auto-generated method stub
227
//			public void widgetSelected(SelectionEvent e) {
228
//				getResult().setFirstDimension(2);
229
//				getResult().setSecondDimension(3);
230
//				getResult().setChartDirty();
231
//				getResult().setNeedsToResetView(true);
232
//				item.setText(CAUIMessages.axesColon+" (2,3)");
233
//				compute(true);
338 234
//			}
339
//		};
340
//		plansCombo.addSelectionListener(listener);
341
//		factorsLabel.pack();
342 235
//
343
//		factorsLabelItem.setControl(factorsLabel);
344
//		factorsLabelItem.setWidth(factorsLabel.getSize().x);
345
//		plansCombo.pack();
236
//			@Override
237
//			public void widgetDefaultSelected(SelectionEvent e) { }
238
//		});
346 239
//		
347
//		plansComboItem.setControl(plansCombo);
348
//		plansComboItem.setWidth(plansCombo.getSize().x);
240
//		item.setText(CAUIMessages.axesColon+" (1,2)");
241
//		item.addListener (SWT.Selection, event -> {
242
////			if (event.detail == SWT.PUSH) {
243
//				Rectangle rect = item.getBounds ();
244
//				Point pt = new Point (rect.x, rect.y + rect.height);
245
//				pt = this.chartToolBar.toDisplay (pt);
246
//				menu.setLocation (pt.x, pt.y);
247
//				menu.setVisible (true);
248
////			}
249
//		});
349 250
		
251

  
252
		
253
		
254
		
255
		
256
		
257
		
258
		// Factors plane selection
259
		//FIXME: SJ: other version
260
		new ToolItem(this.chartToolBar, SWT.SEPARATOR);
261
		
262
		LabeledCombo plansSelectionCombo = new LabeledCombo(this.getFirstLineComposite(), this, CAUIMessages.axesColon);
263
		Combo plansCombo = plansSelectionCombo.getCombo();
264
		
265
		
266
		// FIXME: commented because the infos panel is not ready to manage more axes
267
//		 ArrayList<String> planes = null;
268
//		 try {
269
//		 int nbsv = this.getResult().getSingularValues().length;
270
//		 planes = new ArrayList<String>();
271
//		 for(int i = 1 ; i < nbsv ; i ++) {
272
//		 for(int j = i ; j < nbsv ; j++) {
273
//		 if(i != j) {
274
//		 planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
275
//		 }
276
//		 }
277
//		 }
278
//		 }
279
//		 catch (StatException e1) {
280
//		 // TODO Auto-generated catch block
281
//		 org.txm.utils.logger.Log.printStackTrace(e1);
282
//		 } catch (REXPMismatchException e1) {
283
//			// TODO Auto-generated catch block
284
//			e1.printStackTrace();
285
//		}
286
//		 String [] items = planes.toArray(new String[planes.size()]);
287
		
288
		String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
289
		
290
		// TODO : commented because the infos panel is not ready to manage more axes
291
		// if(couples != null && couples.size() > 3) {
292
		// items = couples.toArray(new String[couples.size()]);
293
		// }
294
		
295
		plansCombo.setItems(items);
296
		
297
		// Preselect the plan from the CA data
298
		if (this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
299
			plansCombo.select(2);
300
		}
301
		else if (this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
302
			plansCombo.select(1);
303
		}
304
		else {
305
			plansCombo.select(0);
306
		}
307
		
308
		// Listeners
309
		SelectionListener listener = new SelectionListener() {
310
			
311
			@Override
312
			public void widgetSelected(SelectionEvent e) {
313
				
314
				boolean resetView = false;
315
				
316
				// Change factors
317
				if (e.getSource() == plansCombo) {
318
					
319
					Combo plans = (Combo) e.getSource();
320
					
321
					int dimension1 = 1;
322
					int dimension2 = 2;
323
					
324
					String str = plans.getItem(plans.getSelectionIndex());
325
					str = str.substring(1, str.length() - 1); // remove ( and )
326
					String[] split = str.split(","); // 2 items //$NON-NLS-1$
327
					dimension1 = Integer.parseInt(split[0]);
328
					dimension2 = Integer.parseInt(split[1]);
329
					
330
					getResult().setFirstDimension(dimension1);
331
					getResult().setSecondDimension(dimension2);
332
					
333
					resetView = true;
334
				}
335
				getResult().setChartDirty();
336
				getResult().setNeedsToResetView(resetView);
337
				compute(true);
338
				// forceFocus();
339
			}
340
			
341
			@Override
342
			public void widgetDefaultSelected(SelectionEvent e) {
343
				// TODO Auto-generated method stub
344
			}
345
		};
346
		plansCombo.addSelectionListener(listener);
347
		
348
		
349
		
350

  
351
		
352
		
353
		
350 354
		// parent parameters
351 355
		// thresholds
352 356
		if (!this.getResult().getParent().isVisible()  // the LT parent is not visible
......
375 379
		supColNamesText = new Text(this.getExtendedParametersGroup(), SWT.BORDER);
376 380
		
377 381
		this.chartToolBar.pack();
382
		
378 383
	}
379 384
	
380 385
	@Override
TXM/trunk/bundles/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/swt/AdvancedChartEditorToolBar.java (revision 3728)
10 10
import org.eclipse.swt.events.SelectionListener;
11 11
import org.eclipse.swt.widgets.Combo;
12 12
import org.eclipse.swt.widgets.Composite;
13
import org.eclipse.swt.widgets.Label;
13 14
import org.eclipse.swt.widgets.ToolItem;
14 15
import org.txm.Toolbox;
15 16
import org.txm.chartsengine.core.ChartCreator;
......
50 51
		
51 52
		// Show/hide chart title button
52 53
		final ToolItem showTitleButton = new ToolItem(this, SWT.CHECK);
53
		// showTitleButton.setText(SWTComponentsProviderMessages.showhideTitle);
54
		//showTitleButton.setText(ChartsUIMessages.showhideTitle);
54 55
		showTitleButton.setImage(IImageKeys.getImage(getClass(), "icons/show_title.png")); //$NON-NLS-1$
55 56
		showTitleButton.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_title_disabled.png")); //$NON-NLS-1$
56 57
		showTitleButton.setToolTipText(ChartsUIMessages.showhideTitle);
......
66 67
		
67 68
		// Show/hide chart legend button
68 69
		final ToolItem showLegendButton = new ToolItem(this, SWT.CHECK);
69
		// showLegendButton.setText(SWTComponentsProviderMessages.showhideLegend);
70
		//showLegendButton.setText(ChartsUIMessages.showhideLegend);
70 71
		showLegendButton.setImage(IImageKeys.getImage(getClass(), "icons/show_legend.png")); //$NON-NLS-1$
71 72
		showLegendButton.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_legend_disabled.png")); //$NON-NLS-1$
72 73
		showLegendButton.setToolTipText(ChartsUIMessages.showhideLegend);
......
82 83
		
83 84
		// Show/hide chart background grid button
84 85
		final ToolItem showGridButton = new ToolItem(this, SWT.CHECK);
85
		// showGridButton.setText(SWTComponentsProviderMessages.showhideGrid);
86
		//showGridButton.setText(ChartsUIMessages.showhideGrid);
86 87
		showGridButton.setImage(IImageKeys.getImage(getClass(), "icons/show_grid.png")); //$NON-NLS-1$
87 88
		showGridButton.setDisabledImage(IImageKeys.getImage(getClass(), "icons/show_grid_disabled.png")); //$NON-NLS-1$
88 89
		showGridButton.setToolTipText(ChartsUIMessages.showhideGrid);
......
106 107
		};
107 108
		renderingModeCombo.setItems(colorsModes);
108 109
		
109
		this.addCombo(renderingModeCombo);
110
		this.addControl(renderingModeCombo);
110 111
		
111 112
		if (!chartEditor.getResult().isEmptyPreference(ChartsEnginePreferences.RENDERING_COLORS_MODE)) {
112 113
			renderingModeCombo.select(chartEditor.getResult().getRenderingColorsMode());
......
120 121
		// Font selection
121 122
		final Font currentFont = ChartsEngine.createFont(chartEditor.getResult().getFont());
122 123

  
123
		 // FIXME: SJ: may be better here to get the fonts from SWT rather than from Java, see  java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
124
		 // FIXME: SJ: may be better here to get the fonts from SWT rather than from Java, see java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
124 125
		final Combo fontCombo = new Combo(this, SWT.READ_ONLY);
125 126
		String fonts[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
126 127
		fontCombo.setItems(fonts);
127 128
		
128
		this.addCombo(fontCombo);
129
		this.addControl(fontCombo);
129 130
		
130 131
		int currentFontIndex = 0;
131 132
		for (int i = 0; i < fonts.length; i++) {
......
150 151
		}
151 152
		fontSizeCombo.setItems(fontSizes);
152 153
		
153
		this.addCombo(fontSizeCombo);
154
		this.addControl(fontSizeCombo);
154 155
		
155 156
		fontSizeCombo.select(currentFontSizeIndex);
156 157
		
......
186 187
		int currentFontStyleIndex = currentFont.getStyle();
187 188
		fontStyleCombo.setItems(fontStyles);
188 189
		
189
		this.addCombo(fontStyleCombo);
190
		this.addControl(fontStyleCombo);
190 191
		
191 192
		fontStyleCombo.select(currentFontStyleIndex);
192 193
		
......
228 229
			}
229 230
			chartTypeCombo.setItems(chartTypes);
230 231
			
231
			this.addCombo(chartTypeCombo);
232
			this.addControl(chartTypeCombo);
232 233
			
233 234
			
234 235
			chartTypeCombo.select(currentChartCreatorIndex);
......
243 244
		}
244 245
		
245 246
		
247
					
248
		
246 249
		// Listeners
247 250
		SelectionListener listener = new SelectionListener() {
248 251
			
......
272 275
				}
273 276
				// Chart type / chart creators
274 277
				else if (e.getSource() == chartTypeCombo) {
275
					
276 278
					String[] data = StringUtils.split(chartTypeCombo.getItem(chartTypeCombo.getSelectionIndex()), '/');
277 279
					data[0] = StringUtils.trim(data[0]);
278 280
					data[1] = StringUtils.trim(data[1]);
......
290 292
						|| e.getSource() == showGridButton
291 293
						|| e.getSource() == renderingModeCombo
292 294
						|| e.getSource() == fontSizeCombo
295
						|| e.getSource() == fontStyleCombo
293 296
						|| e.getSource() == chartTypeCombo) {
294 297
					// updates or creates chart
295 298
					getEditorPart().compute(update);
......
312 315
		if (showTitleButton.isEnabled()) {
313 316
			showTitleButton.addSelectionListener(listener);
314 317
		}
315
		if (showLegendButton != null) {
318
		if (showLegendButton.isEnabled()) {
316 319
			showLegendButton.addSelectionListener(listener);
317 320
		}
318
		if (showGridButton != null) {
321
		if (showGridButton.isEnabled()) {
319 322
			showGridButton.addSelectionListener(listener);
320 323
		}
321
		if (renderingModeCombo != null) {
324
		if (renderingModeCombo.isEnabled()) {
322 325
			renderingModeCombo.addSelectionListener(listener);
323 326
		}
324 327
		
325 328
		fontCombo.addSelectionListener(listener);
326 329
		fontSizeCombo.addSelectionListener(listener);
327 330
		fontStyleCombo.addSelectionListener(listener);
328
		if (chartTypeCombo.isVisible()) {
331
//		if (chartTypeCombo.isVisible()) {
329 332
			chartTypeCombo.addSelectionListener(listener);
330
		}
333
	//	}
331 334
	}
332 335
	
333 336
	
TXM/trunk/bundles/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesSelectionEditor.java (revision 3728)
54 54
		// Banality
55 55
		Composite extendedParametersArea = this.getExtendedParametersGroup();
56 56

  
57
		LabeledSpinner banality = new LabeledSpinner(extendedParametersArea, this, new Label(extendedParametersArea, SWT.NONE), new FloatSpinner(extendedParametersArea, SWT.BORDER), SpecificitiesUIMessages.banality, SpecificitiesUIMessages.banalityThreshold, true);
57
		LabeledSpinner banality = new LabeledSpinner(extendedParametersArea, this, new FloatSpinner(extendedParametersArea, SWT.BORDER), SpecificitiesUIMessages.banality, SpecificitiesUIMessages.banalityThreshold, true);
58 58
		this.banalitySpinner = (FloatSpinner) banality.getSpinner();
59 59
		this.banalitySpinner.setMaximumAsFloat(200);
60 60
		
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 3728)
11 11
import org.eclipse.swt.layout.FillLayout;
12 12
import org.eclipse.swt.layout.GridData;
13 13
import org.eclipse.swt.layout.RowLayout;
14
import org.eclipse.swt.widgets.Combo;
15 14
import org.eclipse.swt.widgets.Composite;
16 15
import org.eclipse.swt.widgets.Control;
17 16
import org.eclipse.swt.widgets.Event;
18 17
import org.eclipse.swt.widgets.Group;
18
import org.eclipse.swt.widgets.Label;
19 19
import org.eclipse.swt.widgets.Listener;
20 20
import org.eclipse.swt.widgets.MenuItem;
21 21
import org.eclipse.swt.widgets.ToolBar;
......
149 149
	
150 150
	
151 151
	/**
152
	 * Adds the specified Combo to this tool bar.
153
	 * Convenience method to add non-ToolItem Combo to the tool bar using the SWT.SEPARATOR trick, plus to pack and to set the right width.
152
	 * Adds the specified Control to this tool bar.
153
	 * Convenience method to add non-ToolItem Control to the tool bar using the SWT.SEPARATOR trick, plus to pack and to set the right width.
154 154
	 * 
155
	 * @param combo
155
	 * @param control
156 156
	 */
157
	public void addCombo(final Combo combo) {
157
	public void addControl(final Control control) {
158 158
		final ToolItem itemSeparator = new ToolItem(this, SWT.SEPARATOR);
159
		combo.pack();
160
		itemSeparator.setWidth(combo.getBounds().width);
161
		itemSeparator.setControl(combo);
159
		control.pack();
160
		itemSeparator.setWidth(control.getBounds().width);
161
		itemSeparator.setControl(control);
162 162
		Listener listener = new Listener() {
163 163
			
164 164
			@Override
165 165
			public void handleEvent(Event event) {
166
				combo.pack();
167
				itemSeparator.setWidth(combo.getBounds().width);
166
				control.pack();
167
				itemSeparator.setWidth(control.getBounds().width);
168
				//System.err.println("TXMEditorToolBar.addControl(...).new Listener() {...}.handleEvent()");
168 169
			}
169 170
		};
170 171

  
171
		combo.addListener(SWT.RESIZE, listener);
172
		combo.addListener(SWT.Modify, listener);
172
		//control.addListener(SWT.RESIZE, listener);
173
		//control.addListener(SWT.Resize, listener);
174
		control.addListener(SWT.Modify, listener);
175
		
176
		//control.addListener(SWT.CHANGED, listener);
177
		
178
		//this.addListener(SWT.Resize, listener);
179
		
173 180
	}
174 181
	
182
	
183
	
175 184
	/**
176 185
	 * Creates a <code>GLComposite</code> in the toolbar subwidgets container.
177 186
	 * 
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/LabeledCombo.java (revision 3728)
1
/**
2
 * 
3
 */
4
package org.txm.rcp.swt.widget;
5

  
6
import org.eclipse.swt.SWT;
7
import org.eclipse.swt.widgets.Combo;
8
import org.eclipse.swt.widgets.Composite;
9
import org.eclipse.swt.widgets.Label;
10
import org.txm.rcp.editors.TXMEditor;
11

  
12
/**
13
 * Convenience class to create a labeled combo dedicated to editor parameters areas.
14
 * This class also adds all the needed computing listeners.
15
 * 
16
 * @author sjacquot
17
 *
18
 */
19
public class LabeledCombo extends LabeledControl {
20
	
21
	
22
	/**
23
	 * 
24
	 * @param parent
25
	 * @param editor
26
	 * @param labelText
27
	 * @param controlTooltip
28
	 * @param autoCompute
29
	 */
30
	public LabeledCombo(Composite parent, TXMEditor editor, String labelText, String controlTooltip, boolean autoCompute) {
31
		super(parent, editor, new Label(parent, SWT.NONE), new Combo(parent, SWT.READ_ONLY), labelText, controlTooltip, autoCompute);
32
		
33
		// add computing listener
34
		this.getCombo().addModifyListener(this.computingListener);
35
	}
36

  
37
	/**
38
	 * 
39
	 * @param parent
40
	 * @param editor
41
	 * @param labelText
42
	 */
43
	public LabeledCombo(Composite parent, TXMEditor editor, String labelText) {
44
		this(parent, editor, labelText, null, false);
45
	}
46
	
47
	/**
48
	 * 
49
	 * @param parent
50
	 * @param editor
51
	 * @param labelText
52
	 * @param controlTooltip
53
	 */
54
	public LabeledCombo(Composite parent, TXMEditor editor, String labelText, String controlTooltip) {
55
		this(parent, editor, labelText, controlTooltip, false);
56
	}
57

  
58
	
59
	/**
60
	 * Gets the combo composite.
61
	 * 
62
	 * @return the combo
63
	 */
64
	public Combo getCombo() {
65
		return (Combo) super.getControl();
66
	}
67
	
68
}
0 69

  
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/LabeledSpinner.java (revision 3728)
5 5

  
6 6
import org.eclipse.swt.SWT;
7 7
import org.eclipse.swt.widgets.Composite;
8
import org.eclipse.swt.widgets.Label;
8
import org.eclipse.swt.widgets.Control;
9 9
import org.eclipse.swt.widgets.Spinner;
10 10
import org.txm.rcp.editors.TXMEditor;
11
import org.txm.rcp.editors.listeners.ComputeKeyListener;
12 11

  
13 12
/**
14 13
 * Convenience class to create a labeled Spinner dedicated to editor parameters areas.
......
17 16
 * @author sjacquot
18 17
 *
19 18
 */
20
public class LabeledSpinner {
19
public class LabeledSpinner extends LabeledControl {
21 20
	
22
	/**
23
	 * The label.
24
	 */
25
	protected Label label;
26 21
	
27 22
	
28 23
	/**
29
	 * The spinner.
30
	 */
31
	protected Spinner spinner;
32
	
33
	
34
	
35
	/**
36 24
	 * 
37 25
	 * @param parent
38 26
	 * @param editor
39
	 * @param label
40
	 * @param spinner
27
	 * @param control
41 28
	 * @param labelText
42
	 * @param spinnerTooltip
29
	 * @param controlTooltip
43 30
	 * @param autoCompute
44 31
	 */
45
	public LabeledSpinner(Composite parent, TXMEditor editor, Label label, Spinner spinner, String labelText, String spinnerTooltip, boolean autoCompute) {
46
		this.label = label;
47
		this.spinner = spinner;
32
	public LabeledSpinner(Composite parent, TXMEditor editor, Control control, String labelText, String controlTooltip, boolean autoCompute) {
33
		super(parent, editor, null, control, labelText, controlTooltip, autoCompute);
48 34
		
49
		
50
		if (this.label == null) {
51
			this.label = new Label(parent, SWT.NONE);
52
		}
53
		
54
		if (this.spinner == null) {
55
			this.spinner = new Spinner(parent, SWT.BORDER);
56
		}
57
		
58
		this.label.setText(labelText);
59
		
60
		if (spinnerTooltip != null) {
61
			this.spinner.setToolTipText(spinnerTooltip);
62
		}
63
		
64 35
		// default parameters and range
65
		this.spinner.setMinimum(0);
66
		this.spinner.setMaximum(Integer.MAX_VALUE);
67
		this.spinner.setIncrement(1);
68
		this.spinner.setPageIncrement(100);
36
		this.getSpinner().setMinimum(0);
37
		this.getSpinner().setMaximum(Integer.MAX_VALUE);
38
		this.getSpinner().setIncrement(1);
39
		this.getSpinner().setPageIncrement(100);
69 40
		
70
		// add computing listeners
71
		ComputeKeyListener listener = new ComputeKeyListener(editor, autoCompute);
72
		this.spinner.addKeyListener(listener);
73
		this.spinner.addModifyListener(listener);
41
		// add computing listener
42
		this.getSpinner().addModifyListener(this.computingListener);
43

  
74 44
	}
75
	
45

  
76 46
	/**
77 47
	 * 
78 48
	 * @param parent
79 49
	 * @param editor
80
	 * @param label
81
	 * @param spinner
82 50
	 * @param labelText
51
	 * @param controlTooltip
52
	 * @param autoCompute
83 53
	 */
84
	public LabeledSpinner(Composite parent, TXMEditor editor, Label label, Spinner spinner, String labelText) {
85
		this(parent, editor, label, spinner, labelText, null, false);
54
	public LabeledSpinner(Composite parent, TXMEditor editor, String labelText, String controlTooltip, boolean autoCompute) {
55
		this(parent, editor, new Spinner(parent, SWT.BORDER), labelText, controlTooltip, autoCompute);
86 56
	}
87
	
57

  
88 58
	/**
89 59
	 * 
90 60
	 * @param parent
91 61
	 * @param editor
62
	 * @param control
92 63
	 * @param labelText
93
	 * @param spinnerTooltip
94 64
	 */
95
	public LabeledSpinner(Composite parent, TXMEditor editor, String labelText, String spinnerTooltip) {
96
		this(parent, editor, null, null, labelText, spinnerTooltip, false);
65
	public LabeledSpinner(Composite parent, TXMEditor editor, Control control, String labelText) {
66
		this(parent, editor, control, labelText, null, false);
97 67
	}
98 68
	
69
	 
99 70
	/**
100 71
	 * 
101 72
	 * @param parent
102 73
	 * @param editor
103 74
	 * @param labelText
75
	 * @param controlTooltip
104 76
	 */
105
	public LabeledSpinner(Composite parent, TXMEditor editor, String labelText) {
106
		this(parent, editor, labelText, null);
77
	public LabeledSpinner(Composite parent, TXMEditor editor, String labelText, String controlTooltip) {
78
		this(parent, editor, labelText, controlTooltip, false);
107 79
	}
80

  
108 81
	
82

  
109 83
	/**
110
	 * Gets the label composite.
111 84
	 * 
112
	 * @return the label
85
	 * @param parent
86
	 * @param editor
87
	 * @param labelText
113 88
	 */
114
	public Label getLabel() {
115
		return label;
89
	public LabeledSpinner(Composite parent, TXMEditor editor, String labelText) {
90
		this(parent, editor, labelText, null, false);
116 91
	}
117 92
	
118 93
	
94

  
119 95
	/**
120 96
	 * Gets the spinner composite.
121 97
	 * 
122 98
	 * @return the spinner
123 99
	 */
124 100
	public Spinner getSpinner() {
125
		return spinner;
101
		return (Spinner) super.getControl();
126 102
	}
127 103
	
128 104
}
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/LabeledControl.java (revision 3728)
1
/**
2
 * 
3
 */
4
package org.txm.rcp.swt.widget;
5

  
6
import org.eclipse.swt.SWT;
7
import org.eclipse.swt.widgets.Composite;
8
import org.eclipse.swt.widgets.Control;
9
import org.eclipse.swt.widgets.Label;
10
import org.eclipse.swt.widgets.Spinner;
11
import org.txm.rcp.editors.TXMEditor;
12
import org.txm.rcp.editors.listeners.ComputeKeyListener;
13
import org.txm.rcp.swt.GLComposite;
14

  
15
/**
16
 * Convenience class to create a labeled control dedicated to editor parameters areas.
17
 * If the parent is a GLComposite then the number of columns of its GridLayout will be adjusted to receive the label and the control.
18
 * This class also adds all the needed computing listeners.
19
 * 
20
 * @author sjacquot
21
 *
22
 */
23
public class LabeledControl {
24
	
25
	/**
26
	 * The label.
27
	 */
28
	protected Label label;
29
	
30
	
31
	/**
32
	 * The control.
33
	 */
34
	protected Control control;
35
	
36
	
37
	/**
38
	 * The computing listener.
39
	 */
40
	protected ComputeKeyListener computingListener;
41
	
42
	
43
	/**
44
	 * 
45
	 * @param parent
46
	 * @param editor
47
	 * @param label
48
	 * @param control
49
	 * @param labelText
50
	 * @param controlTooltip
51
	 * @param autoCompute
52
	 */
53
	public LabeledControl(Composite parent, TXMEditor editor, Label label, Control control, String labelText, String controlTooltip, boolean autoCompute) {
54
		
55
		this.label = label;
56
		this.control = control;
57
		
58
		if (this.label == null) {
59
			this.label = new Label(parent, SWT.NONE);
60
		}
61
		
62
		this.label.setText(labelText);
63
		
64
		if (controlTooltip != null) {
65
			this.control.setToolTipText(controlTooltip);
66
		}
67
		
68
		// add computing listeners
69
		this.computingListener = new ComputeKeyListener(editor, autoCompute);
70
		this.control.addKeyListener(this.computingListener);
71

  
72
		// adjust the parent GridLayout number of columns
73
		if(parent instanceof GLComposite) {
74
			((GLComposite) parent).getLayout().numColumns += 2;
75
		}
76
		
77
		this.label.moveAbove(this.control);
78
	}
79
	
80
	/**
81
	 * 
82
	 * @param parent
83
	 * @param editor
84
	 * @param label
85
	 * @param spinner
86
	 * @param labelText
87
	 */
88
	public LabeledControl(Composite parent, TXMEditor editor, Label label, Spinner spinner, String labelText) {
89
		this(parent, editor, label, spinner, labelText, null, false);
90
	}
91
	
92
	/**
93
	 * 
94
	 * @param parent
95
	 * @param editor
96
	 * @param labelText
97
	 * @param spinnerTooltip
98
	 */
99
	public LabeledControl(Composite parent, TXMEditor editor, String labelText, String spinnerTooltip) {
100
		this(parent, editor, null, null, labelText, spinnerTooltip, false);
101
	}
102
	
103
	/**
104
	 * 
105
	 * @param parent
106
	 * @param editor
107
	 * @param labelText
108
	 */
109
	public LabeledControl(Composite parent, TXMEditor editor, String labelText) {
110
		this(parent, editor, labelText, null);
111
	}
112
	
113
	
114
	
115
	/**
116
	 * Gets the label.
117
	 * 
118
	 * @return the label
119
	 */
120
	public Label getLabel() {
121
		return label;
122
	}
123
	
124
	
125
	/**
126
	 * Gets the control.
127
	 * 
128
	 * @return the control
129
	 */
130
	public Control getControl() {
131
		return control;
132
	}
133
	
134
}
0 135

  
TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/ThresholdsGroup.java (revision 3728)
12 12
import org.eclipse.swt.widgets.Spinner;
13 13
import org.txm.core.messages.TXMCoreMessages;
14 14
import org.txm.rcp.editors.TXMEditor;
15
import org.txm.rcp.editors.listeners.ComputeKeyListener;
16
import org.txm.rcp.editors.listeners.ComputeSelectionListener;
17 15

  
18 16
/**
19 17
 * Widget to manage shared threshold filters : fmin, fmax and vmax.
TXM/trunk/bundles/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrencesEditor.java (revision 3728)
308 308
		this.cMin = cMin.getSpinner();
309 309
		
310 310
		// Minimum score
311
		LabeledSpinner minimumScore = new LabeledSpinner(filtercontrols, this, new Label(filtercontrols, SWT.NONE), new FloatSpinner(filtercontrols, SWT.BORDER), CooccurrenceUIMessages.score_2);
311
		LabeledSpinner minimumScore = new LabeledSpinner(filtercontrols, this, new FloatSpinner(filtercontrols, SWT.BORDER), CooccurrenceUIMessages.score_2);
312 312
		this.minScore = (FloatSpinner) minimumScore.getSpinner();
313 313
		
314 314
		// empant

Formats disponibles : Unified diff