Révision 3380

TXM/trunk/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 3380)
8 8
import org.eclipse.swt.custom.CLabel;
9 9
import org.eclipse.swt.events.SelectionEvent;
10 10
import org.eclipse.swt.events.SelectionListener;
11
import org.eclipse.swt.graphics.Point;
12
import org.eclipse.swt.graphics.Rectangle;
11 13
import org.eclipse.swt.widgets.Combo;
12 14
import org.eclipse.swt.widgets.Label;
15
import org.eclipse.swt.widgets.Menu;
16
import org.eclipse.swt.widgets.MenuItem;
13 17
import org.eclipse.swt.widgets.Spinner;
14 18
import org.eclipse.swt.widgets.ToolItem;
15 19
import org.txm.ca.core.functions.CA;
......
174 178
		showPointShapes.addSelectionListener(computeSelectionListener);
175 179
		
176 180
		
177
		// Factors plane selection
178
		CLabel factorsLabel = new CLabel(this.chartToolBar, SWT.CENTER);
179
		factorsLabel.setText(CAUIMessages.axesColon);
180
		this.chartToolBar.addControl(factorsLabel);
181
		
182
		final Combo plansCombo = new Combo(this.chartToolBar, SWT.READ_ONLY);
183
		
184
		// FIXME: commented because the infos panel is not ready to manage more axes
185
		// ArrayList<String> planes = null;
186
		// try {
187
		// int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length;
188
		// planes = new ArrayList<String>();
189
		// for(int i = 1 ; i < nbsv ; i ++) {
190
		// for(int j = i ; j < nbsv ; j++) {
191
		// if(i != j) {
192
		// planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
193
		// }
194
		// }
195
		// }
196
		// }
197
		// catch (StatException e1) {
198
		// // TODO Auto-generated catch block
199
		// org.txm.utils.logger.Log.printStackTrace(e1);
200
		// }
201
		// String [] items = planes.toArray(new String[planes.size()]);
202
		
203
		String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
204
		
205
		// TODO : commented because the infos panel is not ready to manage more axes
206
		// if(couples != null && couples.size() > 3) {
207
		// items = couples.toArray(new String[couples.size()]);
208
		// }
209
		
210
		plansCombo.setItems(items);
211
		
212
		// Preselect the plan from the CA data
213
		if (this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
214
			plansCombo.select(2);
215
		}
216
		else if (this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
217
			plansCombo.select(1);
218
		}
219
		else {
220
			plansCombo.select(0);
221
		}
222
		
223
		this.chartToolBar.addControl(plansCombo);
224
		
225
		// Listeners
