/**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- *
+ * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs;
import java.util.ArrayList;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages;
/**
* This is the filters list dialog.<br>
* It is associated to an SDView and to a ISDFilterProvider.<br>
- *
+ *
* @version 1.0
* @author sveyrier
*/
/**
* Standard constructor
- *
+ *
* @param view The view reference
* @param loader The filter provider implementation
*/
// ------------------------------------------------------------------------
/**
* Adds a criteria to the table
- *
+ *
* @param criteria A criteria to add
- * @param checked A flag whether criteria is checked (selected) or not
+ * @param checked A flag whether criteria is checked (selected) or not
* @param positive A flag whether criteria is for positive filter or not
* @param loaderClassName A loader class name for the filters
*/
/**
* Replaces a selected criteria with a new criteria.
- *
+ *
* @param newCriteria A new criteria.
*/
protected void replaceSelectedCriteria(Criteria newCriteria) {
});
if (fFilters != null) {
for (Iterator<FilterCriteria> i = fFilters.iterator(); i.hasNext();) {
- FilterCriteria filterCriteria = (FilterCriteria) i.next();
+ FilterCriteria filterCriteria = i.next();
addCriteria(filterCriteria.getCriteria(), filterCriteria.isActive(), filterCriteria.isPositive(), filterCriteria.getLoaderClassName());
}
}
public void widgetDefaultSelected(SelectionEvent e) {
// Nothing to do
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
/**
* Opens the filter dialog box with given parameter.
- *
+ *
* @param criteria The criteria reference to pass
* @param action to distinguish between "Update" and "Create"
* @return the criteria that has been updated or created
/**
* Sets the list of filters.
- *
+ *
* @param filters The list of filters to set.
*/
public void setFilters(List<FilterCriteria> filters) {
/**
* Returns the filters list after editing.
- *
+ *
* @return the filters list after editing
*/
public List<FilterCriteria> getFilters() {
protected void loadFiltersCriteria() {
List<FilterCriteria> globalFilters = getGlobalFilters();
for (Iterator<FilterCriteria> i = globalFilters.iterator(); i.hasNext();) {
- FilterCriteria filterCriteria = (FilterCriteria) i.next();
+ FilterCriteria filterCriteria = i.next();
addCriteria(filterCriteria.getCriteria(), filterCriteria.isActive(), filterCriteria.isPositive(), filterCriteria.getLoaderClassName());
}
}
/**
* Returns the global filters which are saved in the dialog settings..
- *
+ *
* @return the saved global filters
*/
+
public static List<FilterCriteria> getGlobalFilters() {
- DialogSettings settings = (DialogSettings) TmfUiPlugin.getDefault().getDialogSettings().getSection(FILTERS_LIST_CRITERIA);
+ DialogSettings settings = (DialogSettings) Activator.getDefault().getDialogSettings().getSection(FILTERS_LIST_CRITERIA);
int i = 0;
DialogSettings section = null;
int size = 0;
+ List<FilterCriteria> globalFilters = new ArrayList<FilterCriteria>();
if (settings != null) {
try {
size = settings.getInt(FILTERS_LIST_SIZE);
size = 0;
}
section = (DialogSettings) settings.getSection(FILTERS_LIST_CRITERIA + i);
- }
- List<FilterCriteria> globalFilters = new ArrayList<FilterCriteria>();
-
- while ((section != null) && (i < size)) {
- FilterCriteria criteria = new FilterCriteria();
- criteria.setCriteria(new Criteria());
- criteria.load(section);
- globalFilters.add(criteria);
- section = (DialogSettings) settings.getSection(FILTERS_LIST_CRITERIA + (++i));
+ while ((section != null) && (i < size)) {
+ FilterCriteria criteria = new FilterCriteria();
+ criteria.setCriteria(new Criteria());
+ criteria.load(section);
+ globalFilters.add(criteria);
+ section = (DialogSettings) settings.getSection(FILTERS_LIST_CRITERIA + (++i));
+ }
}
return globalFilters;
/**
* Saves the filter criteria in the dialog settings.
- *
+ *
* @param globalFilters A list of filters to save.
*/
public static void saveFiltersCriteria(List<FilterCriteria> globalFilters) {
- DialogSettings settings = (DialogSettings) TmfUiPlugin.getDefault().getDialogSettings();
+ DialogSettings settings = (DialogSettings) Activator.getDefault().getDialogSettings();
DialogSettings section = (DialogSettings) settings.getSection(FILTERS_LIST_CRITERIA);
if (section == null) {
section = (DialogSettings) settings.addNewSection(FILTERS_LIST_CRITERIA);
FilterCriteria criteria;
for (int j = 0; j < globalFilters.size(); j++) {
- if (!(globalFilters.get(j) instanceof FilterCriteria)) {
+ if (globalFilters.get(j) == null) {
return;
}
- criteria = (FilterCriteria) globalFilters.get(j);
+ criteria = globalFilters.get(j);
DialogSettings subSection = (DialogSettings) section.getSection(FILTERS_LIST_CRITERIA + j);
if (subSection == null) {
criteria.save(subSection);
}
}
-
+
/**
* Deactivates the saved global filters.
*/
/**
* Constructor
- *
+ *
* @param parent The parent table
- * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
+ * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
* @param isPositive <code>true</code> for positive filter else <code>false</code>
* @param loaderClassName The loader class name
*/
/**
* Constructor
- *
+ *
* @param parent The parent table
- * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
+ * @param isActive <code>true</code> if filter criteria is active else <code>false</code>
* @param isPositive <code>true</code> for positive filter else <code>false</code>
* @param loaderClassName The loader class name
* @param index The table item index
/**
* Sets the criteria.
- *
+ *
* @param criteria The criteria to set
*/
public void setCriteria(Criteria criteria) {
/**
* Returns whether positive filtering is active or not.
- *
+ *
* @return <code>true</code> for positive filter else <code>false</code>
*/
public boolean isPositive() {
/**
* Returns the loader class name.
- *
+ *
* @return the loader class name
*/
public String getLoaderClassName() {