|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005 Jira Dashboard project. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Brock Janiczak - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.mylar.internal.jira.ui.wizards; |
| 12 |
|
| 13 |
import java.util.ArrayList; |
| 14 |
import java.util.Iterator; |
| 15 |
import java.util.List; |
| 16 |
|
| 17 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 18 |
import org.eclipse.jface.viewers.IColorProvider; |
| 19 |
import org.eclipse.jface.viewers.ILabelProvider; |
| 20 |
import org.eclipse.jface.viewers.ILabelProviderListener; |
| 21 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 22 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
| 23 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 24 |
import org.eclipse.jface.viewers.LabelProvider; |
| 25 |
import org.eclipse.jface.viewers.ListViewer; |
| 26 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 27 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 28 |
import org.eclipse.jface.viewers.Viewer; |
| 29 |
import org.eclipse.jface.wizard.IWizardPage; |
| 30 |
import org.eclipse.jface.wizard.WizardPage; |
| 31 |
import org.eclipse.mylar.internal.jira.JiraCustomQuery; |
| 32 |
import org.eclipse.mylar.internal.jira.JiraServerFacade; |
| 33 |
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryConnector; |
| 34 |
import org.eclipse.mylar.provisional.tasklist.AbstractRepositoryQuery; |
| 35 |
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin; |
| 36 |
import org.eclipse.mylar.provisional.tasklist.TaskRepository; |
| 37 |
import org.eclipse.swt.SWT; |
| 38 |
import org.eclipse.swt.events.FocusAdapter; |
| 39 |
import org.eclipse.swt.events.FocusEvent; |
| 40 |
import org.eclipse.swt.events.SelectionAdapter; |
| 41 |
import org.eclipse.swt.events.SelectionEvent; |
| 42 |
import org.eclipse.swt.graphics.Color; |
| 43 |
import org.eclipse.swt.graphics.Image; |
| 44 |
import org.eclipse.swt.layout.GridData; |
| 45 |
import org.eclipse.swt.layout.GridLayout; |
| 46 |
import org.eclipse.swt.widgets.Button; |
| 47 |
import org.eclipse.swt.widgets.Composite; |
| 48 |
import org.eclipse.swt.widgets.Display; |
| 49 |
import org.eclipse.swt.widgets.Label; |
| 50 |
import org.eclipse.swt.widgets.Text; |
| 51 |
import org.tigris.jira.core.model.Component; |
| 52 |
import org.tigris.jira.core.model.Project; |
| 53 |
import org.tigris.jira.core.model.Version; |
| 54 |
import org.tigris.jira.core.model.filter.ComponentFilter; |
| 55 |
import org.tigris.jira.core.model.filter.ContentFilter; |
| 56 |
import org.tigris.jira.core.model.filter.FilterDefinition; |
| 57 |
import org.tigris.jira.core.model.filter.ProjectFilter; |
| 58 |
import org.tigris.jira.core.model.filter.VersionFilter; |
| 59 |
import org.tigris.jira.core.service.JiraServer; |
| 60 |
|
| 61 |
public class FilterSummaryPage extends WizardPage { |
| 62 |
private final Placeholder ANY_FIX_VERSION = new Placeholder("Any"); |
| 63 |
private final Placeholder NO_FIX_VERSION = new Placeholder("No Fix Version"); |
| 64 |
|
| 65 |
private final Placeholder ANY_REPORTED_VERSION = new Placeholder("Any"); |
| 66 |
private final Placeholder NO_REPORTED_VERSION = new Placeholder("No Version"); |
| 67 |
private final Placeholder UNRELEASED_VERSION = new Placeholder("Unreleased Versions"); |
| 68 |
private final Placeholder RELEASED_VERSION = new Placeholder("Released Versions"); |
| 69 |
|
| 70 |
private final Placeholder ANY_COMPONENT = new Placeholder("Any"); |
| 71 |
private final Placeholder NO_COMPONENT = new Placeholder("No Component"); |
| 72 |
|
| 73 |
private final JiraServer server; |
| 74 |
private ListViewer project; |
| 75 |
private ListViewer reportedIn; |
| 76 |
private ListViewer components; |
| 77 |
private ListViewer fixFor; |
| 78 |
|
| 79 |
private final FilterDefinition workingCopy; |
| 80 |
private Text name; |
| 81 |
private Text description; |
| 82 |
private Text queryString; |
| 83 |
private Button searchSummary; |
| 84 |
private Button searchDescription; |
| 85 |
private Button searchComments; |
| 86 |
private Button searchEnvironment; |
| 87 |
private final boolean isNew; |
| 88 |
|
| 89 |
private IssueAttributesPage issueAttributesPage; |
| 90 |
private final TaskRepository repository; |
| 91 |
|
| 92 |
/** |
| 93 |
* @param pageName |
| 94 |
* @param title |
| 95 |
* @param titleImage |
| 96 |
*/ |
| 97 |
protected FilterSummaryPage(TaskRepository repository, String pageName, String title, ImageDescriptor titleImage, FilterDefinition workingCopy, boolean isNew) { |
| 98 |
super(pageName, title, titleImage); |
| 99 |
this.repository = repository; |
| 100 |
|
| 101 |
this.server = JiraServerFacade.getDefault().getJiraServer(repository); |
| 102 |
this.workingCopy = workingCopy; |
| 103 |
this.isNew = isNew; |
| 104 |
|
| 105 |
setPageComplete(false); |
| 106 |
} |
| 107 |
|
| 108 |
public void createControl(Composite parent) { |
| 109 |
GridData gd; |
| 110 |
Composite c = new Composite(parent, SWT.NONE); |
| 111 |
c.setLayout(new GridLayout(3, false)); |
| 112 |
|
| 113 |
Label lblName = new Label(c, SWT.NONE); |
| 114 |
final GridData gridData = new GridData(); |
| 115 |
lblName.setLayoutData(gridData); |
| 116 |
lblName.setText("Name:"); |
| 117 |
|
| 118 |
name = new Text(c, SWT.BORDER); |
| 119 |
name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); |
| 120 |
name.addFocusListener(new FocusAdapter() { |
| 121 |
|
| 122 |
public void focusLost(FocusEvent e) { |
| 123 |
validatePage(); |
| 124 |
} |
| 125 |
|
| 126 |
}); |
| 127 |
|
| 128 |
if (!isNew) { |
| 129 |
name.setEnabled(false); |
| 130 |
} |
| 131 |
|
| 132 |
Label lblDescription = new Label(c, SWT.NONE); |
| 133 |
lblDescription.setText("Description:"); |
| 134 |
lblDescription.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); |
| 135 |
|
| 136 |
description = new Text(c, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); |
| 137 |
gd = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); |
| 138 |
gd.heightHint = 40; |
| 139 |
description.setLayoutData(gd); |
| 140 |
description.addFocusListener(new FocusAdapter() { |
| 141 |
|
| 142 |
public void focusLost(FocusEvent e) { |
| 143 |
validatePage(); |
| 144 |
} |
| 145 |
|
| 146 |
}); |
| 147 |
|
| 148 |
{ |
| 149 |
Composite cc = new Composite(c, SWT.NONE); |
| 150 |
final GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1); |
| 151 |
cc.setLayoutData(gridData_1); |
| 152 |
cc.setLayout(new GridLayout(4, false)); |
| 153 |
|
| 154 |
|
| 155 |
Label lblProject = new Label(cc, SWT.NONE); |
| 156 |
lblProject.setText("Project:"); |
| 157 |
|
| 158 |
Label lblFixFor = new Label(cc, SWT.NONE); |
| 159 |
lblFixFor.setText("Fix For:"); |
| 160 |
lblFixFor.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); |
| 161 |
|
| 162 |
Label lblComponent = new Label(cc, SWT.NONE); |
| 163 |
lblComponent.setText("In Components:"); |
| 164 |
lblComponent.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); |
| 165 |
|
| 166 |
Label lblReportedIn = new Label(cc, SWT.NONE); |
| 167 |
lblReportedIn.setText("Reported In:"); |
| 168 |
lblReportedIn.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); |
| 169 |
|
| 170 |
createProjectsViewer(cc); |
| 171 |
createFixForViewer(cc); |
| 172 |
createComponentsViewer(cc); |
| 173 |
createReportedInViewer(cc); |
| 174 |
|
| 175 |
} |
| 176 |
|
| 177 |
Label lblQuery = new Label(c, SWT.NONE); |
| 178 |
lblQuery.setLayoutData(new GridData()); |
| 179 |
lblQuery.setText("Query:"); |
| 180 |
queryString = new Text(c, SWT.BORDER); |
| 181 |
queryString.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1)); |
| 182 |
// TODO put content assist here and a label describing what is available |
| 183 |
|
| 184 |
queryString.addFocusListener(new FocusAdapter() { |
| 185 |
|
| 186 |
public void focusLost(FocusEvent e) { |
| 187 |
validatePage(); |
| 188 |
} |
| 189 |
|
| 190 |
}); |
| 191 |
|
| 192 |
Label lblFields = new Label(c, SWT.NONE); |
| 193 |
lblFields.setText("Fields:"); |
| 194 |
lblFields.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false)); |
| 195 |
|
| 196 |
searchSummary = new Button(c, SWT.CHECK); |
| 197 |
searchSummary.setLayoutData(new GridData()); |
| 198 |
searchSummary.setText("Summary"); |
| 199 |
searchSummary.addSelectionListener(new SelectionAdapter() { |
| 200 |
|
| 201 |
public void widgetSelected(SelectionEvent e) { |
| 202 |
validatePage(); |
| 203 |
} |
| 204 |
|
| 205 |
}); |
| 206 |
|
| 207 |
searchDescription = new Button(c, SWT.CHECK); |
| 208 |
searchDescription.setLayoutData(new GridData()); |
| 209 |
searchDescription.setText("Description"); |
| 210 |
searchDescription.addSelectionListener(new SelectionAdapter() { |
| 211 |
|
| 212 |
public void widgetSelected(SelectionEvent e) { |
| 213 |
validatePage(); |
| 214 |
} |
| 215 |
|
| 216 |
}); |
| 217 |
new Label(c, SWT.NONE); |
| 218 |
|
| 219 |
// Need to turn off validation here |
| 220 |
if (isNew) { |
| 221 |
loadFromDefaults(); |
| 222 |
} else { |
| 223 |
loadFromWorkingCopy(); |
| 224 |
} |
| 225 |
|
| 226 |
setControl(c); |
| 227 |
|
| 228 |
searchComments = new Button(c, SWT.CHECK); |
| 229 |
searchComments.setLayoutData(new GridData()); |
| 230 |
searchComments.setText("Comments"); |
| 231 |
searchComments.addSelectionListener(new SelectionAdapter() { |
| 232 |
|
| 233 |
public void widgetSelected(SelectionEvent e) { |
| 234 |
validatePage(); |
| 235 |
} |
| 236 |
|
| 237 |
}); |
| 238 |
|
| 239 |
searchEnvironment = new Button(c, SWT.CHECK); |
| 240 |
searchEnvironment.setLayoutData(new GridData()); |
| 241 |
searchEnvironment.setText("Environment"); |
| 242 |
searchEnvironment.addSelectionListener(new SelectionAdapter() { |
| 243 |
|
| 244 |
public void widgetSelected(SelectionEvent e) { |
| 245 |
validatePage(); |
| 246 |
} |
| 247 |
|
| 248 |
}); |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
public IWizardPage getNextPage() { |
| 253 |
if(issueAttributesPage==null) { |
| 254 |
issueAttributesPage = new IssueAttributesPage(repository, "issueAttributes", "Issue Attributes", null, workingCopy, isNew); |
| 255 |
issueAttributesPage.setWizard(getWizard()); |
| 256 |
} |
| 257 |
|
| 258 |
return issueAttributesPage; |
| 259 |
} |
| 260 |
|
| 261 |
private void createReportedInViewer(Composite c) { |
| 262 |
GridData gd; |
| 263 |
reportedIn = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); |
| 264 |
gd = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 265 |
gd.heightHint = 40; |
| 266 |
reportedIn.getControl().setLayoutData(gd); |
| 267 |
|
| 268 |
reportedIn.setContentProvider(new IStructuredContentProvider() { |
| 269 |
private Project project; |
| 270 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 271 |
project = (Project)newInput; |
| 272 |
} |
| 273 |
|
| 274 |
public void dispose() { |
| 275 |
} |
| 276 |
|
| 277 |
public Object[] getElements(Object inputElement) { |
| 278 |
if (project != null) { |
| 279 |
Version[] versions = project.getVersions(); |
| 280 |
Version[] releasedVersions = project.getReleasedVersions(); |
| 281 |
Version[] unreleasedVersions = project.getUnreleasedVersions(); |
| 282 |
|
| 283 |
Object[] elements = new Object[versions.length + 4]; |
| 284 |
elements[0] = ANY_REPORTED_VERSION; |
| 285 |
elements[1] = NO_REPORTED_VERSION; |
| 286 |
elements[2] = RELEASED_VERSION; |
| 287 |
System.arraycopy(releasedVersions, 0, elements, 3, releasedVersions.length); |
| 288 |
|
| 289 |
elements[releasedVersions.length + 3] = UNRELEASED_VERSION; |
| 290 |
|
| 291 |
System.arraycopy(unreleasedVersions, 0, elements, releasedVersions.length + 4, unreleasedVersions.length); |
| 292 |
return elements; |
| 293 |
} else { |
| 294 |
return new Object[] {ANY_REPORTED_VERSION}; |
| 295 |
} |
| 296 |
|
| 297 |
} |
| 298 |
|
| 299 |
}); |
| 300 |
reportedIn.setLabelProvider(new VersionLabelProvider()); |
| 301 |
reportedIn.setInput(null); |
| 302 |
} |
| 303 |
|
| 304 |
private void createComponentsViewer(Composite c) { |
| 305 |
GridData gd; |
| 306 |
components = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); |
| 307 |
gd = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 308 |
gd.heightHint = 40; |
| 309 |
components.getControl().setLayoutData(gd); |
| 310 |
|
| 311 |
components.setContentProvider(new IStructuredContentProvider() { |
| 312 |
private Project project; |
| 313 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 314 |
project = (Project)newInput; |
| 315 |
} |
| 316 |
|
| 317 |
public void dispose() { |
| 318 |
} |
| 319 |
|
| 320 |
public Object[] getElements(Object inputElement) { |
| 321 |
if (project != null) { |
| 322 |
Component[] components = project.getComponents(); |
| 323 |
|
| 324 |
Object[] elements = new Object[components.length + 2]; |
| 325 |
elements[0] = ANY_COMPONENT; |
| 326 |
elements[1] = NO_COMPONENT; |
| 327 |
System.arraycopy(components, 0, elements, 2, components.length); |
| 328 |
return elements; |
| 329 |
} else { |
| 330 |
return new Object[] {ANY_COMPONENT}; |
| 331 |
} |
| 332 |
|
| 333 |
} |
| 334 |
|
| 335 |
}); |
| 336 |
components.setLabelProvider(new ComponentLabelProvider()); |
| 337 |
components.setInput(null); |
| 338 |
} |
| 339 |
|
| 340 |
private void createFixForViewer(Composite c) { |
| 341 |
GridData gd; |
| 342 |
fixFor = new ListViewer(c, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); |
| 343 |
gd = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 344 |
gd.heightHint = 40; |
| 345 |
fixFor.getControl().setLayoutData(gd); |
| 346 |
|
| 347 |
fixFor.setContentProvider(new IStructuredContentProvider() { |
| 348 |
private Project project; |
| 349 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 350 |
project = (Project)newInput; |
| 351 |
} |
| 352 |
|
| 353 |
public void dispose() { |
| 354 |
} |
| 355 |
|
| 356 |
public Object[] getElements(Object inputElement) { |
| 357 |
if (project != null) { |
| 358 |
Version[] versions = project.getVersions(); |
| 359 |
Version[] releasedVersions = project.getReleasedVersions(); |
| 360 |
Version[] unreleasedVersions = project.getUnreleasedVersions(); |
| 361 |
|
| 362 |
Object[] elements = new Object[versions.length + 4]; |
| 363 |
elements[0] = ANY_FIX_VERSION; |
| 364 |
elements[1] = NO_FIX_VERSION; |
| 365 |
elements[2] = RELEASED_VERSION; |
| 366 |
System.arraycopy(releasedVersions, 0, elements, 3, releasedVersions.length); |
| 367 |
|
| 368 |
elements[releasedVersions.length + 3] = UNRELEASED_VERSION; |
| 369 |
|
| 370 |
System.arraycopy(unreleasedVersions, 0, elements, releasedVersions.length + 4, unreleasedVersions.length); |
| 371 |
return elements; |
| 372 |
} else { |
| 373 |
return new Object[] {ANY_REPORTED_VERSION}; |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
}); |
| 378 |
fixFor.setLabelProvider(new VersionLabelProvider()); |
| 379 |
fixFor.setInput(null); |
| 380 |
} |
| 381 |
|
| 382 |
private void createProjectsViewer(Composite c) { |
| 383 |
project = new ListViewer(c, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER); |
| 384 |
project.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
| 385 |
project.setContentProvider(new IStructuredContentProvider() { |
| 386 |
|
| 387 |
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
| 388 |
} |
| 389 |
|
| 390 |
public void dispose() { |
| 391 |
} |
| 392 |
|
| 393 |
public Object[] getElements(Object inputElement) { |
| 394 |
JiraServer server = (JiraServer) inputElement; |
| 395 |
Object[] elements = new Object[server.getProjects().length + 1]; |
| 396 |
elements[0] = new Placeholder("All Projects"); |
| 397 |
System.arraycopy(server.getProjects(), 0, elements, 1, server.getProjects().length); |
| 398 |
|
| 399 |
return elements; |
| 400 |
} |
| 401 |
|
| 402 |
}); |
| 403 |
|
| 404 |
project.setLabelProvider(new LabelProvider() { |
| 405 |
|
| 406 |
public String getText(Object element) { |
| 407 |
if (element instanceof Placeholder) { |
| 408 |
return ((Placeholder)element).getText(); |
| 409 |
} |
| 410 |
|
| 411 |
return ((Project)element).getName(); |
| 412 |
} |
| 413 |
|
| 414 |
}); |
| 415 |
|
| 416 |
project.setInput(server); |
| 417 |
project.addSelectionChangedListener(new ISelectionChangedListener() { |
| 418 |
|
| 419 |
public void selectionChanged(SelectionChangedEvent event) { |
| 420 |
IStructuredSelection selection = ((IStructuredSelection)event.getSelection()); |
| 421 |
Project selectedProject = null; |
| 422 |
if (!selection.isEmpty() && !(selection.getFirstElement() instanceof Placeholder)) { |
| 423 |
selectedProject = (Project)selection.getFirstElement(); |
| 424 |
} |
| 425 |
|
| 426 |
updateCurrentProject(selectedProject); |
| 427 |
validatePage(); |
| 428 |
} |
| 429 |
|
| 430 |
}); |
| 431 |
} |
| 432 |
|
| 433 |
private void updateCurrentProject(Project project) { |
| 434 |
this.fixFor.setInput(project); |
| 435 |
this.components.setInput(project); |
| 436 |
this.reportedIn.setInput(project); |
| 437 |
|
| 438 |
} |
| 439 |
|
| 440 |
private void validatePage() { |
| 441 |
if (name.getText().length() == 0) { |
| 442 |
setErrorMessage("Name is mandatory"); |
| 443 |
setPageComplete(false); |
| 444 |
return; |
| 445 |
} |
| 446 |
|
| 447 |
setErrorMessage(null); |
| 448 |
setPageComplete(true); |
| 449 |
} |
| 450 |
|
| 451 |
private void loadFromDefaults() { |
| 452 |
project.setSelection(new StructuredSelection(new Placeholder("All Projects"))); |
| 453 |
searchSummary.setSelection(true); |
| 454 |
searchDescription.setSelection(true); |
| 455 |
} |
| 456 |
|
| 457 |
private void loadFromWorkingCopy() { |
| 458 |
if (workingCopy.getName() != null) { |
| 459 |
name.setText(workingCopy.getName()); |
| 460 |
} |
| 461 |
|
| 462 |
if (workingCopy.getDescription() != null) { |
| 463 |
description.setText(workingCopy.getDescription()); |
| 464 |
} |
| 465 |
|
| 466 |
if (workingCopy.getProjectFilter() != null) { |
| 467 |
project.setSelection(new StructuredSelection(workingCopy.getProjectFilter().getProject())); |
| 468 |
} else { |
| 469 |
project.setSelection(new StructuredSelection(new Placeholder("All Projects"))); |
| 470 |
} |
| 471 |
|
| 472 |
if (workingCopy.getFixForVersionFilter() != null) { |
| 473 |
if (workingCopy.getFixForVersionFilter().hasNoVersion()) { |
| 474 |
fixFor.setSelection(new StructuredSelection(new Object[] {NO_FIX_VERSION})); |
| 475 |
} else if (workingCopy.getFixForVersionFilter().isReleasedVersions() && workingCopy.getFixForVersionFilter().isUnreleasedVersions()) { |
| 476 |
fixFor.setSelection(new StructuredSelection(new Object[] {RELEASED_VERSION, UNRELEASED_VERSION})); |
| 477 |
} else if (workingCopy.getFixForVersionFilter().isReleasedVersions()) { |
| 478 |
fixFor.setSelection(new StructuredSelection(RELEASED_VERSION)); |
| 479 |
} else if (workingCopy.getFixForVersionFilter().isUnreleasedVersions()) { |
| 480 |
fixFor.setSelection(new StructuredSelection(UNRELEASED_VERSION)); |
| 481 |
} else { |
| 482 |
fixFor.setSelection(new StructuredSelection(workingCopy.getFixForVersionFilter().getVersions())); |
| 483 |
} |
| 484 |
} else { |
| 485 |
fixFor.setSelection(new StructuredSelection(ANY_FIX_VERSION)); |
| 486 |
} |
| 487 |
|
| 488 |
if (workingCopy.getReportedInVersionFilter() != null) { |
| 489 |
if (workingCopy.getReportedInVersionFilter().hasNoVersion()) { |
| 490 |
reportedIn.setSelection(new StructuredSelection(new Object[] {NO_REPORTED_VERSION})); |
| 491 |
} else if (workingCopy.getReportedInVersionFilter().isReleasedVersions() && workingCopy.getReportedInVersionFilter().isUnreleasedVersions()) { |
| 492 |
reportedIn.setSelection(new StructuredSelection(new Object[] {RELEASED_VERSION, UNRELEASED_VERSION})); |
| 493 |
} else if (workingCopy.getReportedInVersionFilter().isReleasedVersions()) { |
| 494 |
reportedIn.setSelection(new StructuredSelection(RELEASED_VERSION)); |
| 495 |
} else if (workingCopy.getReportedInVersionFilter().isUnreleasedVersions()) { |
| 496 |
reportedIn.setSelection(new StructuredSelection(UNRELEASED_VERSION)); |
| 497 |
} else { |
| 498 |
reportedIn.setSelection(new StructuredSelection(workingCopy.getReportedInVersionFilter().getVersions())); |
| 499 |
} |
| 500 |
} else { |
| 501 |
reportedIn.setSelection(new StructuredSelection(ANY_REPORTED_VERSION)); |
| 502 |
} |
| 503 |
|
| 504 |
if (workingCopy.getContentFilter() != null) { |
| 505 |
this.queryString.setText(workingCopy.getContentFilter().getQueryString()); |
| 506 |
this.searchComments.setSelection(workingCopy.getContentFilter().isSearchingComments()); |
| 507 |
this.searchDescription.setSelection(workingCopy.getContentFilter().isSearchingDescription()); |
| 508 |
this.searchEnvironment.setSelection(workingCopy.getContentFilter().isSearchingEnvironment()); |
| 509 |
this.searchSummary.setSelection(workingCopy.getContentFilter().isSearchingSummary()); |
| 510 |
} |
| 511 |
|
| 512 |
if (workingCopy.getComponentFilter() != null) { |
| 513 |
if (workingCopy.getComponentFilter().hasNoComponent()) { |
| 514 |
components.setSelection(new StructuredSelection(NO_COMPONENT)); |
| 515 |
} else { |
| 516 |
components.setSelection(new StructuredSelection(workingCopy.getComponentFilter().getComponents())); |
| 517 |
} |
| 518 |
} else { |
| 519 |
components.setSelection(new StructuredSelection(ANY_COMPONENT)); |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
/* default */ void applyChanges() { |
| 524 |
workingCopy.setName(this.name.getText()); |
| 525 |
workingCopy.setDescription(this.description.getText()); |
| 526 |
if (this.queryString.getText().length() > 0 || this.searchSummary.getSelection() || this.searchDescription.getSelection() || this.searchEnvironment.getSelection() || this.searchComments.getSelection()) { |
| 527 |
workingCopy.setContentFilter(new ContentFilter(this.queryString.getText(), this.searchSummary.getSelection(), this.searchDescription.getSelection(), this.searchEnvironment.getSelection(), this.searchComments.getSelection())); |
| 528 |
} else { |
| 529 |
workingCopy.setContentFilter(null); |
| 530 |
} |
| 531 |
|
| 532 |
IStructuredSelection projectSelection = (IStructuredSelection)this.project.getSelection(); |
| 533 |
if (!projectSelection.isEmpty() && projectSelection.getFirstElement() instanceof Project) { |
| 534 |
workingCopy.setProjectFilter(new ProjectFilter((Project) projectSelection.getFirstElement())); |
| 535 |
} else { |
| 536 |
workingCopy.setProjectFilter(null); |
| 537 |
} |
| 538 |
|
| 539 |
IStructuredSelection reportedInSelection = (IStructuredSelection)reportedIn.getSelection(); |
| 540 |
if (reportedInSelection.isEmpty()) { |
| 541 |
workingCopy.setReportedInVersionFilter(null); |
| 542 |
} else { |
| 543 |
boolean selectionContainsReleased = false; |
| 544 |
boolean selectionContainsUnreleased = false; |
| 545 |
boolean selectionContainsAll = false; |
| 546 |
boolean selectionContainsNone = false; |
| 547 |
|
| 548 |
List selectedVersions = new ArrayList(); |
| 549 |
|
| 550 |
for (Iterator i = reportedInSelection.iterator(); i.hasNext(); ) { |
| 551 |
Object selection = i.next(); |
| 552 |
if (ANY_REPORTED_VERSION.equals(selection)) { |
| 553 |
selectionContainsAll = true; |
| 554 |
} else if (NO_REPORTED_VERSION.equals(selection)) { |
| 555 |
selectionContainsNone = true; |
| 556 |
} else if (RELEASED_VERSION.equals(selection)) { |
| 557 |
selectionContainsReleased = true; |
| 558 |
} else if (UNRELEASED_VERSION.equals(selection)) { |
| 559 |
selectionContainsUnreleased = true; |
| 560 |
} else if (selection instanceof Version) { |
| 561 |
selectedVersions.add(selection); |
| 562 |
} |
| 563 |
} |
| 564 |
|
| 565 |
if (selectionContainsAll) { |
| 566 |
workingCopy.setReportedInVersionFilter(null); |
| 567 |
} else if (selectionContainsNone) { |
| 568 |
workingCopy.setReportedInVersionFilter(new VersionFilter(new Version[0])); |
| 569 |
} else if (selectionContainsReleased || selectionContainsUnreleased) { |
| 570 |
workingCopy.setReportedInVersionFilter(new VersionFilter(selectionContainsReleased, selectionContainsUnreleased)); |
| 571 |
} else if (selectedVersions.size() > 0) { |
| 572 |
workingCopy.setReportedInVersionFilter(new VersionFilter((Version[]) selectedVersions.toArray(new Version[selectedVersions.size()]))); |
| 573 |
} else { |
| 574 |
workingCopy.setReportedInVersionFilter(null); |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
IStructuredSelection fixForSelection = (IStructuredSelection)fixFor.getSelection(); |
| 579 |
if (fixForSelection.isEmpty()) { |
| 580 |
workingCopy.setFixForVersionFilter(null); |
| 581 |
} else { |
| 582 |
boolean selectionContainsReleased = false; |
| 583 |
boolean selectionContainsUnreleased = false; |
| 584 |
boolean selectionContainsAll = false; |
| 585 |
boolean selectionContainsNone = false; |
| 586 |
|
| 587 |
List selectedVersions = new ArrayList(); |
| 588 |
|
| 589 |
for (Iterator i = fixForSelection.iterator(); i.hasNext(); ) { |
| 590 |
Object selection = i.next(); |
| 591 |
if (ANY_FIX_VERSION.equals(selection)) { |
| 592 |
selectionContainsAll = true; |
| 593 |
} else if (NO_FIX_VERSION.equals(selection)) { |
| 594 |
selectionContainsNone = true; |
| 595 |
} else if (RELEASED_VERSION.equals(selection)) { |
| 596 |
selectionContainsReleased = true; |
| 597 |
} else if (UNRELEASED_VERSION.equals(selection)) { |
| 598 |
selectionContainsUnreleased = true; |
| 599 |
} else if (selection instanceof Version) { |
| 600 |
selectedVersions.add(selection); |
| 601 |
} |
| 602 |
} |
| 603 |
|
| 604 |
if (selectionContainsAll) { |
| 605 |
workingCopy.setFixForVersionFilter(null); |
| 606 |
} else if (selectionContainsNone) { |
| 607 |
workingCopy.setFixForVersionFilter(new VersionFilter(new Version[0])); |
| 608 |
} else if (selectionContainsReleased || selectionContainsUnreleased) { |
| 609 |
workingCopy.setFixForVersionFilter(new VersionFilter(selectionContainsReleased, selectionContainsUnreleased)); |
| 610 |
} else if (selectedVersions.size() > 0) { |
| 611 |
workingCopy.setFixForVersionFilter(new VersionFilter((Version[]) selectedVersions.toArray(new Version[selectedVersions.size()]))); |
| 612 |
} else { |
| 613 |
workingCopy.setFixForVersionFilter(null); |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
IStructuredSelection componentsSelection = (IStructuredSelection)components.getSelection(); |
| 618 |
if (componentsSelection.isEmpty()) { |
| 619 |
workingCopy.setComponentFilter(null); |
| 620 |
} else { |
| 621 |
|
| 622 |
boolean selectionContainsAll = false; |
| 623 |
boolean selectionContainsNone = false; |
| 624 |
List selectedComponents = new ArrayList(); |
| 625 |
|
| 626 |
for (Iterator i = componentsSelection.iterator(); i.hasNext(); ) { |
| 627 |
Object selection = i.next(); |
| 628 |
if (ANY_COMPONENT.equals(selection)) { |
| 629 |
selectionContainsAll = true; |
| 630 |
} else if (NO_COMPONENT.equals(selection)) { |
| 631 |
selectionContainsNone = true; |
| 632 |
} else if (selection instanceof Component){ |
| 633 |
selectedComponents.add(selection); |
| 634 |
} |
| 635 |
} |
| 636 |
|
| 637 |
if (selectionContainsAll) { |
| 638 |
workingCopy.setComponentFilter(null); |
| 639 |
} else if (selectedComponents.size() > 0) { |
| 640 |
workingCopy.setComponentFilter(new ComponentFilter((Component[]) selectedComponents.toArray(new Component[selectedComponents.size()]))); |
| 641 |
} else if (selectionContainsNone){ |
| 642 |
workingCopy.setComponentFilter(new ComponentFilter(new Component[0])); |
| 643 |
} else { |
| 644 |
workingCopy.setComponentFilter(null); |
| 645 |
} |
| 646 |
} |
| 647 |
} |
| 648 |
|
| 649 |
private final class ComponentLabelProvider implements ILabelProvider { |
| 650 |
|
| 651 |
/* (non-Javadoc) |
| 652 |
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) |
| 653 |
*/ |
| 654 |
public Image getImage(Object element) { |
| 655 |
return null; |
| 656 |
} |
| 657 |
|
| 658 |
/* (non-Javadoc) |
| 659 |
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) |
| 660 |
*/ |
| 661 |
public String getText(Object element) { |
| 662 |
if (element instanceof Placeholder) { |
| 663 |
return ((Placeholder)element).getText(); |
| 664 |
} |
| 665 |
return ((Component)element).getName(); |
| 666 |
} |
| 667 |
|
| 668 |
/* (non-Javadoc) |
| 669 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) |
| 670 |
*/ |
| 671 |
public void addListener(ILabelProviderListener listener) { |
| 672 |
} |
| 673 |
|
| 674 |
/* (non-Javadoc) |
| 675 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() |
| 676 |
*/ |
| 677 |
public void dispose() { |
| 678 |
} |
| 679 |
|
| 680 |
/* (non-Javadoc) |
| 681 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) |
| 682 |
*/ |
| 683 |
public boolean isLabelProperty(Object element, String property) { |
| 684 |
return false; |
| 685 |
} |
| 686 |
|
| 687 |
/* (non-Javadoc) |
| 688 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) |
| 689 |
*/ |
| 690 |
public void removeListener(ILabelProviderListener listener) { |
| 691 |
} |
| 692 |
|
| 693 |
} |
| 694 |
|
| 695 |
private final class VersionLabelProvider implements ILabelProvider, IColorProvider { |
| 696 |
|
| 697 |
/* (non-Javadoc) |
| 698 |
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) |
| 699 |
*/ |
| 700 |
public Image getImage(Object element) { |
| 701 |
return null; |
| 702 |
} |
| 703 |
|
| 704 |
/* (non-Javadoc) |
| 705 |
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) |
| 706 |
*/ |
| 707 |
public String getText(Object element) { |
| 708 |
if (element instanceof Placeholder) { |
| 709 |
return ((Placeholder)element).getText(); |
| 710 |
} |
| 711 |
return ((Version)element).getName(); |
| 712 |
} |
| 713 |
|
| 714 |
/* (non-Javadoc) |
| 715 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) |
| 716 |
*/ |
| 717 |
public void addListener(ILabelProviderListener listener) { |
| 718 |
|
| 719 |
} |
| 720 |
|
| 721 |
/* (non-Javadoc) |
| 722 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() |
| 723 |
*/ |
| 724 |
public void dispose() { |
| 725 |
} |
| 726 |
|
| 727 |
/* (non-Javadoc) |
| 728 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) |
| 729 |
*/ |
| 730 |
public boolean isLabelProperty(Object element, String property) { |
| 731 |
return false; |
| 732 |
} |
| 733 |
|
| 734 |
/* (non-Javadoc) |
| 735 |
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) |
| 736 |
*/ |
| 737 |
public void removeListener(ILabelProviderListener listener) { |
| 738 |
} |
| 739 |
|
| 740 |
/* (non-Javadoc) |
| 741 |
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) |
| 742 |
*/ |
| 743 |
public Color getForeground(Object element) { |
| 744 |
return null; |
| 745 |
} |
| 746 |
|
| 747 |
/* (non-Javadoc) |
| 748 |
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) |
| 749 |
*/ |
| 750 |
public Color getBackground(Object element) { |
| 751 |
if (element instanceof Placeholder) { |
| 752 |
return Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND); |
| 753 |
} |
| 754 |
return null; |
| 755 |
} |
| 756 |
|
| 757 |
} |
| 758 |
|
| 759 |
private final class Placeholder { |
| 760 |
private final String text; |
| 761 |
|
| 762 |
public Placeholder(String text) { |
| 763 |
this.text = text; |
| 764 |
} |
| 765 |
/* (non-Javadoc) |
| 766 |
* @see java.lang.Object#equals(java.lang.Object) |
| 767 |
*/ |
| 768 |
public boolean equals(Object obj) { |
| 769 |
if (obj == null) return false; |
| 770 |
if (!(obj instanceof Placeholder)) return false; |
| 771 |
|
| 772 |
Placeholder that = (Placeholder) obj; |
| 773 |
return this.text.equals(that.text); |
| 774 |
} |
| 775 |
public String getText() { |
| 776 |
return this.text; |
| 777 |
} |
| 778 |
} |
| 779 |
|
| 780 |
public AbstractRepositoryQuery getQuery() { |
| 781 |
this.applyChanges(); |
| 782 |
issueAttributesPage.applyChanges(); |
| 783 |
if(isNew) { |
| 784 |
server.addLocalFilter(workingCopy); |
| 785 |
} |
| 786 |
|
| 787 |
return new JiraCustomQuery(repository.getUrl(), workingCopy, |
| 788 |
MylarTaskListPlugin.getTaskListManager().getTaskList()); |
| 789 |
} |
| 790 |
} |