Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 25826
Collapse All | Expand All

(-)CollapseAllAction.java (+59 lines)
Added Link Here
1
/*
2
 * (c) Copyright IBM Corp. 2000, 2001.
3
 * All Rights Reserved.
4
 */
5
package org.eclipse.ui.views.navigator;
6
7
import java.net.MalformedURLException;
8
import java.net.URL;
9
10
import org.eclipse.core.runtime.Platform;
11
import org.eclipse.jface.resource.ImageDescriptor;
12
import org.eclipse.ui.PlatformUI;
13
import org.eclipse.ui.help.WorkbenchHelp;
14
import org.eclipse.ui.plugin.AbstractUIPlugin;
15
16
/**
17
 * Collapse all project nodes.
18
 */
19
public class CollapseAllAction extends ResourceNavigatorAction {
20
	private static final String COLLAPSE_ALL_TOOL_TIP = ResourceNavigatorMessages.getString("CollapseAllAction.toolTip"); //$NON-NLS-1$
21
	
22
23
/**
24
 * Creates the action.
25
 * 
26
 * @param navigator the resource navigator
27
 * @param label the label for the action
28
 */
29
public CollapseAllAction(IResourceNavigator navigator, String label) {
30
	super(navigator, label);
31
	setToolTipText(COLLAPSE_ALL_TOOL_TIP);
32
	setImageDescriptor(getImageDescriptor("elcl16/collapseall.gif")); //$NON-NLS-1$
33
	WorkbenchHelp.setHelp(this, INavigatorHelpContextIds.COLLAPSE_ALL_ACTION);
34
	setEnabled(true);
35
}
36
37
/**
38
 * Returns the image descriptor with the given relative path.
39
 */
40
private ImageDescriptor getImageDescriptor(String relativePath) {
41
	String iconPath = "icons/full/"; //$NON-NLS-1$
42
	try {
43
		AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
44
		URL installURL = plugin.getDescriptor().getInstallURL();
45
		URL url = new URL(installURL, iconPath + relativePath);
46
		return ImageDescriptor.createFromURL(url);
47
	} catch (MalformedURLException e) {
48
		// should not happen
49
		return ImageDescriptor.getMissingImageDescriptor();
50
	}
51
}
52
	
53
/*
54
 * Implementation of method defined on <code>IAction</code>.
55
 */
56
public void run() {
57
	getNavigator().getViewer().collapseAll();
58
}
59
}
(-)INavigatorHelpContextIds.java (+1 lines)
Lines 26-31 Link Here
26
	public static final String SORT_VIEW_ACTION = PREFIX + "sort_view_action_context"; //$NON-NLS-1$
26
	public static final String SORT_VIEW_ACTION = PREFIX + "sort_view_action_context"; //$NON-NLS-1$
27
	public static final String COPY_ACTION = PREFIX + "resource_navigator_copy_action_context"; //$NON-NLS-1$
27
	public static final String COPY_ACTION = PREFIX + "resource_navigator_copy_action_context"; //$NON-NLS-1$
28
	public static final String PASTE_ACTION = PREFIX + "resource_navigator_paste_action_context"; //$NON-NLS-1$
28
	public static final String PASTE_ACTION = PREFIX + "resource_navigator_paste_action_context"; //$NON-NLS-1$
29
	public static final String COLLAPSE_ALL_ACTION = PREFIX + "collapse_all_action_context"; //$NON-NLS-1$
29
30
30
31
31
	// Dialogs
32
	// Dialogs
(-)MainActionGroup.java (+7 lines)
Lines 31-36 Link Here
31
	protected PropertyDialogAction propertyDialogAction;
31
	protected PropertyDialogAction propertyDialogAction;
32
	protected ImportResourcesAction importAction;
32
	protected ImportResourcesAction importAction;
33
	protected ExportResourcesAction exportAction;
33
	protected ExportResourcesAction exportAction;
34
	protected CollapseAllAction collapseAllAction;
34
	
35
	
35
	protected GotoActionGroup gotoGroup;
36
	protected GotoActionGroup gotoGroup;
36
	protected OpenActionGroup openGroup;
37
	protected OpenActionGroup openGroup;
Lines 59-64 Link Here
59
			new PropertyDialogAction(shell, navigator.getViewer());
60
			new PropertyDialogAction(shell, navigator.getViewer());
60
		importAction = new ImportResourcesAction(workbench);
61
		importAction = new ImportResourcesAction(workbench);
61
		exportAction = new ExportResourcesAction(workbench);
62
		exportAction = new ExportResourcesAction(workbench);
63
		collapseAllAction = new CollapseAllAction(navigator , ResourceNavigatorMessages.getString("ResourceNavigator.collapseAll")); //$NON-NLS-1$
62
	}
64
	}
63
	
65
	
64
	/**
66
	/**
Lines 152-157 Link Here
152
		refactorGroup.fillActionBars(actionBars);
154
		refactorGroup.fillActionBars(actionBars);
153
		sortAndFilterGroup.fillActionBars(actionBars);
155
		sortAndFilterGroup.fillActionBars(actionBars);
154
		workspaceGroup.fillActionBars(actionBars);
156
		workspaceGroup.fillActionBars(actionBars);
157
		
158
		IToolBarManager toolBar = actionBars.getToolBarManager();
159
		
160
		toolBar.add(new Separator());
161
		toolBar.add(collapseAllAction);		
155
	}
162
	}
156
	
163
	
157
	/**
164
	/**
(-)messages.properties (+3 lines)
Lines 30-35 Link Here
30
ResourceNavigator.resourceText = &Resource...
30
ResourceNavigator.resourceText = &Resource...
31
ResourceNavigator.openPerspective = Open &Perspective
31
ResourceNavigator.openPerspective = Open &Perspective
32
ResourceNavigator.openWith = Open Wit&h
32
ResourceNavigator.openWith = Open Wit&h
33
ResourceNavigator.collapseAll = Co&llapse All
33
34
34
ShowInNavigator.text = Show in &Navigator
35
ShowInNavigator.text = Show in &Navigator
35
ShowInNavigator.toolTip = Show Selected Objects in Navigator View
36
ShowInNavigator.toolTip = Show Selected Objects in Navigator View
Lines 39-44 Link Here
39
40
40
PasteAction.title=&Paste
41
PasteAction.title=&Paste
41
PasteAction.toolTip = Paste
42
PasteAction.toolTip = Paste
43
44
CollapseAllAction.toolTip = Collapse All
42
45
43
GoToResource.showNavError=Could not open resource navigator view.
46
GoToResource.showNavError=Could not open resource navigator view.
44
# --- Dialogs ---
47
# --- Dialogs ---

Return to bug 25826