1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2006, 2007 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
|
|
12
|
package org.eclipse.ui.internal.navigator.filters;
|
13
|
|
14
|
import java.util.Iterator;
|
15
|
import java.util.LinkedHashSet;
|
16
|
import java.util.Set;
|
17
|
|
18
|
import org.eclipse.core.runtime.Assert;
|
19
|
import org.eclipse.jface.action.GroupMarker;
|
20
|
import org.eclipse.jface.action.IAction;
|
21
|
import org.eclipse.jface.action.IMenuManager;
|
22
|
import org.eclipse.jface.action.Separator;
|
23
|
import org.eclipse.jface.resource.ImageDescriptor;
|
24
|
import org.eclipse.ui.IActionBars;
|
25
|
import org.eclipse.ui.IWorkbenchActionConstants;
|
26
|
import org.eclipse.ui.actions.ActionGroup;
|
27
|
import org.eclipse.ui.internal.navigator.NavigatorPlugin;
|
28
|
import org.eclipse.ui.navigator.CommonViewer;
|
29
|
import org.eclipse.ui.navigator.INavigatorViewerDescriptor;
|
30
|
|
31
|
/**
|
32
|
* Creates the last 5 filters that were touched as view menu options.
|
33
|
*
|
34
|
* @since 3.2
|
35
|
*
|
36
|
*/
|
37
|
public class FilterActionGroup extends ActionGroup {
|
38
|
|
39
|
private static final String FILTER_ACTION_GROUP = "filterActionGroup"; //$NON-NLS-1$
|
40
|
|
41
|
private static final String FILTER_ACTION_GROUP_FILTERS_START = FILTER_ACTION_GROUP+"Filters-start"; //$NON-NLS-1$
|
42
|
|
43
|
private static final String FILTER_ACTION_GROUP_FILTERS_END = FILTER_ACTION_GROUP+"Filters-end"; //$NON-NLS-1$
|
44
|
|
45
|
private SelectFiltersAction selectFiltersAction;
|
46
|
private CommonViewer commonViewer;
|
47
|
private INavigatorViewerDescriptor viewerDescriptor;
|
48
|
|
49
|
private final Set filterShortcutActions = new LinkedHashSet();
|
50
|
|
51
|
|
52
|
/**
|
53
|
* @param aCommonViewer The viewer this action group is associated with
|
54
|
*/
|
55
|
public FilterActionGroup(CommonViewer aCommonViewer) {
|
56
|
Assert.isNotNull(aCommonViewer);
|
57
|
commonViewer = aCommonViewer;
|
58
|
viewerDescriptor = commonViewer.getNavigatorContentService().getViewerDescriptor();
|
59
|
makeActions();
|
60
|
}
|
61
|
|
62
|
/*
|
63
|
* (non-Javadoc)
|
64
|
*
|
65
|
* @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
|
66
|
*/
|
67
|
public void fillActionBars(IActionBars actionBars) {
|
68
|
IMenuManager menu = actionBars.getMenuManager();
|
69
|
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS,
|
70
|
new Separator(FILTER_ACTION_GROUP));
|
71
|
if (selectFiltersAction != null) {
|
72
|
menu.appendToGroup(FILTER_ACTION_GROUP,
|
73
|
selectFiltersAction);
|
74
|
|
75
|
menu.appendToGroup(FILTER_ACTION_GROUP,
|
76
|
new GroupMarker(FILTER_ACTION_GROUP_FILTERS_START));
|
77
|
|
78
|
menu.appendToGroup(FILTER_ACTION_GROUP_FILTERS_START,
|
79
|
new Separator(FILTER_ACTION_GROUP_FILTERS_END));
|
80
|
|
81
|
|
82
|
for (Iterator iter = filterShortcutActions.iterator(); iter.hasNext();) {
|
83
|
IAction action = (IAction) iter.next();
|
84
|
menu.appendToGroup(FILTER_ACTION_GROUP_FILTERS_START, action);
|
85
|
}
|
86
|
|
87
|
}
|
88
|
}
|
89
|
|
90
|
/* (non-Javadoc)
|
91
|
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
|
92
|
*/
|
93
|
public void fillContextMenu(IMenuManager menu) {
|
94
|
super.fillContextMenu(menu);
|
95
|
}
|
96
|
|
97
|
/**
|
98
|
*
|
99
|
*/
|
100
|
private void makeActions() {
|
101
|
boolean hideAvailableCustomizationsDialog = viewerDescriptor
|
102
|
.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_AVAILABLE_CUSTOMIZATIONS_DIALOG);
|
103
|
if (!hideAvailableCustomizationsDialog) {
|
104
|
selectFiltersAction = new SelectFiltersAction(commonViewer, this);
|
105
|
ImageDescriptor selectFiltersIcon = NavigatorPlugin.getImageDescriptor("icons/full/elcl16/filter_ps.gif"); //$NON-NLS-1$
|
106
|
selectFiltersAction.setImageDescriptor(selectFiltersIcon);
|
107
|
selectFiltersAction.setHoverImageDescriptor(selectFiltersIcon);
|
108
|
}
|
109
|
}
|
110
|
|
111
|
protected void updateFilterShortcuts() {
|
112
|
|
113
|
}
|
114
|
}
|