1 /**********************************************************************
2 * Copyright (c) 2005, 2008, 2011 IBM Corporation 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 * $Id: FilterCriteria.java,v 1.3 2008/01/24 02:29:09 apnan Exp $
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.widgets
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
18 import org
.eclipse
.jface
.dialogs
.DialogSettings
;
21 * A filter criteria is a criteria that can be activated or not, positive or not.
23 public class FilterCriteria
{
25 protected static final String ACTIVE
= "active"; //$NON-NLS-1$
26 protected static final String POSITIVE
= "positive"; //$NON-NLS-1$
27 protected static final String LOADERCLASSNAME
= "loaderClassName"; //$NON-NLS-1$
29 protected Criteria criteria
;
30 protected boolean active
;
31 protected boolean positive
;
32 protected String loaderClassName
;
35 public String
toString() {
36 StringBuffer sb
= new StringBuffer(super.toString());
37 sb
.append(":"); //$NON-NLS-1$
38 if (criteria
!= null) {
39 sb
.append(" expression=");sb
.append(criteria
.getExpression()); //$NON-NLS-1$
40 sb
.append(" active=");sb
.append(active
); //$NON-NLS-1$
41 sb
.append(" positive=");sb
.append(positive
); //$NON-NLS-1$
43 sb
.append("empty criteria"); //$NON-NLS-1$
53 public FilterCriteria(Criteria criteria_
, boolean active_
, boolean positive_
) {
54 setCriteria(criteria_
);
56 setPositive(positive_
);
63 * @param loaderClassName_
65 public FilterCriteria(Criteria criteria_
, boolean active_
, boolean positive_
, String loaderClassName_
) {
66 setCriteria(criteria_
);
68 setPositive(positive_
);
69 setLoaderClassName(loaderClassName_
);
74 * @param other FilterCriteria
76 public FilterCriteria (FilterCriteria other
) {
77 criteria
= new Criteria(other
.criteria
);
78 this.active
= other
.active
;
79 this.positive
= other
.positive
;
80 this.loaderClassName
= other
.loaderClassName
;
83 protected FilterCriteria() {
89 public void setCriteria(Criteria criteria_
) {
93 public Criteria
getCriteria() {
100 public void setActive(boolean active_
) {
104 public boolean isActive() {
109 * @param positive The positive to set.
111 public void setPositive(boolean positive_
) {
112 positive
= positive_
;
116 * @return Returns the positive.
118 public boolean isPositive() {
123 * @return Returns the class loader name.
125 public void setLoaderClassName(String loaderClassName_
) {
126 loaderClassName
= loaderClassName_
;
130 * @return Returns the class loader name.
132 public String
getLoaderClassName() {
133 return loaderClassName
;
136 public static FilterCriteria
find(FilterCriteria what
, List
<FilterCriteria
> list
) {
137 if (what
!= null && list
!= null) {
139 for (Iterator
<FilterCriteria
> i
= list
.iterator(); i
.hasNext();) {
140 FilterCriteria fc
= (FilterCriteria
) i
.next();
141 if (what
.compareTo(fc
)) {
145 } catch (Exception e
) {
152 public boolean compareTo(FilterCriteria to
) {
153 if (isPositive() == to
.isPositive() && getCriteria().compareTo(to
.getCriteria())) {
154 if (getLoaderClassName() == null && to
.getLoaderClassName() == null) {
157 if ((getLoaderClassName() != null && to
.getLoaderClassName() != null) && getLoaderClassName().equals(to
.getLoaderClassName())) {
164 public void save(DialogSettings settings
) {
165 settings
.put(ACTIVE
, isActive());
166 settings
.put(POSITIVE
, isPositive());
167 if (getLoaderClassName() != null) {
168 settings
.put(LOADERCLASSNAME
, getLoaderClassName());
170 settings
.put(LOADERCLASSNAME
, ""); //$NON-NLS-1$
172 if (criteria
!= null)
173 criteria
.save(settings
);
179 public void load(DialogSettings settings
) {
180 setActive(settings
.getBoolean(ACTIVE
));
181 setPositive(settings
.getBoolean(POSITIVE
));
182 String loaderClassName_
= settings
.get(LOADERCLASSNAME
);
183 setLoaderClassName(loaderClassName_
!= null && loaderClassName_
.length() > 0 ? loaderClassName_
: null);
184 if (criteria
!= null)
185 criteria
.load(settings
);
This page took 0.034819 seconds and 5 git commands to generate.