34 |
34 |
|
35 |
35 |
import javax.xml.parsers.ParserConfigurationException;
|
36 |
36 |
|
|
37 |
import org.eclipse.jface.dialogs.MessageDialog;
|
37 |
38 |
import org.eclipse.jface.viewers.TableViewer;
|
38 |
39 |
import org.eclipse.jface.viewers.TreeViewer;
|
39 |
40 |
import org.eclipse.jface.wizard.WizardDialog;
|
... | ... | |
43 |
44 |
import org.eclipse.swt.graphics.FontData;
|
44 |
45 |
import org.eclipse.swt.layout.RowLayout;
|
45 |
46 |
import org.eclipse.swt.widgets.Composite;
|
|
47 |
import org.eclipse.swt.widgets.Display;
|
46 |
48 |
import org.eclipse.swt.widgets.Label;
|
47 |
49 |
import org.eclipse.ui.IEditorPart;
|
48 |
50 |
import org.eclipse.ui.IWorkbenchPartConstants;
|
... | ... | |
88 |
90 |
* set corpus parameters
|
89 |
91 |
*/
|
90 |
92 |
public class CorpusPage extends FormPage {
|
91 |
|
|
|
93 |
|
92 |
94 |
private static String lastOpenedSrcDir;
|
93 |
|
|
|
95 |
|
94 |
96 |
ImportFormEditor editor;
|
|
97 |
|
95 |
98 |
ScrolledForm form;
|
|
99 |
|
96 |
100 |
FormToolkit toolkit;
|
97 |
|
|
|
101 |
|
98 |
102 |
HashMap<String, Boolean> moduleParams; // the import sections configuration depends on the import module selected
|
99 |
|
|
|
103 |
|
100 |
104 |
// All the sections that populate the import parameter file
|
101 |
105 |
Section pattrSection;
|
|
106 |
|
102 |
107 |
Section preBuildSection;
|
|
108 |
|
103 |
109 |
Section querySection;
|
|
110 |
|
104 |
111 |
Section sattrSection;
|
|
112 |
|
105 |
113 |
ImportEditorSection uiSection;
|
|
114 |
|
106 |
115 |
ImportEditorSection xsltSection;
|
|
116 |
|
107 |
117 |
ImportEditorSection tokenizerSection;
|
|
118 |
|
108 |
119 |
ImportEditorSection editionSection;
|
|
120 |
|
109 |
121 |
ImportEditorSection encodingSection;
|
|
122 |
|
110 |
123 |
ImportEditorSection fontSection;
|
|
124 |
|
111 |
125 |
ImportEditorSection infosSection;
|
|
126 |
|
112 |
127 |
ImportEditorSection langSection;
|
|
128 |
|
113 |
129 |
ImportEditorSection textualPlansSection;
|
|
130 |
|
114 |
131 |
ImportEditorSection optionsSection;
|
115 |
|
|
|
132 |
|
116 |
133 |
// old widgets to be moved/deleted
|
117 |
134 |
TableViewer preBuildViewer;
|
|
135 |
|
118 |
136 |
TreeViewer preBuildViewer2;
|
|
137 |
|
119 |
138 |
TableViewer queriesViewer;
|
|
139 |
|
120 |
140 |
TableViewer sattributesViewer;
|
|
141 |
|
121 |
142 |
TableViewer editionsViewer;
|
|
143 |
|
122 |
144 |
TableViewer viewer;
|
|
145 |
|
123 |
146 |
TableViewer pattributesViewer;
|
124 |
|
|
|
147 |
|
125 |
148 |
private Project project;
|
126 |
|
|
|
149 |
|
127 |
150 |
/**
|
128 |
151 |
* Instantiates a new main page.
|
129 |
152 |
*
|
130 |
153 |
* @param editor the editor
|
131 |
|
* @param corpusname
|
|
154 |
* @param corpusname
|
132 |
155 |
*/
|
133 |
156 |
public CorpusPage(ImportFormEditor editor) {
|
134 |
|
super(editor, TXMUIMessages.parameters, TXMUIMessages.parameters);
|
|
157 |
super(editor, TXMUIMessages.parameters, TXMUIMessages.parameters);
|
135 |
158 |
this.editor = editor;
|
136 |
159 |
}
|
137 |
|
|
|
160 |
|
138 |
161 |
private int createEditionsSection() {
|
139 |
|
editionSection = new EditionSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE, moduleParams, editor.getGroovyScript().getName());
|
|
162 |
editionSection = new EditionSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE, moduleParams, editor.getGroovyScript().getName());
|
140 |
163 |
return editionSection.getSectionSize();
|
141 |
164 |
}
|
142 |
|
|
|
165 |
|
143 |
166 |
private int createEmptyCell() {
|
144 |
167 |
Label l = toolkit.createLabel(form.getBody(), "", SWT.NONE); //$NON-NLS-1$
|
145 |
168 |
TableWrapData td = new TableWrapData();
|
146 |
169 |
td.colspan = 1;
|
147 |
170 |
l.setLayoutData(td);
|
148 |
|
|
|
171 |
|
149 |
172 |
return 1;
|
150 |
173 |
}
|
151 |
|
|
|
174 |
|
152 |
175 |
private int createEncodingSection() {
|
153 |
|
encodingSection = new EncodingSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
176 |
encodingSection = new EncodingSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
154 |
177 |
return encodingSection.getSectionSize();
|
155 |
178 |
}
|
156 |
|
|
|
179 |
|
157 |
180 |
private int createFontSection() {
|
158 |
|
fontSection = new FontSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
181 |
fontSection = new FontSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
159 |
182 |
return fontSection.getSectionSize();
|
160 |
183 |
}
|
161 |
|
|
162 |
|
/* (non-Javadoc)
|
|
184 |
|
|
185 |
/*
|
|
186 |
* (non-Javadoc)
|
163 |
187 |
* @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
|
164 |
188 |
*/
|
165 |
189 |
@Override
|
... | ... | |
169 |
193 |
TableWrapLayout layout = new TableWrapLayout();
|
170 |
194 |
layout.numColumns = 2;
|
171 |
195 |
layout.makeColumnsEqualWidth = false;
|
172 |
|
|
|
196 |
|
173 |
197 |
form.getBody().setLayout(layout);
|
174 |
|
|
|
198 |
|
175 |
199 |
createToolbar();
|
176 |
|
|
|
200 |
|
177 |
201 |
String importName = editor.getGroovyscript().getName();
|
178 |
202 |
moduleParams = ImportModuleCustomization.getParameters(importName);
|
179 |
|
|
|
203 |
|
180 |
204 |
// CREATE THE SECTIONS
|
181 |
205 |
int N_SECTIONS = 0;
|
182 |
206 |
N_SECTIONS += createInfosSection(); // mandatory
|
183 |
|
|
|
207 |
|
184 |
208 |
if (moduleParams.get(ImportModuleCustomization.ENCODING)) {
|
185 |
209 |
N_SECTIONS += createEncodingSection();
|
186 |
210 |
}
|
187 |
|
|
|
211 |
|
188 |
212 |
if (moduleParams.get(ImportModuleCustomization.LANG)) {
|
189 |
213 |
N_SECTIONS += createLangSection();
|
190 |
214 |
}
|
191 |
|
|
|
215 |
|
192 |
216 |
if (moduleParams.get(ImportModuleCustomization.TOKENIZER)) {
|
193 |
217 |
N_SECTIONS += createTokenizerSection();
|
194 |
218 |
}
|
195 |
|
|
|
219 |
|
196 |
220 |
if (moduleParams.get(ImportModuleCustomization.XSLT)) {
|
197 |
|
if (N_SECTIONS%2 != 0) { // needs 2 cells to draw
|
|
221 |
if (N_SECTIONS % 2 != 0) { // needs 2 cells to draw
|
198 |
222 |
N_SECTIONS += createEmptyCell();
|
199 |
223 |
}
|
200 |
224 |
N_SECTIONS += createFrontXSLTSection();
|
201 |
225 |
}
|
202 |
|
|
203 |
|
if (moduleParams.get(ImportModuleCustomization.EDITIONS_PAGEELEMENT) || moduleParams.get(ImportModuleCustomization.EDITIONS_WORDSPERPAGE) ) {
|
|
226 |
|
|
227 |
if (moduleParams.get(ImportModuleCustomization.EDITIONS_PAGEELEMENT) || moduleParams.get(ImportModuleCustomization.EDITIONS_WORDSPERPAGE)) {
|
204 |
228 |
N_SECTIONS += createEditionsSection();
|
205 |
229 |
}
|
206 |
|
|
|
230 |
|
207 |
231 |
N_SECTIONS += createFontSection();
|
208 |
|
|
|
232 |
|
209 |
233 |
if (moduleParams.get(ImportModuleCustomization.UI)) {
|
210 |
234 |
N_SECTIONS += createUIsSection();
|
211 |
235 |
}
|
212 |
|
|
|
236 |
|
213 |
237 |
if (moduleParams.get(ImportModuleCustomization.TEXTUALPLANS)) {
|
214 |
238 |
N_SECTIONS += createTextualPlansSection();
|
215 |
239 |
}
|
216 |
240 |
if (moduleParams.get(ImportModuleCustomization.OPTIONS)) {
|
217 |
241 |
N_SECTIONS += createOptionsSection();
|
218 |
242 |
}
|
219 |
|
|
|
243 |
|
220 |
244 |
// END OF SECTIONS CREATION, ENSURE THAT THE NUMBER OF CELL is %2
|
221 |
|
if (N_SECTIONS%2 != 0) N_SECTIONS += createEmptyCell();
|
222 |
|
|
|
245 |
if (N_SECTIONS % 2 != 0) N_SECTIONS += createEmptyCell();
|
|
246 |
|
223 |
247 |
// create notes messages
|
224 |
|
Label separatorLabel = toolkit.createLabel(form.getBody(), "",SWT.SEPARATOR | SWT.HORIZONTAL); //$NON-NLS-1$
|
225 |
|
TableWrapData gdata = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE, 2,1);
|
|
248 |
Label separatorLabel = toolkit.createLabel(form.getBody(), "", SWT.SEPARATOR | SWT.HORIZONTAL); //$NON-NLS-1$
|
|
249 |
TableWrapData gdata = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.MIDDLE, 2, 1);
|
226 |
250 |
gdata.colspan = 2;
|
227 |
251 |
separatorLabel.setLayoutData(gdata);
|
228 |
|
|
|
252 |
|
229 |
253 |
Label mandatoryLabel = toolkit.createLabel(form.getBody(), TXMUIMessages.dDotMandatoryField, SWT.WRAP);
|
230 |
|
gdata = new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE, 2,1);
|
|
254 |
gdata = new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE, 2, 1);
|
231 |
255 |
gdata.colspan = 2;
|
232 |
256 |
mandatoryLabel.setLayoutData(gdata);
|
233 |
|
|
|
257 |
|
234 |
258 |
form.layout(true);
|
235 |
259 |
managedForm.reflow(true);
|
236 |
260 |
}
|
237 |
|
|
|
261 |
|
238 |
262 |
private int createTextualPlansSection() {
|
239 |
|
textualPlansSection = new TextualPlansSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
263 |
textualPlansSection = new TextualPlansSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
240 |
264 |
return textualPlansSection.getSectionSize();
|
241 |
265 |
}
|
242 |
|
|
|
266 |
|
243 |
267 |
private int createOptionsSection() {
|
244 |
|
optionsSection = new OptionsSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
268 |
optionsSection = new OptionsSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
245 |
269 |
return optionsSection.getSectionSize();
|
246 |
270 |
}
|
247 |
|
|
|
271 |
|
248 |
272 |
private int createInfosSection() {
|
249 |
|
infosSection = new InfosSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
273 |
infosSection = new InfosSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
250 |
274 |
return infosSection.getSectionSize();
|
251 |
275 |
}
|
252 |
|
|
|
276 |
|
253 |
277 |
/**
|
254 |
278 |
* Creates the front xslt section.
|
255 |
279 |
*/
|
256 |
280 |
private int createFrontXSLTSection() {
|
257 |
|
xsltSection = new FrontXSLSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
281 |
xsltSection = new FrontXSLSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
258 |
282 |
return xsltSection.getSectionSize();
|
259 |
283 |
}
|
260 |
|
|
|
284 |
|
261 |
285 |
/**
|
262 |
286 |
* Creates the lang section.
|
263 |
287 |
*/
|
264 |
288 |
private int createLangSection() {
|
265 |
|
langSection = new LangSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
289 |
langSection = new LangSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
266 |
290 |
return langSection.getSectionSize();
|
267 |
291 |
}
|
268 |
|
|
|
292 |
|
269 |
293 |
private void createPAttributesSection() {
|
270 |
|
/* pattrSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
271 |
|
pattrSection.setText(Messages.CorpusPage_10);
|
272 |
|
GridLayout layout = new GridLayout(1, true);
|
273 |
|
pattrSection.setLayout(layout);
|
274 |
|
pattrSection.setLayoutData(getSectionGridData(2));
|
275 |
|
pattrSection.setEnabled(false);
|
276 |
|
|
277 |
|
pattrSection.addExpansionListener(new ExpansionAdapter() {
|
278 |
|
@Override
|
279 |
|
public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
280 |
|
});
|
281 |
|
|
282 |
|
Composite sectionClient = toolkit.createComposite(pattrSection);
|
283 |
|
sectionClient.setLayout(new GridLayout(2, false));
|
284 |
|
pattrSection.setClient(sectionClient);
|
285 |
|
|
286 |
|
Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_11, SWT.PUSH);
|
287 |
|
addButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
288 |
|
addButton.addSelectionListener(new SelectionListener() {
|
289 |
|
@Override
|
290 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
291 |
|
}
|
292 |
|
|
293 |
|
@Override
|
294 |
|
public void widgetSelected(SelectionEvent e) {
|
295 |
|
if (params == null) return;
|
296 |
|
LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
297 |
|
values.put("id", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
298 |
|
values.put("shortname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
299 |
|
values.put("longname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
300 |
|
values.put("pattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
301 |
|
values.put("renderer", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
302 |
|
values.put("tooltip", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
303 |
|
values.put("type", "String"); //$NON-NLS-1$ //$NON-NLS-2$
|
304 |
|
values.put("import", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
305 |
|
values.put("mandatory", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
306 |
|
values.put("inputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
307 |
|
values.put("outputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
308 |
|
|
309 |
|
MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_12, values);
|
310 |
|
if (dlg.open() == Window.OK) {
|
311 |
|
params.addPAttribute(params.getCorpusElement(), values.get("id"), values.get("shortname"), values.get("longname"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
312 |
|
values.get("type"), values.get("renderer"), values.get("tooltip"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
313 |
|
values.get("pattern"), values.get("import"), values.get("mandatory"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
314 |
|
values.get("inputFormat"), values.get("outputFormat")); //$NON-NLS-1$ //$NON-NLS-2$
|
315 |
|
updatePAttributeSection();
|
316 |
|
}
|
317 |
|
}
|
318 |
|
});
|
319 |
|
|
320 |
|
Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_13, SWT.PUSH);
|
321 |
|
removeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
322 |
|
removeButton.addSelectionListener(new SelectionListener() {
|
323 |
|
@Override
|
324 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
325 |
|
}
|
326 |
|
|
327 |
|
@Override
|
328 |
|
public void widgetSelected(SelectionEvent e) {
|
329 |
|
if (params == null) return;
|
330 |
|
ISelection sel = pattributesViewer.getSelection();
|
331 |
|
IStructuredSelection ssel = (IStructuredSelection) sel;
|
332 |
|
Object obj = ssel.getFirstElement();
|
333 |
|
if (obj instanceof Element) {
|
334 |
|
Element query = (Element) obj;
|
335 |
|
params.getPAttributesElement(params.getCorpusElement()).removeChild(query);
|
336 |
|
updatePAttributeSection();
|
337 |
|
}
|
338 |
|
}
|
339 |
|
});
|
340 |
|
|
341 |
|
Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
342 |
|
pattributesViewer = new TableViewer(table);
|
343 |
|
pattributesViewer.getTable().addKeyListener(new TableKeyListener(pattributesViewer));
|
344 |
|
GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false,2,1);
|
345 |
|
gd.heightHint = 150;
|
346 |
|
pattributesViewer.getTable().setLayoutData(gd);
|
347 |
|
pattributesViewer.setContentProvider(new NodeListContentProvider());
|
348 |
|
pattributesViewer.getTable().setHeaderVisible(true);
|
349 |
|
pattributesViewer.getTable().setLinesVisible(true);
|
350 |
|
|
351 |
|
String[] cols = {"id", "shortname", "longname", "import", "mandatory", "pattern", "renderer", "tooltip", "type"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
|
352 |
|
for (String col : cols) {
|
353 |
|
TableViewerColumn columnViewer = new TableViewerColumn(pattributesViewer, SWT.NONE);
|
354 |
|
TableColumn column = columnViewer.getColumn();
|
355 |
|
column.setText(col);
|
356 |
|
column.setWidth(100);
|
357 |
|
columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
358 |
|
}
|
|
294 |
/*
|
|
295 |
* pattrSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
296 |
* pattrSection.setText(Messages.CorpusPage_10);
|
|
297 |
* GridLayout layout = new GridLayout(1, true);
|
|
298 |
* pattrSection.setLayout(layout);
|
|
299 |
* pattrSection.setLayoutData(getSectionGridData(2));
|
|
300 |
* pattrSection.setEnabled(false);
|
|
301 |
* pattrSection.addExpansionListener(new ExpansionAdapter() {
|
|
302 |
* @Override
|
|
303 |
* public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
|
304 |
* });
|
|
305 |
* Composite sectionClient = toolkit.createComposite(pattrSection);
|
|
306 |
* sectionClient.setLayout(new GridLayout(2, false));
|
|
307 |
* pattrSection.setClient(sectionClient);
|
|
308 |
* Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_11, SWT.PUSH);
|
|
309 |
* addButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
310 |
* addButton.addSelectionListener(new SelectionListener() {
|
|
311 |
* @Override
|
|
312 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
313 |
* }
|
|
314 |
* @Override
|
|
315 |
* public void widgetSelected(SelectionEvent e) {
|
|
316 |
* if (params == null) return;
|
|
317 |
* LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
|
318 |
* values.put("id", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
319 |
* values.put("shortname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
320 |
* values.put("longname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
321 |
* values.put("pattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
322 |
* values.put("renderer", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
323 |
* values.put("tooltip", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
324 |
* values.put("type", "String"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
325 |
* values.put("import", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
326 |
* values.put("mandatory", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
327 |
* values.put("inputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
328 |
* values.put("outputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
329 |
* MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_12, values);
|
|
330 |
* if (dlg.open() == Window.OK) {
|
|
331 |
* params.addPAttribute(params.getCorpusElement(), values.get("id"), values.get("shortname"), values.get("longname"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
332 |
* values.get("type"), values.get("renderer"), values.get("tooltip"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
333 |
* values.get("pattern"), values.get("import"), values.get("mandatory"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
334 |
* values.get("inputFormat"), values.get("outputFormat")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
335 |
* updatePAttributeSection();
|
|
336 |
* }
|
|
337 |
* }
|
|
338 |
* });
|
|
339 |
* Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_13, SWT.PUSH);
|
|
340 |
* removeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
341 |
* removeButton.addSelectionListener(new SelectionListener() {
|
|
342 |
* @Override
|
|
343 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
344 |
* }
|
|
345 |
* @Override
|
|
346 |
* public void widgetSelected(SelectionEvent e) {
|
|
347 |
* if (params == null) return;
|
|
348 |
* ISelection sel = pattributesViewer.getSelection();
|
|
349 |
* IStructuredSelection ssel = (IStructuredSelection) sel;
|
|
350 |
* Object obj = ssel.getFirstElement();
|
|
351 |
* if (obj instanceof Element) {
|
|
352 |
* Element query = (Element) obj;
|
|
353 |
* params.getPAttributesElement(params.getCorpusElement()).removeChild(query);
|
|
354 |
* updatePAttributeSection();
|
|
355 |
* }
|
|
356 |
* }
|
|
357 |
* });
|
|
358 |
* Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
|
359 |
* pattributesViewer = new TableViewer(table);
|
|
360 |
* pattributesViewer.getTable().addKeyListener(new TableKeyListener(pattributesViewer));
|
|
361 |
* GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false,2,1);
|
|
362 |
* gd.heightHint = 150;
|
|
363 |
* pattributesViewer.getTable().setLayoutData(gd);
|
|
364 |
* pattributesViewer.setContentProvider(new NodeListContentProvider());
|
|
365 |
* pattributesViewer.getTable().setHeaderVisible(true);
|
|
366 |
* pattributesViewer.getTable().setLinesVisible(true);
|
|
367 |
* String[] cols = {"id", "shortname", "longname", "import", "mandatory", "pattern", "renderer", "tooltip", "type"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
368 |
* //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
|
|
369 |
* for (String col : cols) {
|
|
370 |
* TableViewerColumn columnViewer = new TableViewerColumn(pattributesViewer, SWT.NONE);
|
|
371 |
* TableColumn column = columnViewer.getColumn();
|
|
372 |
* column.setText(col);
|
|
373 |
* column.setWidth(100);
|
|
374 |
* columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
|
375 |
* }
|
359 |
376 |
*/
|
360 |
377 |
}
|
361 |
|
|
|
378 |
|
362 |
379 |
private void createPreBuildSection() {
|
363 |
|
/* preBuildSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
364 |
|
preBuildSection.setText(Messages.CorpusPage_14);
|
365 |
|
GridLayout layout = new GridLayout(1, true);
|
366 |
|
preBuildSection.setLayout(layout);
|
367 |
|
preBuildSection.setLayoutData(getSectionGridData(2));
|
368 |
|
preBuildSection.setEnabled(false);
|
369 |
|
|
370 |
|
preBuildSection.addExpansionListener(new ExpansionAdapter() {
|
371 |
|
@Override
|
372 |
|
public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
373 |
|
});
|
374 |
|
|
375 |
|
Composite sectionClient = toolkit.createComposite(preBuildSection);
|
376 |
|
sectionClient.setLayout(new GridLayout(4, false));
|
377 |
|
preBuildSection.setClient(sectionClient);
|
378 |
|
|
379 |
|
Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_15, SWT.PUSH);
|
380 |
|
addButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
381 |
|
addButton.addSelectionListener(new SelectionListener() {
|
382 |
|
@Override
|
383 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
384 |
|
}
|
385 |
|
|
386 |
|
@Override
|
387 |
|
public void widgetSelected(SelectionEvent e) {
|
388 |
|
if (params == null) return;
|
389 |
|
LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
390 |
|
values.put("subcorpus", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
391 |
|
values.put("query", "[]"); //$NON-NLS-1$ //$NON-NLS-2$
|
392 |
|
values.put("desc", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
393 |
|
MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_15, values);
|
394 |
|
if (dlg.open() == Window.OK) {
|
395 |
|
params.addSubcorpus(params.getCorpusElement(), values.get("subcorpus"), values.get("query"), values.get("desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
396 |
|
updatePreBuildSection();
|
397 |
|
}
|
398 |
|
}
|
399 |
|
});
|
400 |
|
|
401 |
|
Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_17, SWT.PUSH);
|
402 |
|
removeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
403 |
|
removeButton.addSelectionListener(new SelectionListener() {
|
404 |
|
@Override
|
405 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
406 |
|
}
|
407 |
|
|
408 |
|
@Override
|
409 |
|
public void widgetSelected(SelectionEvent e) {
|
410 |
|
if (params == null) return;
|
411 |
|
ISelection sel = preBuildViewer.getSelection();
|
412 |
|
IStructuredSelection ssel = (IStructuredSelection) sel;
|
413 |
|
Object obj = ssel.getFirstElement();
|
414 |
|
if (obj instanceof Element) {
|
415 |
|
Element subcorpus = (Element) obj;
|
416 |
|
System.out.println("SELECTED: "+subcorpus); //$NON-NLS-1$
|
417 |
|
params.getPreBuildElement(params.getCorpusElement()).removeChild(subcorpus);
|
418 |
|
updatePreBuildSection();
|
419 |
|
}
|
420 |
|
}
|
421 |
|
});
|
422 |
|
|
423 |
|
Button add2Button = toolkit.createButton(sectionClient, Messages.CorpusPage_18, SWT.PUSH);
|
424 |
|
add2Button.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
425 |
|
add2Button.addSelectionListener(new SelectionListener() {
|
426 |
|
@Override
|
427 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
428 |
|
}
|
429 |
|
|
430 |
|
@Override
|
431 |
|
public void widgetSelected(SelectionEvent e) {
|
432 |
|
if (params == null) return;
|
433 |
|
LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
434 |
|
values.put("partition", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
435 |
|
ArrayList<LinkedHashMap<String, String>> subvaluesArray = new ArrayList<LinkedHashMap<String, String>>();
|
436 |
|
LinkedHashMap<String, String> subvalues = new LinkedHashMap<String, String>();
|
437 |
|
subvaluesArray.add(subvalues);
|
438 |
|
subvalues.put("part", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
439 |
|
subvalues.put("query", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
440 |
|
MultipleValueTreeDialog dlg = new MultipleValueTreeDialog(form.getShell(), Messages.CorpusPage_18, values, subvaluesArray, "part"); //$NON-NLS-1$
|
441 |
|
if (dlg.open() == Window.OK) {
|
442 |
|
String[] names = new String[subvaluesArray.size()];
|
443 |
|
String[] queries = new String[subvaluesArray.size()];
|
444 |
|
for (int i = 0 ; i < subvaluesArray.size() ; i++) {
|
445 |
|
LinkedHashMap<String, String> it = subvaluesArray.get(i);
|
446 |
|
names[i] = it.get("part"); //$NON-NLS-1$
|
447 |
|
queries[i] = it.get("query"); //$NON-NLS-1$
|
448 |
|
}
|
449 |
|
params.addPartition(params.getCorpusElement(), values.get("partition"), queries, names); //$NON-NLS-1$
|
450 |
|
updatePreBuildSection();
|
451 |
|
}
|
452 |
|
}
|
453 |
|
});
|
454 |
|
|
455 |
|
Button remove2Button = toolkit.createButton(sectionClient, Messages.CorpusPage_20, SWT.PUSH);
|
456 |
|
remove2Button.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
457 |
|
remove2Button.addSelectionListener(new SelectionListener() {
|
458 |
|
@Override
|
459 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
460 |
|
}
|
461 |
|
|
462 |
|
@Override
|
463 |
|
public void widgetSelected(SelectionEvent e) {
|
464 |
|
if (params == null) return;
|
465 |
|
ISelection sel = preBuildViewer2.getSelection();
|
466 |
|
IStructuredSelection ssel = (IStructuredSelection) sel;
|
467 |
|
Object obj = ssel.getFirstElement();
|
468 |
|
System.out.println("SELECTED: "+obj); //$NON-NLS-1$
|
469 |
|
if (obj instanceof Element) {
|
470 |
|
Element partitionElem = (Element) obj;
|
471 |
|
if (partitionElem.getParentNode().equals(params.getPreBuildElement(params.getCorpusElement())))
|
472 |
|
{ params.getPreBuildElement(params.getCorpusElement()).removeChild(partitionElem);
|
473 |
|
updatePreBuildSection();
|
474 |
|
}
|
475 |
|
}
|
476 |
|
}
|
477 |
|
});
|
478 |
|
|
479 |
|
Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
480 |
|
preBuildViewer = new TableViewer(table);
|
481 |
|
preBuildViewer.getTable().addKeyListener(new TableKeyListener(preBuildViewer));
|
482 |
|
GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false,1,1);
|
483 |
|
gd.heightHint = 150;
|
484 |
|
preBuildViewer.getTable().setLayoutData(gd);
|
485 |
|
preBuildViewer.setContentProvider(new NodeListContentProvider());
|
486 |
|
preBuildViewer.getTable().setHeaderVisible(true);
|
487 |
|
preBuildViewer.getTable().setLinesVisible(true);
|
488 |
|
|
489 |
|
String[] cols = {"name", "query", "desc"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
490 |
|
for (String col : cols) {
|
491 |
|
TableViewerColumn columnViewer = new TableViewerColumn(preBuildViewer, SWT.NONE);
|
492 |
|
TableColumn column = columnViewer.getColumn();
|
493 |
|
column.setText(col);
|
494 |
|
column.setWidth(100);
|
495 |
|
columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
496 |
|
}
|
497 |
|
|
498 |
|
Tree table2 = toolkit.createTree(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
499 |
|
preBuildViewer2 = new TreeViewer(table2);
|
500 |
|
GridData gd2 = new GridData(GridData.FILL, GridData.FILL, false, false, 3, 1);
|
501 |
|
gd2.heightHint = 150;
|
502 |
|
preBuildViewer2.getTree().setLayoutData(gd2);
|
503 |
|
preBuildViewer2.getTree().setHeaderVisible(true);
|
504 |
|
preBuildViewer2.getTree().setLinesVisible(true);
|
505 |
|
|
506 |
|
String[] cols1 = {"name"}; //$NON-NLS-1$
|
507 |
|
String[] cols2 = {"name", "query"}; //$NON-NLS-1$ //$NON-NLS-2$
|
508 |
|
preBuildViewer2.setContentProvider(new ElementTreeContentProvider("partition", "part", cols1, cols2)); //$NON-NLS-1$ //$NON-NLS-2$
|
509 |
|
//preBuildViewer2.setLabelProvider(new ElementTreeLabelProvider("partition", "part", cols1, cols2));
|
510 |
|
|
511 |
|
int c = 0;
|
512 |
|
for (String col : cols2) {
|
513 |
|
TreeViewerColumn columnViewer = new TreeViewerColumn(preBuildViewer2, SWT.NONE);
|
514 |
|
TreeColumn column = columnViewer.getColumn();
|
515 |
|
column.setText(col);
|
516 |
|
column.setWidth(100);
|
517 |
|
columnViewer.setLabelProvider(new ElementTreeLabelProvider(c++, "partition", "part", cols1, cols2)); //$NON-NLS-1$ //$NON-NLS-2$
|
518 |
|
}
|
|
380 |
/*
|
|
381 |
* preBuildSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
382 |
* preBuildSection.setText(Messages.CorpusPage_14);
|
|
383 |
* GridLayout layout = new GridLayout(1, true);
|
|
384 |
* preBuildSection.setLayout(layout);
|
|
385 |
* preBuildSection.setLayoutData(getSectionGridData(2));
|
|
386 |
* preBuildSection.setEnabled(false);
|
|
387 |
* preBuildSection.addExpansionListener(new ExpansionAdapter() {
|
|
388 |
* @Override
|
|
389 |
* public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
|
390 |
* });
|
|
391 |
* Composite sectionClient = toolkit.createComposite(preBuildSection);
|
|
392 |
* sectionClient.setLayout(new GridLayout(4, false));
|
|
393 |
* preBuildSection.setClient(sectionClient);
|
|
394 |
* Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_15, SWT.PUSH);
|
|
395 |
* addButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
396 |
* addButton.addSelectionListener(new SelectionListener() {
|
|
397 |
* @Override
|
|
398 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
399 |
* }
|
|
400 |
* @Override
|
|
401 |
* public void widgetSelected(SelectionEvent e) {
|
|
402 |
* if (params == null) return;
|
|
403 |
* LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
|
404 |
* values.put("subcorpus", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
405 |
* values.put("query", "[]"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
406 |
* values.put("desc", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
407 |
* MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_15, values);
|
|
408 |
* if (dlg.open() == Window.OK) {
|
|
409 |
* params.addSubcorpus(params.getCorpusElement(), values.get("subcorpus"), values.get("query"), values.get("desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
410 |
* updatePreBuildSection();
|
|
411 |
* }
|
|
412 |
* }
|
|
413 |
* });
|
|
414 |
* Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_17, SWT.PUSH);
|
|
415 |
* removeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
416 |
* removeButton.addSelectionListener(new SelectionListener() {
|
|
417 |
* @Override
|
|
418 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
419 |
* }
|
|
420 |
* @Override
|
|
421 |
* public void widgetSelected(SelectionEvent e) {
|
|
422 |
* if (params == null) return;
|
|
423 |
* ISelection sel = preBuildViewer.getSelection();
|
|
424 |
* IStructuredSelection ssel = (IStructuredSelection) sel;
|
|
425 |
* Object obj = ssel.getFirstElement();
|
|
426 |
* if (obj instanceof Element) {
|
|
427 |
* Element subcorpus = (Element) obj;
|
|
428 |
* System.out.println("SELECTED: "+subcorpus); //$NON-NLS-1$
|
|
429 |
* params.getPreBuildElement(params.getCorpusElement()).removeChild(subcorpus);
|
|
430 |
* updatePreBuildSection();
|
|
431 |
* }
|
|
432 |
* }
|
|
433 |
* });
|
|
434 |
* Button add2Button = toolkit.createButton(sectionClient, Messages.CorpusPage_18, SWT.PUSH);
|
|
435 |
* add2Button.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
436 |
* add2Button.addSelectionListener(new SelectionListener() {
|
|
437 |
* @Override
|
|
438 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
439 |
* }
|
|
440 |
* @Override
|
|
441 |
* public void widgetSelected(SelectionEvent e) {
|
|
442 |
* if (params == null) return;
|
|
443 |
* LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
|
444 |
* values.put("partition", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
445 |
* ArrayList<LinkedHashMap<String, String>> subvaluesArray = new ArrayList<LinkedHashMap<String, String>>();
|
|
446 |
* LinkedHashMap<String, String> subvalues = new LinkedHashMap<String, String>();
|
|
447 |
* subvaluesArray.add(subvalues);
|
|
448 |
* subvalues.put("part", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
449 |
* subvalues.put("query", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
450 |
* MultipleValueTreeDialog dlg = new MultipleValueTreeDialog(form.getShell(), Messages.CorpusPage_18, values, subvaluesArray, "part"); //$NON-NLS-1$
|
|
451 |
* if (dlg.open() == Window.OK) {
|
|
452 |
* String[] names = new String[subvaluesArray.size()];
|
|
453 |
* String[] queries = new String[subvaluesArray.size()];
|
|
454 |
* for (int i = 0 ; i < subvaluesArray.size() ; i++) {
|
|
455 |
* LinkedHashMap<String, String> it = subvaluesArray.get(i);
|
|
456 |
* names[i] = it.get("part"); //$NON-NLS-1$
|
|
457 |
* queries[i] = it.get("query"); //$NON-NLS-1$
|
|
458 |
* }
|
|
459 |
* params.addPartition(params.getCorpusElement(), values.get("partition"), queries, names); //$NON-NLS-1$
|
|
460 |
* updatePreBuildSection();
|
|
461 |
* }
|
|
462 |
* }
|
|
463 |
* });
|
|
464 |
* Button remove2Button = toolkit.createButton(sectionClient, Messages.CorpusPage_20, SWT.PUSH);
|
|
465 |
* remove2Button.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
466 |
* remove2Button.addSelectionListener(new SelectionListener() {
|
|
467 |
* @Override
|
|
468 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
469 |
* }
|
|
470 |
* @Override
|
|
471 |
* public void widgetSelected(SelectionEvent e) {
|
|
472 |
* if (params == null) return;
|
|
473 |
* ISelection sel = preBuildViewer2.getSelection();
|
|
474 |
* IStructuredSelection ssel = (IStructuredSelection) sel;
|
|
475 |
* Object obj = ssel.getFirstElement();
|
|
476 |
* System.out.println("SELECTED: "+obj); //$NON-NLS-1$
|
|
477 |
* if (obj instanceof Element) {
|
|
478 |
* Element partitionElem = (Element) obj;
|
|
479 |
* if (partitionElem.getParentNode().equals(params.getPreBuildElement(params.getCorpusElement())))
|
|
480 |
* { params.getPreBuildElement(params.getCorpusElement()).removeChild(partitionElem);
|
|
481 |
* updatePreBuildSection();
|
|
482 |
* }
|
|
483 |
* }
|
|
484 |
* }
|
|
485 |
* });
|
|
486 |
* Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
|
487 |
* preBuildViewer = new TableViewer(table);
|
|
488 |
* preBuildViewer.getTable().addKeyListener(new TableKeyListener(preBuildViewer));
|
|
489 |
* GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false,1,1);
|
|
490 |
* gd.heightHint = 150;
|
|
491 |
* preBuildViewer.getTable().setLayoutData(gd);
|
|
492 |
* preBuildViewer.setContentProvider(new NodeListContentProvider());
|
|
493 |
* preBuildViewer.getTable().setHeaderVisible(true);
|
|
494 |
* preBuildViewer.getTable().setLinesVisible(true);
|
|
495 |
* String[] cols = {"name", "query", "desc"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
496 |
* for (String col : cols) {
|
|
497 |
* TableViewerColumn columnViewer = new TableViewerColumn(preBuildViewer, SWT.NONE);
|
|
498 |
* TableColumn column = columnViewer.getColumn();
|
|
499 |
* column.setText(col);
|
|
500 |
* column.setWidth(100);
|
|
501 |
* columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
|
502 |
* }
|
|
503 |
* Tree table2 = toolkit.createTree(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
|
504 |
* preBuildViewer2 = new TreeViewer(table2);
|
|
505 |
* GridData gd2 = new GridData(GridData.FILL, GridData.FILL, false, false, 3, 1);
|
|
506 |
* gd2.heightHint = 150;
|
|
507 |
* preBuildViewer2.getTree().setLayoutData(gd2);
|
|
508 |
* preBuildViewer2.getTree().setHeaderVisible(true);
|
|
509 |
* preBuildViewer2.getTree().setLinesVisible(true);
|
|
510 |
* String[] cols1 = {"name"}; //$NON-NLS-1$
|
|
511 |
* String[] cols2 = {"name", "query"}; //$NON-NLS-1$ //$NON-NLS-2$
|
|
512 |
* preBuildViewer2.setContentProvider(new ElementTreeContentProvider("partition", "part", cols1, cols2)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
513 |
* //preBuildViewer2.setLabelProvider(new ElementTreeLabelProvider("partition", "part", cols1, cols2));
|
|
514 |
* int c = 0;
|
|
515 |
* for (String col : cols2) {
|
|
516 |
* TreeViewerColumn columnViewer = new TreeViewerColumn(preBuildViewer2, SWT.NONE);
|
|
517 |
* TreeColumn column = columnViewer.getColumn();
|
|
518 |
* column.setText(col);
|
|
519 |
* column.setWidth(100);
|
|
520 |
* columnViewer.setLabelProvider(new ElementTreeLabelProvider(c++, "partition", "part", cols1, cols2)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
521 |
* }
|
519 |
522 |
*/
|
520 |
523 |
}
|
|
524 |
|
521 |
525 |
private void createQueriesSection() {
|
522 |
|
/* querySection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
523 |
|
querySection.setText("Queries"); //$NON-NLS-1$
|
524 |
|
GridLayout layout = new GridLayout(1, true);
|
525 |
|
querySection.setLayout(layout);
|
526 |
|
querySection.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1));
|
527 |
|
querySection.setEnabled(false);
|
528 |
|
|
529 |
|
querySection.addExpansionListener(new ExpansionAdapter() {
|
530 |
|
@Override
|
531 |
|
public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
532 |
|
});
|
533 |
|
|
534 |
|
//filesection.setDescription("Select how to find source files");
|
535 |
|
Composite sectionClient = toolkit.createComposite(querySection);
|
536 |
|
sectionClient.setLayout(new GridLayout(2, false));
|
537 |
|
querySection.setClient(sectionClient);
|
538 |
|
|
539 |
|
Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_21, SWT.PUSH);
|
540 |
|
addButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
541 |
|
addButton.addSelectionListener(new SelectionListener() {
|
542 |
|
@Override
|
543 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
544 |
|
}
|
545 |
|
|
546 |
|
@Override
|
547 |
|
public void widgetSelected(SelectionEvent e) {
|
548 |
|
if (params == null) return;
|
549 |
|
LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
550 |
|
values.put("name", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
551 |
|
values.put("query", "[]"); //$NON-NLS-1$ //$NON-NLS-2$
|
552 |
|
values.put("desc", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
553 |
|
MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_21, values);
|
554 |
|
if (dlg.open() == Window.OK) {
|
555 |
|
params.addQuery(params.getCorpusElement(), values.get("name"), values.get("query"), values.get("desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
556 |
|
updateQuerySection();
|
557 |
|
}
|
558 |
|
}
|
559 |
|
});
|
560 |
|
|
561 |
|
Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_23, SWT.PUSH);
|
562 |
|
removeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
563 |
|
removeButton.addSelectionListener(new SelectionListener() {
|
564 |
|
@Override
|
565 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
566 |
|
}
|
567 |
|
|
568 |
|
@Override
|
569 |
|
public void widgetSelected(SelectionEvent e) {
|
570 |
|
if (params == null) return;
|
571 |
|
ISelection sel = queriesViewer.getSelection();
|
572 |
|
IStructuredSelection ssel = (IStructuredSelection) sel;
|
573 |
|
Object obj = ssel.getFirstElement();
|
574 |
|
if (obj instanceof Element) {
|
575 |
|
Element query = (Element) obj;
|
576 |
|
params.getQueriesElement(params.getCorpusElement()).removeChild(query);
|
577 |
|
updateQuerySection();
|
578 |
|
}
|
579 |
|
}
|
580 |
|
});
|
581 |
|
|
582 |
|
Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
583 |
|
queriesViewer = new TableViewer(table);
|
584 |
|
queriesViewer.getTable().addKeyListener(new TableKeyListener(queriesViewer));
|
585 |
|
GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false,2,1);
|
586 |
|
gd.heightHint = 150;
|
587 |
|
queriesViewer.getTable().setLayoutData(gd);
|
588 |
|
queriesViewer.setContentProvider(new NodeListContentProvider());
|
589 |
|
queriesViewer.getTable().setHeaderVisible(true);
|
590 |
|
queriesViewer.getTable().setLinesVisible(true);
|
591 |
|
|
592 |
|
String[] cols = {"name", "value", "desc"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
593 |
|
for (String col : cols) {
|
594 |
|
TableViewerColumn columnViewer = new TableViewerColumn(queriesViewer, SWT.NONE);
|
595 |
|
TableColumn column = columnViewer.getColumn();
|
596 |
|
column.setText(col);
|
597 |
|
column.setWidth(100);
|
598 |
|
columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
599 |
|
}
|
|
526 |
/*
|
|
527 |
* querySection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
528 |
* querySection.setText("Queries"); //$NON-NLS-1$
|
|
529 |
* GridLayout layout = new GridLayout(1, true);
|
|
530 |
* querySection.setLayout(layout);
|
|
531 |
* querySection.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1));
|
|
532 |
* querySection.setEnabled(false);
|
|
533 |
* querySection.addExpansionListener(new ExpansionAdapter() {
|
|
534 |
* @Override
|
|
535 |
* public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
|
536 |
* });
|
|
537 |
* //filesection.setDescription("Select how to find source files");
|
|
538 |
* Composite sectionClient = toolkit.createComposite(querySection);
|
|
539 |
* sectionClient.setLayout(new GridLayout(2, false));
|
|
540 |
* querySection.setClient(sectionClient);
|
|
541 |
* Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_21, SWT.PUSH);
|
|
542 |
* addButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
543 |
* addButton.addSelectionListener(new SelectionListener() {
|
|
544 |
* @Override
|
|
545 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
546 |
* }
|
|
547 |
* @Override
|
|
548 |
* public void widgetSelected(SelectionEvent e) {
|
|
549 |
* if (params == null) return;
|
|
550 |
* LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
|
551 |
* values.put("name", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
552 |
* values.put("query", "[]"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
553 |
* values.put("desc", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
554 |
* MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_21, values);
|
|
555 |
* if (dlg.open() == Window.OK) {
|
|
556 |
* params.addQuery(params.getCorpusElement(), values.get("name"), values.get("query"), values.get("desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
557 |
* updateQuerySection();
|
|
558 |
* }
|
|
559 |
* }
|
|
560 |
* });
|
|
561 |
* Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_23, SWT.PUSH);
|
|
562 |
* removeButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
|
|
563 |
* removeButton.addSelectionListener(new SelectionListener() {
|
|
564 |
* @Override
|
|
565 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
566 |
* }
|
|
567 |
* @Override
|
|
568 |
* public void widgetSelected(SelectionEvent e) {
|
|
569 |
* if (params == null) return;
|
|
570 |
* ISelection sel = queriesViewer.getSelection();
|
|
571 |
* IStructuredSelection ssel = (IStructuredSelection) sel;
|
|
572 |
* Object obj = ssel.getFirstElement();
|
|
573 |
* if (obj instanceof Element) {
|
|
574 |
* Element query = (Element) obj;
|
|
575 |
* params.getQueriesElement(params.getCorpusElement()).removeChild(query);
|
|
576 |
* updateQuerySection();
|
|
577 |
* }
|
|
578 |
* }
|
|
579 |
* });
|
|
580 |
* Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
|
581 |
* queriesViewer = new TableViewer(table);
|
|
582 |
* queriesViewer.getTable().addKeyListener(new TableKeyListener(queriesViewer));
|
|
583 |
* GridData gd = new GridData(GridData.FILL, GridData.FILL, false, false,2,1);
|
|
584 |
* gd.heightHint = 150;
|
|
585 |
* queriesViewer.getTable().setLayoutData(gd);
|
|
586 |
* queriesViewer.setContentProvider(new NodeListContentProvider());
|
|
587 |
* queriesViewer.getTable().setHeaderVisible(true);
|
|
588 |
* queriesViewer.getTable().setLinesVisible(true);
|
|
589 |
* String[] cols = {"name", "value", "desc"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
590 |
* for (String col : cols) {
|
|
591 |
* TableViewerColumn columnViewer = new TableViewerColumn(queriesViewer, SWT.NONE);
|
|
592 |
* TableColumn column = columnViewer.getColumn();
|
|
593 |
* column.setText(col);
|
|
594 |
* column.setWidth(100);
|
|
595 |
* columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
|
596 |
* }
|
600 |
597 |
*/
|
601 |
598 |
}
|
|
599 |
|
602 |
600 |
private void createSAttributesSection() {
|
603 |
|
/* sattrSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
604 |
|
sattrSection.setText(Messages.CorpusPage_24);
|
605 |
|
GridLayout layout = new GridLayout(1, true);
|
606 |
|
sattrSection.setLayout(layout);
|
607 |
|
sattrSection.setLayoutData(getSectionGridData(2));
|
608 |
|
sattrSection.setEnabled(false);
|
609 |
|
|
610 |
|
sattrSection.addExpansionListener(new ExpansionAdapter() {
|
611 |
|
@Override
|
612 |
|
public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
613 |
|
});
|
614 |
|
|
615 |
|
Composite sectionClient = toolkit.createComposite(sattrSection);
|
616 |
|
sectionClient.setLayout(new GridLayout(2, false));
|
617 |
|
sattrSection.setClient(sectionClient);
|
618 |
|
|
619 |
|
Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_25, SWT.PUSH);
|
620 |
|
addButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false));
|
621 |
|
addButton.addSelectionListener(new SelectionListener() {
|
622 |
|
@Override
|
623 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
624 |
|
}
|
625 |
|
|
626 |
|
@Override
|
627 |
|
public void widgetSelected(SelectionEvent e) {
|
628 |
|
if (params == null) return;
|
629 |
|
LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
630 |
|
values.put("id", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
631 |
|
values.put("shortname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
632 |
|
values.put("longname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
633 |
|
values.put("pattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
634 |
|
values.put("renderer", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
635 |
|
values.put("tooltip", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
636 |
|
values.put("type", "String"); //$NON-NLS-1$ //$NON-NLS-2$
|
637 |
|
values.put("import", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
638 |
|
values.put("mandatory", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
639 |
|
values.put("inputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
640 |
|
values.put("outputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
641 |
|
|
642 |
|
MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_25, values);
|
643 |
|
if (dlg.open() == Window.OK) {
|
644 |
|
params.addSAttribute(params.getCorpusElement(), values.get("id"), values.get("shortname"), values.get("longname"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
645 |
|
values.get("type"), values.get("renderer"), values.get("tooltip"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
646 |
|
values.get("pattern"), values.get("import"), values.get("mandatory"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
647 |
|
values.get("inputFormat"), values.get("outputFormat")); //$NON-NLS-1$ //$NON-NLS-2$
|
648 |
|
updateSAttributeSection();
|
649 |
|
}
|
650 |
|
}
|
651 |
|
});
|
652 |
|
|
653 |
|
Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_27, SWT.PUSH);
|
654 |
|
removeButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false));
|
655 |
|
removeButton.addSelectionListener(new SelectionListener() {
|
656 |
|
@Override
|
657 |
|
public void widgetDefaultSelected(SelectionEvent e) {
|
658 |
|
}
|
659 |
|
|
660 |
|
@Override
|
661 |
|
public void widgetSelected(SelectionEvent e) {
|
662 |
|
if ( params == null) return;
|
663 |
|
ISelection sel = sattributesViewer.getSelection();
|
664 |
|
IStructuredSelection ssel = (IStructuredSelection) sel;
|
665 |
|
Object obj = ssel.getFirstElement();
|
666 |
|
if (obj instanceof Element) {
|
667 |
|
Element query = (Element) obj;
|
668 |
|
params.getSAttributesElement(params.getCorpusElement()).removeChild(query);
|
669 |
|
updateSAttributeSection();
|
670 |
|
}
|
671 |
|
}
|
672 |
|
});
|
673 |
|
|
674 |
|
Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
675 |
|
sattributesViewer = new TableViewer(table);
|
676 |
|
sattributesViewer.getTable().addKeyListener(new TableKeyListener(sattributesViewer));
|
677 |
|
GridData gdata = new GridData(GridData.FILL, GridData.FILL, false, false,2,1);
|
678 |
|
gdata.heightHint = 150;
|
679 |
|
sattributesViewer.getTable().setLayoutData(gdata);
|
680 |
|
sattributesViewer.setContentProvider(new NodeListContentProvider());
|
681 |
|
sattributesViewer.getTable().setHeaderVisible(true);
|
682 |
|
sattributesViewer.getTable().setLinesVisible(true);
|
683 |
|
|
684 |
|
String[] cols = {"id", "shortname", "longname", "import", "mandatory", "pattern", "renderer", "tooltip", "type"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
|
685 |
|
for (String col : cols) {
|
686 |
|
TableViewerColumn columnViewer = new TableViewerColumn(sattributesViewer, SWT.NONE);
|
687 |
|
TableColumn column = columnViewer.getColumn();
|
688 |
|
column.setText(col);
|
689 |
|
//column.setWidth(10*col.length());
|
690 |
|
columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
691 |
|
column.pack();
|
692 |
|
}
|
|
601 |
/*
|
|
602 |
* sattrSection = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
603 |
* sattrSection.setText(Messages.CorpusPage_24);
|
|
604 |
* GridLayout layout = new GridLayout(1, true);
|
|
605 |
* sattrSection.setLayout(layout);
|
|
606 |
* sattrSection.setLayoutData(getSectionGridData(2));
|
|
607 |
* sattrSection.setEnabled(false);
|
|
608 |
* sattrSection.addExpansionListener(new ExpansionAdapter() {
|
|
609 |
* @Override
|
|
610 |
* public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
|
611 |
* });
|
|
612 |
* Composite sectionClient = toolkit.createComposite(sattrSection);
|
|
613 |
* sectionClient.setLayout(new GridLayout(2, false));
|
|
614 |
* sattrSection.setClient(sectionClient);
|
|
615 |
* Button addButton = toolkit.createButton(sectionClient, Messages.CorpusPage_25, SWT.PUSH);
|
|
616 |
* addButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false));
|
|
617 |
* addButton.addSelectionListener(new SelectionListener() {
|
|
618 |
* @Override
|
|
619 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
620 |
* }
|
|
621 |
* @Override
|
|
622 |
* public void widgetSelected(SelectionEvent e) {
|
|
623 |
* if (params == null) return;
|
|
624 |
* LinkedHashMap<String, String> values = new LinkedHashMap<String, String>();
|
|
625 |
* values.put("id", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
626 |
* values.put("shortname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
627 |
* values.put("longname", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
628 |
* values.put("pattern", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
629 |
* values.put("renderer", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
630 |
* values.put("tooltip", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
631 |
* values.put("type", "String"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
632 |
* values.put("import", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
633 |
* values.put("mandatory", "true"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
634 |
* values.put("inputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
635 |
* values.put("outputFormat", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
|
636 |
* MultipleValueDialog dlg = new MultipleValueDialog(form.getShell(), Messages.CorpusPage_25, values);
|
|
637 |
* if (dlg.open() == Window.OK) {
|
|
638 |
* params.addSAttribute(params.getCorpusElement(), values.get("id"), values.get("shortname"), values.get("longname"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
639 |
* values.get("type"), values.get("renderer"), values.get("tooltip"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
640 |
* values.get("pattern"), values.get("import"), values.get("mandatory"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
641 |
* values.get("inputFormat"), values.get("outputFormat")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
642 |
* updateSAttributeSection();
|
|
643 |
* }
|
|
644 |
* }
|
|
645 |
* });
|
|
646 |
* Button removeButton = toolkit.createButton(sectionClient, Messages.CorpusPage_27, SWT.PUSH);
|
|
647 |
* removeButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, false, false));
|
|
648 |
* removeButton.addSelectionListener(new SelectionListener() {
|
|
649 |
* @Override
|
|
650 |
* public void widgetDefaultSelected(SelectionEvent e) {
|
|
651 |
* }
|
|
652 |
* @Override
|
|
653 |
* public void widgetSelected(SelectionEvent e) {
|
|
654 |
* if ( params == null) return;
|
|
655 |
* ISelection sel = sattributesViewer.getSelection();
|
|
656 |
* IStructuredSelection ssel = (IStructuredSelection) sel;
|
|
657 |
* Object obj = ssel.getFirstElement();
|
|
658 |
* if (obj instanceof Element) {
|
|
659 |
* Element query = (Element) obj;
|
|
660 |
* params.getSAttributesElement(params.getCorpusElement()).removeChild(query);
|
|
661 |
* updateSAttributeSection();
|
|
662 |
* }
|
|
663 |
* }
|
|
664 |
* });
|
|
665 |
* Table table = toolkit.createTable(sectionClient, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.VIRTUAL);
|
|
666 |
* sattributesViewer = new TableViewer(table);
|
|
667 |
* sattributesViewer.getTable().addKeyListener(new TableKeyListener(sattributesViewer));
|
|
668 |
* GridData gdata = new GridData(GridData.FILL, GridData.FILL, false, false,2,1);
|
|
669 |
* gdata.heightHint = 150;
|
|
670 |
* sattributesViewer.getTable().setLayoutData(gdata);
|
|
671 |
* sattributesViewer.setContentProvider(new NodeListContentProvider());
|
|
672 |
* sattributesViewer.getTable().setHeaderVisible(true);
|
|
673 |
* sattributesViewer.getTable().setLinesVisible(true);
|
|
674 |
* String[] cols = {"id", "shortname", "longname", "import", "mandatory", "pattern", "renderer", "tooltip", "type"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
675 |
* //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
|
|
676 |
* for (String col : cols) {
|
|
677 |
* TableViewerColumn columnViewer = new TableViewerColumn(sattributesViewer, SWT.NONE);
|
|
678 |
* TableColumn column = columnViewer.getColumn();
|
|
679 |
* column.setText(col);
|
|
680 |
* //column.setWidth(10*col.length());
|
|
681 |
* columnViewer.setLabelProvider(new ElementColumnLabelProvider(col));
|
|
682 |
* column.pack();
|
|
683 |
* }
|
693 |
684 |
*/
|
694 |
685 |
}
|
695 |
|
|
|
686 |
|
696 |
687 |
/**
|
697 |
688 |
* Creates the tokenizer section.
|
698 |
689 |
*/
|
699 |
690 |
private int createTokenizerSection() {
|
700 |
|
tokenizerSection = new TokenizerSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE, moduleParams);
|
|
691 |
tokenizerSection = new TokenizerSection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE, moduleParams);
|
701 |
692 |
return tokenizerSection.getSectionSize();
|
702 |
693 |
}
|
703 |
|
|
|
694 |
|
704 |
695 |
private void createToolbar() {
|
705 |
696 |
Composite hyperlinks = toolkit.createComposite(form.getBody());
|
706 |
697 |
TableWrapData gdata = new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL, 2, 1);
|
707 |
698 |
gdata.colspan = 2;
|
708 |
699 |
hyperlinks.setLayoutData(gdata);
|
709 |
|
|
|
700 |
|
710 |
701 |
TableWrapLayout layout = new TableWrapLayout();
|
711 |
702 |
layout.numColumns = 4;
|
712 |
703 |
layout.makeColumnsEqualWidth = false;
|
713 |
704 |
hyperlinks.setLayout(layout);
|
714 |
|
|
715 |
|
Label titleLabel = toolkit.createLabel(hyperlinks,"", SWT.WRAP); //$NON-NLS-1$
|
|
705 |
|
|
706 |
Label titleLabel = toolkit.createLabel(hyperlinks, "", SWT.WRAP); //$NON-NLS-1$
|
716 |
707 |
titleLabel.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.TOP));
|
717 |
|
titleLabel.setText(NLS.bind(TXMUIMessages.importParametersOfP0,
|
|
708 |
titleLabel.setText(NLS.bind(TXMUIMessages.importParametersOfP0,
|
718 |
709 |
ImportModuleCustomization.getName(editor.getGroovyScript().getName())));
|
719 |
710 |
FontData[] fD = titleLabel.getFont().getFontData();
|
720 |
711 |
fD[0].setHeight(16);
|
721 |
|
titleLabel.setFont( new Font(titleLabel.getDisplay(),fD[0]));
|
722 |
|
|
|
712 |
titleLabel.setFont(new Font(titleLabel.getDisplay(), fD[0]));
|
|
713 |
|
723 |
714 |
HyperlinkAdapter selectDirHListener = new HyperlinkAdapter() {
|
|
715 |
|
724 |
716 |
@Override
|
725 |
717 |
public void linkActivated(HyperlinkEvent e) {
|
726 |
|
//System.out.println("Opening...");
|
|
718 |
// System.out.println("Opening...");
|
727 |
719 |
selectSourceDir();
|
728 |
720 |
}
|
729 |
721 |
};
|
730 |
722 |
|
731 |
723 |
HyperlinkAdapter saveHListener = new HyperlinkAdapter() {
|
|
724 |
|
732 |
725 |
@Override
|
733 |
726 |
public void linkActivated(HyperlinkEvent e) {
|
734 |
727 |
if (project != null) {
|
735 |
728 |
saveConfig();
|
736 |
|
} else
|
|
729 |
}
|
|
730 |
else
|
737 |
731 |
System.out.println(TXMUIMessages.cannotStartImportConfigurationNoSourceFolderSelected);
|
738 |
732 |
}
|
739 |
733 |
};
|
740 |
|
|
|
734 |
|
741 |
735 |
HyperlinkAdapter startImportListener = new HyperlinkAdapter() {
|
|
736 |
|
742 |
737 |
@Override
|
743 |
738 |
public void linkActivated(HyperlinkEvent e) {
|
744 |
|
//System.out.println("Starting...");
|
|
739 |
// System.out.println("Starting...");
|
745 |
740 |
if (project != null) {
|
746 |
741 |
if (saveConfig()) {
|
747 |
742 |
startImport();
|
748 |
743 |
}
|
749 |
|
} else
|
|
744 |
}
|
|
745 |
else
|
750 |
746 |
System.out.println(TXMUIMessages.cannotStartImportConfigurationNoSourceFolderSelected);
|
751 |
747 |
}
|
752 |
748 |
};
|
753 |
|
|
|
749 |
|
754 |
750 |
ImageHyperlink openImportLink = toolkit.createImageHyperlink(hyperlinks, SWT.NULL);
|
755 |
751 |
openImportLink.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE));
|
756 |
752 |
openImportLink.setImage(IImageKeys.getImage(IImageKeys.FOLDER));
|
... | ... | |
760 |
756 |
saveImportLink.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE));
|
761 |
757 |
saveImportLink.setImage(IImageKeys.getImage(IImageKeys.SAVE));
|
762 |
758 |
saveImportLink.addHyperlinkListener(saveHListener);
|
763 |
|
|
|
759 |
|
764 |
760 |
ImageHyperlink startImportLink = toolkit.createImageHyperlink(hyperlinks, SWT.NULL);
|
765 |
761 |
startImportLink.setLayoutData(new TableWrapData(TableWrapData.FILL, TableWrapData.MIDDLE));
|
766 |
762 |
startImportLink.setImage(IImageKeys.getImage(IImageKeys.START));
|
767 |
|
startImportLink.addHyperlinkListener(startImportListener);
|
768 |
|
|
769 |
|
|
|
763 |
startImportLink.addHyperlinkListener(startImportListener);
|
|
764 |
|
|
765 |
|
770 |
766 |
Composite line1 = toolkit.createComposite(form.getBody());
|
771 |
767 |
gdata = new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL, 2, 1);
|
772 |
768 |
gdata.colspan = 2;
|
... | ... | |
775 |
771 |
hLayout.center = true;
|
776 |
772 |
line1.setLayout(hLayout);
|
777 |
773 |
toolkit.createLabel(line1, TXMUIMessages._1, SWT.WRAP);
|
778 |
|
|
|
774 |
|
779 |
775 |
Hyperlink hyperlink1 = toolkit.createHyperlink(line1, TXMUIMessages.selectTheSourceDirectory, SWT.WRAP);
|
780 |
776 |
hyperlink1.addHyperlinkListener(selectDirHListener);
|
781 |
|
|
|
777 |
|
782 |
778 |
ImageHyperlink openImportLink2 = toolkit.createImageHyperlink(line1, SWT.WRAP);
|
783 |
779 |
openImportLink2.setImage(IImageKeys.getImage(IImageKeys.FOLDER));
|
784 |
780 |
openImportLink2.addHyperlinkListener(selectDirHListener);
|
785 |
|
|
|
781 |
|
786 |
782 |
Composite line2 = toolkit.createComposite(form.getBody());
|
787 |
783 |
gdata = new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL, 2, 1);
|
788 |
784 |
gdata.colspan = 2;
|
... | ... | |
792 |
788 |
line2.setLayout(hLayout);
|
793 |
789 |
toolkit.createLabel(line2, TXMUIMessages._2, SWT.WRAP);
|
794 |
790 |
toolkit.createLabel(line2, TXMUIMessages.setImportParametersInTheSectionsBelow, SWT.WRAP);
|
795 |
|
|
|
791 |
|
796 |
792 |
Composite line4 = toolkit.createComposite(form.getBody());
|
797 |
793 |
gdata = new TableWrapData(TableWrapData.LEFT, TableWrapData.FILL, 2, 1);
|
798 |
794 |
gdata.colspan = 2;
|
... | ... | |
807 |
803 |
startImportLink2.setImage(IImageKeys.getImage(IImageKeys.START));
|
808 |
804 |
startImportLink2.addHyperlinkListener(startImportListener);
|
809 |
805 |
}
|
810 |
|
|
|
806 |
|
811 |
807 |
private int createUIsSection() {
|
812 |
|
uiSection = new UISection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
|
|
808 |
uiSection = new UISection(toolkit, form, form.getBody(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
|
813 |
809 |
return uiSection.getSectionSize();
|
814 |
810 |
}
|
815 |
|
|
|
811 |
|
816 |
812 |
/**
|
817 |
|
* Called by "selectSourceDir".
|
|
813 |
* Called by "selectSourceDir".
|
818 |
814 |
* Theparameter file is read to fill the section fields.
|
819 |
815 |
*
|
820 |
816 |
* @throws ParserConfigurationException
|
... | ... | |
822 |
818 |
* @throws IOException
|
823 |
819 |
*/
|
824 |
820 |
public void loadParams() throws ParserConfigurationException, SAXException, IOException {
|
825 |
|
|
826 |
|
File metadataFile = Metadatas.findMetadataFile(project.getSrcdir()); //$NON-NLS-1$
|
|
821 |
|
|
822 |
File metadataFile = Metadatas.findMetadataFile(project.getSrcdir());
|
827 |
823 |
if (metadataFile.exists())
|
828 |
824 |
this.editor.getMetaPage().setMetadataFile(metadataFile);
|
829 |
|
|
|
825 |
|
830 |
826 |
Log.fine(NLS.bind(TXMUIMessages.moduleUIParametersColonP0, moduleParams));
|
831 |
827 |
this.setPartName(project.getName());
|
832 |
|
|
|
828 |
|
833 |
829 |
if (infosSection != null && !infosSection.isDisposed()) {
|
834 |
830 |
infosSection.setEnabled(true);
|
835 |
831 |
infosSection.update(project);
|
... | ... | |
866 |
862 |
textualPlansSection.setEnabled(true);
|
867 |
863 |
textualPlansSection.update(project);
|
868 |
864 |
}
|
869 |
|
|
|
865 |
|
870 |
866 |
if (optionsSection != null && !optionsSection.isDisposed()) {
|
871 |
867 |
optionsSection.setEnabled(true);
|
872 |
868 |
optionsSection.update(project);
|
873 |
869 |
}
|
874 |
|
|
|
870 |
|
875 |
871 |
/*
|
876 |
|
if (sattrSection != null && !sattrSection.isDisposed()) {
|
877 |
|
sattrSection.setEnabled(true);
|
878 |
|
}
|
879 |
|
|
880 |
|
if (querySection != null && !querySection.isDisposed()) {
|
881 |
|
querySection.setEnabled(true);
|
882 |
|
updateQuerySection();
|
883 |
|
}
|
884 |
|
if (preBuildSection != null && !preBuildSection.isDisposed()) {
|
885 |
|
preBuildSection.setEnabled(true);
|
886 |
|
updatePreBuildSection();
|
887 |
|
}
|
888 |
|
if (pattrSection != null && !pattrSection.isDisposed()) {
|
889 |
|
pattrSection.setEnabled(true);
|
890 |
|
updatePAttributeSection();
|
891 |
|
}
|
|
872 |
* if (sattrSection != null && !sattrSection.isDisposed()) {
|
|
873 |
* sattrSection.setEnabled(true);
|
|
874 |
* }
|
|
875 |
* if (querySection != null && !querySection.isDisposed()) {
|
|
876 |
* querySection.setEnabled(true);
|
|
877 |
* updateQuerySection();
|
|
878 |
* }
|
|
879 |
* if (preBuildSection != null && !preBuildSection.isDisposed()) {
|
|
880 |
* preBuildSection.setEnabled(true);
|
|
881 |
* updatePreBuildSection();
|
|
882 |
* }
|
|
883 |
* if (pattrSection != null && !pattrSection.isDisposed()) {
|
|
884 |
* pattrSection.setEnabled(true);
|
|
885 |
* updatePAttributeSection();
|
|
886 |
* }
|
892 |
887 |
*/
|
893 |
888 |
}
|
894 |
|
|
|
889 |
|
895 |
890 |
/**
|
896 |
891 |
* Called by "startImport". Save the field values in the Parameter file
|
|
892 |
*
|
897 |
893 |
* @return true if import parameters are saved
|
898 |
894 |
*/
|
899 |
895 |
public boolean saveConfig() {
|
... | ... | |
905 |
901 |
return false;
|
906 |
902 |
}
|
907 |
903 |
|
908 |
|
// params.rootDir = project.getSrcdir().getAbsolutePath();
|
909 |
|
// project.scriptFile = editor.getGroovyScript().getName();
|
910 |
|
|
911 |
|
// params.getCorpusElement().setAttribute("name", params.name); //$NON-NLS-1$
|
912 |
|
// params.getCorpusElement().setAttribute("desc", params.description); //$NON-NLS-1$
|
913 |
|
// params.getCorpusElement().setAttribute("cqpid", params.name.toUpperCase()+new Date().getTime()); //$NON-NLS-1$
|
914 |
|
|
|
904 |
// params.rootDir = project.getSrcdir().getAbsolutePath();
|
|
905 |
// project.scriptFile = editor.getGroovyScript().getName();
|
|
906 |
|
|
907 |
// params.getCorpusElement().setAttribute("name", params.name); //$NON-NLS-1$
|
|
908 |
// params.getCorpusElement().setAttribute("desc", params.description); //$NON-NLS-1$
|
|
909 |
// params.getCorpusElement().setAttribute("cqpid", params.name.toUpperCase()+new Date().getTime()); //$NON-NLS-1$
|
|
910 |
|
915 |
911 |
// TEST ALL SECTIONS
|
916 |
912 |
boolean doSave = true;
|
917 |
913 |
if (infosSection != null && !infosSection.isDisposed()) {
|
... | ... | |
948 |
944 |
System.out.println("Some fields are not correctly filled.");
|
949 |
945 |
return false;
|
950 |
946 |
}
|
951 |
|
|
|
947 |
|
952 |
948 |
// SAVE ALL SECTIONS
|
953 |
949 |
boolean successfulSave = true;
|
954 |
950 |
if (infosSection != null && !infosSection.isDisposed()) {
|
... | ... | |
981 |
977 |
if (optionsSection != null && !optionsSection.isDisposed()) {
|
982 |
978 |
successfulSave = successfulSave & optionsSection.save(project);
|
983 |
979 |
}
|
984 |
|
|
|
980 |
|
985 |
981 |
if (successfulSave) {
|
986 |
982 |
try {
|
987 |
983 |
project.save();
|
988 |
|
// DomUtils.save(params.root.getOwnerDocument(), paramFile);
|
989 |
|
} catch (Exception e1) {
|
|
984 |
// DomUtils.save(params.root.getOwnerDocument(), paramFile);
|
|
985 |
}
|
|
986 |
catch (Exception e1) {
|
990 |
987 |
org.txm.utils.logger.Log.printStackTrace(e1);
|
991 |
988 |
}
|
992 |
|
|
|
989 |
|
993 |
990 |
return true;
|
994 |
991 |
}
|
995 |
992 |
System.out.println("Error while saving parameters.");
|
996 |
993 |
return false;
|
997 |
|
|
|
994 |
|
998 |
995 |
}
|
999 |
|
|
|
996 |
|
1000 |
997 |
/**
|
1001 |
|
* Called by the "folder" button
|
|
998 |
* Called by the "folder" button
|
1002 |
999 |
*/
|
1003 |
1000 |
public void selectSourceDir() {
|
1004 |
|
|
|
1001 |
|
1005 |
1002 |
ImportWizard wiz = new ImportWizard();
|
1006 |
1003 |
WizardDialog wdialog = new WizardDialog(this.getEditor().getSite().getShell(), wiz);
|
1007 |
1004 |
wdialog.open();
|
1008 |
|
|
|
1005 |
|
1009 |
1006 |
project = wiz.getProject();
|
1010 |
1007 |
if (project == null) {
|
1011 |
|
//System.out.println("Error: no project created");
|
|
1008 |
// System.out.println("Error: no project created");
|
1012 |
1009 |
return;
|
1013 |
1010 |
}
|
1014 |
|
//TODO currently the script directory is the same as the import name
|
|
1011 |
// TODO currently the script directory is the same as the import name
|
1015 |
1012 |
project.setImportModuleName(editor.getGroovyScript().getParentFile().getName());
|
1016 |
1013 |
|
1017 |
1014 |
try {
|
1018 |
1015 |
loadParams();
|
1019 |
|
|
|
1016 |
|
1020 |
1017 |
this.editor.getMetaPage().reload();
|
1021 |
1018 |
this.editor.firePropertyChange(IEditorPart.PROP_TITLE);
|
1022 |
|
} catch (Exception e1) {
|
|
1019 |
}
|
|
1020 |
catch (Exception e1) {
|
1023 |
1021 |
org.txm.utils.logger.Log.printStackTrace(e1);
|