|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.s60tools.appdep.ui.wizards; |
|
20 |
|
21 import org.eclipse.jface.viewers.Viewer; |
|
22 import org.eclipse.jface.viewers.ViewerFilter; |
|
23 |
|
24 /** |
|
25 * Accepts in Build Target Selection -wizard page only the targets |
|
26 * that are non-empty or supported. |
|
27 * |
|
28 * The enabling and disabling of filter is managed using <code>setFilterEnabled</code> |
|
29 * method because using <code>addFilter</code> and <code>removeFilter</code> methods |
|
30 * did not produce wanted UI behavior (transient state while adding/removing could be |
|
31 * detected by user by flicker and showing temporarily unwanted data set before filter |
|
32 * was fully applied). |
|
33 */ |
|
34 public class BuildTargetSelectionNonEmptyAndNonSuppTargetFilter extends ViewerFilter { |
|
35 |
|
36 |
|
37 /** |
|
38 * By default the filter is enabled. |
|
39 */ |
|
40 boolean isFilterEnabled = true; |
|
41 |
|
42 /** |
|
43 * Constructor. |
|
44 * @param isFilterEnabled set to <code>true</code> to enable filter |
|
45 * and to <code>false</code> to disable filter. |
|
46 */ |
|
47 public BuildTargetSelectionNonEmptyAndNonSuppTargetFilter(boolean isFilterEnabled){ |
|
48 this.isFilterEnabled = isFilterEnabled; |
|
49 } |
|
50 |
|
51 /* (non-Javadoc) |
|
52 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
|
53 */ |
|
54 @Override |
|
55 public boolean select(Viewer viewer, Object parentElement, Object element) { |
|
56 BuildTargetEntry targetEntry = (BuildTargetEntry) element; |
|
57 // If filter is enabled... |
|
58 if(isFilterEnabled){ |
|
59 // The target entry must be both |
|
60 // - non-empty target, and |
|
61 // - supported one. |
|
62 return (!targetEntry.isEmptyTarget()) && (targetEntry.isSupportedTarget()); |
|
63 } |
|
64 // Otherwise accepting all |
|
65 return true; |
|
66 } |
|
67 |
|
68 /** |
|
69 * Sets filter into enabled or disabled state. |
|
70 * @param isFilterEnabled set to <code>true</code> to enable filter |
|
71 * and to <code>false</code> to disable filter. |
|
72 */ |
|
73 public void setFilterEnabled(boolean isFilterEnabled) { |
|
74 this.isFilterEnabled = isFilterEnabled; |
|
75 } |
|
76 |
|
77 |
|
78 } |