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