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 47810 Details for
Bug 153539
Trac connector: Implement generialized issue search
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]
Generic search for Trac
mylar-trac-search.patch (text/plain), 15.98 KB, created by
Steffen Pingel
on 2006-08-12 10:40:22 EDT
(
hide
)
Description:
Generic search for Trac
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2006-08-12 10:40:22 EDT
Size:
15.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.trac.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.trac.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.29 >diff -u -r1.29 MANIFEST.MF >--- META-INF/MANIFEST.MF 12 Aug 2006 02:14:16 -0000 1.29 >+++ META-INF/MANIFEST.MF 12 Aug 2006 14:41:37 -0000 >@@ -7,6 +7,7 @@ > Bundle-Vendor: Eclipse.org > Bundle-Localization: plugin > Require-Bundle: org.eclipse.ui, >+ org.eclipse.ui.forms, > org.eclipse.core.runtime, > org.eclipse.mylar.context.core, > org.eclipse.mylar.tasks.ui, >Index: src/org/eclipse/mylar/internal/trac/TracRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.trac.ui/src/org/eclipse/mylar/internal/trac/TracRepositoryConnector.java,v >retrieving revision 1.18 >diff -u -r1.18 TracRepositoryConnector.java >--- src/org/eclipse/mylar/internal/trac/TracRepositoryConnector.java 12 Aug 2006 02:14:16 -0000 1.18 >+++ src/org/eclipse/mylar/internal/trac/TracRepositoryConnector.java 12 Aug 2006 14:41:38 -0000 >@@ -308,7 +308,7 @@ > > @Override > public boolean hasSearchPage() { >- return false; >+ return true; > } > > } >\ No newline at end of file >Index: src/org/eclipse/mylar/internal/trac/ui/wizard/TracCustomQueryPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.trac.ui/src/org/eclipse/mylar/internal/trac/ui/wizard/TracCustomQueryPage.java,v >retrieving revision 1.4 >diff -u -r1.4 TracCustomQueryPage.java >--- src/org/eclipse/mylar/internal/trac/ui/wizard/TracCustomQueryPage.java 12 Aug 2006 02:14:17 -0000 1.4 >+++ src/org/eclipse/mylar/internal/trac/ui/wizard/TracCustomQueryPage.java 12 Aug 2006 14:41:39 -0000 >@@ -15,11 +15,13 @@ > import java.util.HashMap; > import java.util.Map; > >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.mylar.context.core.MylarStatusHandler; > import org.eclipse.mylar.internal.tasks.ui.search.AbstractRepositoryQueryPage; >+import org.eclipse.mylar.internal.tasks.ui.search.RepositorySearchResult; > import org.eclipse.mylar.internal.trac.TracRepositoryConnector; > import org.eclipse.mylar.internal.trac.TracRepositoryQuery; > import org.eclipse.mylar.internal.trac.TracUiPlugin; >@@ -28,10 +30,16 @@ > import org.eclipse.mylar.internal.trac.model.TracSearch; > import org.eclipse.mylar.internal.trac.model.TracSearchFilter; > import org.eclipse.mylar.internal.trac.model.TracSearchFilter.CompareOperator; >+import org.eclipse.mylar.internal.trac.ui.search.AbstractQueryHitCollector; >+import org.eclipse.mylar.internal.trac.ui.search.IQueryHitCollector; >+import org.eclipse.mylar.internal.trac.ui.search.RepositorySearchQuery; >+import org.eclipse.mylar.tasks.core.AbstractQueryHit; > import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery; > import org.eclipse.mylar.tasks.core.TaskRepository; > import org.eclipse.mylar.tasks.ui.TaskRepositoryManager; > import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+import org.eclipse.search.ui.NewSearchUI; >+import org.eclipse.search.ui.text.Match; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.KeyListener; >@@ -120,7 +128,7 @@ > } > > public void createControl(Composite parent) { >- >+ > Composite control = new Composite(parent, SWT.NONE); > GridData gd = new GridData(GridData.FILL_BOTH); > control.setLayoutData(gd); >@@ -128,7 +136,7 @@ > control.setLayout(layout); > > createTitleGroup(control); >- >+ > summaryField = new TextSearchField("summary"); > summaryField.createControls(control, "Summary"); > >@@ -169,11 +177,10 @@ > } > > private void createTitleGroup(Composite control) { >- // Group group = new Group(composite, SWT.NONE); >- // group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >- // group.setText(TITLE_QUERY_TITLE); >- // group.setLayout(new GridLayout(1, false)); >- if(inSearchContainer()) return; >+ if (inSearchContainer()) { >+ return; >+ } >+ > Label titleLabel = new Label(control, SWT.NONE); > titleLabel.setText(TITLE_QUERY_TITLE); > >@@ -306,6 +313,15 @@ > return group; > } > >+ @Override >+ public void setVisible(boolean visible) { >+ super.setVisible(visible); >+ >+ if (scontainer != null) { >+ scontainer.setPerformActionEnabled(true); >+ } >+ } >+ > private void updateAttributesFromRepository(boolean connect) { > TracRepositoryConnector connector = (TracRepositoryConnector) TasksUiPlugin.getRepositoryManager() > .getRepositoryConnector(TracUiPlugin.REPOSITORY_KIND); >@@ -386,10 +402,47 @@ > } > > public TracRepositoryQuery getQuery() { >- return new TracRepositoryQuery(repository.getUrl(), getQueryUrl(repository.getUrl()), titleText.getText(), >+ return new TracRepositoryQuery(repository.getUrl(), getQueryUrl(repository.getUrl()), getTitleText(), > TasksUiPlugin.getTaskListManager().getTaskList()); > } > >+ private String getTitleText() { >+ return (titleText != null) ? titleText.getText() : "<search>"; >+ } >+ >+ public boolean performAction() { >+ if (repository == null) { >+ MessageDialog.openInformation(Display.getCurrent().getActiveShell(), TracUiPlugin.TITLE_MESSAGE_DIALOG, >+ TaskRepositoryManager.MESSAGE_NO_REPOSITORY); >+ return false; >+ } >+ >+ final RepositorySearchQuery searchQuery = new RepositorySearchQuery(repository, getQuery()); >+ IQueryHitCollector collector = new AbstractQueryHitCollector() { >+ >+ private RepositorySearchResult searchResult; >+ >+ @Override >+ public void aboutToStart(int startMatchCount) throws CoreException { >+ super.aboutToStart(startMatchCount); >+ >+ NewSearchUI.activateSearchResultView(); >+ searchResult = (RepositorySearchResult) searchQuery.getSearchResult(); >+ searchResult.removeAll(); >+ } >+ >+ @Override >+ public void addMatch(AbstractQueryHit hit) { >+ searchResult.addMatch(new Match(hit, 0, 0)); >+ } >+ >+ }; >+ searchQuery.setCollector(collector); >+ NewSearchUI.runQueryInBackground(searchQuery); >+ >+ return true; >+ } >+ > private abstract class SearchField { > > protected String fieldName; >@@ -553,4 +606,4 @@ > > } > >-} >+} >\ No newline at end of file >Index: src/org/eclipse/mylar/internal/trac/ui/search/IQueryHitCollector.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/trac/ui/search/IQueryHitCollector.java >diff -N src/org/eclipse/mylar/internal/trac/ui/search/IQueryHitCollector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/trac/ui/search/IQueryHitCollector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia 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: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.trac.ui.search; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.mylar.tasks.core.AbstractQueryHit; >+ >+/** >+ * Interface for the Mylar search result collector. >+ * >+ * @author Shawn Minto >+ */ >+public interface IQueryHitCollector { >+ >+ /** >+ * Called before the actual search starts. >+ * >+ * @param startCount - >+ * The starting count for the number of matches >+ * @throws CoreException >+ */ >+ public void aboutToStart(int startCount) throws CoreException; >+ >+ /** >+ * Accept a search hit and add it as a match and set the markers. >+ * >+ * @param hit >+ * The search hit that was a match >+ * @throws CoreException >+ */ >+ public void accept(AbstractQueryHit hit) throws CoreException; >+ >+ /** >+ * Called when the search has ended. >+ */ >+ public void done(); >+ >+ /** >+ * Get the progress monitor for the search. >+ * >+ * @return The progress monitor >+ */ >+ public IProgressMonitor getProgressMonitor(); >+ >+ /** >+ * Set the progress monitor. >+ * >+ * @param monitor >+ * The progress monitor the search should use >+ */ >+ public void setProgressMonitor(IProgressMonitor monitor); >+ >+} >Index: src/org/eclipse/mylar/internal/trac/ui/search/AbstractQueryHitCollector.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/trac/ui/search/AbstractQueryHitCollector.java >diff -N src/org/eclipse/mylar/internal/trac/ui/search/AbstractQueryHitCollector.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/trac/ui/search/AbstractQueryHitCollector.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,102 @@ >+/******************************************************************************* >+ * Copyright (c) 2003 - 2006 University Of British Columbia 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: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.internal.trac.ui.search; >+ >+import java.text.MessageFormat; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.mylar.tasks.core.AbstractQueryHit; >+ >+/** >+ * Collects results of a search. >+ */ >+public abstract class AbstractQueryHitCollector implements IQueryHitCollector { >+ >+ /** The progress monitor for the search operation */ >+ private IProgressMonitor monitor; >+ >+ /** The number of matches found */ >+ private int matchCount; >+ >+ /** The string to display to the user while querying */ >+ private static final String STARTING = "querying the server"; >+ >+ /** The string to display to the user when we have 1 match */ >+ private static final String MATCH = "1 match"; >+ >+ /** The string to display to the user when we have multiple or no matches */ >+ private static final String MATCHES = "{0} matches"; >+ >+ /** The string to display to the user when the query is done */ >+ private static final String DONE = "done"; >+ >+ public void aboutToStart(int startMatchCount) throws CoreException { >+ matchCount = startMatchCount; >+ >+ // set the progress monitor to say that we are querying the server >+ monitor.setTaskName(STARTING); >+ } >+ >+ public void accept(AbstractQueryHit hit) throws CoreException { >+ addMatch(hit); >+ >+ // increment the match count >+ matchCount++; >+ >+ if (!getProgressMonitor().isCanceled()) { >+ // if the operation is cancelled finish with whatever data was >+ // already found >+ getProgressMonitor().subTask(getFormattedMatchesString(matchCount)); >+ getProgressMonitor().worked(1); >+ } >+ } >+ >+ public abstract void addMatch(AbstractQueryHit hit); >+ >+ public void done() { >+ if (!monitor.isCanceled()) { >+ // if the operation is cancelled, finish with the data that we >+ // already have >+ String matchesString = getFormattedMatchesString(matchCount); >+ monitor.setTaskName(MessageFormat.format(DONE, new Object[] { matchesString })); >+ } >+ >+ // Cut no longer used references because the collector might be re-used >+ monitor = null; >+ } >+ >+ /** >+ * Get the string specifying the number of matches found >+ * >+ * @param count >+ * The number of matches found >+ * @return The <code>String</code> specifying the number of matches found >+ */ >+ protected String getFormattedMatchesString(int count) { >+ // if only 1 match, return the singular match string >+ if (count == 1) >+ return MATCH; >+ >+ // format the matches string and return it >+ Object[] messageFormatArgs = { new Integer(count) }; >+ return MessageFormat.format(MATCHES, messageFormatArgs); >+ } >+ >+ public IProgressMonitor getProgressMonitor() { >+ return monitor; >+ } >+ >+ public void setProgressMonitor(IProgressMonitor monitor) { >+ this.monitor = monitor; >+ } >+ >+} >Index: src/org/eclipse/mylar/internal/trac/ui/search/RepositorySearchQuery.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/trac/ui/search/RepositorySearchQuery.java >diff -N src/org/eclipse/mylar/internal/trac/ui/search/RepositorySearchQuery.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/trac/ui/search/RepositorySearchQuery.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2006 University Of British Columbia 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: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylar.internal.trac.ui.search; >+ >+import java.util.List; >+ >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.MultiStatus; >+import org.eclipse.core.runtime.OperationCanceledException; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.ErrorDialog; >+import org.eclipse.mylar.internal.tasks.ui.search.AbstractRepositorySearchQuery; >+import org.eclipse.mylar.tasks.core.AbstractQueryHit; >+import org.eclipse.mylar.tasks.core.AbstractRepositoryQuery; >+import org.eclipse.mylar.tasks.core.TaskRepository; >+import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnector; >+import org.eclipse.mylar.tasks.ui.TasksUiPlugin; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * This class performs a search query. >+ * >+ * @author Steffen Pingel >+ */ >+public class RepositorySearchQuery extends AbstractRepositorySearchQuery { >+ >+ private IQueryHitCollector collector; >+ >+ private TaskRepository repository; >+ >+ private AbstractRepositoryQuery query; >+ >+ public RepositorySearchQuery(TaskRepository repository, AbstractRepositoryQuery query) { >+ this.repository = repository; >+ this.query = query; >+ } >+ >+ public IQueryHitCollector getCollector() { >+ return collector; >+ } >+ >+ public void setCollector(IQueryHitCollector collector) { >+ this.collector = collector; >+ } >+ >+ public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { >+ MultiStatus queryStatus = new MultiStatus(TasksUiPlugin.PLUGIN_ID, IStatus.OK, "Query result", null); >+ try { >+ collector.setProgressMonitor(monitor); >+ collector.aboutToStart(0); >+ >+ AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector( >+ repository.getKind()); >+ >+ // TODO pass collector to performQuery() so results show up right away >+ List<AbstractQueryHit> result = connector.performQuery(query, monitor, queryStatus); >+ for (AbstractQueryHit hit : result) { >+ collector.accept(hit); >+ } >+ collector.done(); >+ } catch (final CoreException e) { >+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ ErrorDialog.openError(null, "Repository Search Error", null, e.getStatus()); >+ } >+ }); >+ return Status.OK_STATUS; >+ } >+ >+ final IStatus status = queryStatus.getChildren()[0]; >+ if (status.getCode() == IStatus.CANCEL) { >+ return Status.OK_STATUS; >+ } else if (!status.isOK()) { >+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { >+ public void run() { >+ ErrorDialog.openError(null, "Repository Search Error", null, status); >+ } >+ }); >+ return Status.OK_STATUS; >+ } >+ return status; >+ } >+}
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 153539
: 47810 |
48552
|
48553