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 39731 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.
Mik's updates
patch-queries.txt (text/plain), 74.33 KB, created by
Mik Kersten
on 2006-04-27 20:37:17 EDT
(
hide
)
Description:
Mik's updates
Filename:
MIME Type:
Creator:
Mik Kersten
Created:
2006-04-27 20:37:17 EDT
Size:
74.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.jira >Index: src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java,v >retrieving revision 1.18 >diff -u -r1.18 JiraRepositoryConnector.java >--- src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java 13 Apr 2006 20:58:45 -0000 1.18 >+++ src/org/eclipse/mylar/internal/jira/JiraRepositoryConnector.java 28 Apr 2006 00:36:06 -0000 >@@ -37,6 +37,7 @@ > import org.eclipse.mylar.provisional.tasklist.TaskRepository; > import org.tigris.jira.core.model.Issue; > import org.tigris.jira.core.model.filter.IssueCollector; >+import org.tigris.jira.core.service.JiraServer; > > /** > * @author Mik Kersten >@@ -56,13 +57,13 @@ > > private final IProgressMonitor monitor; > >- private final JiraRepositoryQuery query; >+ private final AbstractRepositoryQuery query; > > private final List<AbstractQueryHit> hits; > > private boolean done = false; > >- private JiraIssueCollector(IProgressMonitor monitor, JiraRepositoryQuery query, List<AbstractQueryHit> hits) { >+ JiraIssueCollector(IProgressMonitor monitor, AbstractRepositoryQuery query, List<AbstractQueryHit> hits) { > this.monitor = monitor; > this.query = query; > this.hits = hits; >@@ -137,29 +138,41 @@ > > @Override > public void openEditQueryDialog(AbstractRepositoryQuery query) { >- JiraRepositoryQuery filter = (JiraRepositoryQuery) query; >- String title = "Filter: " + filter.getDescription(); >- TaskUiUtil.openUrl(title, title, filter.getQueryUrl()); >+// JiraRepositoryQuery filter = (JiraRepositoryQuery) query; >+// String title = "Filter: " + filter.getDescription(); >+// TaskUiUtil.openUrl(title, title, filter.getQueryUrl()); >+ >+ if (query instanceof JiraRepositoryQuery) { >+ JiraRepositoryQuery filter = (JiraRepositoryQuery) query; >+ String title = "Filter: " + filter.getDescription(); >+ TaskUiUtil.openUrl(title, title, filter.getQueryUrl()); >+ } >+ // TODO support custom filters > } > > @Override > protected List<AbstractQueryHit> performQuery(AbstractRepositoryQuery repositoryQuery, > final IProgressMonitor monitor, MultiStatus queryStatus) { >- if (!(repositoryQuery instanceof JiraRepositoryQuery)) { >- return Collections.emptyList(); >- } >- final JiraRepositoryQuery jiraRepositoryQuery = (JiraRepositoryQuery) repositoryQuery; > final List<AbstractQueryHit> hits = new ArrayList<AbstractQueryHit>(); >- JiraIssueCollector collector = new JiraIssueCollector(monitor, jiraRepositoryQuery, hits); >- try { >- TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository( >- MylarJiraPlugin.REPOSITORY_KIND, repositoryQuery.getRepositoryUrl()); >- JiraServerFacade.getDefault().getJiraServer(repository).search(jiraRepositoryQuery.getNamedFilter(), collector); > >+ TaskRepository repository = MylarTaskListPlugin.getRepositoryManager().getRepository( >+ MylarJiraPlugin.REPOSITORY_KIND, repositoryQuery.getRepositoryUrl()); >+ >+ JiraIssueCollector collector = new JiraIssueCollector(monitor, repositoryQuery, hits); >+ >+ try { >+ JiraServer jiraServer = JiraServerFacade.getDefault().getJiraServer(repository); >+ >+ if (repositoryQuery instanceof JiraRepositoryQuery) { >+ jiraServer.search(((JiraRepositoryQuery) repositoryQuery).getNamedFilter(), collector); >+ >+ } else if (repositoryQuery instanceof JiraCustomQuery) { >+ jiraServer.search(((JiraCustomQuery) repositoryQuery).getFilterDefinition(), collector); >+ } > } catch (Exception e) { >- queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, >+ queryStatus.add(new Status(IStatus.OK, MylarTaskListPlugin.PLUGIN_ID, IStatus.OK, > "Could not log in to server: " + repositoryQuery.getRepositoryUrl() >- + "\n\nCheck network connection.", e)); >+ + "\n\nCheck network connection.", e)); > } > queryStatus.add(Status.OK_STATUS); > return hits; >@@ -219,13 +232,11 @@ > public String getRepositoryUrlFromTaskUrl(String url) { > if (url == null) { > return null; >- } else { >- int index = url.indexOf(DELIM_URL); >- if (index != -1) { >- return url.substring(0, index); >- } else { >- return null; >- } > } >+ int index = url.indexOf(DELIM_URL); >+ if (index != -1) { >+ return url.substring(0, index); >+ } >+ return null; > } > } >Index: src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java,v >retrieving revision 1.23 >diff -u -r1.23 JiraTaskExternalizer.java >--- src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java 14 Mar 2006 01:22:27 -0000 1.23 >+++ src/org/eclipse/mylar/internal/jira/JiraTaskExternalizer.java 28 Apr 2006 00:36:06 -0000 >@@ -24,6 +24,7 @@ > import org.eclipse.mylar.provisional.tasklist.TaskList; > import org.tigris.jira.core.model.Issue; > import org.tigris.jira.core.model.NamedFilter; >+import org.tigris.jira.core.model.filter.FilterDefinition; > import org.w3c.dom.Document; > import org.w3c.dom.Element; > import org.w3c.dom.Node; >@@ -38,12 +39,14 @@ > private static final String KEY_ISSUE_SUMMARY = "IssueSummary"; > > private static final String KEY_JIRA = "Jira"; >+ private static final String KEY_CUSTOM = "JiraCustom"; > > private static final String KEY_JIRA_CATEGORY = "JiraQuery" + KEY_CATEGORY; > > private static final String KEY_JIRA_QUERY_HIT = KEY_JIRA + KEY_QUERY_HIT; > > private static final String KEY_JIRA_QUERY = KEY_JIRA + KEY_QUERY; >+ private static final String KEY_JIRA_CUSTOM = KEY_JIRA + KEY_CUSTOM + KEY_QUERY; > > private static final String KEY_JIRA_ISSUE = "JiraIssue"; > >@@ -54,11 +57,13 @@ > private static final String KEY_FILTER_DESCRIPTION = "FilterDesc"; > > public boolean canReadQuery(Node node) { >- return node.getNodeName().equals(KEY_JIRA_QUERY); >+ return node.getNodeName().equals(KEY_JIRA_QUERY) >+ || node.getNodeName().equals(KEY_JIRA_CUSTOM); > } > > public boolean canCreateElementFor(AbstractRepositoryQuery category) { >- return category instanceof JiraRepositoryQuery; >+ return category instanceof JiraRepositoryQuery >+ || category instanceof JiraCustomQuery; > } > > public boolean canCreateElementFor(ITask task) { >@@ -87,25 +92,32 @@ > } > if (hasCaughtException) { > throw new TaskExternalizationException("Failed to load all hits"); >- } else { >- return query; > } >+ return query; > } > > public Element createQueryElement(AbstractRepositoryQuery query, Document doc, Element parent) { > String queryTagName = getQueryTagNameForElement(query); > Element node = doc.createElement(queryTagName); > >- NamedFilter filter = ((JiraRepositoryQuery) 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()); >- >+ if (query instanceof JiraRepositoryQuery) { >+ NamedFilter filter = ((JiraRepositoryQuery) query).getNamedFilter(); >+ node.setAttribute(KEY_FILTER_ID, filter.getId()); >+ node.setAttribute(KEY_FILTER_NAME, filter.getName()); >+ node.setAttribute(KEY_FILTER_DESCRIPTION, filter.getDescription()); >+ } else { >+ FilterDefinition filter = ((JiraCustomQuery) query).getFilterDefinition(); >+ // XXX implement actual export >+ node.setAttribute(KEY_FILTER_ID, filter.getName()); >+ node.setAttribute(KEY_FILTER_NAME, filter.getName()); >+ node.setAttribute(KEY_FILTER_DESCRIPTION, filter.getDescription()); >+ } >+ > for (AbstractQueryHit hit : query.getHits()) { > try { > Element element = null; >@@ -226,6 +238,8 @@ > public String getQueryTagNameForElement(AbstractRepositoryQuery query) { > if (query instanceof JiraRepositoryQuery) { > return KEY_JIRA_QUERY; >+ } else if( query instanceof JiraCustomQuery) { >+ return KEY_JIRA_CUSTOM; > } > return ""; > } >Index: src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java,v >retrieving revision 1.11 >diff -u -r1.11 NewJiraQueryWizard.java >--- src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java 6 Apr 2006 15:54:46 -0000 1.11 >+++ src/org/eclipse/mylar/internal/jira/ui/wizards/NewJiraQueryWizard.java 28 Apr 2006 00:36:06 -0000 >@@ -12,11 +12,10 @@ > package org.eclipse.mylar.internal.jira.ui.wizards; > > import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.mylar.internal.jira.JiraRepositoryQuery; > import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; > import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; >-import org.tigris.jira.core.model.NamedFilter; > > /** > * Wizard that allows the user to select one of their named Jira filters on the >@@ -42,20 +41,19 @@ > @Override > public void addPages() { > queryPage = new JiraQueryWizardPage(repository); >+ queryPage.setWizard(this); > addPage(queryPage); > } > > @Override > public boolean performFinish() { > >- NamedFilter namedFilter = queryPage.getSelectedFilter(); >- >- if (namedFilter != null) { >- JiraRepositoryQuery filter = new JiraRepositoryQuery(repository.getUrl(), namedFilter, MylarTaskListPlugin.getTaskListManager().getTaskList()); >- MylarTaskListPlugin.getTaskListManager().getTaskList().addQuery(filter); >+ AbstractRepositoryQuery query = queryPage.getQuery(); >+ if (query != null) { >+ MylarTaskListPlugin.getTaskListManager().getTaskList().addQuery(query); > AbstractRepositoryConnector connector = MylarTaskListPlugin.getRepositoryManager().getRepositoryConnector(repository.getKind()); > if (connector != null) { >- connector.synchronize(filter, null); >+ connector.synchronize(query, null); > } > // filter.refreshHits(); > } >@@ -63,4 +61,13 @@ > return true; > } > >+ >+ >+ public boolean canFinish() { >+ if(queryPage.getNextPage() == null) { >+ return queryPage.isPageComplete(); >+ } >+ return queryPage.getNextPage().isPageComplete(); >+ } >+ > } >Index: src/org/eclipse/mylar/internal/jira/ui/wizards/JiraQueryWizardPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.jira/src/org/eclipse/mylar/internal/jira/ui/wizards/JiraQueryWizardPage.java,v >retrieving revision 1.8 >diff -u -r1.8 JiraQueryWizardPage.java >--- src/org/eclipse/mylar/internal/jira/ui/wizards/JiraQueryWizardPage.java 28 Mar 2006 17:19:05 -0000 1.8 >+++ src/org/eclipse/mylar/internal/jira/ui/wizards/JiraQueryWizardPage.java 28 Apr 2006 00:36:06 -0000 >@@ -16,8 +16,12 @@ > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.mylar.internal.jira.JiraRepositoryQuery; > import org.eclipse.mylar.internal.jira.JiraServerFacade; >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; >+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; > import org.eclipse.mylar.provisional.tasklist.TaskRepository; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionAdapter; >@@ -25,11 +29,11 @@ > import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; >-import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.List; > import org.tigris.jira.core.model.NamedFilter; >+import org.tigris.jira.core.model.filter.FilterDefinition; > import org.tigris.jira.core.service.JiraServer; > > /** >@@ -41,13 +45,13 @@ > */ > public class JiraQueryWizardPage extends WizardPage { > >- private static final int COMBO_WIDTH_HINT = 200; >+ // private static final int COMBO_WIDTH_HINT = 200; > > private static final String TITLE = "New Jira Query"; > > private static final String DESCRIPTION = "Please select a filter defined on the server."; > >- private static final String COMBO_LABEL = "Filter:"; >+ // private static final String COMBO_LABEL = "Filter:"; > > private static final String WAIT_MESSAGE = "Downloading..."; > >@@ -55,12 +59,18 @@ > > private NamedFilter[] filters = null; > >- private Combo filterCombo = null; >- >+ private List filterCombo; >+ > private TaskRepository repository; > > private Button updateButton = null; >- >+ >+ private Button buttonCustom; >+ >+ private Button buttonSaved; >+ >+ private FilterSummaryPage filterSummaryPage; >+ > public JiraQueryWizardPage(TaskRepository repository) { > super(TITLE); > this.repository = repository; >@@ -77,23 +87,39 @@ > gl.numColumns = 2; > innerComposite.setLayout(gl); > >- Label label = new Label(innerComposite, SWT.NONE); >- label.setText(COMBO_LABEL); >- label.setLayoutData(new GridData()); >+ buttonCustom = new Button(innerComposite, SWT.RADIO); >+ buttonCustom.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); >+ buttonCustom.setText("Custom Query"); >+ buttonCustom.setSelection(true); >+ >+ buttonSaved = new Button(innerComposite, SWT.RADIO); >+ buttonSaved.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); >+ buttonSaved.setText("Saved Query"); >+ buttonSaved.addSelectionListener(new SelectionAdapter() { >+ public void widgetSelected(SelectionEvent e) { >+ boolean selection = buttonSaved.getSelection(); >+ filterCombo.setEnabled(selection); >+ updateButton.setEnabled(selection); >+ setPageComplete(selection); >+ } >+ }); > >- filterCombo = new Combo(innerComposite, SWT.READ_ONLY); >+ filterCombo = new List(innerComposite, SWT.V_SCROLL | SWT.BORDER); > filterCombo.add(WAIT_MESSAGE); > filterCombo.select(0); > >- GridData data = new GridData(); >- data.widthHint = COMBO_WIDTH_HINT; >+ GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); >+ data.horizontalIndent = 15; > filterCombo.setLayoutData(data); >+ filterCombo.setEnabled(false); > >- new Label(innerComposite, SWT.NULL); // spacer > updateButton = new Button(innerComposite, SWT.LEFT | SWT.PUSH); >- updateButton.setText("Update Filters from Repository"); >+ final GridData gridData = new GridData(SWT.FILL, SWT.TOP, false, true); >+ updateButton.setLayoutData(gridData); >+ updateButton.setText("Update from Repository"); >+ updateButton.setEnabled(false); > updateButton.addSelectionListener(new SelectionAdapter() { >- >+ > @Override > public void widgetSelected(SelectionEvent e) { > filterCombo.removeAll(); >@@ -102,13 +128,32 @@ > JiraServerFacade.getDefault().refreshServerSettings(repository); > downloadFilters(); > } >- >+ > }); >- >+ > setControl(innerComposite); > downloadFilters(); > } > >+ public IWizardPage getNextPage() { >+ if (!buttonCustom.getSelection()) { >+ return null; >+ } >+ if (filterSummaryPage == null) { >+ FilterDefinition workingCopy = new FilterDefinition(); >+ boolean isAdd = true; >+ >+ filterSummaryPage = new FilterSummaryPage(repository, "summaryPage", "Filter Summary", null, workingCopy, >+ isAdd); >+ filterSummaryPage.setWizard(getWizard()); >+ } >+ return filterSummaryPage; >+ } >+ >+ public boolean canFlipToNextPage() { >+ return buttonCustom.getSelection(); >+ } >+ > protected void downloadFilters() { > Job job = new Job(JOB_LABEL) { > @Override >@@ -153,11 +198,24 @@ > } > > /** Returns the filter selected by the user or null on failure */ >- public NamedFilter getSelectedFilter() { >+ private NamedFilter getSelectedFilter() { > if (filters != null && filters.length > 0) { > return filters[filterCombo.getSelectionIndex()]; > } > return null; > } > >+ public AbstractRepositoryQuery getQuery() { >+ if (buttonSaved.getSelection()) { >+ return new JiraRepositoryQuery(repository.getUrl(), getSelectedFilter(), MylarTaskListPlugin >+ .getTaskListManager().getTaskList()); >+ } >+ >+ if (filterSummaryPage != null) { >+ return filterSummaryPage.getQuery(); >+ } >+ >+ return null; >+ } >+ > } >Index: src/org/eclipse/mylar/internal/jira/JiraCustomQuery.java >=================================================================== >RCS file: src/org/eclipse/mylar/internal/jira/JiraCustomQuery.java >diff -N src/org/eclipse/mylar/internal/jira/JiraCustomQuery.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylar/internal/jira/JiraCustomQuery.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/******************************************************************************* >+ * 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.eclipse.mylar.provisional.tasklist.TaskList; >+import org.tigris.jira.core.model.filter.FilterDefinition; >+ >+/** >+ * A JiraFilter represents a query for issues from a Jira repository. >+ * >+ * @author Mik Kersten >+ */ >+public class JiraCustomQuery extends AbstractRepositoryQuery { >+ >+ private static final int MAX_HITS = 75; >+ >+ protected FilterDefinition filter = null; >+ >+// private boolean isRefreshing = false; >+ >+ public JiraCustomQuery(String repositoryUrl, FilterDefinition filter, TaskList taskList) { >+ super(filter.getName(), taskList); >+ setMaxHits(MAX_HITS); >+ this.filter = filter; >+ super.repositoryUrl = repositoryUrl; >+ setQueryUrl(repositoryUrl + MylarJiraPlugin.FILTER_URL_PREFIX + filter.getName()); >+// super.setDescription(filter.getName()); >+ } >+ >+ public String getRepositoryKind() { >+ return MylarJiraPlugin.REPOSITORY_KIND; >+ } >+ >+ public FilterDefinition getFilterDefinition() { >+ return filter; >+ } >+} >+ >+//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 void setRefreshing(boolean refreshing) { >+//this.isRefreshing = refreshing; >+//} >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,866 @@ >+/******************************************************************************* >+ * 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: >+ * 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.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.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.mylar.internal.jira.JiraCustomQuery; >+import org.eclipse.mylar.internal.jira.JiraServerFacade; >+import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; >+import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+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; >+ >+/** >+ * @author Brock Janiczak >+ * @author Eugene Kuleshov (layout and other improvements) >+ */ >+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 project; >+ >+ private ListViewer reportedIn; >+ >+ private ListViewer components; >+ >+ private ListViewer fixFor; >+ >+ private final FilterDefinition workingCopy; >+ >+ private Text name; >+ >+ private Text description; >+ >+ private Text queryString; >+ >+ private Button searchSummary; >+ >+ private Button searchDescription; >+ >+ private Button searchComments; >+ >+ private Button searchEnvironment; >+ >+ private final boolean isNew; >+ >+ private IssueAttributesPage issueAttributesPage; >+ >+ private final TaskRepository repository; >+ >+ /** >+ * @param pageName >+ * @param title >+ * @param titleImage >+ */ >+ protected FilterSummaryPage(TaskRepository repository, String pageName, String title, ImageDescriptor titleImage, >+ FilterDefinition workingCopy, boolean isNew) { >+ super(pageName, title, titleImage); >+ this.repository = repository; >+ >+ this.server = JiraServerFacade.getDefault().getJiraServer(repository); >+ this.workingCopy = workingCopy; >+ this.isNew = isNew; >+ >+ setPageComplete(false); >+ } >+ >+ 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); >+ final GridData gridData = new GridData(); >+ lblName.setLayoutData(gridData); >+ 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(); >+ } >+ >+ }); >+ >+ { >+ Composite cc = new Composite(c, SWT.NONE); >+ final GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1); >+ cc.setLayoutData(gridData_1); >+ cc.setLayout(new GridLayout(4, false)); >+ >+ Label lblProject = new Label(cc, SWT.NONE); >+ lblProject.setText("Project:"); >+ >+ Label lblFixFor = new Label(cc, SWT.NONE); >+ lblFixFor.setText("Fix For:"); >+ lblFixFor.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ Label lblComponent = new Label(cc, SWT.NONE); >+ lblComponent.setText("In Components:"); >+ lblComponent.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ Label lblReportedIn = new Label(cc, SWT.NONE); >+ lblReportedIn.setText("Reported In:"); >+ lblReportedIn.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ createProjectsViewer(cc); >+ createFixForViewer(cc); >+ createComponentsViewer(cc); >+ createReportedInViewer(cc); >+ >+ } >+ >+ Label lblQuery = new Label(c, SWT.NONE); >+ lblQuery.setLayoutData(new GridData()); >+ 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)); >+ >+ searchSummary = new Button(c, SWT.CHECK); >+ searchSummary.setLayoutData(new GridData()); >+ searchSummary.setText("Summary"); >+ searchSummary.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ searchDescription = new Button(c, SWT.CHECK); >+ searchDescription.setLayoutData(new GridData()); >+ searchDescription.setText("Description"); >+ searchDescription.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ new Label(c, SWT.NONE); >+ >+ // Need to turn off validation here >+ if (isNew) { >+ loadFromDefaults(); >+ } else { >+ loadFromWorkingCopy(); >+ } >+ >+ setControl(c); >+ >+ searchComments = new Button(c, SWT.CHECK); >+ searchComments.setLayoutData(new GridData()); >+ searchComments.setText("Comments"); >+ searchComments.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ >+ searchEnvironment = new Button(c, SWT.CHECK); >+ searchEnvironment.setLayoutData(new GridData()); >+ searchEnvironment.setText("Environment"); >+ searchEnvironment.addSelectionListener(new SelectionAdapter() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ validatePage(); >+ } >+ >+ }); >+ } >+ >+ public IWizardPage getNextPage() { >+ if (issueAttributesPage == null) { >+ issueAttributesPage = new IssueAttributesPage(repository, "issueAttributes", "Issue Attributes", null, >+ workingCopy, isNew); >+ issueAttributesPage.setWizard(getWizard()); >+ } >+ >+ return issueAttributesPage; >+ } >+ >+ private void createReportedInViewer(Composite c) { >+ GridData gd; >+ reportedIn = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ 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); >+ } >+ >+ private void createComponentsViewer(Composite c) { >+ GridData gd; >+ components = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ 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); >+ } >+ >+ private void createFixForViewer(Composite c) { >+ GridData gd; >+ fixFor = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); >+ gd = new GridData(SWT.FILL, SWT.FILL, true, true); >+ 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); >+ } >+ >+ private void createProjectsViewer(Composite c) { >+ project = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER); >+ project.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ 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(); >+ } >+ >+ }); >+ } >+ >+ 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; >+ } >+ } >+ >+ public AbstractRepositoryQuery getQuery() { >+ this.applyChanges(); >+ issueAttributesPage.applyChanges(); >+ if (isNew) { >+ server.addLocalFilter(workingCopy); >+ } >+ >+ return new JiraCustomQuery(repository.getUrl(), workingCopy, MylarTaskListPlugin.getTaskListManager() >+ .getTaskList()); >+ } >+} >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,719 @@ >+/******************************************************************************* >+ * 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: >+ * 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.mylar.internal.jira.JiraServerFacade; >+import org.eclipse.mylar.provisional.tasklist.TaskRepository; >+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; >+ >+/** >+ * @author Brock Janiczak >+ * @author Eugene Kuleshov (layout and other improvements) >+ */ >+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 TaskRepository repository; >+ >+ 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 repository >+ * @param pageName >+ * @param title >+ * @param titleImage >+ * @param server >+ */ >+ protected IssueAttributesPage(TaskRepository repository, String pageName, String title, ImageDescriptor titleImage, >+ FilterDefinition workingCopy, boolean isNew) { >+ super(pageName, title, titleImage); >+// this.repository = repository; >+ this.jiraServer = JiraServerFacade.getDefault().getJiraServer(repository); >+ this.workingCopy = workingCopy; >+ this.isNew = isNew; >+ >+ setPageComplete(false); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ */ >+ public void createControl(Composite parent) { >+ GridData gd; >+ >+ Composite cc = new Composite(parent, SWT.NONE); >+ cc.setLayout(new GridLayout(1, false)); >+ >+ { >+ Composite c = new Composite(cc, SWT.NONE); >+ final GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); >+ gridData.widthHint = 515; >+ c.setLayoutData(gridData); >+ c.setLayout(new GridLayout(3, false)); >+ >+ Label lblReportedBy = new Label(c, SWT.NONE); >+ lblReportedBy.setText("Reported By:"); >+ lblReportedBy.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ reporterType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY); >+ final GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, false, false); >+ gridData_1.widthHint = 133; >+ reporterType.getControl().setLayoutData(gridData_1); >+ >+ 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(); >+ } >+ >+ }); >+ >+ Label lblAssignedTo = new Label(c, SWT.NONE); >+ lblAssignedTo.setText("Assigned To:"); >+ lblAssignedTo.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); >+ >+ assigneeType = new ComboViewer(c, SWT.BORDER | SWT.READ_ONLY); >+ final GridData gridData_2 = new GridData(SWT.FILL, SWT.FILL, false, false); >+ gridData_2.widthHint = 118; >+ assigneeType.getControl().setLayoutData(gridData_2); >+ >+ 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); >+ 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(); >+ } >+ >+ }); >+ >+ 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); >+ } >+ } >+ >+ }); >+ >+ 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(); >+ } >+ >+ }); >+ >+ } >+ >+ { >+ Composite c = new Composite(cc, SWT.NONE); >+ final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); >+ gridData.heightHint = 149; >+ c.setLayoutData(gridData); >+ c.setLayout(new GridLayout(4, false)); >+ >+ Label lblIssueType = new Label(c, SWT.NONE); >+ lblIssueType.setText("Type:"); >+ lblIssueType.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); >+ >+ Label lblStatus = new Label(c, SWT.NONE); >+ lblStatus.setText("Status:"); >+ lblStatus.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); >+ >+ Label lblResolution = new Label(c, SWT.NONE); >+ lblResolution.setText("Resolution:"); >+ lblResolution.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); >+ >+ Label lblPriority = new Label(c, SWT.NONE); >+ lblPriority.setText("Priority:"); >+ lblPriority.setLayoutData(new GridData(SWT.FILL, 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); >+ >+ 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); >+ >+ 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); >+ >+ 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(cc); >+ } >+ >+ 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 Raw
Actions:
View
Attachments on
bug 129086
:
35968
|
39630
| 39731 |
39732
|
39758
|
39794
|
39840