|
Lines 49-64
Link Here
|
| 49 |
|
49 |
|
| 50 |
/** |
50 |
/** |
| 51 |
* Wizard page for configuring and preview web query |
51 |
* Wizard page for configuring and preview web query |
| 52 |
* |
52 |
* |
| 53 |
* @author Eugene Kuleshov |
53 |
* @author Eugene Kuleshov |
| 54 |
*/ |
54 |
*/ |
| 55 |
public class WebQueryWizardPage extends AbstractRepositoryQueryPage { |
55 |
public class WebQueryWizardPage extends AbstractRepositoryQueryPage { |
| 56 |
private Text queryUrlText; |
56 |
private Text queryUrlText; |
| 57 |
private Text queryPatternText; |
57 |
private Text queryPatternText; |
| 58 |
private Table previewTable; |
58 |
private Table previewTable; |
| 59 |
|
59 |
|
| 60 |
private String webPage; |
60 |
private String webPage; |
| 61 |
|
61 |
|
| 62 |
private TaskRepository repository; |
62 |
private TaskRepository repository; |
| 63 |
private WebQuery query; |
63 |
private WebQuery query; |
| 64 |
private UpdatePreviewJob updatePreviewJob; |
64 |
private UpdatePreviewJob updatePreviewJob; |
|
Lines 66-73
Link Here
|
| 66 |
private FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
66 |
private FormToolkit toolkit = new FormToolkit(Display.getCurrent()); |
| 67 |
private ParametersEditor parametersEditor; |
67 |
private ParametersEditor parametersEditor; |
| 68 |
private Map<String, String> oldProperties; |
68 |
private Map<String, String> oldProperties; |
| 69 |
|
69 |
|
| 70 |
|
70 |
|
| 71 |
public WebQueryWizardPage(TaskRepository repository) { |
71 |
public WebQueryWizardPage(TaskRepository repository) { |
| 72 |
this(repository, null); |
72 |
this(repository, null); |
| 73 |
} |
73 |
} |
|
Lines 116-122
Link Here
|
| 116 |
// } |
116 |
// } |
| 117 |
// }); |
117 |
// }); |
| 118 |
// queryTitleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
118 |
// queryTitleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
| 119 |
|
119 |
|
| 120 |
parametersEditor = new ParametersEditor(composite, SWT.NONE); |
120 |
parametersEditor = new ParametersEditor(composite, SWT.NONE); |
| 121 |
GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true); |
121 |
GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 122 |
gridData1.heightHint = 80; |
122 |
gridData1.heightHint = 80; |
|
Lines 160-166
Link Here
|
| 160 |
GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); |
160 |
GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); |
| 161 |
gridData.heightHint = 45; |
161 |
gridData.heightHint = 45; |
| 162 |
queryPatternText.setLayoutData(gridData); |
162 |
queryPatternText.setLayoutData(gridData); |
| 163 |
|
163 |
|
| 164 |
// regexpText.addModifyListener(new ModifyListener() { |
164 |
// regexpText.addModifyListener(new ModifyListener() { |
| 165 |
// public void modifyText(final ModifyEvent e) { |
165 |
// public void modifyText(final ModifyEvent e) { |
| 166 |
// if(webPage!=null) { |
166 |
// if(webPage!=null) { |
|
Lines 178-184
Link Here
|
| 178 |
updatePreview(); |
178 |
updatePreview(); |
| 179 |
} |
179 |
} |
| 180 |
}); |
180 |
}); |
| 181 |
|
181 |
|
| 182 |
previewTable = new Table(composite1, SWT.BORDER); |
182 |
previewTable = new Table(composite1, SWT.BORDER); |
| 183 |
GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1); |
183 |
GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1); |
| 184 |
gridData2.heightHint = 60; |
184 |
gridData2.heightHint = 60; |
|
Lines 195-209
Link Here
|
| 195 |
colDescription.setText("Description"); |
195 |
colDescription.setText("Description"); |
| 196 |
|
196 |
|
| 197 |
setControl(composite); |
197 |
setControl(composite); |
| 198 |
|
198 |
|
| 199 |
LinkedHashMap<String, String> vars = new LinkedHashMap<String, String>(); |
199 |
LinkedHashMap<String, String> vars = new LinkedHashMap<String, String>(); |
| 200 |
Map<String, String> params = new LinkedHashMap<String, String>(); |
200 |
Map<String, String> params = new LinkedHashMap<String, String>(); |
| 201 |
if(repository!=null) { |
201 |
if(repository!=null) { |
| 202 |
|
202 |
|
| 203 |
|
203 |
|
| 204 |
queryUrlText.setText(addVars(vars, repository.getProperty(WebRepositoryConnector.PROPERTY_QUERY_URL))); |
204 |
queryUrlText.setText(addVars(vars, repository.getProperty(WebRepositoryConnector.PROPERTY_QUERY_URL))); |
| 205 |
queryPatternText.setText(addVars(vars, repository.getProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP))); |
205 |
queryPatternText.setText(addVars(vars, repository.getProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP))); |
| 206 |
|
206 |
|
| 207 |
oldProperties = repository.getProperties(); |
207 |
oldProperties = repository.getProperties(); |
| 208 |
params.putAll(oldProperties); |
208 |
params.putAll(oldProperties); |
| 209 |
} |
209 |
} |
|
Lines 245-258
Link Here
|
| 245 |
if(!updatePreviewJob.isActive()) { |
245 |
if(!updatePreviewJob.isActive()) { |
| 246 |
updatePreviewJob.schedule(); |
246 |
updatePreviewJob.schedule(); |
| 247 |
} |
247 |
} |
| 248 |
|
|
|
| 249 |
} |
248 |
} |
| 250 |
|
249 |
|
|
|
250 |
public boolean isPageComplete() { |
| 251 |
if(getErrorMessage()!=null) { |
| 252 |
return false; |
| 253 |
} |
| 254 |
return super.isPageComplete(); |
| 255 |
} |
| 256 |
|
| 251 |
void updatePreviewTable(List<AbstractQueryHit> hits, MultiStatus queryStatus) { |
257 |
void updatePreviewTable(List<AbstractQueryHit> hits, MultiStatus queryStatus) { |
| 252 |
if(previewTable.isDisposed()) { |
258 |
if(previewTable.isDisposed()) { |
| 253 |
return; |
259 |
return; |
| 254 |
} |
260 |
} |
| 255 |
|
261 |
|
| 256 |
previewTable.removeAll(); |
262 |
previewTable.removeAll(); |
| 257 |
|
263 |
|
| 258 |
if(hits!=null) { |
264 |
if(hits!=null) { |
|
Lines 279-285
Link Here
|
| 279 |
setPageComplete(false); |
285 |
setPageComplete(false); |
| 280 |
} |
286 |
} |
| 281 |
} |
287 |
} |
| 282 |
|
288 |
|
| 283 |
private final class UpdatePreviewJob extends Job { |
289 |
private final class UpdatePreviewJob extends Job { |
| 284 |
private volatile String url; |
290 |
private volatile String url; |
| 285 |
private volatile String regexp; |
291 |
private volatile String regexp; |
|
Lines 289-295
Link Here
|
| 289 |
private UpdatePreviewJob(String name) { |
295 |
private UpdatePreviewJob(String name) { |
| 290 |
super(name); |
296 |
super(name); |
| 291 |
} |
297 |
} |
| 292 |
|
298 |
|
| 293 |
public boolean isActive() { |
299 |
public boolean isActive() { |
| 294 |
return active; |
300 |
return active; |
| 295 |
} |
301 |
} |
|
Lines 319-328
Link Here
|
| 319 |
queryHits.add(hit); |
325 |
queryHits.add(hit); |
| 320 |
} |
326 |
} |
| 321 |
}; |
327 |
}; |
| 322 |
|
328 |
|
| 323 |
// TODO: Handle returned status |
329 |
IStatus status = WebRepositoryConnector.performQuery(webPage, evaluatedRegexp, null, monitor, collector, repository); |
| 324 |
WebRepositoryConnector.performQuery(webPage, evaluatedRegexp, null, null, monitor, collector); |
330 |
if(!status.isOK()) { |
| 325 |
|
331 |
queryStatus.add(status); |
|
|
332 |
} |
| 333 |
|
| 326 |
} catch (final IOException ex) { |
334 |
} catch (final IOException ex) { |
| 327 |
queryStatus.add(new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, |
335 |
queryStatus.add(new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, |
| 328 |
"Unable to fetch resource: "+ex.getMessage(), null)); |
336 |
"Unable to fetch resource: "+ex.getMessage(), null)); |
|
Lines 330-336
Link Here
|
| 330 |
queryStatus.add(new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, |
338 |
queryStatus.add(new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, |
| 331 |
"Parsing error: "+ex.getMessage(), null)); |
339 |
"Parsing error: "+ex.getMessage(), null)); |
| 332 |
} |
340 |
} |
| 333 |
|
341 |
|
| 334 |
Display.getDefault().asyncExec(new Runnable() { |
342 |
Display.getDefault().asyncExec(new Runnable() { |
| 335 |
public void run() { |
343 |
public void run() { |
| 336 |
updatePreviewTable(queryHits, queryStatus); |
344 |
updatePreviewTable(queryHits, queryStatus); |
|
Lines 341-346
Link Here
|
| 341 |
return Status.OK_STATUS; |
349 |
return Status.OK_STATUS; |
| 342 |
} |
350 |
} |
| 343 |
} |
351 |
} |
| 344 |
|
352 |
|
| 345 |
} |
353 |
} |