226
		SelectionListener listener = new SelectionListener() {
181
		final ToolItem item = new ToolItem (this.chartToolBar, SWT.PUSH);
182
		final Menu menu = new Menu (this.chartToolBar.getShell(), SWT.POP_UP);
183
		MenuItem item12 = new MenuItem (menu, SWT.PUSH);
184
		item12.setText ("(1,2)"); // , "(1,3)", "(2,3)"
185
		item12.addSelectionListener(new SelectionListener() {
227 186
			
228 187
			@Override
229 188
			public void widgetSelected(SelectionEvent e) {
230
				
231
				boolean resetView = false;
232
				
233
				// Change factors
234
				if (e.getSource() == plansCombo) {
235
					
236
					Combo plans = (Combo) e.getSource();
237
					
238
					int dimension1 = 1;
239
					int dimension2 = 2;
240
					
241
					String str = plans.getItem(plans.getSelectionIndex());
242
					str = str.substring(1, str.length() - 1); // remove ( and )
243
					String[] split = str.split(","); // 2 items //$NON-NLS-1$
244
					dimension1 = Integer.parseInt(split[0]);
245
					dimension2 = Integer.parseInt(split[1]);
246
					
247
					getResult().setFirstDimension(dimension1);
248
					getResult().setSecondDimension(dimension2);
249
					
250
					resetView = true;
251
				}
189
				getResult().setFirstDimension(1);
190
				getResult().setSecondDimension(2);
252 191
				getResult().setChartDirty();
253
				getResult().setNeedsToResetView(resetView);
192
				getResult().setNeedsToResetView(true);
193
				item.setText(CAUIMessages.axesColon+" (1,2)");
254 194
				compute(true);
255
				// forceFocus();
256 195
			}
196

  
197
			@Override
198
			public void widgetDefaultSelected(SelectionEvent e) { }
199
		});
200
		MenuItem item13 = new MenuItem (menu, SWT.PUSH);
201
		item13.setText ("(1,3)"); // "(1,2)", "(1,3)", "(2,3)"
202
		item13.addSelectionListener(new SelectionListener() {
257 203
			
258 204
			@Override
259
			public void widgetDefaultSelected(SelectionEvent e) {
260
				// TODO Auto-generated method stub
205
			public void widgetSelected(SelectionEvent e) {
206
				getResult().setFirstDimension(1);
207
				getResult().setSecondDimension(3);
208
				getResult().setChartDirty();
209
				getResult().setNeedsToResetView(true);
210
				item.setText(CAUIMessages.axesColon+" (1,3)");
211
				compute(true);
261 212
			}
262
		};
263
		plansCombo.addSelectionListener(listener);
213

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

  
231
			@Override
232
			public void widgetDefaultSelected(SelectionEvent e) { }
233
		});
264 234
		
235
		item.setText(CAUIMessages.axesColon+" (1,2)");
236
		item.addListener (SWT.Selection, event -> {
237
//			if (event.detail == SWT.PUSH) {
238
				Rectangle rect = item.getBounds ();
239
				Point pt = new Point (rect.x, rect.y + rect.height);
240
				pt = this.chartToolBar.toDisplay (pt);
241
				menu.setLocation (pt.x, pt.y);
242
				menu.setVisible (true);
243
//			}
244
		});
245
		
246
//		// Factors plane selection
247
//		ToolItem factorsLabelItem = new ToolItem(this.chartToolBar, SWT.SEPARATOR);
248
//		
249
//		CLabel factorsLabel = new CLabel(this.chartToolBar, SWT.CENTER);
250
//		factorsLabel.setText(CAUIMessages.axesColon);
251
//		
252
//		ToolItem plansComboItem = new ToolItem(this.chartToolBar, SWT.SEPARATOR);
253
//		final Combo plansCombo = new Combo(this.chartToolBar, SWT.READ_ONLY);
254
//		
255
//		// FIXME: commented because the infos panel is not ready to manage more axes
256
//		// ArrayList<String> planes = null;
257
//		// try {
258
//		// int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length;
259
//		// planes = new ArrayList<String>();
260
//		// for(int i = 1 ; i < nbsv ; i ++) {
261
//		// for(int j = i ; j < nbsv ; j++) {
262
//		// if(i != j) {
263
//		// planes.add("("+i+","+j+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
264
//		// }
265
//		// }
266
//		// }
267
//		// }
268
//		// catch (StatException e1) {
269
//		// // TODO Auto-generated catch block
270
//		// org.txm.utils.logger.Log.printStackTrace(e1);
271
//		// }
272
//		// String [] items = planes.toArray(new String[planes.size()]);
273
//		
274
//		String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
275
//		
276
//		// TODO : commented because the infos panel is not ready to manage more axes
277
//		// if(couples != null && couples.size() > 3) {
278
//		// items = couples.toArray(new String[couples.size()]);
279
//		// }
280
//		
281
//		plansCombo.setItems(items);
282
//		
283
//		// Preselect the plan from the CA data
284
//		if (this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
285
//			plansCombo.select(2);
286
//		}
287
//		else if (this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
288
//			plansCombo.select(1);
289
//		}
290
//		else {
291
//			plansCombo.select(0);
292
//		}
293
//		
294
//		//this.chartToolBar.addControl(plansCombo);
295
//		
296
//		// Listeners
297
//		SelectionListener listener = new SelectionListener() {
298
//			
299
//			@Override
300
//			public void widgetSelected(SelectionEvent e) {
301
//				
302
//				boolean resetView = false;
303
//				
304
//				// Change factors
305
//				if (e.getSource() == plansCombo) {
306
//					
307
//					Combo plans = (Combo) e.getSource();
308
//					
309
//					int dimension1 = 1;
310
//					int dimension2 = 2;
311
//					
312
//					String str = plans.getItem(plans.getSelectionIndex());
313
//					str = str.substring(1, str.length() - 1); // remove ( and )
314
//					String[] split = str.split(","); // 2 items //$NON-NLS-1$
315
//					dimension1 = Integer.parseInt(split[0]);
316
//					dimension2 = Integer.parseInt(split[1]);
317
//					
318
//					getResult().setFirstDimension(dimension1);
319
//					getResult().setSecondDimension(dimension2);
320
//					
321
//					resetView = true;
322
//				}
323
//				getResult().setChartDirty();
324
//				getResult().setNeedsToResetView(resetView);
325
//				compute(true);
326
//				// forceFocus();
327
//			}
328
//			
329
//			@Override
330
//			public void widgetDefaultSelected(SelectionEvent e) {
331
//				// TODO Auto-generated method stub
332
//			}
333
//		};
334
//		plansCombo.addSelectionListener(listener);
335
//		factorsLabel.pack();
336
//
337
//		factorsLabelItem.setControl(factorsLabel);
338
//		factorsLabelItem.setWidth(factorsLabel.getSize().x);
339
//		plansCombo.pack();
340
//		
341
//		plansComboItem.setControl(plansCombo);
342
//		plansComboItem.setWidth(plansCombo.getSize().x);
343
		
265 344
		// parent parameters
266 345
		// thresholds
267 346
		if (!this.getResult().getParent().isVisible()  // the LT parent is not visible
......
280 359
		}
281 360
		
282 361
		this.chartToolBar.pack();
283
		
284 362
	}
285 363
	
286 364
	@Override

Formats disponibles : Unified diff