tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / dialogs / FilterListDialog.java
index 084624ddec1469cde129840c0b82a0f4ebee1364..8a0d64035fcc099d3d077a84f56636dfb7627c07 100755 (executable)
@@ -1,16 +1,15 @@
 /**********************************************************************
- * 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;
@@ -19,7 +18,7 @@ import java.util.List;
 
 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;
@@ -39,7 +38,7 @@ import org.eclipse.ui.IViewPart;
 /**
  * This is the filters list dialog.<br>
  * It is associated to an SDView and to a ISDFilterProvider.<br>
- * 
+ *
  * @version 1.0
  * @author sveyrier
  */
@@ -48,8 +47,13 @@ public class FilterListDialog extends Dialog {
     // ------------------------------------------------------------------------
     // Constants
     // ------------------------------------------------------------------------
-
+    /**
+     * Filter list criteria property name
+     */
     protected static final String FILTERS_LIST_CRITERIA = "filtersListsCriteria"; //$NON-NLS-1$
+    /**
+     * Filter list size property name
+     */
     protected static final String FILTERS_LIST_SIZE = "filtersListSize"; //$NON-NLS-1$
 
     // ------------------------------------------------------------------------
@@ -59,31 +63,31 @@ public class FilterListDialog extends Dialog {
     /**
      * The viewer and provided are kept here as attributes
      */
-    protected IViewPart viewer = null;
+    protected IViewPart fViewer = null;
     /**
      * The filter provider implementation
      */
-    protected ISDFilterProvider provider = null;
+    protected ISDFilterProvider fProvider = null;
     /**
      * The filters are the result of editing this list
      */
-    protected List<FilterCriteria> filters;
+    protected List<FilterCriteria> fFilters;
     /**
      * The add button.
      */
-    protected Button add;
+    protected Button fAdd;
     /**
      * The remove button.
      */
-    protected Button remove;
+    protected Button fRemove;
     /**
      * The edit button.
      */
-    protected Button edit;
+    protected Button fEdit;
     /**
      * The table with list of filters.
      */
-    protected Table table;
+    protected Table fTable;
 
     // ------------------------------------------------------------------------
     // Constructor
@@ -91,15 +95,15 @@ public class FilterListDialog extends Dialog {
 
     /**
      * Standard constructor
-     * 
-     * @param view_ The view reference
-     * @param loader_ The filter provider implementation
+     *
+     * @param view The view reference
+     * @param loader The filter provider implementation
      */
-    public FilterListDialog(IViewPart view_, ISDFilterProvider loader_) {
-        super(view_.getSite().getShell());
-        viewer = view_;
-        provider = loader_;
-        filters = null;
+    public FilterListDialog(IViewPart view, ISDFilterProvider loader) {
+        super(view.getSite().getShell());
+        fViewer = view;
+        fProvider = loader;
+        fFilters = null;
         // filters = provider.getCurrentFilters();
         setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
     }
@@ -109,34 +113,34 @@ public class FilterListDialog extends Dialog {
     // ------------------------------------------------------------------------
     /**
      * 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
      */
     protected void addCriteria(Criteria criteria, boolean checked, boolean positive, String loaderClassName) {
-        CriteriaTableItem cti = new CriteriaTableItem(table, checked, positive, loaderClassName);
+        CriteriaTableItem cti = new CriteriaTableItem(fTable, checked, positive, loaderClassName);
         cti.setCriteria(criteria);
     }
 
     /**
      * Replaces a selected criteria with a new criteria.
-     * 
-     * @param new_ A new criteria.
+     *
+     * @param newCriteria A new criteria.
      */
-    protected void replaceSelectedCriteria(Criteria new_) {
-        CriteriaTableItem cti = (CriteriaTableItem) table.getSelection()[0].getData();
-        cti.setCriteria(new_);
+    protected void replaceSelectedCriteria(Criteria newCriteria) {
+        CriteriaTableItem cti = (CriteriaTableItem) fTable.getSelection()[0].getData();
+        cti.setCriteria(newCriteria);
     }
 
     /**
         * Handles table selection count.
         */
     protected void handleTableSelectionCount() {
-        int count = table.getSelectionCount();
-        edit.setEnabled(count == 1);
-        remove.setEnabled(count > 0);
+        int count = fTable.getSelectionCount();
+        fEdit.setEnabled(count == 1);
+        fRemove.setEnabled(count > 0);
     }
 
     /*
@@ -160,19 +164,19 @@ public class FilterListDialog extends Dialog {
         rowLayout.spacing = 8;
         ret.setLayout(rowLayout);
 
-        table = new Table(ret, SWT.MULTI | SWT.CHECK);
-        table.setLayoutData(new RowData(220, 84));
-        table.setHeaderVisible(false);
-        table.addSelectionListener(new SelectionListener() {
+        fTable = new Table(ret, SWT.MULTI | SWT.CHECK);
+        fTable.setLayoutData(new RowData(220, 84));
+        fTable.setHeaderVisible(false);
+        fTable.addSelectionListener(new SelectionListener() {
             /*
              * (non-Javadoc)
              * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
              */
             @Override
             public void widgetDefaultSelected(SelectionEvent e) {
-                int count = table.getSelectionCount();
+                int count = fTable.getSelectionCount();
                 if (count == 1) {
-                    Criteria criteria = openFilterDialog(((CriteriaTableItem) table.getSelection()[0].getData()).getCriteria(), SDMessages._63);
+                    Criteria criteria = openFilterDialog(((CriteriaTableItem) fTable.getSelection()[0].getData()).getCriteria(), SDMessages._63);
                     if (criteria != null) {
                         replaceSelectedCriteria(criteria);
                     }
@@ -188,9 +192,9 @@ public class FilterListDialog extends Dialog {
                 handleTableSelectionCount();
             }
         });
-        if (filters != null) {
-            for (Iterator<FilterCriteria> i = filters.iterator(); i.hasNext();) {
-                FilterCriteria filterCriteria = (FilterCriteria) i.next();
+        if (fFilters != null) {
+            for (Iterator<FilterCriteria> i = fFilters.iterator(); i.hasNext();) {
+                FilterCriteria filterCriteria = i.next();
                 addCriteria(filterCriteria.getCriteria(), filterCriteria.isActive(), filterCriteria.isPositive(), filterCriteria.getLoaderClassName());
             }
         }
@@ -207,9 +211,9 @@ public class FilterListDialog extends Dialog {
         rowLayoutCommands.marginBottom = 4;
         rowLayoutCommands.spacing = 8;
         commands.setLayout(rowLayoutCommands);
-        add = new Button(commands, SWT.NONE);
-        add.setText(SDMessages._61);
-        add.addSelectionListener(new SelectionListener() {
+        fAdd = new Button(commands, SWT.NONE);
+        fAdd.setText(SDMessages._61);
+        fAdd.addSelectionListener(new SelectionListener() {
             /*
              * (non-Javadoc)
              * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
@@ -233,9 +237,9 @@ public class FilterListDialog extends Dialog {
             }
         });
 
-        edit = new Button(commands, SWT.NONE);
-        edit.setText(SDMessages._60);
-        edit.addSelectionListener(new SelectionListener() {
+        fEdit = new Button(commands, SWT.NONE);
+        fEdit.setText(SDMessages._60);
+        fEdit.addSelectionListener(new SelectionListener() {
             /*
              * (non-Javadoc)
              * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
@@ -244,24 +248,24 @@ public class FilterListDialog extends Dialog {
             public void widgetDefaultSelected(SelectionEvent e) {
                 // Nothing to do
             }
-            
+
             /*
              * (non-Javadoc)
              * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
              */
             @Override
             public void widgetSelected(SelectionEvent e) {
-                Criteria c = openFilterDialog(((CriteriaTableItem) table.getSelection()[0].getData()).getCriteria(), SDMessages._63);
+                Criteria c = openFilterDialog(((CriteriaTableItem) fTable.getSelection()[0].getData()).getCriteria(), SDMessages._63);
                 if (c != null) {
                     replaceSelectedCriteria(c);
                 }
             }
         });
-        edit.setEnabled(false);
+        fEdit.setEnabled(false);
 
-        remove = new Button(commands, SWT.NONE);
-        remove.setText(SDMessages._64);
-        remove.addSelectionListener(new SelectionListener() {
+        fRemove = new Button(commands, SWT.NONE);
+        fRemove.setText(SDMessages._64);
+        fRemove.addSelectionListener(new SelectionListener() {
             /*
              * (non-Javadoc)
              * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
@@ -277,11 +281,11 @@ public class FilterListDialog extends Dialog {
              */
             @Override
             public void widgetSelected(SelectionEvent e) {
-                table.remove(table.getSelectionIndices());
+                fTable.remove(fTable.getSelectionIndices());
                 handleTableSelectionCount();
             }
         });
-        remove.setEnabled(false);
+        fRemove.setEnabled(false);
 
         getShell().setText(SDMessages._65);
         /*
@@ -293,13 +297,13 @@ public class FilterListDialog extends Dialog {
 
     /**
      * 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
      */
     protected Criteria openFilterDialog(Criteria criteria, String action) {
-        SearchFilterDialog filter = new SearchFilterDialog((SDView) viewer, provider, true, SWT.APPLICATION_MODAL);
+        SearchFilterDialog filter = new SearchFilterDialog((SDView) fViewer, fProvider, true, SWT.APPLICATION_MODAL);
         filter.setCriteria(criteria);
         filter.setOkText(action);
         filter.setTitle(SDMessages._66);
@@ -326,43 +330,43 @@ public class FilterListDialog extends Dialog {
      */
     @Override
     public void okPressed() {
-        if (table.getItemCount() > 0) {
-            filters = new ArrayList<FilterCriteria>();
+        if (fTable.getItemCount() > 0) {
+            fFilters = new ArrayList<FilterCriteria>();
         } else {
-            filters = null;
+            fFilters = null;
         }
-        for (int i = 0; i < table.getItemCount(); i++) {
-            TableItem item = table.getItem(i);
+        for (int i = 0; i < fTable.getItemCount(); i++) {
+            TableItem item = fTable.getItem(i);
             CriteriaTableItem cti = (CriteriaTableItem) item.getData();
-            FilterCriteria fc = new FilterCriteria(cti.getCriteria(), item.getChecked(), cti.getPositive(), cti.getLoaderClassName());
-            FilterCriteria efc = FilterCriteria.find(fc, filters);
+            FilterCriteria fc = new FilterCriteria(cti.getCriteria(), item.getChecked(), cti.isPositive(), cti.getLoaderClassName());
+            FilterCriteria efc = FilterCriteria.find(fc, fFilters);
             if (efc == null) {
-                filters.add(fc);
+                fFilters.add(fc);
             } else {
                 efc.setActive(efc.isActive() || fc.isActive());
             }
         }
         super.close();
-        provider.filter(filters);
-        saveFiltersCriteria(filters);
+        fProvider.filter(fFilters);
+        saveFiltersCriteria(fFilters);
     }
 
     /**
      * Sets the list of filters.
-     * 
-     * @param filters_ The list of filters to set.
+     *
+     * @param filters The list of filters to set.
      */
-    public void setFilters(ArrayList<FilterCriteria> filters_) {
-        filters = filters_;
+    public void setFilters(List<FilterCriteria> filters) {
+        fFilters = filters;
     }
 
     /**
      * Returns the filters list after editing.
-     * 
+     *
      * @return the filters list after editing
      */
     public List<FilterCriteria> getFilters() {
-        return filters;
+        return fFilters;
     }
 
     /**
@@ -371,21 +375,23 @@ public class FilterListDialog extends Dialog {
     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);
@@ -394,16 +400,14 @@ public class FilterListDialog extends Dialog {
                 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;
@@ -411,11 +415,11 @@ public class FilterListDialog extends Dialog {
 
     /**
      * 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);
@@ -431,11 +435,11 @@ public class FilterListDialog extends Dialog {
         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) {
@@ -444,7 +448,7 @@ public class FilterListDialog extends Dialog {
             criteria.save(subSection);
         }
     }
-    
+
     /**
      * Deactivates the saved global filters.
      */
@@ -469,60 +473,60 @@ public class FilterListDialog extends Dialog {
         /**
          * The criteria reference
          */
-        protected Criteria criteria;
+        protected Criteria fCriteria;
         /**
          * The "positive" value.
          */
-        protected boolean positive;
+        protected boolean fIsPositive;
         /**
          * The loader class name
          */
-        protected String loaderClassName;
+        protected String fLoaderClassName;
         /**
          * The actual table item.
          */
-        protected TableItem tableItem;
+        protected TableItem fTableItem;
 
         /**
          * Constructor
-         * 
+         *
          * @param parent The parent table
-         * @param active_ <code>true</code> if filter criteria is active else <code>false</code> 
-         * @param positive_  <code>true</code> for positive filter else <code>false</code>
-         * @param loaderClassName_ The loader class name
+         * @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
          */
-        public CriteriaTableItem(Table parent, boolean active_, boolean positive_, String loaderClassName_) {
-            tableItem = new TableItem(parent, SWT.NONE);
-            tableItem.setData(this);
-            tableItem.setChecked(active_);
-            positive = positive_;
-            loaderClassName = loaderClassName_;
+        public CriteriaTableItem(Table parent, boolean isActive, boolean isPositive, String loaderClassName) {
+            fTableItem = new TableItem(parent, SWT.NONE);
+            fTableItem.setData(this);
+            fTableItem.setChecked(isActive);
+            fIsPositive = isPositive;
+            fLoaderClassName = loaderClassName;
         }
 
         /**
          * Constructor
-         * 
+         *
          * @param parent The parent table
-         * @param active_ <code>true</code> if filter criteria is active else <code>false</code> 
-         * @param positive_  <code>true</code> for positive filter else <code>false</code>
-         * @param loaderClassName_ The loader class name
+         * @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
          */
-        public CriteriaTableItem(Table parent, boolean checked_, boolean positive_, String loaderClassName_, int index) {
-            tableItem = new TableItem(parent, SWT.NONE, index);
-            tableItem.setChecked(checked_);
-            positive = positive_;
-            loaderClassName = loaderClassName_;
+        public CriteriaTableItem(Table parent, boolean isActive, boolean isPositive, String loaderClassName, int index) {
+            fTableItem = new TableItem(parent, SWT.NONE, index);
+            fTableItem.setChecked(isActive);
+            fIsPositive = isPositive;
+            fLoaderClassName = loaderClassName;
         }
 
         /**
          * Sets the criteria.
-         * 
-         * @param criteria_ The criteria to set
+         *
+         * @param criteria The criteria to set
          */
-        public void setCriteria(Criteria criteria_) {
-            criteria = criteria_;
-            tableItem.setText((positive ? SDMessages._59 : SDMessages._58) + " " + criteria.getExpression() + " " + criteria.getGraphNodeSummary(provider, loaderClassName)); //$NON-NLS-1$ //$NON-NLS-2$
+        public void setCriteria(Criteria criteria) {
+            fCriteria = criteria;
+            fTableItem.setText((fIsPositive ? SDMessages._59 : SDMessages._58) + " " + fCriteria.getExpression() + " " + fCriteria.getGraphNodeSummary(fProvider, fLoaderClassName)); //$NON-NLS-1$ //$NON-NLS-2$
         }
 
         /**
@@ -530,25 +534,25 @@ public class FilterListDialog extends Dialog {
          * @return the criteria
          */
         public Criteria getCriteria() {
-            return criteria;
+            return fCriteria;
         }
 
         /**
          * Returns whether positive filtering is active or not.
-         * 
+         *
          * @return <code>true</code> for positive filter else <code>false</code>
          */
-        public boolean getPositive() {
-            return positive;
+        public boolean isPositive() {
+            return fIsPositive;
         }
 
         /**
          * Returns the loader class name.
-         * 
+         *
          * @return the loader class name
          */
         public String getLoaderClassName() {
-            return loaderClassName;
+            return fLoaderClassName;
         }
     }
 
This page took 0.033572 seconds and 5 git commands to generate.