Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 46185 Details for
Bug 145123
Support for generic web-based repositories
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Implemented templating support for query wizard
Clipboard-attachment (text/plain), 18.22 KB, created by
Eugene Kuleshov
on 2006-07-12 13:51:34 EDT
(
hide
)
Description:
Implemented templating support for query wizard
Filename:
MIME Type:
Creator:
Eugene Kuleshov
Created:
2006-07-12 13:51:34 EDT
Size:
18.22 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.sandbox >Index: src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.sandbox/src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java,v >retrieving revision 1.3 >diff -u -r1.3 WebQueryWizardPage.java >--- src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java 11 Jul 2006 21:30:56 -0000 1.3 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java 12 Jul 2006 17:53:50 -0000 >@@ -16,11 +16,6 @@ > import org.eclipse.core.runtime.MultiStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.jobs.Job; >-import org.eclipse.jface.bindings.keys.KeyStroke; >-import org.eclipse.jface.fieldassist.ContentProposalAdapter; >-import org.eclipse.jface.fieldassist.IContentProposal; >-import org.eclipse.jface.fieldassist.IContentProposalProvider; >-import org.eclipse.jface.fieldassist.TextContentAdapter; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.mylar.provisional.tasklist.AbstractQueryHit; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; >@@ -32,9 +27,11 @@ > import org.eclipse.swt.events.ModifyListener; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Label; >@@ -44,22 +41,13 @@ > import org.eclipse.swt.widgets.Text; > > /** >- * >- * Subclipse (IssueZilla) >- * url: http://subclipse.tigris.org/issues/buglist.cgi?issue_status=NEW;issue_status=STARTED;issue_status=REOPENED&order=issues.issue_id >- * regexp: <a href="show_bug.cgi\?id\=(.+?)">.+?<span class="summary">(.+?)</span> >- * task prefix: http://subclipse.tigris.org/issues/show_bug.cgi?id= >- * >- * ASM (GForge) >- * url: http://forge.objectweb.org/tracker/?group_id=23&atid=350023 >- * regexp: <a class="tracker" href="/tracker/index.php\?func=detail&aid=(.+?)&group_id=23&atid=350023">(.+?)</a></td> >- * task prefix: http://forge.objectweb.org/tracker/index.php?func=detail&group_id=23&atid=350023&aid= >+ * Wizard page for configuring and preview web query > * > * @author Eugene Kuleshov > */ > public class WebQueryWizardPage extends WizardPage { > private Text taskPrefixText; >- private Text descriptionText; >+ private Combo descriptionText; > private Text queryUrlText; > private Text regexpText; > private Table previewTable; >@@ -96,8 +84,29 @@ > descriptionLabel.setLayoutData(new GridData()); > descriptionLabel.setText("Description:"); > >- descriptionText = new Text(composite, SWT.BORDER); >+ descriptionText = new Combo(composite, SWT.NONE); > descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); >+ descriptionText.addSelectionListener(new SelectionListener() { >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ WebRepositoryTemplate template = WebRepositoryConnector.getTemplate(descriptionText.getText()); >+ if(template!=null) { >+ queryUrlText.setText(template.query); >+ regexpText.setText(template.regexp); >+ taskPrefixText.setText(template.prefix); >+ } >+ } >+ >+ }); >+ >+ for (WebRepositoryTemplate template : WebRepositoryConnector.REPOSITORY_TEMPLATES) { >+ descriptionText.add(template.label); >+ } >+ > new Label(composite, SWT.NONE); > > Label queryUrlLabel = new Label(composite, SWT.NONE); >@@ -129,9 +138,6 @@ > } > }); > >- new ContentProposalAdapter(regexpText, new TextContentAdapter(), >- new RegExpProposalProvider(), KeyStroke.getInstance(SWT.CTRL, ' '), null); >- > Button preview = new Button(composite, SWT.NONE); > preview.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true)); > preview.setText("Preview"); >@@ -170,7 +176,7 @@ > regexpText.setText(query.getRegexp()); > taskPrefixText.setText(query.getTaskPrefix()); > } >- sashForm.setWeights(new int[] {141, 172 }); >+ sashForm.setWeights(new int[] {145, 107 }); > } > > public AbstractRepositoryQuery getQuery() { >@@ -277,50 +283,6 @@ > return Status.OK_STATUS; > } > } >- >- >- /** >- * Simple proposal provider for regexps >- */ >- private static final class RegExpProposalProvider implements IContentProposalProvider { >- private static final String[] LABELS = { >- "IssueZilla", >- "GForge", >- "Trac", >- "Jira", >- "vBulletin" >- }; >- private static final String[] PROPOSALS = { >- "<a href=\"show_bug.cgi\\?id\\=(.+?)\">.+?<span class=\"summary\">(.+?)</span>", >- "<a class=\"tracker\" href=\"/tracker/index.php\\?func=detail&aid=(.+?)&group_id=GROUP&atid=ATID\">(.+?)</a></td>", >- "<td class=\"summary\"><a title=\"View ticket\" href=\"/project/ticket/(.+?)\">(.+?)</a></td>", >- "<td class=\"nav summary\">\\s+?<a href=\"/browse/(.+?)\".+?>(.+?)</a>", >- "<a href=\"showthread.php\\?.+?t=(\\d+?)\" id=\"thread_title_\\1\">(.+?)</a>" >- }; >- >- public IContentProposal[] getProposals(String contents, int position) { >- IContentProposal[] res = new IContentProposal[LABELS.length]; >- for (int i = 0; i < LABELS.length; i++) { >- final String label = LABELS[i]; >- final String content = PROPOSALS[i]; >- res[i] = new IContentProposal() { >- public String getContent() { >- return content; >- } >- public int getCursorPosition() { >- return content.length(); >- } >- public String getDescription() { >- return content; >- } >- public String getLabel() { >- return label; >- } >- }; >- } >- return res; >- } >- } > > } > >Index: src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.sandbox/src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java,v >retrieving revision 1.8 >diff -u -r1.8 WebRepositoryConnector.java >--- src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java 11 Jul 2006 02:14:41 -0000 1.8 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java 12 Jul 2006 17:53:51 -0000 >@@ -59,6 +59,53 @@ > > public static final String PROPERTY_TASK_PREFIX_URL = "taskprefixurl"; > >+ public static WebRepositoryTemplate[] REPOSITORY_TEMPLATES = { >+ new WebRepositoryTemplate( >+ "Subclipse (IssueZilla)", >+ "http://subclipse.tigris.org/issues/", >+ "http://subclipse.tigris.org/issues/enter_bug.cgi?component=subclipse", >+ "http://subclipse.tigris.org/issues/show_bug.cgi?id=", >+ "http://subclipse.tigris.org/issues/buglist.cgi?issue_status=NEW&issue_status=STARTED&issue_status=REOPENED&order=Issue+Number", >+ "<a href=\"show_bug.cgi\\?id\\=(.+?)\">.+?<span class=\"summary\">(.+?)</span>"), >+ new WebRepositoryTemplate( >+ "GlasFish (IssueZilla)", >+ "https://glassfish.dev.java.net/servlets/ProjectIssues", >+ "https://glassfish.dev.java.net/issues/enter_bug.cgi?issue_type=DEFECT", >+ "https://glassfish.dev.java.net/issues/show_bug.cgi?id=", >+ "https://glassfish.dev.java.net/issues/buglist.cgi?component=glassfish&issue_status=NEW&issue_status=STARTED&issue_status=REOPENED&order=Issue+Number", >+ "<a href=\"show_bug.cgi\\?id\\=(.+?)\">.+?<span class=\"summary\">(.+?)</span>"), >+ new WebRepositoryTemplate("Spring Framework (Jira)", >+ "http://opensource.atlassian.com/projects/spring/browse/SPR", >+ "http://opensource.atlassian.com/projects/spring/secure/CreateIssue!default.jspa", >+ "http://opensource.atlassian.com/projects/spring/browse/", >+ "http://opensource.atlassian.com/projects/spring/secure/IssueNavigator.jspa?reset=true&mode=hide&pid=10000&resolution=-1&sorter/field=updated&sorter/order=DESC", >+ "<td class=\"nav summary\">\\s+?<a href=\"/projects/spring/browse/(.+?)\".+?>(.+?)</a>"), >+ new WebRepositoryTemplate("SpringIDE (Trac)", >+ "http://springide.org/project/", >+ "http://springide.org/project/newticket", >+ "http://springide.org/project/ticket/", >+ "http://springide.org/project/query?status=new&status=assigned&status=reopened&order=id", >+ "<td class=\"summary\"><a href=\"/project/ticket/(.+?)\" title=\"View ticket\">(.+?)</a></td>"), >+ new WebRepositoryTemplate("edgewall.org (Trac)", >+ "http://trac.edgewall.org/", >+ "http://trac.edgewall.org/newticket", >+ "http://trac.edgewall.org/ticket/", >+ "http://trac.edgewall.org/query?status=new&status=assigned&status=reopened&order=id", >+ "<td class=\"summary\"><a href=\"/ticket/(.+?)\" title=\"View ticket\">(.+?)</a></td>"), >+ new WebRepositoryTemplate("ASM (GForge)", >+ "http://forge.objectweb.org/tracker/?atid=100023&group_id=23", >+ "http://forge.objectweb.org/tracker/?func=add&group_id=23&atid=100023", >+ "http://forge.objectweb.org/tracker/index.php?func=detail&group_id=23&atid=100023&aid=", >+ "http://forge.objectweb.org/tracker/?atid=100023&group_id=23", >+ "<a class=\"tracker\" href=\"/tracker/index.php\\?func=detail&aid=(.+?)&group_id=23&atid=100023\">(.+?)</a></td>"), >+ new WebRepositoryTemplate("Azureus (SourceForge)", >+ "http://sourceforge.net/tracker/?atid=575154&group_id=84122", >+ "http://sourceforge.net/tracker/?func=add&group_id=84122&atid=575154", >+ "http://sourceforge.net/tracker/index.php?func=detail&group_id=84122&atid=575154&aid=", >+ "http://sourceforge.net/tracker/?atid=575154&group_id=84122", >+ "<a href=\"/tracker/index.php\\?func=detail&aid=(.+?)&group_id=84122&atid=575154\">(.+?)</a>"), >+ }; >+ > > public String getRepositoryType() { > return REPOSITORY_TYPE; >@@ -221,7 +268,7 @@ > > if(!matcher.find()) { > queryStatus.add(new Status(IStatus.ERROR, MylarTaskListPlugin.PLUGIN_ID, IStatus.ERROR, >- "Unable to parse fetched resource. Check query regexp", null)); >+ "Unable to parse resource. Check query regexp", null)); > } else { > boolean isCorrect = true; > do { >@@ -246,6 +293,7 @@ > return hits; > } > >+ // TODO use commons http client > public static StringBuffer fetchResource(String url) throws IOException { > URL u = new URL(url); > InputStream is = null; >@@ -282,5 +330,14 @@ > } > > } >+ >+ public static WebRepositoryTemplate getTemplate(String label) { >+ for (WebRepositoryTemplate template : REPOSITORY_TEMPLATES) { >+ if(label.equals(template.label)) { >+ return template; >+ } >+ } >+ return null; >+ } > } > >Index: src/org/eclipse/mylar/internal/sandbox/web/WebRepositorySettingsPage.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.sandbox/src/org/eclipse/mylar/internal/sandbox/web/WebRepositorySettingsPage.java,v >retrieving revision 1.2 >diff -u -r1.2 WebRepositorySettingsPage.java >--- src/org/eclipse/mylar/internal/sandbox/web/WebRepositorySettingsPage.java 16 Jun 2006 18:34:08 -0000 1.2 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebRepositorySettingsPage.java 12 Jul 2006 17:53:51 -0000 >@@ -11,15 +11,14 @@ > > package org.eclipse.mylar.internal.sandbox.web; > >-import java.util.HashMap; >-import java.util.Map; >- > import org.eclipse.jface.preference.StringFieldEditor; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.mylar.internal.tasklist.ui.wizards.AbstractRepositorySettingsPage; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; > import org.eclipse.swt.widgets.Composite; > > /** >@@ -39,7 +38,31 @@ > super(TITLE, DESCRIPTION, connector); > } > >+ @Override > protected void createAdditionalControls(Composite parent) { >+ for (WebRepositoryTemplate template : WebRepositoryConnector.REPOSITORY_TEMPLATES) { >+ if(repositoryLabelCombo.indexOf(template.label)==-1) { >+ repositoryLabelCombo.add(template.label); >+ } >+ } >+ >+ repositoryLabelCombo.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ WebRepositoryTemplate template = WebRepositoryConnector.getTemplate(repositoryLabelCombo.getText()); >+ if(template!=null) { >+ serverUrlEditor.setStringValue(template.url); >+ taskPrefixUrlEditor.setStringValue(template.prefix); >+ newTaskUrlEditor.setStringValue(template.newTask); >+ } >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ >+ }); >+ > taskPrefixUrlEditor = new StringFieldEditor("taskPrefixUrl", "Task prefix URL:", StringFieldEditor.UNLIMITED, parent); > taskPrefixUrlEditor.setPropertyChangeListener(this); > >@@ -72,10 +95,10 @@ > > @Override > public TaskRepository createTaskRepository() { >- Map<String, String> properties = new HashMap<String, String>(); >- properties.put(WebRepositoryConnector.PROPERTY_TASK_PREFIX_URL, taskPrefixUrlEditor.getStringValue()); >- properties.put(WebRepositoryConnector.PROPERTY_NEW_TASK_URL, newTaskUrlEditor.getStringValue()); >- return new TaskRepository(getConnector().getRepositoryType(), getServerUrl(), properties); >+ TaskRepository repository = super.createTaskRepository(); >+ repository.setProperty(WebRepositoryConnector.PROPERTY_TASK_PREFIX_URL, taskPrefixUrlEditor.getStringValue()); >+ repository.setProperty(WebRepositoryConnector.PROPERTY_NEW_TASK_URL, newTaskUrlEditor.getStringValue()); >+ return repository; > } > > } >Index: src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnectorTest.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnectorTest.java >diff -N src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnectorTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnectorTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,70 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 - 2006 Mylar eclipse.org project and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Mylar project committers - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.sandbox.web; >+ >+import java.util.Arrays; >+import java.util.List; >+ >+import junit.extensions.ActiveTestSuite; >+import junit.framework.TestCase; >+import junit.framework.TestSuite; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.mylar.provisional.tasklist.AbstractQueryHit; >+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; >+ >+/** >+ * @author Eugene Kuleshov >+ */ >+public class WebRepositoryConnectorTest extends TestCase { >+ >+ private final WebRepositoryTemplate template; >+ >+ >+ public WebRepositoryConnectorTest(WebRepositoryTemplate template) { >+ super("testRepositoryTemplate"); >+ this.template = template; >+ } >+ >+ public void testRepositoryTemplate() throws Exception { >+ StringBuffer buffer = WebRepositoryConnector.fetchResource(template.query); >+ >+ IProgressMonitor monitor = new NullProgressMonitor(); >+ MultiStatus queryStatus = new MultiStatus(MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, "Query result", null); >+ >+ List<AbstractQueryHit> hits = WebRepositoryConnector.performQuery(buffer, template.regexp, template.prefix, template.url, monitor, queryStatus); >+ >+ assertTrue(Arrays.asList(queryStatus.getChildren()).toString(), queryStatus.isOK()); >+ assertTrue("Expected non-empty query result", hits.size()>0); >+ >+ } >+ >+ public String getName() { >+ return template.label; >+ } >+ >+ public static TestSuite suite() { >+ TestSuite suite = new ActiveTestSuite(WebRepositoryConnectorTest.class.getName()); >+ // TestSuite suite = new TestSuite(WebRepositoryConnectorTest.class.getName()); >+ >+ for (WebRepositoryTemplate template : WebRepositoryConnector.REPOSITORY_TEMPLATES) { >+ suite.addTest(new WebRepositoryConnectorTest(template)); >+ } >+ >+ >+ return suite; >+ } >+ >+} >Index: src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryTemplate.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryTemplate.java >diff -N src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryTemplate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryTemplate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 Mylar committers and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.sandbox.web; >+ >+class WebRepositoryTemplate { >+ public final String label; >+ public final String url; >+ public final String newTask; >+ public final String prefix; >+ public final String query; >+ public final String regexp; >+ >+ public WebRepositoryTemplate(String label, String url, String newTask, String prefix, String query, String regexp) { >+ this.label = label; >+ this.url = url; >+ this.newTask = newTask; >+ this.prefix = prefix; >+ this.query = query; >+ this.regexp = regexp; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 145123
:
44702
|
45141
|
45184
|
45736
|
45811
|
45814
|
45892
|
46105
|
46185
|
46217
|
46219
|
46247
|
46300