KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > HistoryFilterAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui;
12
13 import org.eclipse.jface.action.IAction;
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.jface.window.Window;
16 import org.eclipse.ui.IViewActionDelegate;
17 import org.eclipse.ui.IViewPart;
18
19 public class HistoryFilterAction implements IViewActionDelegate {
20     private HistoryView view;
21     private HistoryFilter filter;
22     
23     /**
24      * @see IViewActionDelegate#init(IViewPart)
25      */

26     public void init(IViewPart view) {
27         this.view = (HistoryView)view;
28     }
29     /**
30      * @see IActionDelegate#run(IAction)
31      */

32     public void run(IAction action) {
33         HistoryFilterDialog historyDialog = new HistoryFilterDialog(view);
34         if (filter != null) {
35             historyDialog.setFilter(filter);
36         }
37         if (historyDialog.open() == Window.CANCEL) {
38             return;
39         }
40         if (filter != null) {
41             view.getViewer().removeFilter(filter);
42         }
43         filter = historyDialog.getFilter();
44         //don't add the filter if it is blank
45
if (!(filter.hasAuthor() || filter.hasDate() || filter.hasComment())) {
46             return;
47         }
48         view.getViewer().addFilter(filter);
49     }
50     /**
51      * @see IActionDelegate#selectionChanged(IAction, ISelection)
52      */

53     public void selectionChanged(IAction action, ISelection selection) {
54     }
55 }
56
Popular Tags