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 35968 Details for
Bug 129086
new jira query wizard
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]
Custom query support
custom query.patch (text/plain), 81.94 KB, created by
Brock Janiczak
on 2006-03-09 05:09:44 EST
(
hide
)
Description:
Custom query support
Filename:
MIME Type:
Creator:
Brock Janiczak
Created:
2006-03-09 05:09:44 EST
Size:
81.94 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.jira >Index: src/org/eclipse/mylar/internal/jira/JiraFilter.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/JiraFilter.java >diff -N src/org/eclipse/mylar/internal/jira/JiraFilter.java >--- src/org/eclipse/mylar/internal/jira/JiraFilter.java 2 Mar 2006 04:24:09 -0000 1.14 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,141 +0,0 @@ >-/******************************************************************************* >- * 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.jira; >- >-import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; >-import org.tigris.jira.core.model.NamedFilter; >- >-/** >- * A JiraFilter represents a query for issues from a Jira repository. >- * >- * @author Mik Kersten >- * @author Wesley Coelho (initial integration patch) >- */ >-public class JiraFilter extends AbstractRepositoryQuery { >- >-// private static final String LABEL_REFRESH_JOB = "Refreshing Jira Filter(s)"; >- >- private static final int MAX_HITS = 75; >- >- protected NamedFilter filter = null; >- >-// private boolean isRefreshing = false; >- >- public JiraFilter(String repositoryUrl, NamedFilter filter) { >- setMaxHits(MAX_HITS); >- this.filter = filter; >- super.repositoryUrl = repositoryUrl; >- setQueryUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + filter.getId()); >- >- super.setDescription(filter.getName()); >- } >- >- public NamedFilter getNamedFilter() { >- return filter; >- } >- >-// /** >-// * TODO: refactor into common refresh mechanism. >-// */ >-// public void refreshHits() { >-// isRefreshing = true; >-// Job j = new Job(LABEL_REFRESH_JOB) { >-// >-// @Override >-// protected IStatus run(final IProgressMonitor monitor) { >-// clearHits(); >-// try { >-// TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.JIRA_REPOSITORY_KIND, repositoryUrl); >-// JiraServerFacade.getDefault().getJiraServer(repository).executeNamedFilter(filter, new IssueCollector() { >-// >-// public void done() { >-// isRefreshing = false; >-// Display.getDefault().asyncExec(new Runnable() { >-// public void run() { >-// if (TaskListView.getDefault() != null) >-// TaskListView.getDefault().refreshAndFocus(); >-// } >-// }); >-// } >-// >-// public boolean isCancelled() { >-// return monitor.isCanceled(); >-// } >-// >-// public void collectIssue(Issue issue) { >-// int issueId = new Integer(issue.getId()); >-// JiraFilterHit hit = new JiraFilterHit(issue, JiraFilter.this.getRepositoryUrl(), issueId); >-// addHit(hit); >-// } >-// >-// public void start() { >-// >-// } >-// }); >-// >-// } catch (Exception e) { >-// isRefreshing = false; >-// JiraServerFacade.handleConnectionException(e); >-// return Status.CANCEL_STATUS; >-// } >-// >-// return Status.OK_STATUS; >-// } >-// >-// }; >-// >-// j.schedule(); >-// >-// } >- >- public String getQueryUrl() { >- return super.getQueryUrl(); >- } >- >- public String getPriority() { >- return ""; >- } >- >- public String getDescription() { >- if (filter.getName() != null) { >- return filter.getName(); >- } else { >- return super.getDescription(); >- } >- } >- >- public void setDescription(String description) { >- filter.setDescription(description); >- } >- >- public boolean isLocal() { >- return false; >- } >- >-// /** True if the filter is currently downloading hits */ >-// public boolean isRefreshing() { >-// return isRefreshing; >-// } >- >- public String getRepositoryKind() { >- return MylarJiraPlugin.JIRA_REPOSITORY_KIND; >- } >- >- public NamedFilter getFilter() { >- return filter; >- } >- >-// public void setRefreshing(boolean refreshing) { >-// this.isRefreshing = refreshing; >-// } >- >-} >Index: src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java,v >retrieving revision 1.8 >diff -u -r1.8 JiraRepositoryConnector.java >--- src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java 2 Mar 2006 04:59:24 -0000 1.8 >+++ src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java 9 Mar 2006 09:42:29 -0000 >@@ -22,6 +22,7 @@ > import org.eclipse.jface.wizard.IWizard; > import org.eclipse.mylar.internal.core.util.MylarStatusHandler; > import org.eclipse.mylar.internal.jira.ui.wizards.AddExistingJiraTaskWizard; >+import org.eclipse.mylar.internal.jira.ui.wizards.IssueFilterWizard; > import org.eclipse.mylar.internal.jira.ui.wizards.JiraRepositorySettingsPage; > import org.eclipse.mylar.internal.jira.ui.wizards.NewJiraQueryWizard; > import org.eclipse.mylar.internal.tasklist.ui.TaskListUiUtil; >@@ -84,7 +85,8 @@ > } > > public IWizard getQueryWizard(TaskRepository repository) { >- return new NewJiraQueryWizard(repository); >+// return new NewJiraQueryWizard(repository); >+ return new IssueFilterWizard(repository); > } > > public IWizard getAddExistingTaskWizard(TaskRepository repository) { >@@ -118,9 +120,12 @@ > > @Override > public void openEditQueryDialog(AbstractRepositoryQuery query) { >- JiraFilter filter = (JiraFilter) query; >- String title = "Filter: " + filter.getDescription(); >- TaskListUiUtil.openUrl(title, title, filter.getQueryUrl()); >+ if (query instanceof JiraNamedFilter) { >+ JiraNamedFilter filter = (JiraNamedFilter) query; >+ String title = "Filter: " + filter.getDescription(); >+ TaskListUiUtil.openUrl(title, title, filter.getQueryUrl()); >+ } >+ // TODO support custom filters > } > > // public void refreshFilters() { >@@ -162,51 +167,99 @@ > > @Override > protected List<AbstractQueryHit> performQuery(AbstractRepositoryQuery repositoryQuery, final IProgressMonitor monitor, MultiStatus queryStatus) { >- if (!(repositoryQuery instanceof JiraFilter)) { >- return Collections.emptyList(); >- } >- final JiraFilter jiraFilter = (JiraFilter)repositoryQuery; >+// if (!(repositoryQuery instanceof JiraNamedFilter)) { >+// return Collections.emptyList(); >+// } > final List<AbstractQueryHit> hits = new ArrayList<AbstractQueryHit>(); >-// jiraFilter.setRefreshing(true); >- try { >- TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.JIRA_REPOSITORY_KIND, repositoryQuery.getRepositoryUrl()); >- JiraServerFacade.getDefault().getJiraServer(repository).executeNamedFilter(jiraFilter.getNamedFilter(), new IssueCollector() { >- >- public void done() { >-// jiraFilter.setRefreshing(false); >-// Display.getDefault().asyncExec(new Runnable() { >-// public void run() { >-// if (TaskListView.getDefault() != null) >-// TaskListView.getDefault().refreshAndFocus(); >-// } >-// }); >- } >- >- public boolean isCancelled() { >- return monitor.isCanceled(); >- } >- >- public void collectIssue(Issue issue) { >- int issueId = new Integer(issue.getId()); >- JiraFilterHit hit = new JiraFilterHit(issue, jiraFilter.getRepositoryUrl(), issueId); >- hits.add(hit); >-// addHit(hit); >- } >- >- public void start() { >- >- } >- }); >- >- } catch (Exception e) { >-// isRefreshing = false; >-// jiraFilter.setRefreshing(false); >-// JiraServerFacade.handleConnectionException(e); >- queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, >- "Could not log in to server: " + repositoryQuery.getRepositoryUrl() >- + "\n\nCheck network connection.", e)); >-// queryStatus.add(Status.CANCEL_STATUS); >+ >+ if (repositoryQuery instanceof JiraNamedFilter) { > >+ final JiraNamedFilter jiraNamedFilter = (JiraNamedFilter)repositoryQuery; >+ // jiraFilter.setRefreshing(true); >+ try { >+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.JIRA_REPOSITORY_KIND, repositoryQuery.getRepositoryUrl()); >+ JiraServerFacade.getDefault().getJiraServer(repository).executeNamedFilter(jiraNamedFilter.getNamedFilter(), new IssueCollector() { >+ >+ public void done() { >+ // jiraFilter.setRefreshing(false); >+ // Display.getDefault().asyncExec(new Runnable() { >+ // public void run() { >+ // if (TaskListView.getDefault() != null) >+ // TaskListView.getDefault().refreshAndFocus(); >+ // } >+ // }); >+ } >+ >+ public boolean isCancelled() { >+ return monitor.isCanceled(); >+ } >+ >+ public void collectIssue(Issue issue) { >+ int issueId = new Integer(issue.getId()); >+ JiraFilterHit hit = new JiraFilterHit(issue, jiraNamedFilter.getRepositoryUrl(), issueId); >+ hits.add(hit); >+ // addHit(hit); >+ } >+ >+ public void start() { >+ >+ } >+ }); >+ >+ } catch (Exception e) { >+ // isRefreshing = false; >+ // jiraFilter.setRefreshing(false); >+ // JiraServerFacade.handleConnectionException(e); >+ queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, >+ "Could not log in to server: " + repositoryQuery.getRepositoryUrl() >+ + "\n\nCheck network connection.", e)); >+ // queryStatus.add(Status.CANCEL_STATUS); >+ >+ } >+ } else if (repositoryQuery instanceof JiraCustomFilter) { >+ final JiraCustomFilter jiraCustomFilter = (JiraCustomFilter)repositoryQuery; >+ >+ // jiraFilter.setRefreshing(true); >+ try { >+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.JIRA_REPOSITORY_KIND, repositoryQuery.getRepositoryUrl()); >+ JiraServerFacade.getDefault().getJiraServer(repository).findIssues(jiraCustomFilter.getFilter(), new IssueCollector() { >+ >+ public void done() { >+ // jiraFilter.setRefreshing(false); >+ // Display.getDefault().asyncExec(new Runnable() { >+ // public void run() { >+ // if (TaskListView.getDefault() != null) >+ // TaskListView.getDefault().refreshAndFocus(); >+ // } >+ // }); >+ } >+ >+ public boolean isCancelled() { >+ return monitor.isCanceled(); >+ } >+ >+ public void collectIssue(Issue issue) { >+ int issueId = new Integer(issue.getId()); >+ JiraFilterHit hit = new JiraFilterHit(issue, jiraCustomFilter.getRepositoryUrl(), issueId); >+ hits.add(hit); >+ // addHit(hit); >+ } >+ >+ public void start() { >+ >+ } >+ }); >+ >+ } catch (Exception e) { >+ // isRefreshing = false; >+ // jiraFilter.setRefreshing(false); >+ // JiraServerFacade.handleConnectionException(e); >+ queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, >+ "Could not log in to server: " + repositoryQuery.getRepositoryUrl() >+ + "\n\nCheck network connection.", e)); >+ // queryStatus.add(Status.CANCEL_STATUS); >+ >+ } > } > queryStatus.add(Status.OK_STATUS); > return hits; >Index: src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java,v >retrieving revision 1.19 >diff -u -r1.19 JiraTaskExternalizer.java >--- src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java 21 Feb 2006 20:01:52 -0000 1.19 >+++ src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java 9 Mar 2006 09:42:30 -0000 >@@ -51,75 +51,88 @@ > private static final String KEY_FILTER_ID = "FilterID"; > > private static final String KEY_FILTER_DESCRIPTION = "FilterDesc"; >+ >+ private static final String KEY_QUERY_TYPE = "QueryType"; > > public boolean canReadQuery(Node node) { > return node.getNodeName().equals(KEY_JIRA_QUERY); > } > > public boolean canCreateElementFor(AbstractRepositoryQuery category) { >- return category instanceof JiraFilter; >+ return category instanceof JiraNamedFilter || category instanceof JiraCustomFilter; > } > > public boolean canCreateElementFor(ITask task) { > return task instanceof JiraTask; > } > >+ @Override > public AbstractRepositoryQuery readQuery(Node node, TaskList taskList) throws TaskExternalizationException { > boolean hasCaughtException = false; > Element element = (Element) node; > >- NamedFilter namedFilter = new NamedFilter(); >- namedFilter.setId(element.getAttribute(KEY_FILTER_ID)); >- namedFilter.setName(element.getAttribute(KEY_FILTER_NAME)); >-// namedFilter.setDescription(element.getAttribute(KEY_FILTER_DESCRIPTION)); >- >- AbstractRepositoryQuery query = new JiraFilter(element.getAttribute(KEY_REPOSITORY_URL), namedFilter); >+ String queryType = element.getAttribute(KEY_QUERY_TYPE); >+ if ("Custom".equals(queryType)) { >+ return null; >+ } else { >+ NamedFilter namedFilter = new NamedFilter(); >+ namedFilter.setId(element.getAttribute(KEY_FILTER_ID)); >+ namedFilter.setName(element.getAttribute(KEY_FILTER_NAME)); >+ // namedFilter.setDescription(element.getAttribute(KEY_FILTER_DESCRIPTION)); >+ >+ AbstractRepositoryQuery query = new JiraNamedFilter(element.getAttribute(KEY_REPOSITORY_URL), namedFilter); > >- NodeList list = node.getChildNodes(); >- for (int i = 0; i < list.getLength(); i++) { >- Node child = list.item(i); >- try { >- readQueryHit(child, taskList, query); >- } catch (TaskExternalizationException e) { >- hasCaughtException = true; >+ NodeList list = node.getChildNodes(); >+ for (int i = 0; i < list.getLength(); i++) { >+ Node child = list.item(i); >+ try { >+ readQueryHit(child, taskList, query); >+ } catch (TaskExternalizationException e) { >+ hasCaughtException = true; >+ } >+ } >+ if (hasCaughtException) { >+ throw new TaskExternalizationException("Failed to load all hits"); >+ } else { >+ return query; > } > } >- if (hasCaughtException) { >- throw new TaskExternalizationException("Failed to load all hits"); >- } else { >- return query; >- } >+ > } > > public Element createQueryElement(AbstractRepositoryQuery query, Document doc, Element parent) { > String queryTagName = getQueryTagNameForElement(query); > Element node = doc.createElement(queryTagName); > >- NamedFilter filter = ((JiraFilter) query).getNamedFilter(); >- node.setAttribute(KEY_NAME, query.getDescription()); >- node.setAttribute(KEY_QUERY_MAX_HITS, query.getMaxHits() + ""); >- node.setAttribute(KEY_QUERY_STRING, query.getQueryUrl()); >- node.setAttribute(KEY_REPOSITORY_URL, query.getRepositoryUrl()); >- >- node.setAttribute(KEY_FILTER_ID, filter.getId()); >- node.setAttribute(KEY_FILTER_NAME, filter.getName()); >- node.setAttribute(KEY_FILTER_DESCRIPTION, filter.getDescription()); >- >- for (AbstractQueryHit hit : query.getHits()) { >- try { >- Element element = null; >- for (ITaskListExternalizer externalizer : super.getDelegateExternalizers()) { >- if (externalizer.canCreateElementFor(hit)) >- element = externalizer.createQueryHitElement(hit, doc, node); >+ if (query instanceof JiraNamedFilter) { >+ NamedFilter filter = ((JiraNamedFilter) query).getNamedFilter(); >+ node.setAttribute(KEY_NAME, query.getDescription()); >+ node.setAttribute(KEY_QUERY_MAX_HITS, query.getMaxHits() + ""); >+ node.setAttribute(KEY_QUERY_STRING, query.getQueryUrl()); >+ node.setAttribute(KEY_REPOSITORY_URL, query.getRepositoryUrl()); >+ >+ node.setAttribute(KEY_FILTER_ID, filter.getId()); >+ node.setAttribute(KEY_FILTER_NAME, filter.getName()); >+ node.setAttribute(KEY_FILTER_DESCRIPTION, filter.getDescription()); >+ >+ for (AbstractQueryHit hit : query.getHits()) { >+ try { >+ Element element = null; >+ for (ITaskListExternalizer externalizer : super.getDelegateExternalizers()) { >+ if (externalizer.canCreateElementFor(hit)) >+ element = externalizer.createQueryHitElement(hit, doc, node); >+ } >+ if (element == null) >+ createQueryHitElement(hit, doc, node); >+ } catch (Exception e) { >+ MylarStatusHandler.log(e, e.getMessage()); > } >- if (element == null) >- createQueryHitElement(hit, doc, node); >- } catch (Exception e) { >- MylarStatusHandler.log(e, e.getMessage()); > } >+ parent.appendChild(node); >+ return node; >+ } else { >+ return node; > } >- parent.appendChild(node); >- return node; > } > > @Override >@@ -222,7 +235,7 @@ > } > > public String getQueryTagNameForElement(AbstractRepositoryQuery query) { >- if (query instanceof JiraFilter) { >+ if (query instanceof JiraNamedFilter || query instanceof JiraCustomFilter) { > return KEY_JIRA_QUERY; > } > return ""; >Index: .settings/org.eclipse.jdt.ui.prefs >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/org.eclipse.mylar.jira/.settings/org.eclipse.jdt.ui.prefs,v >retrieving revision 1.2 >diff -u -r1.2 org.eclipse.jdt.ui.prefs >--- .settings/org.eclipse.jdt.ui.prefs 10 Feb 2006 04:53:25 -0000 1.2 >+++ .settings/org.eclipse.jdt.ui.prefs 9 Mar 2006 09:42:29 -0000 >@@ -1,5 +1,5 @@ >-#Thu Feb 09 16:45:35 PST 2006 >+#Sat Feb 18 09:21:28 EST 2006 > eclipse.preferences.version=1 > formatter_profile=_Mylar based on Eclipse [built-in] >-formatter_settings_version=9 >+formatter_settings_version=10 > internal.default.compliance=default >Index: src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java,v >retrieving revision 1.7 >diff -u -r1.7 NewJiraQueryWizard.java >--- src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java 2 Mar 2006 02:19:34 -0000 1.7 >+++ src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java 9 Mar 2006 09:42:30 -0000 >@@ -12,7 +12,7 @@ > package org.eclipse.mylar.internal.jira.ui.wizards; > > import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.mylar.internal.jira.JiraFilter; >+import org.eclipse.mylar.internal.jira.JiraNamedFilter; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; >@@ -48,7 +48,7 @@ > NamedFilter namedFilter = queryPage.getSelectedFilter(); > > if (namedFilter != null) { >- JiraFilter filter = new JiraFilter(repository.getUrl().toExternalForm(), namedFilter); >+ JiraNamedFilter filter = new JiraNamedFilter(repository.getUrl().toExternalForm(), namedFilter); > MylarTaskListPlugin.getTaskListManager().addQuery(filter); > AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); > if (connector != null) { >Index: src/org/eclipse/mylar/internal/jira/JiraCustomFilter.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/JiraCustomFilter.java >diff -N src/org/eclipse/mylar/internal/jira/JiraCustomFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/jira/JiraCustomFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,138 @@ >+/******************************************************************************* >+ * 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.jira; >+ >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; >+import org.tigris.jira.core.model.NamedFilter; >+import org.tigris.jira.core.model.filter.FilterDefinition; >+ >+/** >+ * A JiraFilter represents a query for issues from a Jira repository. >+ * >+ * @author Mik Kersten >+ * @author Wesley Coelho (initial integration patch) >+ */ >+public class JiraCustomFilter extends AbstractRepositoryQuery { >+ >+// private static final String LABEL_REFRESH_JOB = "Refreshing Jira Filter(s)"; >+ >+ private static final int MAX_HITS = 75; >+ >+ protected FilterDefinition filter = null; >+ >+// private boolean isRefreshing = false; >+ >+ public JiraCustomFilter(String repositoryUrl, FilterDefinition filter) { >+ setMaxHits(MAX_HITS); >+ this.filter = filter; >+ super.repositoryUrl = repositoryUrl; >+ setQueryUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + filter.getName()); >+ >+ super.setDescription(filter.getName()); >+ } >+ >+ public FilterDefinition getFilter() { >+ return filter; >+ } >+ >+// /** >+// * TODO: refactor into common refresh mechanism. >+// */ >+// public void refreshHits() { >+// isRefreshing = true; >+// Job j = new Job(LABEL_REFRESH_JOB) { >+// >+// @Override >+// protected IStatus run(final IProgressMonitor monitor) { >+// clearHits(); >+// try { >+// TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.JIRA_REPOSITORY_KIND, repositoryUrl); >+// JiraServerFacade.getDefault().getJiraServer(repository).executeNamedFilter(filter, new IssueCollector() { >+// >+// public void done() { >+// isRefreshing = false; >+// Display.getDefault().asyncExec(new Runnable() { >+// public void run() { >+// if (TaskListView.getDefault() != null) >+// TaskListView.getDefault().refreshAndFocus(); >+// } >+// }); >+// } >+// >+// public boolean isCancelled() { >+// return monitor.isCanceled(); >+// } >+// >+// public void collectIssue(Issue issue) { >+// int issueId = new Integer(issue.getId()); >+// JiraFilterHit hit = new JiraFilterHit(issue, JiraFilter.this.getRepositoryUrl(), issueId); >+// addHit(hit); >+// } >+// >+// public void start() { >+// >+// } >+// }); >+// >+// } catch (Exception e) { >+// isRefreshing = false; >+// JiraServerFacade.handleConnectionException(e); >+// return Status.CANCEL_STATUS; >+// } >+// >+// return Status.OK_STATUS; >+// } >+// >+// }; >+// >+// j.schedule(); >+// >+// } >+ >+ public String getQueryUrl() { >+ return super.getQueryUrl(); >+ } >+ >+ public String getPriority() { >+ return ""; >+ } >+ >+ public String getDescription() { >+ if (filter.getName() != null) { >+ return filter.getName(); >+ } else { >+ return super.getDescription(); >+ } >+ } >+ >+ public void setDescription(String description) { >+ filter.setDescription(description); >+ } >+ >+ public boolean isLocal() { >+ return false; >+ } >+ >+// /** True if the filter is currently downloading hits */ >+// public boolean isRefreshing() { >+// return isRefreshing; >+// } >+ >+ public String getRepositoryKind() { >+ return MylarJiraPlugin.JIRA_REPOSITORY_KIND; >+ } >+ >+// public void setRefreshing(boolean refreshing) { >+// this.isRefreshing = refreshing; >+// } >+ >+} >Index: src/org/eclipse/mylar/internal/jira/ui/wizards/IssueFilterWizard.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/ui/wizards/IssueFilterWizard.java >diff -N src/org/eclipse/mylar/internal/jira/ui/wizards/IssueFilterWizard.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/jira/ui/wizards/IssueFilterWizard.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 Jira Dashboard project. >+ * 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: >+ * Brock Janiczak - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.internal.jira.ui.wizards; >+ >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.mylar.internal.jira.JiraCustomFilter; >+import org.eclipse.mylar.internal.jira.JiraNamedFilter; >+import org.eclipse.mylar.internal.jira.JiraServerFacade; >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; >+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+import org.tigris.jira.core.model.filter.FilterDefinition; >+import org.tigris.jira.core.service.JiraServer; >+ >+ >+// TODO this should be two different wizards (create and update) >+public class IssueFilterWizard extends Wizard { >+ >+ private FilterSummaryPage filterSummaryPage; >+ private final JiraServer server; >+ private FilterDefinition workingCopy; >+ private final boolean isAdd; >+ private FilterDefinition filter; >+ private IssueAttributesPage issueAttributesPage; >+ private final TaskRepository repository; >+ >+ public IssueFilterWizard(TaskRepository repository) { >+ this.repository = repository; >+ // TODO this is most likely not a cool thing to be doing >+ this.server = JiraServerFacade.getDefault().getJiraServer(repository); >+ workingCopy = new FilterDefinition(); >+ this.setWindowTitle("Create Issue Filter"); >+ isAdd = true; >+ } >+ >+ public IssueFilterWizard(TaskRepository repository, FilterDefinition filter) { >+ this.repository = repository; >+ // TODO this is most likely not a cool thing to be doing >+ this.server = JiraServerFacade.getDefault().getJiraServer(repository); >+ this.filter = filter; >+ workingCopy = new FilterDefinition(filter); >+ this.setWindowTitle("Create Issue Filter"); >+ isAdd = false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.wizard.Wizard#addPages() >+ */ >+ public void addPages() { >+ filterSummaryPage = new FilterSummaryPage("summaryPage", "Filter Summary", null, server, workingCopy, isAdd); >+ issueAttributesPage = new IssueAttributesPage("issueAttributes", "Issue Attributes", null, server, workingCopy, isAdd); >+ >+ addPage(filterSummaryPage); >+ addPage(issueAttributesPage); >+ >+ } >+ >+ public boolean performFinish() { >+ if (isAdd) { >+ filterSummaryPage.applyChanges(); >+ issueAttributesPage.applyChanges(); >+ server.addLocalFilter(workingCopy); >+ >+ JiraCustomFilter customFilter = new JiraCustomFilter(repository.getUrl().toExternalForm(), workingCopy); >+ MylarTaskListPlugin.getTaskListManager().addQuery(customFilter); >+ AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); >+ if (connector != null) { >+ connector.synchronize(customFilter, null); >+ } >+// filter.refreshHits(); >+ } else { >+ filterSummaryPage.applyChanges(); >+ issueAttributesPage.applyChanges(); >+ filter.copyAttributes(workingCopy); >+ >+ JiraCustomFilter customFilter = new JiraCustomFilter(repository.getUrl().toExternalForm(), workingCopy); >+ MylarTaskListPlugin.getTaskListManager().addQuery(customFilter); >+ AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); >+ if (connector != null) { >+ connector.synchronize(customFilter, null); >+ } >+// filter.refreshHits(); >+ } >+ return true; >+ } >+ >+} >Index: src/org/eclipse/mylar/internal/jira/ui/wizards/FilterSummaryPage.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/ui/wizards/FilterSummaryPage.java >diff -N src/org/eclipse/mylar/internal/jira/ui/wizards/FilterSummaryPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/jira/ui/wizards/FilterSummaryPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,723 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 Jira Dashboard project. >+ * 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: >+ * Brock Janiczak - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.internal.jira.ui.wizards; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.ComboViewer; >+import org.eclipse.jface.viewers.IColorProvider; >+import org.eclipse.jface.viewers.ILabelProvider; >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.ListViewer; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.FocusAdapter; >+import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.swt.events.SelectionAdapter; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.tigris.jira.core.model.Component; >+import org.tigris.jira.core.model.Project; >+import org.tigris.jira.core.model.Version; >+import org.tigris.jira.core.model.filter.ComponentFilter; >+import org.tigris.jira.core.model.filter.ContentFilter; >+import org.tigris.jira.core.model.filter.FilterDefinition; >+import org.tigris.jira.core.model.filter.ProjectFilter; >+import org.tigris.jira.core.model.filter.VersionFilter; >+import org.tigris.jira.core.service.JiraServer; >+ >+public class FilterSummaryPage extends WizardPage { >+ private final Placeholder ANY_FIX_VERSION = new Placeholder("Any"); >+ private final Placeholder NO_FIX_VERSION = new Placeholder("No Fix Version"); >+ >+ private final Placeholder ANY_REPORTED_VERSION = new Placeholder("Any"); >+ private final Placeholder NO_REPORTED_VERSION = new Placeholder("No Version"); >+ private final Placeholder UNRELEASED_VERSION = new Placeholder("Unreleased Versions"); >+ private final Placeholder RELEASED_VERSION = new Placeholder("Released Versions"); >+ >+ private final Placeholder ANY_COMPONENT = new Placeholder("Any"); >+ private final Placeholder NO_COMPONENT = new Placeholder("No Component"); >+ >+ private final JiraServer server; >+ private ListViewer reportedIn; >+ private ListViewer components; >+ private ListViewer fixFor; >+ >+ private final FilterDefinition workingCopy; >+ private Text name; >+ private Text description; >+ private ComboViewer project; >+ private Text queryString; >+ private Button searchSummary; >+ private Button searchDescription; >+ private Button searchComments; >+ private Button searchEnvironment; >+ private final boolean isNew; >+ >+ /** >+ * @param pageName >+ * @param title >+ * @param titleImage >+ */ >+ protected FilterSummaryPage(String pageName, String title, ImageDescriptor titleImage, JiraServer server, FilterDefinition workingCopy, boolean isNew) { >+ super(pageName, title, titleImage); >+ this.server = server; >+ this.workingCopy = workingCopy; >+ this.isNew = isNew; >+ } >+ >+ public void createControl(Composite parent) { >+ GridData gd; >+ Composite c = new Composite(parent, SWT.NONE); >+ c.setLayout(new GridLayout(3, false)); >+ >+ Label lblName = new Label(c, SWT.NONE); >+ lblName.setText("Name:"); >+ >+ name = new Text(c, SWT.BORDER); >+ name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); >+ name.addFocusListener(new FocusAdapter() { >+ >+ public void focusLost(FocusEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ if (!isNew) { >+ name.setEnabled(false); >+ } >+ >+ Label lblDescription = new Label(c, SWT.NONE); >+ lblDescription.setText("Description:"); >+ lblDescription.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ description = new Text(c, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); >+ gd.heightHint = 40; >+ description.setLayoutData(gd); >+ description.addFocusListener(new FocusAdapter() { >+ >+ public void focusLost(FocusEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ Label lblProject = new Label(c, SWT.NONE); >+ lblProject.setText("Project:"); >+ >+ project = new ComboViewer(c, SWT.READ_ONLY); >+ project.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); >+ project.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ JiraServer server = (JiraServer) inputElement; >+ Object[] elements = new Object[server.getProjects().length + 1]; >+ elements[0] = new Placeholder("All Projects"); >+ System.arraycopy(server.getProjects(), 0, elements, 1, server.getProjects().length); >+ >+ return elements; >+ } >+ >+ }); >+ >+ project.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ return ((Project)element).getName(); >+ } >+ >+ }); >+ >+ project.setInput(server); >+ project.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ IStructuredSelection selection = ((IStructuredSelection)event.getSelection()); >+ Project selectedProject = null; >+ if (!selection.isEmpty() && !(selection.getFirstElement() instanceof Placeholder)) { >+ selectedProject = (Project)selection.getFirstElement(); >+ } >+ >+ updateCurrentProject(selectedProject); >+ validatePage(); >+ } >+ >+ }); >+ >+ Label lblFixFor = new Label(c, SWT.NONE); >+ lblFixFor.setText("Fix For:"); >+ lblFixFor.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ fixFor = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); >+ gd.heightHint = 40; >+ fixFor.getControl().setLayoutData(gd); >+ >+ fixFor.setContentProvider(new IStructuredContentProvider() { >+ private Project project; >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ project = (Project)newInput; >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (project != null) { >+ Version[] versions = project.getVersions(); >+ Version[] releasedVersions = project.getReleasedVersions(); >+ Version[] unreleasedVersions = project.getUnreleasedVersions(); >+ >+ Object[] elements = new Object[versions.length + 4]; >+ elements[0] = ANY_FIX_VERSION; >+ elements[1] = NO_FIX_VERSION; >+ elements[2] = RELEASED_VERSION; >+ System.arraycopy(releasedVersions, 0, elements, 3, releasedVersions.length); >+ >+ elements[releasedVersions.length + 3] = UNRELEASED_VERSION; >+ >+ System.arraycopy(unreleasedVersions, 0, elements, releasedVersions.length + 4, unreleasedVersions.length); >+ return elements; >+ } else { >+ return new Object[] {ANY_REPORTED_VERSION}; >+ } >+ } >+ >+ }); >+ fixFor.setLabelProvider(new VersionLabelProvider()); >+ fixFor.setInput(null); >+ >+ Label lblComponent = new Label(c, SWT.NONE); >+ lblComponent.setText("In Components:"); >+ lblComponent.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ components = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); >+ gd.heightHint = 40; >+ components.getControl().setLayoutData(gd); >+ >+ components.setContentProvider(new IStructuredContentProvider() { >+ private Project project; >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ project = (Project)newInput; >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (project != null) { >+ Component[] components = project.getComponents(); >+ >+ Object[] elements = new Object[components.length + 2]; >+ elements[0] = ANY_COMPONENT; >+ elements[1] = NO_COMPONENT; >+ System.arraycopy(components, 0, elements, 2, components.length); >+ return elements; >+ } else { >+ return new Object[] {ANY_COMPONENT}; >+ } >+ >+ } >+ >+ }); >+ components.setLabelProvider(new ComponentLabelProvider()); >+ components.setInput(null); >+ >+ Label lblReportedIn = new Label(c, SWT.NONE); >+ lblReportedIn.setText("Reported In:"); >+ lblReportedIn.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ reportedIn = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); >+ gd.heightHint = 40; >+ reportedIn.getControl().setLayoutData(gd); >+ >+ reportedIn.setContentProvider(new IStructuredContentProvider() { >+ private Project project; >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ project = (Project)newInput; >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ if (project != null) { >+ Version[] versions = project.getVersions(); >+ Version[] releasedVersions = project.getReleasedVersions(); >+ Version[] unreleasedVersions = project.getUnreleasedVersions(); >+ >+ Object[] elements = new Object[versions.length + 4]; >+ elements[0] = ANY_REPORTED_VERSION; >+ elements[1] = NO_REPORTED_VERSION; >+ elements[2] = RELEASED_VERSION; >+ System.arraycopy(releasedVersions, 0, elements, 3, releasedVersions.length); >+ >+ elements[releasedVersions.length + 3] = UNRELEASED_VERSION; >+ >+ System.arraycopy(unreleasedVersions, 0, elements, releasedVersions.length + 4, unreleasedVersions.length); >+ return elements; >+ } else { >+ return new Object[] {ANY_REPORTED_VERSION}; >+ } >+ >+ } >+ >+ }); >+ reportedIn.setLabelProvider(new VersionLabelProvider()); >+ reportedIn.setInput(null); >+ >+ Label lblQuery = new Label(c, SWT.NONE); >+ lblQuery.setText("Query:"); >+ queryString = new Text(c, SWT.BORDER); >+ queryString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); >+ // TODO put content assist here and a label describing what is available >+ >+ queryString.addFocusListener(new FocusAdapter() { >+ >+ public void focusLost(FocusEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ Label lblFields = new Label(c, SWT.NONE); >+ lblFields.setText("Fields:"); >+ lblFields.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 2)); >+ >+ searchSummary = new Button(c, SWT.CHECK); >+ searchSummary.setText("Summary"); >+ searchSummary.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ searchDescription = new Button(c, SWT.CHECK); >+ searchDescription.setText("Description"); >+ searchDescription.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ searchComments = new Button(c, SWT.CHECK); >+ searchComments.setText("Comments"); >+ searchComments.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ searchEnvironment = new Button(c, SWT.CHECK); >+ searchEnvironment.setText("Environment"); >+ searchEnvironment.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ // Need to turn off validation here >+ if (isNew) { >+ loadFromDefaults(); >+ } else { >+ loadFromWorkingCopy(); >+ } >+ >+ setControl(c); >+ } >+ >+ private void updateCurrentProject(Project project) { >+ this.fixFor.setInput(project); >+ this.components.setInput(project); >+ this.reportedIn.setInput(project); >+ >+ } >+ >+ private void validatePage() { >+ if (name.getText().length() == 0) { >+ setErrorMessage("Name is mandatory"); >+ setPageComplete(false); >+ return; >+ } >+ >+ setErrorMessage(null); >+ setPageComplete(true); >+ } >+ >+ private void loadFromDefaults() { >+ project.setSelection(new StructuredSelection(new Placeholder("All Projects"))); >+ searchSummary.setSelection(true); >+ searchDescription.setSelection(true); >+ } >+ >+ private void loadFromWorkingCopy() { >+ if (workingCopy.getName() != null) { >+ name.setText(workingCopy.getName()); >+ } >+ >+ if (workingCopy.getDescription() != null) { >+ description.setText(workingCopy.getDescription()); >+ } >+ >+ if (workingCopy.getProjectFilter() != null) { >+ project.setSelection(new StructuredSelection(workingCopy.getProjectFilter().getProject())); >+ } else { >+ project.setSelection(new StructuredSelection(new Placeholder("All Projects"))); >+ } >+ >+ if (workingCopy.getFixForVersionFilter() != null) { >+ if (workingCopy.getFixForVersionFilter().hasNoVersion()) { >+ fixFor.setSelection(new StructuredSelection(new Object[] {NO_FIX_VERSION})); >+ } else if (workingCopy.getFixForVersionFilter().isReleasedVersions() && workingCopy.getFixForVersionFilter().isUnreleasedVersions()) { >+ fixFor.setSelection(new StructuredSelection(new Object[] {RELEASED_VERSION, UNRELEASED_VERSION})); >+ } else if (workingCopy.getFixForVersionFilter().isReleasedVersions()) { >+ fixFor.setSelection(new StructuredSelection(RELEASED_VERSION)); >+ } else if (workingCopy.getFixForVersionFilter().isUnreleasedVersions()) { >+ fixFor.setSelection(new StructuredSelection(UNRELEASED_VERSION)); >+ } else { >+ fixFor.setSelection(new StructuredSelection(workingCopy.getFixForVersionFilter().getVersions())); >+ } >+ } else { >+ fixFor.setSelection(new StructuredSelection(ANY_FIX_VERSION)); >+ } >+ >+ if (workingCopy.getReportedInVersionFilter() != null) { >+ if (workingCopy.getReportedInVersionFilter().hasNoVersion()) { >+ reportedIn.setSelection(new StructuredSelection(new Object[] {NO_REPORTED_VERSION})); >+ } else if (workingCopy.getReportedInVersionFilter().isReleasedVersions() && workingCopy.getReportedInVersionFilter().isUnreleasedVersions()) { >+ reportedIn.setSelection(new StructuredSelection(new Object[] {RELEASED_VERSION, UNRELEASED_VERSION})); >+ } else if (workingCopy.getReportedInVersionFilter().isReleasedVersions()) { >+ reportedIn.setSelection(new StructuredSelection(RELEASED_VERSION)); >+ } else if (workingCopy.getReportedInVersionFilter().isUnreleasedVersions()) { >+ reportedIn.setSelection(new StructuredSelection(UNRELEASED_VERSION)); >+ } else { >+ reportedIn.setSelection(new StructuredSelection(workingCopy.getReportedInVersionFilter().getVersions())); >+ } >+ } else { >+ reportedIn.setSelection(new StructuredSelection(ANY_REPORTED_VERSION)); >+ } >+ >+ if (workingCopy.getContentFilter() != null) { >+ this.queryString.setText(workingCopy.getContentFilter().getQueryString()); >+ this.searchComments.setSelection(workingCopy.getContentFilter().isSearchingComments()); >+ this.searchDescription.setSelection(workingCopy.getContentFilter().isSearchingDescription()); >+ this.searchEnvironment.setSelection(workingCopy.getContentFilter().isSearchingEnvironment()); >+ this.searchSummary.setSelection(workingCopy.getContentFilter().isSearchingSummary()); >+ } >+ >+ if (workingCopy.getComponentFilter() != null) { >+ if (workingCopy.getComponentFilter().hasNoComponent()) { >+ components.setSelection(new StructuredSelection(NO_COMPONENT)); >+ } else { >+ components.setSelection(new StructuredSelection(workingCopy.getComponentFilter().getComponents())); >+ } >+ } else { >+ components.setSelection(new StructuredSelection(ANY_COMPONENT)); >+ } >+ } >+ >+ /* default */ void applyChanges() { >+ workingCopy.setName(this.name.getText()); >+ workingCopy.setDescription(this.description.getText()); >+ if (this.queryString.getText().length() > 0 || this.searchSummary.getSelection() || this.searchDescription.getSelection() || this.searchEnvironment.getSelection() || this.searchComments.getSelection()) { >+ workingCopy.setContentFilter(new ContentFilter(this.queryString.getText(), this.searchSummary.getSelection(), this.searchDescription.getSelection(), this.searchEnvironment.getSelection(), this.searchComments.getSelection())); >+ } else { >+ workingCopy.setContentFilter(null); >+ } >+ >+ IStructuredSelection projectSelection = (IStructuredSelection)this.project.getSelection(); >+ if (!projectSelection.isEmpty() && projectSelection.getFirstElement() instanceof Project) { >+ workingCopy.setProjectFilter(new ProjectFilter((Project) projectSelection.getFirstElement())); >+ } else { >+ workingCopy.setProjectFilter(null); >+ } >+ >+ IStructuredSelection reportedInSelection = (IStructuredSelection)reportedIn.getSelection(); >+ if (reportedInSelection.isEmpty()) { >+ workingCopy.setReportedInVersionFilter(null); >+ } else { >+ boolean selectionContainsReleased = false; >+ boolean selectionContainsUnreleased = false; >+ boolean selectionContainsAll = false; >+ boolean selectionContainsNone = false; >+ >+ List selectedVersions = new ArrayList(); >+ >+ for (Iterator i = reportedInSelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_REPORTED_VERSION.equals(selection)) { >+ selectionContainsAll = true; >+ } else if (NO_REPORTED_VERSION.equals(selection)) { >+ selectionContainsNone = true; >+ } else if (RELEASED_VERSION.equals(selection)) { >+ selectionContainsReleased = true; >+ } else if (UNRELEASED_VERSION.equals(selection)) { >+ selectionContainsUnreleased = true; >+ } else if (selection instanceof Version) { >+ selectedVersions.add(selection); >+ } >+ } >+ >+ if (selectionContainsAll) { >+ workingCopy.setReportedInVersionFilter(null); >+ } else if (selectionContainsNone) { >+ workingCopy.setReportedInVersionFilter(new VersionFilter(new Version[0])); >+ } else if (selectionContainsReleased || selectionContainsUnreleased) { >+ workingCopy.setReportedInVersionFilter(new VersionFilter(selectionContainsReleased, selectionContainsUnreleased)); >+ } else if (selectedVersions.size() > 0) { >+ workingCopy.setReportedInVersionFilter(new VersionFilter((Version[]) selectedVersions.toArray(new Version[selectedVersions.size()]))); >+ } else { >+ workingCopy.setReportedInVersionFilter(null); >+ } >+ } >+ >+ IStructuredSelection fixForSelection = (IStructuredSelection)fixFor.getSelection(); >+ if (fixForSelection.isEmpty()) { >+ workingCopy.setFixForVersionFilter(null); >+ } else { >+ boolean selectionContainsReleased = false; >+ boolean selectionContainsUnreleased = false; >+ boolean selectionContainsAll = false; >+ boolean selectionContainsNone = false; >+ >+ List selectedVersions = new ArrayList(); >+ >+ for (Iterator i = fixForSelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_FIX_VERSION.equals(selection)) { >+ selectionContainsAll = true; >+ } else if (NO_FIX_VERSION.equals(selection)) { >+ selectionContainsNone = true; >+ } else if (RELEASED_VERSION.equals(selection)) { >+ selectionContainsReleased = true; >+ } else if (UNRELEASED_VERSION.equals(selection)) { >+ selectionContainsUnreleased = true; >+ } else if (selection instanceof Version) { >+ selectedVersions.add(selection); >+ } >+ } >+ >+ if (selectionContainsAll) { >+ workingCopy.setFixForVersionFilter(null); >+ } else if (selectionContainsNone) { >+ workingCopy.setFixForVersionFilter(new VersionFilter(new Version[0])); >+ } else if (selectionContainsReleased || selectionContainsUnreleased) { >+ workingCopy.setFixForVersionFilter(new VersionFilter(selectionContainsReleased, selectionContainsUnreleased)); >+ } else if (selectedVersions.size() > 0) { >+ workingCopy.setFixForVersionFilter(new VersionFilter((Version[]) selectedVersions.toArray(new Version[selectedVersions.size()]))); >+ } else { >+ workingCopy.setFixForVersionFilter(null); >+ } >+ } >+ >+ IStructuredSelection componentsSelection = (IStructuredSelection)components.getSelection(); >+ if (componentsSelection.isEmpty()) { >+ workingCopy.setComponentFilter(null); >+ } else { >+ >+ boolean selectionContainsAll = false; >+ boolean selectionContainsNone = false; >+ List selectedComponents = new ArrayList(); >+ >+ for (Iterator i = componentsSelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_COMPONENT.equals(selection)) { >+ selectionContainsAll = true; >+ } else if (NO_COMPONENT.equals(selection)) { >+ selectionContainsNone = true; >+ } else if (selection instanceof Component){ >+ selectedComponents.add(selection); >+ } >+ } >+ >+ if (selectionContainsAll) { >+ workingCopy.setComponentFilter(null); >+ } else if (selectedComponents.size() > 0) { >+ workingCopy.setComponentFilter(new ComponentFilter((Component[]) selectedComponents.toArray(new Component[selectedComponents.size()]))); >+ } else if (selectionContainsNone){ >+ workingCopy.setComponentFilter(new ComponentFilter(new Component[0])); >+ } else { >+ workingCopy.setComponentFilter(null); >+ } >+ } >+ } >+ >+ private final class ComponentLabelProvider implements ILabelProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ return ((Component)element).getName(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ */ >+ public void addListener(ILabelProviderListener listener) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() >+ */ >+ public void dispose() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) >+ */ >+ public boolean isLabelProperty(Object element, String property) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ */ >+ public void removeListener(ILabelProviderListener listener) { >+ } >+ >+ } >+ >+ private final class VersionLabelProvider implements ILabelProvider, IColorProvider { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) >+ */ >+ public Image getImage(Object element) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) >+ */ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ return ((Version)element).getName(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ */ >+ public void addListener(ILabelProviderListener listener) { >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() >+ */ >+ public void dispose() { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) >+ */ >+ public boolean isLabelProperty(Object element, String property) { >+ return false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ */ >+ public void removeListener(ILabelProviderListener listener) { >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) >+ */ >+ public Color getForeground(Object element) { >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) >+ */ >+ public Color getBackground(Object element) { >+ if (element instanceof Placeholder) { >+ return Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND); >+ } >+ return null; >+ } >+ >+ } >+ >+ private final class Placeholder { >+ private final String text; >+ >+ public Placeholder(String text) { >+ this.text = text; >+ } >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (obj == null) return false; >+ if (!(obj instanceof Placeholder)) return false; >+ >+ Placeholder that = (Placeholder) obj; >+ return this.text.equals(that.text); >+ } >+ public String getText() { >+ return this.text; >+ } >+ } >+} >Index: src/org/eclipse/mylar/internal/jira/JiraNamedFilter.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/JiraNamedFilter.java >diff -N src/org/eclipse/mylar/internal/jira/JiraNamedFilter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/jira/JiraNamedFilter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,141 @@ >+/******************************************************************************* >+ * 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.jira; >+ >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; >+import org.tigris.jira.core.model.NamedFilter; >+ >+/** >+ * A JiraFilter represents a query for issues from a Jira repository. >+ * >+ * @author Mik Kersten >+ * @author Wesley Coelho (initial integration patch) >+ */ >+public class JiraNamedFilter extends AbstractRepositoryQuery { >+ >+// private static final String LABEL_REFRESH_JOB = "Refreshing Jira Filter(s)"; >+ >+ private static final int MAX_HITS = 75; >+ >+ protected NamedFilter filter = null; >+ >+// private boolean isRefreshing = false; >+ >+ public JiraNamedFilter(String repositoryUrl, NamedFilter filter) { >+ setMaxHits(MAX_HITS); >+ this.filter = filter; >+ super.repositoryUrl = repositoryUrl; >+ setQueryUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + filter.getId()); >+ >+ super.setDescription(filter.getName()); >+ } >+ >+ public NamedFilter getNamedFilter() { >+ return filter; >+ } >+ >+// /** >+// * TODO: refactor into common refresh mechanism. >+// */ >+// public void refreshHits() { >+// isRefreshing = true; >+// Job j = new Job(LABEL_REFRESH_JOB) { >+// >+// @Override >+// protected IStatus run(final IProgressMonitor monitor) { >+// clearHits(); >+// try { >+// TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository(MylarJiraPlugin.JIRA_REPOSITORY_KIND, repositoryUrl); >+// JiraServerFacade.getDefault().getJiraServer(repository).executeNamedFilter(filter, new IssueCollector() { >+// >+// public void done() { >+// isRefreshing = false; >+// Display.getDefault().asyncExec(new Runnable() { >+// public void run() { >+// if (TaskListView.getDefault() != null) >+// TaskListView.getDefault().refreshAndFocus(); >+// } >+// }); >+// } >+// >+// public boolean isCancelled() { >+// return monitor.isCanceled(); >+// } >+// >+// public void collectIssue(Issue issue) { >+// int issueId = new Integer(issue.getId()); >+// JiraFilterHit hit = new JiraFilterHit(issue, JiraFilter.this.getRepositoryUrl(), issueId); >+// addHit(hit); >+// } >+// >+// public void start() { >+// >+// } >+// }); >+// >+// } catch (Exception e) { >+// isRefreshing = false; >+// JiraServerFacade.handleConnectionException(e); >+// return Status.CANCEL_STATUS; >+// } >+// >+// return Status.OK_STATUS; >+// } >+// >+// }; >+// >+// j.schedule(); >+// >+// } >+ >+ public String getQueryUrl() { >+ return super.getQueryUrl(); >+ } >+ >+ public String getPriority() { >+ return ""; >+ } >+ >+ public String getDescription() { >+ if (filter.getName() != null) { >+ return filter.getName(); >+ } else { >+ return super.getDescription(); >+ } >+ } >+ >+ public void setDescription(String description) { >+ filter.setDescription(description); >+ } >+ >+ public boolean isLocal() { >+ return false; >+ } >+ >+// /** True if the filter is currently downloading hits */ >+// public boolean isRefreshing() { >+// return isRefreshing; >+// } >+ >+ public String getRepositoryKind() { >+ return MylarJiraPlugin.JIRA_REPOSITORY_KIND; >+ } >+ >+ public NamedFilter getFilter() { >+ return filter; >+ } >+ >+// public void setRefreshing(boolean refreshing) { >+// this.isRefreshing = refreshing; >+// } >+ >+} >Index: src/org/eclipse/mylar/internal/jira/ui/wizards/IssueAttributesPage.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/ui/wizards/IssueAttributesPage.java >diff -N src/org/eclipse/mylar/internal/jira/ui/wizards/IssueAttributesPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/jira/ui/wizards/IssueAttributesPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,652 @@ >+/******************************************************************************* >+ * Copyright (c) 2005 Jira Dashboard project. >+ * 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: >+ * Brock Janiczak - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.mylar.internal.jira.ui.wizards; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.viewers.ComboViewer; >+import org.eclipse.jface.viewers.ISelectionChangedListener; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.LabelProvider; >+import org.eclipse.jface.viewers.ListViewer; >+import org.eclipse.jface.viewers.SelectionChangedEvent; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ModifyEvent; >+import org.eclipse.swt.events.ModifyListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Text; >+import org.tigris.jira.core.model.IssueType; >+import org.tigris.jira.core.model.Priority; >+import org.tigris.jira.core.model.Resolution; >+import org.tigris.jira.core.model.Status; >+import org.tigris.jira.core.model.filter.CurrentUserFilter; >+import org.tigris.jira.core.model.filter.FilterDefinition; >+import org.tigris.jira.core.model.filter.IssueTypeFilter; >+import org.tigris.jira.core.model.filter.NobodyFilter; >+import org.tigris.jira.core.model.filter.PriorityFilter; >+import org.tigris.jira.core.model.filter.ResolutionFilter; >+import org.tigris.jira.core.model.filter.SpecificUserFilter; >+import org.tigris.jira.core.model.filter.StatusFilter; >+import org.tigris.jira.core.model.filter.UserFilter; >+import org.tigris.jira.core.model.filter.UserInGroupFilter; >+import org.tigris.jira.core.service.JiraServer; >+ >+public class IssueAttributesPage extends WizardPage { >+ private final Placeholder ANY_ISSUE_TYPE = new Placeholder("Any"); >+ private final Placeholder ANY_RESOLUTION = new Placeholder("Any"); >+ private final Placeholder UNRESOLVED = new Placeholder("Unresolved"); >+ private final Placeholder UNASSIGNED = new Placeholder("Unassigned"); >+ >+ private final Placeholder ANY_REPORTER = new Placeholder("Any"); >+ private final Placeholder NO_REPORTER = new Placeholder("No Reporter"); >+ private final Placeholder CURRENT_USER_REPORTER = new Placeholder("Current User"); >+ private final Placeholder SPECIFIC_USER_REPORTER = new Placeholder("Specified User"); >+ private final Placeholder SPECIFIC_GROUP_REPORTER = new Placeholder("Specified Group"); >+ >+ private final Placeholder ANY_ASSIGNEE = new Placeholder("Any"); >+ private final Placeholder CURRENT_USER_ASSIGNEE = new Placeholder("Current User"); >+ private final Placeholder SPECIFIC_USER_ASSIGNEE = new Placeholder("Specified User"); >+ private final Placeholder SPECIFIC_GROUP_ASSIGNEE = new Placeholder("Specified Group"); >+ >+ private final Placeholder ANY_STATUS = new Placeholder("Any"); >+ private final Placeholder ANY_PRIORITY = new Placeholder("Any"); >+ >+ private final JiraServer jiraServer; >+ private final FilterDefinition workingCopy; >+ private final boolean isNew; >+ private ListViewer issueType; >+ private ComboViewer reporterType; >+ private ComboViewer assigneeType; >+ private ListViewer status; >+ private ListViewer resolution; >+ private ListViewer priority; >+ private Text assignee; >+ private Text reporter; >+ >+ /** >+ * @param pageName >+ * @param title >+ * @param titleImage >+ */ >+ protected IssueAttributesPage(String pageName, String title, ImageDescriptor titleImage, JiraServer jiraServer, FilterDefinition workingCopy, boolean isNew) { >+ super(pageName, title, titleImage); >+ this.jiraServer = jiraServer; >+ this.workingCopy = workingCopy; >+ this.isNew = isNew; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ GridData gd; >+ Composite c = new Composite(parent, SWT.NONE); >+ c.setLayout(new GridLayout(2, false)); >+ >+ Label lblIssueType = new Label(c, SWT.NONE); >+ lblIssueType.setText("Type:"); >+ lblIssueType.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ issueType = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 40; >+ issueType.getControl().setLayoutData(gd); >+ >+ issueType.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ JiraServer server = (JiraServer) inputElement; >+ Object[] elements = new Object[server.getIssueTypes().length + 1]; >+ elements[0] = ANY_ISSUE_TYPE; >+ System.arraycopy(server.getIssueTypes(), 0, elements, 1, server.getIssueTypes().length); >+ >+ return elements; >+ } >+ }); >+ >+ issueType.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ return ((IssueType)element).getName(); >+ } >+ >+ }); >+ >+ issueType.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ validatePage(); >+ } >+ >+ }); >+ issueType.setInput(jiraServer); >+ >+ Label lblReportedBy = new Label(c, SWT.NONE); >+ lblReportedBy.setText("Reported By:"); >+ lblReportedBy.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 2)); >+ >+ reporterType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY); >+ reporterType.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >+ >+ reporterType.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return new Object[] {ANY_REPORTER, NO_REPORTER, CURRENT_USER_REPORTER, SPECIFIC_USER_REPORTER, SPECIFIC_GROUP_REPORTER}; >+ } >+ >+ }); >+ >+ reporterType.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ }); >+ >+ reporterType.setInput(jiraServer); >+ >+ reporter = new Text(c, SWT.BORDER); >+ reporter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >+ reporter.setEnabled(false); >+ >+ reporter.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ reporterType.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ Object selection = ((IStructuredSelection)event.getSelection()).getFirstElement(); >+ if (SPECIFIC_USER_REPORTER.equals(selection) || >+ SPECIFIC_GROUP_REPORTER.equals(selection)) { >+ reporter.setEnabled(true); >+ } else { >+ reporter.setEnabled(false); >+ } >+ } >+ >+ }); >+ >+ Label lblAssignedTo = new Label(c, SWT.NONE); >+ lblAssignedTo.setText("Assigned To:"); >+ lblAssignedTo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 2)); >+ >+ assigneeType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY); >+ assigneeType.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >+ >+ >+ assigneeType.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ return new Object[] {ANY_ASSIGNEE, UNASSIGNED, CURRENT_USER_ASSIGNEE, SPECIFIC_USER_ASSIGNEE, SPECIFIC_GROUP_ASSIGNEE}; >+ } >+ >+ }); >+ >+ assigneeType.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ }); >+ >+ assigneeType.setInput(jiraServer); >+ >+ assignee = new Text(c, SWT.BORDER); >+ assignee.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); >+ assignee.setEnabled(false); >+ >+ assignee.addModifyListener(new ModifyListener() { >+ >+ public void modifyText(ModifyEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ assigneeType.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ Object selection = ((IStructuredSelection)event.getSelection()).getFirstElement(); >+ if (SPECIFIC_USER_ASSIGNEE.equals(selection) || >+ SPECIFIC_GROUP_ASSIGNEE.equals(selection)) { >+ assignee.setEnabled(true); >+ } else { >+ assignee.setEnabled(false); >+ assignee.setText(""); //$NON-NLS-1$ >+ } >+ validatePage(); >+ } >+ >+ }); >+ >+ Label lblStatus = new Label(c, SWT.NONE); >+ lblStatus.setText("Status:"); >+ lblStatus.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ status = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 40; >+ status.getControl().setLayoutData(gd); >+ >+ status.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ JiraServer server = (JiraServer) inputElement; >+ Object[] elements = new Object[server.getStatuses().length + 1]; >+ elements[0] = ANY_STATUS; >+ System.arraycopy(server.getStatuses(), 0, elements, 1, server.getStatuses().length); >+ >+ return elements; >+ } >+ }); >+ >+ status.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ return ((Status)element).getName(); >+ } >+ >+ }); >+ >+ status.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ validatePage(); >+ } >+ >+ }); >+ status.setInput(jiraServer); >+ >+ Label lblResolution = new Label(c, SWT.NONE); >+ lblResolution.setText("Resolution:"); >+ lblResolution.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ resolution = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 40; >+ resolution.getControl().setLayoutData(gd); >+ resolution.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ JiraServer server = (JiraServer) inputElement; >+ Object[] elements = new Object[server.getResolutions().length + 2]; >+ elements[0] = ANY_RESOLUTION; >+ elements[1] = UNRESOLVED; >+ System.arraycopy(server.getResolutions(), 0, elements, 2, server.getResolutions().length); >+ >+ return elements; >+ } >+ }); >+ >+ resolution.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ return ((Resolution)element).getName(); >+ } >+ >+ }); >+ >+ resolution.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ validatePage(); >+ } >+ >+ }); >+ resolution.setInput(jiraServer); >+ >+ Label lblPriority = new Label(c, SWT.NONE); >+ lblPriority.setText("Priority:"); >+ lblPriority.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ priority = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gd.heightHint = 40; >+ priority.getControl().setLayoutData(gd); >+ >+ priority.setContentProvider(new IStructuredContentProvider() { >+ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ } >+ >+ public void dispose() { >+ } >+ >+ public Object[] getElements(Object inputElement) { >+ JiraServer server = (JiraServer) inputElement; >+ Object[] elements = new Object[server.getPriorities().length + 1]; >+ elements[0] = ANY_PRIORITY; >+ System.arraycopy(server.getPriorities(), 0, elements, 1, server.getPriorities().length); >+ >+ return elements; >+ } >+ }); >+ >+ priority.setLabelProvider(new LabelProvider() { >+ >+ public String getText(Object element) { >+ if (element instanceof Placeholder) { >+ return ((Placeholder)element).getText(); >+ } >+ >+ return ((Priority)element).getName(); >+ } >+ >+ }); >+ priority.addSelectionChangedListener(new ISelectionChangedListener() { >+ >+ public void selectionChanged(SelectionChangedEvent event) { >+ validatePage(); >+ } >+ >+ }); >+ priority.setInput(jiraServer); >+ >+ if (isNew) { >+ loadFromDefaults(); >+ } else { >+ loadFromWorkingCopy(); >+ } >+ >+ setControl(c); >+ } >+ >+ private void validatePage() { >+ >+ } >+ >+ /* default */ void applyChanges() { >+ >+ // TODO support standard and subtask issue types >+ IStructuredSelection issueTypeSelection = (IStructuredSelection) issueType.getSelection(); >+ if (issueTypeSelection.isEmpty()) { >+ workingCopy.setIssueTypeFilter(null); >+ } else { >+ boolean isAnyIssueTypeSelected = false; >+ >+ List selectedIssueTypes = new ArrayList(); >+ >+ for (Iterator i = issueTypeSelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_ISSUE_TYPE.equals(selection)) { >+ isAnyIssueTypeSelected = true; >+ } else if (selection instanceof IssueType) { >+ selectedIssueTypes.add(selection); >+ } >+ } >+ >+ if (isAnyIssueTypeSelected) { >+ workingCopy.setIssueTypeFilter(null); >+ } else { >+ workingCopy.setIssueTypeFilter(new IssueTypeFilter((IssueType[]) selectedIssueTypes.toArray(new IssueType[selectedIssueTypes.size()]))); >+ } >+ } >+ >+ IStructuredSelection reporterSelection = (IStructuredSelection) reporterType.getSelection(); >+ if (reporterSelection.isEmpty()) { >+ workingCopy.setReportedByFilter(null); >+ } else { >+ if (ANY_REPORTER.equals(reporterSelection.getFirstElement())) { >+ workingCopy.setReportedByFilter(null); >+ } else if (NO_REPORTER.equals(reporterSelection.getFirstElement())) { >+ workingCopy.setReportedByFilter(new NobodyFilter()); >+ } else if (CURRENT_USER_REPORTER.equals(reporterSelection.getFirstElement())) { >+ workingCopy.setReportedByFilter(new CurrentUserFilter()); >+ } else if (SPECIFIC_GROUP_REPORTER.equals(reporterSelection.getFirstElement())) { >+ workingCopy.setReportedByFilter(new UserInGroupFilter(reporter.getText())); >+ } else if (SPECIFIC_USER_REPORTER.equals(reporterSelection.getFirstElement())) { >+ workingCopy.setReportedByFilter(new SpecificUserFilter(reporter.getText())); >+ } else { >+ workingCopy.setReportedByFilter(null); >+ } >+ } >+ >+ IStructuredSelection assigneeSelection = (IStructuredSelection) assigneeType.getSelection(); >+ if (assigneeSelection.isEmpty()) { >+ workingCopy.setAssignedToFilter(null); >+ } else { >+ if (ANY_REPORTER.equals(assigneeSelection.getFirstElement())) { >+ workingCopy.setAssignedToFilter(null); >+ } else if (UNASSIGNED.equals(assigneeSelection.getFirstElement())) { >+ workingCopy.setAssignedToFilter(new NobodyFilter()); >+ } else if (CURRENT_USER_REPORTER.equals(assigneeSelection.getFirstElement())) { >+ workingCopy.setAssignedToFilter(new CurrentUserFilter()); >+ } else if (SPECIFIC_GROUP_REPORTER.equals(assigneeSelection.getFirstElement())) { >+ workingCopy.setAssignedToFilter(new UserInGroupFilter(assignee.getText())); >+ } else if (SPECIFIC_USER_REPORTER.equals(assigneeSelection.getFirstElement())) { >+ workingCopy.setAssignedToFilter(new SpecificUserFilter(assignee.getText())); >+ } else { >+ workingCopy.setAssignedToFilter(null); >+ } >+ } >+ >+ >+ IStructuredSelection statusSelection = (IStructuredSelection) status.getSelection(); >+ if (statusSelection.isEmpty()) { >+ workingCopy.setStatusFilter(null); >+ } else { >+ boolean isAnyStatusSelected = false; >+ >+ List selectedStatuses = new ArrayList(); >+ >+ for (Iterator i = statusSelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_STATUS.equals(selection)) { >+ isAnyStatusSelected = true; >+ } else if (selection instanceof Status) { >+ selectedStatuses.add(selection); >+ } >+ } >+ >+ if (isAnyStatusSelected) { >+ workingCopy.setStatusFilter(null); >+ } else { >+ workingCopy.setStatusFilter(new StatusFilter((Status[]) selectedStatuses.toArray(new Status[selectedStatuses.size()]))); >+ } >+ } >+ >+ IStructuredSelection resolutionSelection = (IStructuredSelection) resolution.getSelection(); >+ if (resolutionSelection.isEmpty()) { >+ workingCopy.setResolutionFilter(null); >+ } else { >+ boolean isAnyResolutionSelected = false; >+ >+ List selectedResolutions = new ArrayList(); >+ >+ for (Iterator i = resolutionSelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_RESOLUTION.equals(selection)) { >+ isAnyResolutionSelected = true; >+ } else if (selection instanceof Resolution) { >+ selectedResolutions.add(selection); >+ } >+ } >+ >+ if (isAnyResolutionSelected) { >+ workingCopy.setResolutionFilter(null); >+ } else { >+ workingCopy.setResolutionFilter(new ResolutionFilter((Resolution[]) selectedResolutions.toArray(new Resolution[selectedResolutions.size()]))); >+ } >+ } >+ >+ >+ IStructuredSelection prioritySelection = (IStructuredSelection) priority.getSelection(); >+ if (prioritySelection.isEmpty()) { >+ workingCopy.setPriorityFilter(null); >+ } else { >+ boolean isAnyPrioritiesSelected = false; >+ >+ List selectedPriorities = new ArrayList(); >+ >+ for (Iterator i = prioritySelection.iterator(); i.hasNext(); ) { >+ Object selection = i.next(); >+ if (ANY_PRIORITY.equals(selection)) { >+ isAnyPrioritiesSelected = true; >+ } else if (selection instanceof Priority) { >+ selectedPriorities.add(selection); >+ } >+ } >+ >+ if (isAnyPrioritiesSelected) { >+ workingCopy.setPriorityFilter(null); >+ } else { >+ workingCopy.setPriorityFilter(new PriorityFilter((Priority[]) selectedPriorities.toArray(new Priority[selectedPriorities.size()]))); >+ } >+ } >+ } >+ >+ private void loadFromDefaults() { >+ issueType.setSelection(new StructuredSelection(ANY_ISSUE_TYPE)); >+ reporterType.setSelection(new StructuredSelection(ANY_REPORTER)); >+ assigneeType.setSelection(new StructuredSelection(ANY_ASSIGNEE)); >+ status.setSelection(new StructuredSelection(ANY_STATUS)); >+ resolution.setSelection(new StructuredSelection(ANY_RESOLUTION)); >+ priority.setSelection(new StructuredSelection(ANY_PRIORITY)); >+ } >+ >+ private void loadFromWorkingCopy() { >+ if (workingCopy.getIssueTypeFilter() != null) { >+ issueType.setSelection(new StructuredSelection(workingCopy.getIssueTypeFilter().getIsueTypes())); >+ } else { >+ issueType.setSelection(new StructuredSelection(ANY_ISSUE_TYPE)); >+ } >+ >+ if (workingCopy.getReportedByFilter() != null) { >+ UserFilter reportedByFilter = workingCopy.getReportedByFilter(); >+ if (reportedByFilter instanceof NobodyFilter) { >+ reporterType.setSelection(new StructuredSelection(NO_REPORTER)); >+ } else if (reportedByFilter instanceof CurrentUserFilter) { >+ reporterType.setSelection(new StructuredSelection(CURRENT_USER_REPORTER)); >+ } else if (reportedByFilter instanceof SpecificUserFilter) { >+ reporterType.setSelection(new StructuredSelection(SPECIFIC_USER_REPORTER)); >+ reporter.setText(((SpecificUserFilter)reportedByFilter).getUser()); >+ } else if (reportedByFilter instanceof UserInGroupFilter) { >+ reporterType.setSelection(new StructuredSelection(SPECIFIC_GROUP_REPORTER)); >+ reporter.setText(((UserInGroupFilter)reportedByFilter).getGroup()); >+ } >+ } else { >+ reporterType.setSelection(new StructuredSelection(ANY_REPORTER)); >+ } >+ >+ if (workingCopy.getAssignedToFilter() != null) { >+ UserFilter assignedToFilter = workingCopy.getAssignedToFilter(); >+ if (assignedToFilter instanceof NobodyFilter) { >+ assigneeType.setSelection(new StructuredSelection(UNASSIGNED)); >+ } else if (assignedToFilter instanceof CurrentUserFilter) { >+ assigneeType.setSelection(new StructuredSelection(CURRENT_USER_ASSIGNEE)); >+ } else if (assignedToFilter instanceof SpecificUserFilter) { >+ assigneeType.setSelection(new StructuredSelection(SPECIFIC_USER_ASSIGNEE)); >+ assignee.setText(((SpecificUserFilter)assignedToFilter).getUser()); >+ } else if (assignedToFilter instanceof UserInGroupFilter) { >+ assigneeType.setSelection(new StructuredSelection(SPECIFIC_GROUP_ASSIGNEE)); >+ assignee.setText(((UserInGroupFilter)assignedToFilter).getGroup()); >+ } >+ } else { >+ assigneeType.setSelection(new StructuredSelection(ANY_ASSIGNEE)); >+ } >+ >+ if (workingCopy.getStatusFilter() != null) { >+ status.setSelection(new StructuredSelection(workingCopy.getStatusFilter().getStatuses())); >+ } else { >+ status.setSelection(new StructuredSelection(ANY_STATUS)); >+ } >+ >+ if (workingCopy.getResolutionFilter() != null) { >+ resolution.setSelection(new StructuredSelection(workingCopy.getResolutionFilter().getResolutions())); >+ } else { >+ resolution.setSelection(new StructuredSelection(ANY_RESOLUTION)); >+ } >+ >+ if (workingCopy.getPriorityFilter() != null) { >+ priority.setSelection(new StructuredSelection(workingCopy.getPriorityFilter().getPriorities())); >+ } else { >+ priority.setSelection(new StructuredSelection(ANY_PRIORITY)); >+ } >+ } >+ >+ private final class Placeholder { >+ private final String text; >+ >+ public Placeholder(String text) { >+ this.text = text; >+ } >+ /* (non-Javadoc) >+ * @see java.lang.Object#equals(java.lang.Object) >+ */ >+ public boolean equals(Object obj) { >+ if (obj == null) return false; >+ if (!(obj instanceof Placeholder)) return false; >+ >+ Placeholder that = (Placeholder) obj; >+ return this.text.equals(that.text); >+ } >+ public String getText() { >+ return this.text; >+ } >+ } >+}
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 129086
:
35968
|
39630
|
39731
|
39732
|
39758
|
39794
|
39840