Revision 837

tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 837)
160 160

  
161 161
	String locale = TXMPreferences.getString(RCPPreferences.UI_LOCALE, RCPPreferences.PREFERENCES_NODE);
162 162

  
163
	
163

  
164 164
	private static final String BACKTOTEXT_COMMAND_ID = "org.txm.rcp.extensionpoint.backtotext"; //$NON-NLS-1$
165 165

  
166 166
	/** The lineids. */
......
225 225
	/** The right context column. */
226 226
	private TableColumn rightContextColumn;
227 227

  
228
//	/** The view properties label. */
229
//	private Label viewPropertiesLabel;
228
	//	/** The view properties label. */
229
	//	private Label viewPropertiesLabel;
230 230

  
231 231
	/** The set sort property action. */
232 232
	private Action setSortPropertyAction;
......
279 279

  
280 280
	private Listener tableResizeListener;
281 281

  
282
	
283
	
284
	
282

  
283

  
284

  
285 285
	/** The query widget. */
286 286
	@Parameter(key=ConcordancePreferences.QUERY)
287 287
	protected AssistedQueryWidget queryWidget;
......
297 297
	@Override
298 298
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
299 299
		super.init(site, input);
300
		
300

  
301 301
		TXMResult result = this.getResult();
302
		
302

  
303 303
		if (!(result instanceof Concordance)) {
304 304
			throw new PartInitException("Can not open ConcordanceEditor with " + result + ".");
305 305
		}
......
451 451
			}
452 452
		});
453 453
		viewer = new TableViewer(displayArea, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER
454
//				| SWT.VIRTUAL
454
				//				| SWT.VIRTUAL
455 455
				);
456 456
		viewer.getTable().addKeyListener(new TableKeyListener(viewer));
457 457
		//viewer.setLabelProvider(new LineLabelProvider(this));
......
499 499
		viewer.getTable().addKeyListener(kldelete);
500 500
		viewer2.getTable().addKeyListener(kldelete);
501 501

  
502
		//		firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
503
		//		firstColumn.setWidth(0);
504
		//		firstColumn.setResizable(false);
502
		firstColumn = new TableColumn(viewer.getTable(), SWT.LEFT);
503
		firstColumn.setWidth(0);
504
		firstColumn.setResizable(false);
505 505

  
506 506
		TableViewerColumn leftColumnViewer = new TableViewerColumn(viewer, SWT.RIGHT);
507 507
		leftContextColumn = leftColumnViewer.getColumn();
......
819 819

  
820 820
		int from = concordance.getTopIndex();
821 821
		from = Math.max(from, 0);
822
		
822

  
823 823
		int to = from + concordance.getNLinePerPage() - 1;
824 824
		to = Math.min(to, concordance.getNLines());
825
		
825

  
826 826
		viewer.getControl().setRedraw(false);
827 827
		viewer2.getControl().setRedraw(false);
828
		
828

  
829 829
		List<Line> lines = null;
