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