|
Lines 16-26
Link Here
|
| 16 |
import org.eclipse.core.runtime.MultiStatus; |
16 |
import org.eclipse.core.runtime.MultiStatus; |
| 17 |
import org.eclipse.core.runtime.Status; |
17 |
import org.eclipse.core.runtime.Status; |
| 18 |
import org.eclipse.core.runtime.jobs.Job; |
18 |
import org.eclipse.core.runtime.jobs.Job; |
| 19 |
import org.eclipse.jface.bindings.keys.KeyStroke; |
|
|
| 20 |
import org.eclipse.jface.fieldassist.ContentProposalAdapter; |
| 21 |
import org.eclipse.jface.fieldassist.IContentProposal; |
| 22 |
import org.eclipse.jface.fieldassist.IContentProposalProvider; |
| 23 |
import org.eclipse.jface.fieldassist.TextContentAdapter; |
| 24 |
import org.eclipse.jface.wizard.WizardPage; |
19 |
import org.eclipse.jface.wizard.WizardPage; |
| 25 |
import org.eclipse.mylar.provisional.tasklist.AbstractQueryHit; |
20 |
import org.eclipse.mylar.provisional.tasklist.AbstractQueryHit; |
| 26 |
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; |
21 |
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; |
|
Lines 32-40
Link Here
|
| 32 |
import org.eclipse.swt.events.ModifyListener; |
27 |
import org.eclipse.swt.events.ModifyListener; |
| 33 |
import org.eclipse.swt.events.SelectionAdapter; |
28 |
import org.eclipse.swt.events.SelectionAdapter; |
| 34 |
import org.eclipse.swt.events.SelectionEvent; |
29 |
import org.eclipse.swt.events.SelectionEvent; |
|
|
30 |
import org.eclipse.swt.events.SelectionListener; |
| 35 |
import org.eclipse.swt.layout.GridData; |
31 |
import org.eclipse.swt.layout.GridData; |
| 36 |
import org.eclipse.swt.layout.GridLayout; |
32 |
import org.eclipse.swt.layout.GridLayout; |
| 37 |
import org.eclipse.swt.widgets.Button; |
33 |
import org.eclipse.swt.widgets.Button; |
|
|
34 |
import org.eclipse.swt.widgets.Combo; |
| 38 |
import org.eclipse.swt.widgets.Composite; |
35 |
import org.eclipse.swt.widgets.Composite; |
| 39 |
import org.eclipse.swt.widgets.Display; |
36 |
import org.eclipse.swt.widgets.Display; |
| 40 |
import org.eclipse.swt.widgets.Label; |
37 |
import org.eclipse.swt.widgets.Label; |
|
Lines 44-65
Link Here
|
| 44 |
import org.eclipse.swt.widgets.Text; |
41 |
import org.eclipse.swt.widgets.Text; |
| 45 |
|
42 |
|
| 46 |
/** |
43 |
/** |
| 47 |
* |
44 |
* Wizard page for configuring and preview web query |
| 48 |
* Subclipse (IssueZilla) |
|
|
| 49 |
* url: http://subclipse.tigris.org/issues/buglist.cgi?issue_status=NEW;issue_status=STARTED;issue_status=REOPENED&order=issues.issue_id |
| 50 |
* regexp: <a href="show_bug.cgi\?id\=(.+?)">.+?<span class="summary">(.+?)</span> |
| 51 |
* task prefix: http://subclipse.tigris.org/issues/show_bug.cgi?id= |
| 52 |
* |
| 53 |
* ASM (GForge) |
| 54 |
* url: http://forge.objectweb.org/tracker/?group_id=23&atid=350023 |
| 55 |
* regexp: <a class="tracker" href="/tracker/index.php\?func=detail&aid=(.+?)&group_id=23&atid=350023">(.+?)</a></td> |
| 56 |
* task prefix: http://forge.objectweb.org/tracker/index.php?func=detail&group_id=23&atid=350023&aid= |
| 57 |
* |
45 |
* |
| 58 |
* @author Eugene Kuleshov |
46 |
* @author Eugene Kuleshov |
| 59 |
*/ |
47 |
*/ |
| 60 |
public class WebQueryWizardPage extends WizardPage { |
48 |
public class WebQueryWizardPage extends WizardPage { |
| 61 |
private Text taskPrefixText; |
49 |
private Text taskPrefixText; |
| 62 |
private Text descriptionText; |
50 |
private Combo descriptionText; |
| 63 |
private Text queryUrlText; |
51 |
private Text queryUrlText; |
| 64 |
private Text regexpText; |
52 |
private Text regexpText; |
| 65 |
private Table previewTable; |
53 |
private Table previewTable; |
|
Lines 96-103
Link Here
|
| 96 |
descriptionLabel.setLayoutData(new GridData()); |
84 |
descriptionLabel.setLayoutData(new GridData()); |
| 97 |
descriptionLabel.setText("Description:"); |
85 |
descriptionLabel.setText("Description:"); |
| 98 |
|
86 |
|
| 99 |
descriptionText = new Text(composite, SWT.BORDER); |
87 |
descriptionText = new Combo(composite, SWT.NONE); |
| 100 |
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
88 |
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); |
|
|
89 |
descriptionText.addSelectionListener(new SelectionListener() { |
| 90 |
|
| 91 |
public void widgetDefaultSelected(SelectionEvent e) { |
| 92 |
// ignore |
| 93 |
} |
| 94 |
|
| 95 |
public void widgetSelected(SelectionEvent e) { |
| 96 |
WebRepositoryTemplate template = WebRepositoryConnector.getTemplate(descriptionText.getText()); |
| 97 |
if(template!=null) { |
| 98 |
queryUrlText.setText(template.query); |
| 99 |
regexpText.setText(template.regexp); |
| 100 |
taskPrefixText.setText(template.prefix); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
}); |
| 105 |
|
| 106 |
for (WebRepositoryTemplate template : WebRepositoryConnector.REPOSITORY_TEMPLATES) { |
| 107 |
descriptionText.add(template.label); |
| 108 |
} |
| 109 |
|
| 101 |
new Label(composite, SWT.NONE); |
110 |
new Label(composite, SWT.NONE); |
| 102 |
|
111 |
|
| 103 |
Label queryUrlLabel = new Label(composite, SWT.NONE); |
112 |
Label queryUrlLabel = new Label(composite, SWT.NONE); |
|
Lines 129-137
Link Here
|
| 129 |
} |
138 |
} |
| 130 |
}); |
139 |
}); |
| 131 |
|
140 |
|
| 132 |
new ContentProposalAdapter(regexpText, new TextContentAdapter(), |
|
|
| 133 |
new RegExpProposalProvider(), KeyStroke.getInstance(SWT.CTRL, ' '), null); |
| 134 |
|
| 135 |
Button preview = new Button(composite, SWT.NONE); |
141 |
Button preview = new Button(composite, SWT.NONE); |
| 136 |
preview.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true)); |
142 |
preview.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true)); |
| 137 |
preview.setText("Preview"); |
143 |
preview.setText("Preview"); |
|
Lines 170-176
Link Here
|
| 170 |
regexpText.setText(query.getRegexp()); |
176 |
regexpText.setText(query.getRegexp()); |
| 171 |
taskPrefixText.setText(query.getTaskPrefix()); |
177 |
taskPrefixText.setText(query.getTaskPrefix()); |
| 172 |
} |
178 |
} |
| 173 |
sashForm.setWeights(new int[] {141, 172 }); |
179 |
sashForm.setWeights(new int[] {145, 107 }); |
| 174 |
} |
180 |
} |
| 175 |
|
181 |
|
| 176 |
public AbstractRepositoryQuery getQuery() { |
182 |
public AbstractRepositoryQuery getQuery() { |
|
Lines 277-326
Link Here
|
| 277 |
return Status.OK_STATUS; |
283 |
return Status.OK_STATUS; |
| 278 |
} |
284 |
} |
| 279 |
} |
285 |
} |
| 280 |
|
|
|
| 281 |
|
| 282 |
/** |
| 283 |
* Simple proposal provider for regexps |
| 284 |
*/ |
| 285 |
private static final class RegExpProposalProvider implements IContentProposalProvider { |
| 286 |
private static final String[] LABELS = { |
| 287 |
"IssueZilla", |
| 288 |
"GForge", |
| 289 |
"Trac", |
| 290 |
"Jira", |
| 291 |
"vBulletin" |
| 292 |
}; |
| 293 |
private static final String[] PROPOSALS = { |
| 294 |
"<a href=\"show_bug.cgi\\?id\\=(.+?)\">.+?<span class=\"summary\">(.+?)</span>", |
| 295 |
"<a class=\"tracker\" href=\"/tracker/index.php\\?func=detail&aid=(.+?)&group_id=GROUP&atid=ATID\">(.+?)</a></td>", |
| 296 |
"<td class=\"summary\"><a title=\"View ticket\" href=\"/project/ticket/(.+?)\">(.+?)</a></td>", |
| 297 |
"<td class=\"nav summary\">\\s+?<a href=\"/browse/(.+?)\".+?>(.+?)</a>", |
| 298 |
"<a href=\"showthread.php\\?.+?t=(\\d+?)\" id=\"thread_title_\\1\">(.+?)</a>" |
| 299 |
}; |
| 300 |
|
| 301 |
public IContentProposal[] getProposals(String contents, int position) { |
| 302 |
IContentProposal[] res = new IContentProposal[LABELS.length]; |
| 303 |
for (int i = 0; i < LABELS.length; i++) { |
| 304 |
final String label = LABELS[i]; |
| 305 |
final String content = PROPOSALS[i]; |
| 306 |
res[i] = new IContentProposal() { |
| 307 |
public String getContent() { |
| 308 |
return content; |
| 309 |
} |
| 310 |
public int getCursorPosition() { |
| 311 |
return content.length(); |
| 312 |
} |
| 313 |
public String getDescription() { |
| 314 |
return content; |
| 315 |
} |
| 316 |
public String getLabel() { |
| 317 |
return label; |
| 318 |
} |
| 319 |
}; |
| 320 |
} |
| 321 |
return res; |
| 322 |
} |
| 323 |
} |
| 324 |
|
286 |
|
| 325 |
} |
287 |
} |
| 326 |
|
288 |
|