830 830
		if (concordance.getNLines() > 0) {
831 831
			try {
......
899 899
	@Parameter(key=ConcordancePreferences.RIGHT_CONTEXT_SIZE)
900 900
	private Spinner rightSizeSpinner;
901 901

  
902
//	private PropertiesSelector<Property> propsArea;
902
	//	private PropertiesSelector<Property> propsArea;
903 903

  
904 904
	/**
905 905
	 * Get the Composite that contains the query and sort forms
......
958 958
		getMainParametersComposite().getLayout().numColumns = 2;
959 959
		// make
960 960
		getMainParametersComposite().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
961
		
961

  
962 962
		queryLabel = new Label(getMainParametersComposite(), SWT.NONE);
963 963
		queryLabel.setText(TXMUIMessages.CreateSubcorpusDialog_10);
964 964
		queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
......
971 971

  
972 972
		// hide the parameters panel
973 973
		getTopToolbar().setVisible(TXMEditor.COMPUTING_PARAMETERS_GROUP_ID, false); // the settings are not necessary to compute the concordance
974
		
974

  
975 975
		// | Properties: word/pos [Edit] |
976
//		propsArea = new PropertiesSelector<Property>(queryArea, SWT.NONE);
977
//		propsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
978
//		propsArea.setLayout(new GridLayout(3, false));
979
//		this.propsArea.setProperties(concordance.getAvailableKeywordViewProperties(), concordance.getKeywordViewProperties());
980
//		propsArea.addValueChangeListener(new Listener() {
981
//			@Override
982
//			public void handleEvent(Event event) {
983
//				concordance.setKeywordViewProperties(propsArea.getSelectedProperties());
984
//				refreshViewProperties();
985
//			}
986
//		});
976
		//		propsArea = new PropertiesSelector<Property>(queryArea, SWT.NONE);
977
		//		propsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
978
		//		propsArea.setLayout(new GridLayout(3, false));
979
		//		this.propsArea.setProperties(concordance.getAvailableKeywordViewProperties(), concordance.getKeywordViewProperties());
980
		//		propsArea.addValueChangeListener(new Listener() {
981
		//			@Override
982
		//			public void handleEvent(Event event) {
983
		//				concordance.setKeywordViewProperties(propsArea.getSelectedProperties());
984
		//				refreshViewProperties();
985
		//			}
986
		//		});
987 987

  
988 988
		// [Search]
989
//		Button go = new Button(queryArea, SWT.PUSH);
990
//		go.setText(TXMUIMessages.SEARCH);
991
//
992
//		Font f = go.getFont();
993
//		FontData defaultFont = f.getFontData()[0];
994
//		defaultFont.setStyle(SWT.BOLD);
995
//		Font newf = new Font(go.getDisplay(), defaultFont);
996
//		go.setFont(newf);
997
//
998
//		go.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
999
//		go.addSelectionListener(new ComputeSelectionListener(this));
989
		//		Button go = new Button(queryArea, SWT.PUSH);
990
		//		go.setText(TXMUIMessages.SEARCH);
991
		//
992
		//		Font f = go.getFont();
993
		//		FontData defaultFont = f.getFontData()[0];
994
		//		defaultFont.setStyle(SWT.BOLD);
995
		//		Font newf = new Font(go.getDisplay(), defaultFont);
996
		//		go.setFont(newf);
997
		//
998
		//		go.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
999
		//		go.addSelectionListener(new ComputeSelectionListener(this));
1000 1000

  
1001 1001
		// Complex sort chooser (full line)
1002 1002
		complexsorter = new ComplexSortSelector(queryArea, SWT.NONE);
1003 1003
		complexsorter.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
1004 1004
				true, 4, 1));
1005
		
1005

  
1006 1006
		// properties widget like in the portal version
1007
		GLComposite propertiesPanel = new GLComposite(queryArea, SWT.BORDER);
1007
		GLComposite propertiesPanel = new GLComposite(queryArea, SWT.BORDER, "Properties panel");
1008 1008
		propertiesPanel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true,
1009 1009
				true, 4, 1));
1010 1010
		propertiesPanel.getLayout().numColumns = 5;
1011 1011
		propertiesPanel.getLayout().makeColumnsEqualWidth = true;
1012
		
1012

  
1013 1013
		try {
1014 1014
			Label l = new Label(propertiesPanel, SWT.NONE);
1015 1015
			l.setText("");
......
1018 1018
			new Label(propertiesPanel, SWT.NONE).setText("Left");
1019 1019
			new Label(propertiesPanel, SWT.NONE).setText("Keyword");
1020 1020
			new Label(propertiesPanel, SWT.NONE).setText("Right");
1021
			
1021

  
1022 1022
			new Label(propertiesPanel, SWT.NONE).setText("View");
1023 1023
			refViewProperties = new PropertiesSelector<Property>(propertiesPanel, SWT.NONE);
1024 1024
			refViewProperties.setTitle("");
......
1064 1064
					super.widgetSelected(e);
1065 1065
				}
1066 1066
			});
1067
			
1067

  
1068 1068
			new Label(propertiesPanel, SWT.NONE).setText("Sort");
1069 1069
			refSortProperties = new PropertiesSelector<Property>(propertiesPanel, SWT.NONE);
1070 1070
			refSortProperties.setTitle("");
......
1110 1110
					super.widgetSelected(e);
1111 1111
				}
1112 1112
			});
1113
			
1113

  
1114 1114
			new Label(propertiesPanel, SWT.NONE).setText("Size");
1115 1115
			new Label(propertiesPanel, SWT.NONE);
1116 1116
			leftSizeSpinner = new Spinner(propertiesPanel, SWT.BORDER);
......
1153 1153
		// Navigation Area: infoLine and buttons
1154 1154
		GLComposite navigationAreaComposite = getBottomToolbar().installGLComposite("navigation", 1, false);
1155 1155
		navigationAreaComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
1156
	
1156

  
1157 1157
		navigationWidget = new NavigationWidget(navigationAreaComposite, SWT.NONE);
1158 1158
		navigationWidget.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
1159 1159

  
......
1237 1237
	 */
1238 1238
	public void updateEditorFromResult(boolean update) {
1239 1239
		StatusLine.setMessage(ConcordanceUIMessages.ConcordancesEditor_56);
1240
		
1240

  
1241 1241
		//if (true)// concordance==null || concordance.getQuery()!=query)
1242 1242
		try {
1243 1243
			CorporaView.refresh();
......
1245 1245
			QueriesView.refresh();
1246 1246

  
1247 1247
			fillDisplayArea();
1248
				
1248

  
1249 1249
			setPartName(concordance.getName());
1250 1250
			queryWidget.memorize();
1251 1251

  
......
1286 1286
		return concordance.getNLinePerPage();
1287 1287
	}
1288 1288

  
1289
//	/**
1290
//	 * Update view properties label.
1291
//	 */
1292
//	void updateViewPropertiesLabel() {
1293
//		String str = StringUtils.join(concordance.getKeywordViewProperties(), "_");
1294
//		viewPropertiesLabel.setText(str);
1295
//		viewPropertiesLabel.getParent().layout();
1296
//		viewPropertiesLabel.update();
1297
//		queryArea.layout();
1298
//	}
1289
	//	/**
1290
	//	 * Update view properties label.
1291
	//	 */
1292
	//	void updateViewPropertiesLabel() {
1293
	//		String str = StringUtils.join(concordance.getKeywordViewProperties(), "_");
1294
	//		viewPropertiesLabel.setText(str);
1295
	//		viewPropertiesLabel.getParent().layout();
1296
	//		viewPropertiesLabel.update();
1297
	//		queryArea.layout();
1298
	//	}
1299 1299

  
1300 1300
	/* (non-Javadoc)
1301 1301
	 * @see org.eclipse.ui.part.EditorPart#getTitleToolTip()
......
1610 1610
	 * refresh column display accordingly to the views properties.
1611 1611
	 */
1612 1612
	private void refreshViewProperties() {
1613
			concordance.resetLines();
1614
			sort();
1613
		concordance.resetLines();
1614
		sort();
1615 1615
	}
1616 1616

  
1617 1617
	/**
1618 1618
	 * Refresh sort properties.
1619 1619
	 */
1620 1620
	private void refreshSortProperties() {
1621
			concordance.resetLines();
1622
			sort();
1621
		concordance.resetLines();
1622
		sort();
1623 1623
	}
1624 1624

  
1625 1625
	/**
......
1650 1650
	public void setKeywordViewProperties(List<WordProperty> selectedViewProperties) {
1651 1651
		concordance.setKeywordViewProperties(selectedViewProperties);
1652 1652
		refreshViewProperties();
1653
//		updateViewPropertiesLabel();
1653
		//		updateViewPropertiesLabel();
1654 1654
	}
1655 1655

  
1656 1656
	/**
......
2069 2069
	 */
2070 2070
	public static class ConcordanceColumnSizeControlListener implements ControlListener {
2071 2071
		private TableColumn column;
2072
		
2072

  
2073 2073
		public ConcordanceColumnSizeControlListener(TableColumn column) {
2074 2074
			this.column = column;
2075 2075
		}
2076
		
2076

  
2077 2077
		@Override
2078 2078
		public void controlMoved(ControlEvent e) { }
2079
		
2079

  
2080 2080
		@Override
2081 2081
		public void controlResized(ControlEvent e) {
2082 2082
			if (column != null && !column.isDisposed() &&column.getWidth() < 5) {
tmp/org.txm.rcp.feature/feature.xml (revision 837)
93 93
         optional="true"/>
94 94

  
95 95
   <includes
96
         id="org.txm.treetagger.feature"
97
         version="0.0.0"
98
         optional="true"/>
99

  
100
   <includes
101 96
         id="org.txm.ahc.feature"
102 97
         version="0.0.0"
103 98
         optional="true"/>
......
184 179

  
185 180
   <includes
186 181
         id="org.txm.chartsengine.jfreechart.feature"
187
         version="0.0.0"/>
182
         version="0.0.0"
183
         optional="true"/>
188 184

  
189 185
   <includes
190 186
         id="org.txm.chartsengine.r.feature"
191
         version="0.0.0"/>
187
         version="0.0.0"
188
         optional="true"/>
192 189

  
193 190
   <requires>
194 191
      <import plugin="org.eclipse.core.runtime" version="3.10.0" match="greaterOrEqual"/>
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/debug/TXMEditorSWTDebugView.java (revision 837)
27 27
//
28 28
package org.txm.rcp.views.debug;
29 29

  
30
import org.eclipse.jface.viewers.CellLabelProvider;
30 31
import org.eclipse.jface.viewers.DoubleClickEvent;
31 32
import org.eclipse.jface.viewers.IDoubleClickListener;
32
import org.eclipse.jface.viewers.ISelectionChangedListener;
33 33
import org.eclipse.jface.viewers.ITreeContentProvider;
34 34
import org.eclipse.jface.viewers.LabelProvider;
35
import org.eclipse.jface.viewers.SelectionChangedEvent;
36 35
import org.eclipse.jface.viewers.StructuredSelection;
37 36
import org.eclipse.jface.viewers.TreeViewer;
37
import org.eclipse.jface.viewers.TreeViewerColumn;
38 38
import org.eclipse.jface.viewers.Viewer;
39
import org.eclipse.jface.viewers.ViewerCell;
39 40
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.custom.StyledText;
41 41
import org.eclipse.swt.graphics.Color;
42
import org.eclipse.swt.layout.FormData;
43
import org.eclipse.swt.layout.GridData;
44
import org.eclipse.swt.layout.GridLayout;
45
import org.eclipse.swt.widgets.Button;
42 46
import org.eclipse.swt.widgets.Composite;
43 47
import org.eclipse.swt.widgets.Control;
44
import org.eclipse.swt.widgets.Widget;
48
import org.eclipse.swt.widgets.Label;
49
import org.eclipse.swt.widgets.Layout;
50
import org.eclipse.swt.widgets.ToolBar;
45 51
import org.eclipse.ui.IPartListener;
46 52
import org.eclipse.ui.IPartService;
47 53
import org.eclipse.ui.IPropertyListener;
48
import org.eclipse.ui.IWorkbenchPage;
49 54
import org.eclipse.ui.IWorkbenchPart;
50
import org.eclipse.ui.IWorkbenchWindow;
51 55
import org.eclipse.ui.PlatformUI;
52 56
import org.eclipse.ui.part.ViewPart;
53
import org.txm.chartsengine.core.results.ChartResult;
54
import org.txm.core.results.TXMResult;
55 57
import org.txm.rcp.editors.TXMEditor;
56
import org.txm.rcp.views.corpora.CorporaView;
57
import org.txm.searchengine.cqp.corpus.Corpus;
58
import org.txm.rcp.swt.GLComposite;
58 59

  
59 60

  
60 61
/**
......
133 134
					return ((Composite)element).getChildren();
134 135
				} else if (element instanceof Control) {
135 136
					return new Object[0];
137
				} else if (element instanceof ToolBar) {
138
					return ((ToolBar)element).getChildren();
136 139
				}
137 140
				return new Object[0];
138 141
			}
139 142
		});
140
		treeViewer.setLabelProvider(new LabelProvider() {
141
			@Override
142
			public final String getText(Object element) {
143
				if (element instanceof Composite) {
144
					Composite c = (Composite)element;
145
					String s = c.toString()+" "+c.getLayout();
146
					if (isHighlighted(c)) s += "*";
147
					return s;
148
				} else if (element instanceof Control) {
149
					Control c = (Control)element;
150
					String s = c.toString()+" ("+c.getToolTipText()+")";
151
					if (isHighlighted(c)) s += "*";
152
					return s;
153
				}
154
//				else if (element instanceof Control) {
155
//					return ((Composite)element).getLayout().getClass().getSimpleName();
156
//				}
157
				return element.toString();
158
			}
159
		});
160 143
		
144
		
161 145
		treeViewer.addDoubleClickListener(new IDoubleClickListener() {
162 146
			
163 147
			@Override
......
176 160
				treeViewer.refresh();
177 161
			}
178 162
		});
163
		
164
		treeViewer.getTree().setHeaderVisible(true);
165
		treeViewer.getTree().setLinesVisible(true);
166
		
167
		TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
168
		nameColumn.getColumn().setText("Element");
169
		nameColumn.getColumn().pack();
170
		nameColumn.setLabelProvider(new CellLabelProvider() {
171
			@Override
172
			public void update(ViewerCell cell) {
173
				Object element = cell.getElement();
174
				
175
				if (element instanceof GLComposite) {
176
					GLComposite c = (GLComposite)element;
177
					String s = c.getName();
178
					if (isHighlighted(c)) s += "*";
179
					cell.setText(s);
180
				} else if(element instanceof Button) {
181
					Button c = (Button) element;
182
					cell.setText(c.getClass().getSimpleName()+" '"+c.getText()+"'");
183
				} else if(element instanceof Label) {
184
					Label c = (Label) element;
185
					cell.setText(c.getClass().getSimpleName()+" '"+c.getText()+"'");
186
				} else {
187
					cell.setText(element.getClass().getSimpleName());
188
				}
189
			}
190
		});
191
		
192
		TreeViewerColumn layoutColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
193
		layoutColumn.getColumn().setText("Layout");
194
		layoutColumn.getColumn().pack();
195
		layoutColumn.setLabelProvider(new CellLabelProvider() {
196
			@Override
197
			public void update(ViewerCell cell) {
198
				Object element = cell.getElement();
199
				
200
				if (element instanceof Composite) {
201
					String s = getLayoutDetails(((Composite)element).getLayout());
202
					cell.setText(s);
203
				} else {
204
					cell.setText("-");
205
				}
206
			}
207
		});
208
		
209
		TreeViewerColumn layoutDataColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
210
		layoutDataColumn.getColumn().setText("L-data");
211
		layoutDataColumn.getColumn().pack();
212
		layoutDataColumn.setLabelProvider(new CellLabelProvider() {
213
			@Override
214
			public void update(ViewerCell cell) {
215
				Object element = cell.getElement();
216
				
217
				if (element instanceof Control) {
218
					String s = getLayoutDataDetails(((Control)element).getLayoutData());
219
					cell.setText(s);
220
				}else {
221
					cell.setText("-");
222
				}
223
			}
224
		});	
225
		
179 226
	}
227
	protected String getLayoutDataDetails(Object layoutData) {
228
		if (layoutData == null) return "no layout data";
229
		
230
		if (layoutData instanceof GridData) {
231
			GridData data = (GridData)layoutData;
232
			return "GD: "+data.heightHint+" "+data.widthHint
233
					+" "+data.horizontalAlignment+" "+data.horizontalIndent+" "+data.horizontalSpan
234
					+" "+data.minimumHeight+" "+data.minimumWidth
235
					+" "+data.verticalAlignment+" "+data.verticalIndent+" "+data.verticalSpan;
236
		} else if (layoutData instanceof FormData) {
237
			FormData data = (FormData)layoutData;
238
			return "GD: "+data.height+" "+data.width
239
					+" "+data.width+" "+data.bottom+" "+data.left+" "+data.right+" "+data.top;
240
		}
241
		return layoutData.toString();
242
	}
243

  
244
	public static String getLayoutDetails(Layout layout) {
245
		if (layout == null) return "no layout";
246
		
247
		if (layout instanceof GridLayout) {
248
			GridLayout gl = (GridLayout)layout;
249
			return "GL: "+gl.horizontalSpacing+" "+gl.verticalSpacing+" "+gl.marginHeight+" "+gl.marginWidth
250
					+"\n "+gl.marginBottom+" "+gl.marginLeft+" "+gl.marginRight+" "+gl.marginTop
251
					+"\n "+gl.numColumns+" "+gl.makeColumnsEqualWidth;
252
					
253
		} else {
254
			return layout.toString();
255
		}
256
	}
257

  
180 258
	@Override
181 259
	public void partActivated(IWorkbenchPart part) {
182 260
		if (part == null)
......
219 297

  
220 298
	@Override
221 299
	public void setFocus() { }
300

  
301
	public void refresh() {
302
		if (!treeViewer.getTree().isDisposed()) {
303
			treeViewer.refresh();
304
		}
305
	}
222 306
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/debug/RefreshDebugView.java (revision 837)
1
package org.txm.rcp.views.debug;
2

  
3
import org.eclipse.core.commands.ExecutionEvent;
4
import org.eclipse.core.commands.ExecutionException;
5
import org.eclipse.ui.IViewPart;
6
import org.eclipse.ui.PartInitException;
7
import org.txm.rcp.handlers.BaseAbstractHandler;
8

  
9
public class RefreshDebugView extends BaseAbstractHandler {
10

  
11
	@Override
12
	public Object execute(ExecutionEvent event) throws ExecutionException {
13
		try {
14
			IViewPart view = getView(event, TXMEditorSWTDebugView.class.getName());
15
			if (view != null && view instanceof TXMEditorSWTDebugView) {
16
				((TXMEditorSWTDebugView)view).refresh();
17
			}
18
		} catch (PartInitException e) {
19
			// TODO Auto-generated catch block
20
			e.printStackTrace();
21
		}
22
		return null;
23
	}
24
}
0 25

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/BaseAbstractHandler.java (revision 837)
12 12
import org.eclipse.core.commands.ParameterizedCommand;
13 13
import org.eclipse.core.commands.common.NotDefinedException;
14 14
import org.eclipse.swt.widgets.Event;
15
import org.eclipse.ui.IViewPart;
16
import org.eclipse.ui.IWorkbenchPage;
15 17
import org.eclipse.ui.IWorkbenchWindow;
18
import org.eclipse.ui.PartInitException;
16 19
import org.eclipse.ui.PlatformUI;
17 20
import org.eclipse.ui.commands.ICommandService;
18 21
import org.eclipse.ui.handlers.IHandlerService;
......
70 73
		return getSelection(null);
71 74
	}
72 75
	
76
	public static IViewPart getView(ExecutionEvent event, String id) throws PartInitException {
77
		IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
78
		return page.showView(id);
79
	}
80
	
73 81
	/**
74 82
	 * Gets the current selected object.
75 83
	 * @param event the ExecutionEvent that provoke the command call.
tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java (revision 837)
48 48
import org.txm.rcp.messages.TXMUIMessages;
49 49
import org.txm.rcp.swt.widget.ComplexSubcorpusPanel;
50 50
import org.txm.rcp.swt.widget.QueryWidget;
51
import org.txm.rcp.swt.widget.SimpleSubcorpusPanel;
51
import org.txm.rcp.swt.widget.structures.SimpleSubcorpusPanel;
52 52
import org.txm.searchengine.cqp.corpus.Corpus;
53 53
import org.txm.searchengine.cqp.corpus.StructuralUnit;
54 54
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/IImageKeys.java (revision 837)
222 222
	 */
223 223
	public static final String CHARTS_EXPORT_DATA = "icons/functions/export_data.png"; //$NON-NLS-1$
224 224

  
225
	public static final String PENCIL = "icons/functions/pencil.png"; //$NON-NLS-1$
225 226
	public static final String PENCIL_ADD = "icons/functions/pencil_add.png"; //$NON-NLS-1$
226
	public static final String PENCIL = "icons/functions/pencil.png"; //$NON-NLS-1$
227 227
	public static final String PENCIL_SAVE = "icons/functions/pencil_save.png"; //$NON-NLS-1$
228

  
228
	public static final String PENCIL_OPEN = "icons/functions/pencil_open.png"; //$NON-NLS-1$
229
	public static final String PENCIL_CLOSE = "icons/functions/pencil_close.png"; //$NON-NLS-1$
230
	
229 231
	public static final String ACTION_ADD = "icons/add.png";//$NON-NLS-1$
230 232
	public static final String WORLD = "icons/world.png";
231 233

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 837)
3 3
import java.util.HashMap;
4 4

  
5 5
import org.eclipse.jface.action.ToolBarManager;
6
import org.eclipse.jface.fieldassist.ControlDecoration;
7 6
import org.eclipse.swt.SWT;
8 7
import org.eclipse.swt.events.SelectionEvent;
9 8
import org.eclipse.swt.events.SelectionListener;
10
import org.eclipse.swt.graphics.Image;
11 9
import org.eclipse.swt.layout.GridData;
12 10
import org.eclipse.swt.layout.RowLayout;
13
import org.eclipse.swt.widgets.Button;
14 11
import org.eclipse.swt.widgets.Composite;
15 12
import org.eclipse.swt.widgets.Control;
16 13
import org.eclipse.swt.widgets.Event;
17 14
import org.eclipse.swt.widgets.Group;
18 15
import org.eclipse.swt.widgets.Listener;
16
import org.eclipse.swt.widgets.MenuItem;
19 17
import org.eclipse.swt.widgets.ToolBar;
20 18
import org.eclipse.swt.widgets.ToolItem;
21 19
import org.eclipse.ui.menus.IMenuService;
22 20
import org.txm.core.results.TXMResult;
23
import org.txm.rcp.IImageKeys;
24 21
import org.txm.rcp.swt.GLComposite;
22
import org.txm.rcp.swt.toolbar.DropDownCheckToolItem;
23
import org.txm.rcp.swt.toolbar.DropDownToolItem;
24
import org.txm.rcp.swt.toolbar.OpenCloseToolItem;
25 25

  
26 26
/**
27 27
 * 
......
49 49
	/**
50 50
	 * Contains references to installed groups to ToolItem.
51 51
	 */
52
	private HashMap<String, OpenCloseButton> buttons = new HashMap<String, OpenCloseButton>();
52
	private HashMap<String, ToolItem> buttons = new HashMap<String, ToolItem>();
53 53

  
54 54
	/**
55 55
	 * 
......
102 102
	public void setVisible(String id, boolean visible)	{
103 103
		if (groups.containsKey(id) && !groups.get(id).isDisposed()) {
104 104
			Composite composite = groups.get(id);
105
			OpenCloseButton activationButton = buttons.get(id);
106
			setVisible(composite, activationButton, visible);
105
			setVisible(composite, visible);
107 106
		}
108 107
	}
109 108

  
......
114 113
	 * @param composite
115 114
	 * 
116 115
	 */
117
	protected void setVisible(Composite composite, OpenCloseButton showParameters, boolean visible)	{
116
	protected void setVisible(Composite composite, boolean visible)	{
117
		
118 118
		((GridData)composite.getLayoutData()).exclude = !visible;
119 119
		composite.setVisible(visible);
120
		subWidgetComposite.layout(true);
120 121
		composite.layout(true);
121 122
		editorPart.layout(true);
122
		showParameters.setSelection(visible);
123 123
	}
124 124

  
125 125

  
......
163 163
		if (this.groups.containsKey(groupTitle)) {
164 164
			return (GLComposite) this.groups.get(groupTitle);
165 165
		}
166
		final GLComposite comp = new GLComposite(subWidgetComposite, SWT.NONE);
166
		final GLComposite comp = new GLComposite(subWidgetComposite, SWT.NONE, "Group: "+groupTitle);
167 167
		comp.getLayout().numColumns = numColumns;
168 168
		comp.getLayout().makeColumnsEqualWidth = makeColumnsEqualWidth;
169 169
		return comp;
170 170
	}
171 171

  
172 172
	/**
173
	 * Creates a group with a dropdown button and multiple modes
174
	 * @param groupTitle
175
	 * @param buttonToolTip
176
	 * @param openIconFilePath
177
	 * @param closeIconFilePath
178
	 * @param showGroup
179
	 * @param selectionListener
180
	 * @param modes The modes names
181
	 * @param choicesSelectionListeners the corresponding mode selectionListener
182
	 */
183
	public Group installAlternativesGroup(final String groupTitle, String buttonToolTip, String openIconFilePath, String closeIconFilePath, boolean showGroup,
184
			SelectionListener selectionListener, String[] modes, SelectionListener[] modeSelectionListeners) {
185
		
186
		final DropDownCheckToolItem openCloseButton = new DropDownCheckToolItem(this, buttonToolTip, openIconFilePath, closeIconFilePath);
187
		
188
		openCloseButton.addSelectionListener(new SelectionListener() {
189

  
190
			@Override
191
			public void widgetSelected(SelectionEvent e) {
192
				if (e.doit) {
193
					setVisible(groupTitle, openCloseButton.getSelection());
194
				}
195
			}
196

  
197
			@Override
198
			public void widgetDefaultSelected(SelectionEvent e) { }
199
		});
200
		
201
		org.txm.rcp.swt.listeners.DropdownSelectionListener listenerOne = openCloseButton.getDropDownListener();
202
		listenerOne.setDefaultSelectionListener(selectionListener);
203
		for (int i = 0 ; i < modes.length && i < modeSelectionListeners.length; i++) {
204
			MenuItem item1 = new MenuItem(listenerOne.getMenu(), SWT.PUSH);
205
			item1.setText(modes[i]);
206
			item1.addSelectionListener(modeSelectionListeners[i]);
207
		}
208
		
209
		final Group group = new Group(subWidgetComposite, SWT.NONE);
210
		group.setText(groupTitle);
211
		GridData gd2 = new GridData(GridData.FILL_BOTH);
212
		gd2.grabExcessVerticalSpace = false;
213
		gd2.grabExcessHorizontalSpace = true;
214
		gd2.exclude = true;
215
		group.setLayoutData(gd2);
216
		
217
		this.groups.put(groupTitle, group);
218
		this.buttons.put(groupTitle, openCloseButton);
219
		return group;
220
	}
221
	
222
	/**
173 223
	 * Creates a <code>Group</code> with some configuration to make it visible/invisible and a <code>ToolItem</code> attached to the specified tool bar to show/hide this group.
174 224
	 * 
175 225
	 * @param composite
......
202 252
		group.setLayoutData(gd2);
203 253
		group.setVisible(false);
204 254

  
205

  
206 255
		// add finally a button to the toolbar to show/hide the Group
207 256

  
208
		final OpenCloseButton showParameters = new OpenCloseButton(this, groupTitle, openIconFilePath, closeIconFilePath);
257
		final OpenCloseToolItem showParameters = new OpenCloseToolItem(this, groupTitle, openIconFilePath, closeIconFilePath);
209 258
		//		if (iconFilePath != null)	{
210 259
		//			showParameters.setImage(IImageKeys.getImage(iconFilePath));
211 260
		//		}
......
218 267
		//			showParameters.setToolTipText(buttonToolTip);
219 268
		//		}
220 269

  
221
		this.setVisible(group, showParameters, showGroup); // default init
270
		this.setVisible(group, showGroup); // default init
222 271

  
223 272
		showParameters.addSelectionListener(new SelectionListener() {
224 273

  
225 274
			@Override
226 275
			public void widgetSelected(SelectionEvent e) {
227
				setVisible(group, showParameters, showParameters.getSelection());
276
				setVisible(group, showParameters.getSelection());
228 277
			}
229 278

  
230 279
			@Override
231 280
			public void widgetDefaultSelected(SelectionEvent e) { }
232 281
		});
282
		//TODO add an optional selection listener
283
		//showParameters.addSelectionListener(selectionListener);
233 284

  
234 285
		this.groups.put(groupTitle, group);
235 286
		this.buttons.put(groupTitle, showParameters);
236 287
		return group;
237 288
	}
238 289

  
239
	//failure of open/close decorator
240
	public class OpenCloseButton {
241
		//		ToolItem sep;
242
		ToolItem showParameters;
243
		//		ControlDecoration openCloseDeco;
244
		protected Image openIcon;
245
		protected Image closeIcon;
246

  
247
		public OpenCloseButton(TXMEditorToolBar toolbar, String groupTitle, String openIconFilePath, String closeIconFilePath) {
248

  
249
			//			sep = new ToolItem(toolbar, SWT.SEPARATOR);
250
			showParameters = new ToolItem(toolbar, SWT.CHECK);
251
			if (openIconFilePath != null) {
252
				openIcon = IImageKeys.getImage(openIconFilePath);
253
				showParameters.setImage(openIcon);
254
				showParameters.setToolTipText(groupTitle);
255
				if (closeIconFilePath != null) {
256
					closeIcon = IImageKeys.getImage(closeIconFilePath);
257
				}
258
			} else {
259
				showParameters.setText(groupTitle);
260
			}
261

  
262

  
263

  
264
			//			showParameters.pack();
265
			//			sep.setWidth (showParameters.getSize ().x);
266
			//			sep.setControl (showParameters);
267

  
268
			//			openCloseDeco = new ControlDecoration(showParameters, SWT.RIGHT);
269
			//			openCloseDeco.setImage(IImageKeys.getImage(IImageKeys.CLOSE_DECORATOR));
270
		}
271

  
272
		public void setSelection(boolean visible) {
273
			showParameters.setSelection(visible);
274
			if (closeIcon != null) {
275
				if (visible) {
276
					showParameters.setImage(closeIcon);
277
				} else {
278
					showParameters.setImage(openIcon);
279
				}
280
			}
281
		}
282

  
283
		public void addSelectionListener(SelectionListener selectionListener) {
284
			showParameters.addSelectionListener(selectionListener);
285
		}
286

  
287
		public boolean getSelection() {
288
			return showParameters.getSelection();
289
		}
290

  
291
		public void setToolTipText(String buttonToolTip) {
292
			showParameters.setToolTipText(buttonToolTip);
293
		}
294

  
295
		public void setText(String groupTitle) {
296
			showParameters.setText(groupTitle);
297
		}
298

  
299
		public void setImage(Image image) {
300
			showParameters.setImage(image);
301
		}
302

  
303
		public void dispose() {
304
			showParameters.dispose();
305
		}
306

  
307
		public Composite getParent() {
308
			return showParameters.getParent();
309
		}
310
	}
311

  
312 290
	public void unInstallGroup(String groupTitle) {
313 291
		if (this.groups.containsKey(groupTitle)) {
314 292
			this.groups.get(groupTitle).dispose();			
......
318 296
		}
319 297
	}
320 298

  
321
	public OpenCloseButton getGroupButton(String groupTitle) {
299
	public ToolItem getGroupButton(String groupTitle) {
322 300
		return this.buttons.get(groupTitle);
323 301
	}
324 302
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 837)
117 117
	 */
118 118
	private Composite parent;
119 119

  
120
	private Composite topToolBarContainer;
120
	private Composite topToolBarsContainer;
121 121

  
122 122
	/**
123 123
	 * contains the default bottom toolbars widget
......
136 136
	private GLComposite bottomSubWidgetsComposite;
137 137
	private GLComposite firstLineComposite;
138 138
	private boolean createPartControlDoneSucessfully = true; // for now... muahahaha
139
	private GLComposite betweenTopToolbarsAndResultComposite;
139 140

  
140 141

  
141 142
	public Shell getShell() {
......
177 178
			this.initParentLayout(parent, 1);
178 179

  
179 180
			// contains the minimal panels and top toolbars
180
			this.firstLineComposite = new GLComposite(parent, SWT.NONE);
181
			this.firstLineComposite = new GLComposite(parent, SWT.NONE, "Editor first line");
181 182
			this.firstLineComposite.getLayout().numColumns = 2;
182 183
			this.firstLineComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
183 184

  
184
			this.mainParametersComposite = new GLComposite(firstLineComposite, SWT.NONE);
185
			this.mainParametersComposite = new GLComposite(firstLineComposite, SWT.NONE, "Main parameters area");
185 186
			this.mainParametersComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
186 187
			this.mainParametersComposite.getLayout().horizontalSpacing = 5;
187 188

  
188 189
			// create the top tool bar
189
			this.topToolBarContainer = new Composite(firstLineComposite, SWT.NONE);
190
			this.topToolBarContainer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
190
			this.topToolBarsContainer = new Composite(firstLineComposite, SWT.NONE);
191
			this.topToolBarsContainer.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
191 192
			RowLayout rl = new RowLayout(SWT.HORIZONTAL);
192 193
			rl = new RowLayout(SWT.HORIZONTAL);
193 194
			rl.marginTop = rl.marginHeight = rl.marginWidth = rl.marginBottom = 0;
194 195
			rl.center = true;
195 196
			rl.spacing = 0;
196
			this.topToolBarContainer.setLayout(rl);
197
			this.topToolBarsContainer.setLayout(rl);
197 198

  
198
			this.extendedParametersGroupsComposite = new GLComposite(parent, SWT.NONE);
199
			if (parent.getLayout() instanceof GridLayout)	{
200
				this.extendedParametersGroupsComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
201
			}
199
			betweenTopToolbarsAndResultComposite = new GLComposite(parent, SWT.NONE, "Between Top toolbar and result area");
200
			this.betweenTopToolbarsAndResultComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
202 201

  
203
			this.topToolBar = new TXMEditorToolBar(this, this.topToolBarContainer, this.extendedParametersGroupsComposite, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
202
			
203
			this.extendedParametersGroupsComposite = new GLComposite(betweenTopToolbarsAndResultComposite, SWT.NONE, "Extended parameters area");
204
			this.extendedParametersGroupsComposite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
205

  
206
			this.topToolBar = new TXMEditorToolBar(this, this.topToolBarsContainer, this.extendedParametersGroupsComposite, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
204 207
			// FIXME: debug tests for see why there is an empty area at bottom of the toolbar
205 208
			//this.topToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
206 209

  
......
223 226
			
224 227
			
225 228
			// display main area
226
			this.resultArea = new GLComposite(parent, SWT.NONE);
229
			this.resultArea = new GLComposite(parent, SWT.NONE, "Result area");
227 230
			this.resultArea.setLayoutData(new GridData(GridData.FILL_BOTH));
228 231

  
229 232
			// create the bottom tool bar
......
236 239
			this.bottomToolBarContainer.setLayout(rl);
237 240

  
238 241
			
239
			this.bottomSubWidgetsComposite = new GLComposite(parent, SWT.NONE);
242
			this.bottomSubWidgetsComposite = new GLComposite(parent, SWT.NONE, "Bottom parameters area");
240 243
			if (parent.getLayout() instanceof GridLayout)	{
241 244
				this.bottomSubWidgetsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
242 245
			}
......
284 287
	 * @return the composite that contains the default Top toolbar. 
285 288
	 */
286 289
	public Composite getTopToolbarContainer() {
287
		return topToolBarContainer;
290
		return topToolBarsContainer;
288 291
	}
289 292

  
290 293
	/**
294
	 * Use this composite if you need to insert widget between the toptoolbars container and the result area
295
	 * @return
296
	 */
297
	public GLComposite getBetweenTopToolbarsAndResultComposite() {
298
		return betweenTopToolbarsAndResultComposite;
299
	}
300
	
301
	/**
291 302
	 * Use this method to add widget next to the default Bottom toolbar
292 303
	 * 
293 304
	 * @return the composite that contains the default Bottom toolbar. 
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMWebBrowserEditor.java (revision 837)
60 60
			this.browser = browser;
61 61
		}
62 62
		public Object function (Object[] arguments) {
63
			if (arguments.length == 0) return null;
64
			
63 65
			HashMap<String, String> params = new HashMap<String, String>();
64 66
			for (int i = 0 ; i < arguments.length ; i += 2) {
65 67
				params.put(arguments[i].toString(), arguments[i+1].toString());
......
68 70
			String id = params.get("id");
69 71
			if (id != null) {
70 72
				params.remove("id");
71
				System.out.println("CALLING CMD with id="+id+" and parameters="+params);
73
				//System.out.println("CALLING CMD with id="+id+" and parameters="+params);
72 74
				//get the command from plugin.xml
73 75
				IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
74 76
				ICommandService cmdService = (ICommandService)window.getService(ICommandService.class);
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/OpenCloseToolItem.java (revision 837)
1
package org.txm.rcp.swt.toolbar;
2

  
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.events.SelectionEvent;
5
import org.eclipse.swt.events.SelectionListener;
6
import org.eclipse.swt.graphics.Image;
7
import org.eclipse.swt.widgets.ToolBar;
8
import org.eclipse.swt.widgets.ToolItem;
9
import org.txm.rcp.IImageKeys;
10

  
11
/**
12
 * A ToolItem SWT.CHECK with 2 images for the selected and not selected states
13
 * 
14
 * @author mdecorde
15
 *
16
 */
17
public class OpenCloseToolItem extends ToolItem {
18

  
19
	/**
20
	 * 
21
	 * @param parent
22
	 * @param title used as Text if openIconFilePath icon is not set, and as ToolTip text if openIconFilePath icon is set
23
	 * @param openIconFilePath
24
	 * @param closeIconFilePath
25
	 */
26
	public OpenCloseToolItem(ToolBar parent, String title, String openIconFilePath, String closeIconFilePath) {
27
		super(parent, SWT.CHECK);
28

  
29
		if (openIconFilePath != null) {
30
			openIcon = IImageKeys.getImage(openIconFilePath);
31
			this.setImage(openIcon);
32
			this.setToolTipText(title);
33
			if (closeIconFilePath != null) {
34
				closeIcon = IImageKeys.getImage(closeIconFilePath);
35
			}
36
		} else {
37
			this.setText(title);
38
		}
39
		
40
		this.addSelectionListener(new SelectionListener() {
41
			
42
			@Override
43
			public void widgetSelected(SelectionEvent e) {
44
				if (closeIcon != null) {
45
					if (getSelection()) {
46
						setImage(closeIcon);
47
					} else {
48
						setImage(openIcon);
49
					}
50
				}
51
			}
52
			
53
			@Override
54
			public void widgetDefaultSelected(SelectionEvent e) { }
55
		});
56
	}
57
	
58
	@Override
59
	public void checkSubclass() { }
60

  
61
	protected Image openIcon;
62
	protected Image closeIcon;
63
}
0 64

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownCheckToolItem.java (revision 837)
1
package org.txm.rcp.swt.toolbar;
2

  
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.events.SelectionEvent;
5
import org.eclipse.swt.events.SelectionListener;
6
import org.eclipse.swt.graphics.Image;
7
import org.eclipse.swt.widgets.ToolBar;
8
import org.eclipse.swt.widgets.ToolItem;
9
import org.txm.rcp.IImageKeys;
10
import org.txm.rcp.swt.listeners.DropdownSelectionListener;
11

  
12
/**
13
 * A ToolItem SWT.CHECK with 2 images for the selected and not selected states
14
 * 
15
 * @author mdecorde
16
 *
17
 */
18
public class DropDownCheckToolItem extends ToolItem {
19

  
20
	boolean selected = false;
21
	private DropdownSelectionListener dropDownListener;
22
	
23
	/**
24
	 * 
25
	 * @param parent
26
	 * @param title used as Text if openIconFilePath icon is not set, and as ToolTip text if openIconFilePath icon is set
27
	 * @param openIconFilePath
28
	 * @param closeIconFilePath
29
	 */
30
	public DropDownCheckToolItem(ToolBar parent, String title, String openIconFilePath, String closeIconFilePath) {
31
		super(parent, SWT.DROP_DOWN);
32

  
33
		this.dropDownListener = new org.txm.rcp.swt.listeners.DropdownSelectionListener(this);
34
		this.addSelectionListener(dropDownListener); // activate 
35
		
36
		if (openIconFilePath != null) {
37
			openIcon = IImageKeys.getImage(openIconFilePath);
38
			this.setImage(openIcon);
39
			this.setToolTipText(title);
40
			if (closeIconFilePath != null) {
41
				closeIcon = IImageKeys.getImage(closeIconFilePath);
42
			}
43
		} else {
44
			this.setText(title);
45
		}
46
		
47
		this.addSelectionListener(new SelectionListener() {
48
			
49
			@Override
50
			public void widgetSelected(SelectionEvent e) {
51
				if (!e.doit) {
52
					return; // drop down clicked
53
				}
54
				selected = !selected;
55
				if (closeIcon != null) {
56
					if (getSelection()) {
57
						setImage(closeIcon);
58
					} else {
59
						setImage(openIcon);
60
					}
61
				}
62
			}
63
			
64
			@Override
65
			public void widgetDefaultSelected(SelectionEvent e) {
66
				// TODO Auto-generated method stub
67
			}
68
		});
69
	}
70
	
71
	public boolean getSelection() {
72
		return selected;
73
	}
74
	
75
	public void setSelection(boolean selected) {
76
		this.selected = selected;
77
	}
78
	
79
	@Override
80
	public void checkSubclass() { }
81

  
82
	protected Image openIcon;
83
	protected Image closeIcon;
84

  
85
	public DropdownSelectionListener getDropDownListener() {
86
		return dropDownListener;
87
	}
88
}
0 89

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownToolItem.java (revision 837)
1
package org.txm.rcp.swt.toolbar;
2

  
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.events.SelectionEvent;
5
import org.eclipse.swt.events.SelectionListener;
6
import org.eclipse.swt.graphics.Image;
7
import org.eclipse.swt.widgets.ToolBar;
8
import org.eclipse.swt.widgets.ToolItem;
9
import org.txm.rcp.IImageKeys;
10

  
11
/**
12
 * A ToolItem SWT.CHECK with 2 images for the selected and not selected states
13
 * 
14
 * @author mdecorde
15
 *
16
 */
17
public class DropDownToolItem extends ToolItem {
18

  
19
	boolean selected = false;
20
	
21
	/**
22
	 * 
23
	 * @param parent
24
	 * @param title used as Text if openIconFilePath icon is not set, and as ToolTip text if openIconFilePath icon is set
25
	 * @param openIconFilePath
26
	 * @param closeIconFilePath
27
	 */
28
	public DropDownToolItem(ToolBar parent, String title, String openIconFilePath, String closeIconFilePath) {
29
		super(parent, SWT.DROP_DOWN| SWT.CHECK);
30

  
31
		if (openIconFilePath != null) {
32
			openIcon = IImageKeys.getImage(openIconFilePath);
33
			this.setImage(openIcon);
34
			this.setToolTipText(title);
35
			if (closeIconFilePath != null) {
36
				closeIcon = IImageKeys.getImage(closeIconFilePath);
37
			}
38
		} else {
39
			this.setText(title);
40
		}
41
		
42
		this.addSelectionListener(new SelectionListener() {
43
			
44
			@Override
45
			public void widgetSelected(SelectionEvent e) {
46
				//selected = !selected;
47
				if (closeIcon != null) {
48
					if (getSelection()) {
49
						setImage(closeIcon);
50
					} else {
51
						setImage(openIcon);
52
					}
53
				}
54
				
55
			}
56
			
57
			@Override
58
			public void widgetDefaultSelected(SelectionEvent e) {
59
				// TODO Auto-generated method stub
60
				
61
			}
62
		});
63
	}
64
	
65
//	public boolean getSelection() {
66
//		return selected;
67
//	}
68
//	
69
//	public void setSelection(boolean selected) {
70
//		this.selected = selected;
71
//	}
72
	
73
	@Override
74
	public void checkSubclass() { }
75

  
76
	protected Image openIcon;
77
	protected Image closeIcon;
78
}
0 79

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/SimpleSubcorpusPanel.java (revision 837)
1
package org.txm.rcp.swt.widget;
2

  
3
import java.util.ArrayList;
4
import java.util.Collections;
5
import java.util.List;
6

  
7
import org.eclipse.jface.dialogs.IDialogConstants;
8
import org.eclipse.jface.viewers.ArrayContentProvider;
9
import org.eclipse.jface.viewers.ISelection;
10
import org.eclipse.jface.viewers.IStructuredSelection;
11
import org.eclipse.jface.viewers.ListViewer;
12
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.events.SelectionEvent;
14
import org.eclipse.swt.events.SelectionListener;
15
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.layout.GridLayout;
17
import org.eclipse.swt.widgets.Combo;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Label;
20
import org.txm.rcp.actions.CreateSubcorpusDialog;
21
import org.txm.rcp.messages.TXMUIMessages;
22
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
23
import org.txm.searchengine.cqp.corpus.Corpus;
24
import org.txm.searchengine.cqp.corpus.StructuralUnit;
25
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
26
import org.txm.utils.logger.Log;
27

  
28
public class SimpleSubcorpusPanel extends Composite {
29

  
30
	public StructuralUnit selectedStructuralUnit;
31
	public StructuralUnitProperty selectedStructuralUnitProperty;
32
	public List<String> selectedValues;
33
	public List<StructuralUnitProperty> selectableStructuralUnitProperties = null;
34

  
35
	Combo structuralUnitsCombo;
36
	Combo propertyCombo;
37
	ListViewer valueCombo;
38
	
39
	List<StructuralUnit> structuralUnitsFinal;
40
	private CreateSubcorpusDialog dialog;
41
	private Corpus corpus;
42

  
43
	public SimpleSubcorpusPanel(Composite parent, int style, CreateSubcorpusDialog dialog, Corpus corpus) {
44
		super(parent, style);
45

  
46
		this.dialog = dialog;
47
		this.corpus = corpus;
48

  
49
		GridLayout layout = new GridLayout(2, false);
50
		this.setLayout(layout);
51

  
52
		Label structureLabel = new Label(this, SWT.NONE);
53
		structureLabel.setText(TXMUIMessages.CreatePartitionDialog_2);
54
		structureLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
55

  
56
		structuralUnitsCombo = new Combo(this, SWT.READ_ONLY);
57
		structuralUnitsCombo.setLayoutData(new GridData(GridData.FILL,GridData.FILL, true, false));
58

  
59
		Label propertyLabel = new Label(this, SWT.NONE);
60
		propertyLabel.setText(TXMUIMessages.CreatePartitionDialog_4);
61
		propertyLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER,
62
				false, false));
63

  
64
		propertyCombo = new Combo(this, SWT.READ_ONLY);
65
		propertyCombo.setLayoutData(new GridData(GridData.FILL,GridData.FILL, true, false));
66

  
67
		Label valuesLabel = new Label(this, SWT.NONE);
68
		valuesLabel.setText(TXMUIMessages.CreateSubcorpusDialog_6);
69
		valuesLabel.setLayoutData(new GridData(GridData.END, GridData.CENTER, false, false));
70

  
71
		valueCombo = new ListViewer(this, SWT.MULTI |SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
72
		valueCombo.setContentProvider(new ArrayContentProvider());
73
//		valueCombo.setLabelProvider(new LabelProvider() {
74
//
75
//	        @Override
76
//	        public String getText(Object element) {
77
//	            return Activator.getSomeService().key2Value((Integer) element);
78
//	        }
79
//
80
//	    });
81
		GridData data = new GridData(GridData.FILL,GridData.FILL, true, false);
82
		data.heightHint = 100;
83
		valueCombo.getList().setLayoutData(data);
84
	
85

  
86
		// Load StructuralUnit
87
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88
		List<StructuralUnit> structuralUnits = null;
89
		try {
90
			structuralUnits = corpus.getOrderedStructuralUnits();
91
		} catch (Exception e) {
92
			Log.severe(TXMUIMessages.ERROR
93
					+ Log.toString(e));
94
			return;
95
		}
96

  
97
		structuralUnitsFinal = new ArrayList<StructuralUnit>();
98

  
99

  
100
		for (StructuralUnit unit : structuralUnits) {
101
			if (unit.getOrderedProperties() != null
102
					&& unit.getOrderedProperties().size() != 0) {
103
				if (!"txmcorpus".equals(unit.getName())) { // keep all but txmcorpus //$NON-NLS-1$
104
					structuralUnitsFinal.add(unit);
105
					structuralUnitsCombo.add(unit.getName());
106
				}
107
			}
108
		}
109

  
110
		if (structuralUnitsCombo.getItemCount() == 0) {
111
			dialog.getButton(IDialogConstants.OK_ID).setEnabled(false);
112
		} else {
113
			String[] items = structuralUnitsCombo.getItems();
114
			structuralUnitsCombo.select(0);
115
			for (int i = 0 ; i < items.length ; i++)
116
				if (items[i].equals("text")) { //$NON-NLS-1$
117
					structuralUnitsCombo.select(i);
118
					break;
119
				}
120

  
121
			selectedStructuralUnit = structuralUnitsFinal.get(0);
122
		}
123
		// Load StructuralUnitProperty
124
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
125

  
126
		structuralUnitsCombo.addSelectionListener(new SelectionListener() {
127
			@Override
128
			public void widgetDefaultSelected(SelectionEvent e) {
129
			}
130

  
131
			@Override
132
			public void widgetSelected(SelectionEvent event) {
133
				System.out.println(TXMUIMessages.SimpleSubcorpusPanel_0);
134
				reloadProperties();
135
			}
136
		});
137

  
138
		/*
139
		 * for(StructuralUnitProperty property :
140
		 * structuralUnitsFinal.get(0).getProperties()) {
141
		 * propertyCombo.add(property.getName()); }
142
		 * 
143
		 * propertyCombo.select(0); selectedStructuralUnitProperty =
144
		 * selectedStructuralUnit.getProperties().get(0);
145
		 */
146
		// Load Values
147
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148

  
149
		propertyCombo.addSelectionListener(new SelectionListener() {
150
			@Override
151
			public void widgetDefaultSelected(SelectionEvent e) {
152
			}
153

  
154
			@Override
155
			public void widgetSelected(SelectionEvent event) {
156
				reloadValues();
157
			}
158
		});
159

  
160
		valueCombo.getList().addSelectionListener(new SelectionListener() {
161
			@Override
162
			public void widgetSelected(SelectionEvent e) {
163
				ISelection sel = valueCombo.getSelection();
164
				if (sel instanceof IStructuredSelection) {
165
					selectedValues = ((IStructuredSelection)sel).toList();
166
				}
167
			}
168
			
169
			@Override
170
			public void widgetDefaultSelected(SelectionEvent e) {
171
				// TODO Auto-generated method stub
172
				
173
			}
174
		});
175

  
176
		reloadProperties();
177
	}
178

  
179
	/**
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff