Révision 3902

TXM/trunk/bundles/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java (revision 3902)
4 4
import java.util.Arrays;
5 5
import java.util.Collections;
6 6
import java.util.Comparator;
7
import java.util.HashMap;
7 8
import java.util.HashSet;
8 9
import java.util.LinkedHashMap;
9 10
import java.util.LinkedHashSet;
......
148 149
	private Concordance concordance;
149 150
	
150 151
	public static void closeView() {
151
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
152
			ElementSearchView view = (ElementSearchView) page.findView(ElementSearchView.ID);
153
			
154
			// close Element View if opened
155
			if (view != null) {
156
				page.hideView(view);
157
			}
158
			
159
			return;
152
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
153
		ElementSearchView view = (ElementSearchView) page.findView(ElementSearchView.ID);
154
		
155
		// close Element View if opened
156
		if (view != null) {
157
			page.hideView(view);
158
		}
159
		
160
		return;
160 161
	}
161 162
	
162 163
	public static ElementSearchView openView() {
......
392 393
		fields = new Composite(parent, SWT.NONE);
393 394
		GridData fields_gdata = new GridData(GridData.FILL, GridData.FILL, true, true);
394 395
		fields.setLayoutData(fields_gdata);
395
		fields.setLayout(new RowLayout());
396
		fields.setLayout(new GridLayout());
396 397
		this.setPartName("Element");
397 398
		
398 399
		// GridDatas to use when a new field is added
......
409 410
	
410 411
	protected void splitViewIfNecessary() {
411 412
		
412
//		for (IViewReference ref : ElementSearchView.this.getSite().getPage().getViewReferences()) {
413
//			System.out.println("ref="+ref+" id="+ref.getId());
414
//			if (ref.getId().equals(ElementPropertiesView.class.getName())) {
415
//				IWorkbenchPage p = ref.getView(true).getSite().getPage();
416
//				MPart mp1 = ref.getView(true).getSite().getService(MPart.class);
417
//				MPart mp2 = this.getSite().getService(MPart.class);
418
//				SWTEditorsUtils.addPart(mp1, mp2, EModelService.RIGHT_OF, 0.5f);
419
//				return;
420
//			}
421
//		}
413
		//		for (IViewReference ref : ElementSearchView.this.getSite().getPage().getViewReferences()) {
414
		//			System.out.println("ref="+ref+" id="+ref.getId());
415
		//			if (ref.getId().equals(ElementPropertiesView.class.getName())) {
416
		//				IWorkbenchPage p = ref.getView(true).getSite().getPage();
417
		//				MPart mp1 = ref.getView(true).getSite().getService(MPart.class);
418
		//				MPart mp2 = this.getSite().getService(MPart.class);
419
		//				SWTEditorsUtils.addPart(mp1, mp2, EModelService.RIGHT_OF, 0.5f);
420
		//				return;
421
		//			}
422
		//		}
422 423
	}
423

  
424
	
424 425
	protected void updateCurrentLabel() {
425 426
		if (currentIndex >= 0) {
426 427
			this.setPartName("" + (currentIndex + 1) + " / " + matchingElements.size() + " " + typeSearched);
......
468 469
			clear(); // remove all previous widgets
469 470
			
470 471
			String[][] props = vue.getChamps(clazz, type);
471
			if (props.length > 0)
472
				for (String p : props[0]) { // the first is the prop names
472
			
473
			HashMap<String, Integer> niveaux = vue.getNiveauxChampsAVoir(clazz, type);
474
			HashMap<String, Integer> ordres = vue.getPositionsChampsAVoir(clazz, type);
475
			int ncol = 0;
476
			int nline = props.length;
477
			for (int l = 0 ; l < props.length ; l++) {
478
				if (ncol < props[l].length) ncol = props[l].length;
479
			}
480
			
481
			
482
			//TODO use the mix of rowlayout and gridlayout of the ElementPropertiesView
483
			for (int l = 0 ; l < nline ; l++) {
473 484
				
474
				Composite c = new Composite(fields, SWT.NONE);
475
				c.setLayoutData(cData);
476
				c.setLayout(new GridLayout(2, false));
477
				Label l = new Label(c, SWT.None);
478
				l.setText(p);
479
				l.setLayoutData(lData);
480
				
481
				Combo t = new Combo(c, SWT.BORDER);
482
				t.setLayoutData(tData);
483
				textWidgets.put(t, p);
484
				setItems(t, clazz, type, p);
485
				t.addKeyListener(new KeyListener() {
485
				for (String p : props[l]) { // the first is the prop names
486 486
					
487
					@Override
488
					public void keyReleased(KeyEvent e) {
489
						if (!(e.widget instanceof Combo)) return;
490
						if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
491
							search();
487
					Composite c = new Composite(fields, SWT.NONE);
488
					c.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
489
					c.setLayout(new GridLayout(2, false));
490
					
491
					Label l2 = new Label(c, SWT.None);
492
					l2.setText(p);
493
					l2.setLayoutData(lData);
494
					
495
					Combo t = new Combo(c, SWT.BORDER);
496
					t.setLayoutData(tData);
497
					textWidgets.put(t, p);
498
					setItems(t, clazz, type, p);
499
					t.addKeyListener(new KeyListener() {
500
						
501
						@Override
502
						public void keyReleased(KeyEvent e) {
503
							if (!(e.widget instanceof Combo)) return;
504
							if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
505
								search();
506
							}
492 507
						}
493
					}
494
					
495
					@Override
496
					public void keyPressed(KeyEvent e) {}
497
				});
508
						
509
						@Override
510
						public void keyPressed(KeyEvent e) {}
511
					});
498 512
				}
513
				
514
				int missing = ncol - props[l].length;
515
				while (missing > 0) {
516
					Composite lineComposite = new Composite(fields, SWT.NONE);
517
					lineComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
518
					missing--;
519
				}
520
			}
521
			((GridLayout)fields.getLayout()).numColumns = ncol;
522

  
499 523
			fields.layout();
500 524
			fields.getParent().layout();
501 525
		}

Formats disponibles : Unified diff