mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Implement the Collapse All Action in the CView
This commit is contained in:
parent
da41d2be2d
commit
7994b5c333
10 changed files with 159 additions and 17 deletions
|
@ -1,3 +1,20 @@
|
|||
2003-04-05 Alain Magloire
|
||||
|
||||
Implement the new CollapseAll button to be consistent with the
|
||||
JDT package explorer.
|
||||
|
||||
* icons/full/clcl16/collapseall.gif:
|
||||
* icons/full/dlcl16/collapseall.gif:
|
||||
* icons/full/elcl16/collapseall.gif:
|
||||
* src/org/eclipse/cdt/internal/ui/CPluginImages.java:
|
||||
New icon.
|
||||
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java:
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CView.java:
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java:
|
||||
* src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties:
|
||||
* src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java:
|
||||
|
||||
2003-04-05 Alain Magloire
|
||||
|
||||
The way the working copy was implemented, the outline could not
|
||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/full/clcl16/collapseall.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/clcl16/collapseall.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 B |
BIN
core/org.eclipse.cdt.ui/icons/full/dlcl16/collapseall.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/dlcl16/collapseall.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 B |
BIN
core/org.eclipse.cdt.ui/icons/full/elcl16/collapseall.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/full/elcl16/collapseall.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 B |
|
@ -113,6 +113,7 @@ public class CPluginImages {
|
|||
public static final String IMG_MENU_SHIFT_LEFT= NAME_PREFIX + "shift_l_edit.gif";
|
||||
public static final String IMG_MENU_OPEN_INCLUDE= NAME_PREFIX + "open_incl.gif";
|
||||
public static final String IMG_MENU_SEGMENT_EDIT= NAME_PREFIX + "segment_edit.gif";
|
||||
public static final String IMG_MENU_COLLAPSE_ALL= NAME_PREFIX + "collapseall.gif";
|
||||
public static final String IMG_CLEAR_CONSOLE= NAME_PREFIX + "clear_co.gif";
|
||||
public static final String IMG_ALPHA_SORTING= NAME_PREFIX + "alphab_sort_co.gif";
|
||||
public static final String IMG_TOOL_GOTO_PREV_ERROR= NAME_PREFIX + "prev_error_nav.gif";
|
||||
|
|
|
@ -39,4 +39,6 @@ public interface ICHelpContextIds {
|
|||
public static final String TOGGLE_PRESENTATION_ACTION= PREFIX + "toggle_presentation_action_context"; //$NON-NLS-1$
|
||||
public static final String TOGGLE_TEXTHOVER_ACTION= PREFIX + "toggle_texthover_action_context"; //$NON-NLS-1$
|
||||
|
||||
public static final String COLLAPSE_ALL_ACTION= PREFIX + "collapse_all_action"; //$NON-NLS-1$
|
||||
|
||||
}
|
|
@ -168,6 +168,9 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
CWorkingSetFilter workingSetFilter = new CWorkingSetFilter ();
|
||||
ActionContributionItem adjustWorkingSetContributions [] = new ActionContributionItem[5];
|
||||
|
||||
// Collapsing
|
||||
CollapseAllAction collapseAllAction;
|
||||
|
||||
// Persistance tags.
|
||||
static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
|
||||
static final String TAG_EXPANDED= "expanded"; //$NON-NLS-1$
|
||||
|
@ -566,8 +569,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
openFileAction = new OpenFileAction(getSite().getPage());
|
||||
openSystemEditorAction = new OpenSystemEditorAction(getSite().getPage());
|
||||
refreshAction = new RefreshAction(shell);
|
||||
buildAction =
|
||||
new BuildAction(shell, IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
buildAction = new BuildAction(shell, IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
rebuildAction = new BuildAction(shell, IncrementalProjectBuilder.FULL_BUILD);
|
||||
makeTargetAction = new MakeTargetAction(shell);
|
||||
moveResourceAction = new MoveResourceAction (shell);
|
||||
|
@ -616,22 +618,13 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
IActionBars actionBars = getViewSite().getActionBars();
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, deleteResourceAction);
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, addBookmarkAction);
|
||||
actionBars.setGlobalActionHandler(
|
||||
IWorkbenchActionConstants.REFRESH,
|
||||
refreshAction);
|
||||
actionBars.setGlobalActionHandler(
|
||||
IWorkbenchActionConstants.BUILD_PROJECT,
|
||||
buildAction);
|
||||
actionBars.setGlobalActionHandler(
|
||||
IWorkbenchActionConstants.REBUILD_PROJECT,
|
||||
rebuildAction);
|
||||
actionBars.setGlobalActionHandler(
|
||||
IWorkbenchActionConstants.OPEN_PROJECT,
|
||||
openProjectAction);
|
||||
actionBars.setGlobalActionHandler(
|
||||
IWorkbenchActionConstants.CLOSE_PROJECT,
|
||||
closeProjectAction);
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.REFRESH, refreshAction);
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.BUILD_PROJECT, buildAction);
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.REBUILD_PROJECT, rebuildAction);
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.OPEN_PROJECT, openProjectAction);
|
||||
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.CLOSE_PROJECT, closeProjectAction);
|
||||
|
||||
collapseAllAction = new CollapseAllAction(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1027,6 +1020,8 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
toolBar.add(backAction);
|
||||
toolBar.add(forwardAction);
|
||||
toolBar.add(upAction);
|
||||
toolBar.add(new Separator());
|
||||
toolBar.add(collapseAllAction);
|
||||
actionBars.updateActionBars();
|
||||
|
||||
IMenuManager menu = actionBars.getMenuManager();
|
||||
|
@ -1147,6 +1142,22 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
|
|||
return this == getSite().getPage().getActivePart();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see IViewPartInputProvider#getViewPartInput()
|
||||
*/
|
||||
public Object getViewPartInput() {
|
||||
if (viewer != null) {
|
||||
return viewer.getInput();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void collapseAll() {
|
||||
viewer.getControl().setRedraw(false);
|
||||
viewer.collapseToLevel(getViewPartInput(), TreeViewer.ALL_LEVELS);
|
||||
viewer.getControl().setRedraw(true);
|
||||
}
|
||||
|
||||
void restoreFilters() {
|
||||
// restore pattern filters
|
||||
IMemento filtersMem = memento.getChild(TAG_FILTERS);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2003 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.cview;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class CViewMessages {
|
||||
|
||||
private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.cview.CViewMessages";//$NON-NLS-1$
|
||||
|
||||
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
||||
|
||||
private CViewMessages() {
|
||||
}
|
||||
|
||||
public static String getString(String key) {
|
||||
try {
|
||||
return fgResourceBundle.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string from the resource bundle and formats it with the argument
|
||||
*
|
||||
* @param key the string used to get the bundle value, must not be null
|
||||
*/
|
||||
public static String getFormattedString(String key, Object arg) {
|
||||
String format= null;
|
||||
try {
|
||||
format= fgResourceBundle.getString(key);
|
||||
} catch (MissingResourceException e) {
|
||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
||||
}
|
||||
if (arg == null)
|
||||
arg= ""; //$NON-NLS-1$
|
||||
return MessageFormat.format(format, new Object[] { arg });
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string from the resource bundle and formats it with arguments
|
||||
*/
|
||||
public static String getFormattedString(String key, String[] args) {
|
||||
return MessageFormat.format(fgResourceBundle.getString(key), args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2000, 2003 IBM Corporation and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Common Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/cpl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# IBM Corporation - initial API and implementation
|
||||
###############################################################################
|
||||
|
||||
|
||||
CollapseAllAction.label=Collapse All
|
||||
CollapseAllAction.tooltip=Collapse All
|
||||
CollapseAllAction.description=Collapse All
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2003 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.cview;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.ui.help.WorkbenchHelp;
|
||||
|
||||
/**
|
||||
* Collapse all nodes.
|
||||
*/
|
||||
class CollapseAllAction extends Action {
|
||||
|
||||
private CView cview;
|
||||
|
||||
CollapseAllAction(CView part) {
|
||||
super(CViewMessages.getString("CollapseAllAction.label")); //$NON-NLS-1$
|
||||
setDescription(CViewMessages.getString("CollapseAllAction.description")); //$NON-NLS-1$
|
||||
setToolTipText(CViewMessages.getString("CollapseAllAction.tooltip")); //$NON-NLS-1$
|
||||
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
|
||||
cview = part;
|
||||
WorkbenchHelp.setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
cview.collapseAll();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue