1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

[Outline] Add Collapse All button

This commit is contained in:
Marc-Andre Laperle 2012-01-03 00:01:59 -05:00
parent 73d717b386
commit 3bd21a03c4
11 changed files with 88 additions and 56 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2010 IBM Corporation and others.
* Copyright (c) 2001, 2011 IBM Corporation and others.
* 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
@ -91,6 +91,9 @@ public class ActionMessages extends NLS {
public static String FormatAllAction_failedvalidateedit_message;
public static String FormatAllAction_noundo_title;
public static String FormatAllAction_noundo_message;
public static String CollapseAllAction_label;
public static String CollapseAllAction_tooltip;
public static String CollapseAllAction_description;
static {
// Initialize resource bundle.

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2010 IBM Corporation and others.
# Copyright (c) 2000, 2011 IBM Corporation and others.
# 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
@ -109,3 +109,7 @@ FormatAllAction_failedvalidateedit_title=Format
FormatAllAction_failedvalidateedit_message=Problems while accessing selected files.
FormatAllAction_noundo_title=Format
FormatAllAction_noundo_message='Undo' is not supported by this operation. Do you want to continue?
CollapseAllAction_label=Collapse All
CollapseAllAction_tooltip=Collapse All
CollapseAllAction_description=Collapse All

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@ -8,31 +8,38 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.cview;
package org.eclipse.cdt.internal.ui.actions;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
/**
* Collapse all nodes.
*/
class CollapseAllAction extends Action {
public class CollapseAllAction extends Action {
private CView cview;
private final TreeViewer fViewer;
CollapseAllAction(CView part) {
super(CViewMessages.CollapseAllAction_label);
setDescription(CViewMessages.CollapseAllAction_description);
setToolTipText(CViewMessages.CollapseAllAction_tooltip);
public CollapseAllAction(TreeViewer viewer) {
super(ActionMessages.CollapseAllAction_label);
setDescription(ActionMessages.CollapseAllAction_description);
setToolTipText(ActionMessages.CollapseAllAction_tooltip);
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL);
cview = part;
fViewer = viewer;
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION);
}
@Override
public void run() {
cview.collapseAll();
try {
fViewer.getControl().setRedraw(false);
fViewer.collapseAll();
} finally {
fViewer.getControl().setRedraw(true);
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* Copyright (c) 2000, 2011 QNX Software Systems and others.
* 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
@ -929,12 +929,6 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
return null;
}
public void collapseAll() {
viewer.getControl().setRedraw(false);
viewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS);
viewer.getControl().setRedraw(true);
}
void restoreState(IMemento memento) {
CoreModel factory = CoreModel.getDefault();

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@ -25,9 +25,6 @@ public final class CViewMessages extends NLS {
public static String BuildAction_label;
public static String RebuildAction_label;
public static String CleanAction_label;
public static String CollapseAllAction_label;
public static String CollapseAllAction_tooltip;
public static String CollapseAllAction_description;
public static String CopyAction_title;
public static String CopyAction_toolTip;
public static String PasteAction_title;

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2000, 2009 IBM Corporation and others.
# Copyright (c) 2000, 2011 IBM Corporation and others.
# 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
@ -17,10 +17,6 @@ BuildAction_label=&Build Project
RebuildAction_label=Rebuild Pro&ject
CleanAction_label=Clean Project
CollapseAllAction_label=Collapse All
CollapseAllAction_tooltip=Collapse All
CollapseAllAction_description=Collapse All
CopyAction_title = &Copy
CopyAction_toolTip = Copy

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others.
* Copyright (c) 2000, 2011 IBM Corporation and others.
* 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
@ -45,6 +45,7 @@ import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.CollapseAllAction;
import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
@ -133,6 +134,7 @@ public class MainActionGroup extends CViewActionGroup {
//sortByTypeAction = new SortViewAction(this, true);
IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
@ -158,7 +160,7 @@ public class MainActionGroup extends CViewActionGroup {
importAction = new ImportResourcesAction(getCView().getSite().getWorkbenchWindow());
exportAction = new ExportResourcesAction(getCView().getSite().getWorkbenchWindow());
collapseAllAction = new CollapseAllAction(getCView());
collapseAllAction = new CollapseAllAction(getCView().getViewer());
toggleLinkingAction = new ToggleLinkingAction(getCView());
toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$

View file

@ -21,6 +21,7 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.commands.ActionHandler;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.util.PropertyChangeEvent;
@ -46,6 +47,8 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.handlers.CollapseAllHandler;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.resources.ProjectExplorer;
import org.eclipse.ui.part.IPageSite;
import org.eclipse.ui.part.IShowInSource;
@ -71,6 +74,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.internal.ui.actions.CollapseAllAction;
import org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter;
import org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter;
@ -294,6 +298,10 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
* @since 3.0
*/
private ActionGroup fCustomFiltersActionGroup;
/**
* @since 5.4
*/
private CollapseAllAction fCollapseAllAction;
/**
* Create a new outline page for the given editor.
@ -520,6 +528,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
fTreeViewer.setInput(fInput);
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW);
IHandlerService handlerService= (IHandlerService)site.getService(IHandlerService.class);
handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction));
}
@Override
@ -582,6 +593,8 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent
protected void registerActionBars(IActionBars actionBars) {
IToolBarManager toolBarManager= actionBars.getToolBarManager();
fCollapseAllAction = new CollapseAllAction(fTreeViewer);
toolBarManager.add(fCollapseAllAction);
LexicalSortingAction action= new LexicalSortingAction(getTreeViewer());
toolBarManager.add(action);

View file

@ -72,27 +72,35 @@ items:</p>
</ul>
<h2>Icons</h2>
<p><table border="1" >
<tr>
<th id="icon">Icon</th>
<th id="description">Description</th>
</tr>
<tr>
<td headers="icon"><img src="../images/outlineView-hideFields.png" width="22" height="22" alt="Hide Fields Button"></td>
<td headers="description">Hide Fields </td>
</tr>
<tr>
<td headers="icon"><img src="../images/outlineView-hideStaticMembers.png" width="22" height="22" alt="Hide Static Members Button"></td>
<td headers="description">Hide Static Members </td>
</tr>
<tr>
<td headers="icon"><img src="../images/outlineView-hideNon-PublicMembers.png" width="22" height="22" alt="Hide Non Public Members Button"></td>
<td headers="description">Hide Non-Public Members </td>
</tr>
<tr>
<td headers="icon"><img src="../images/outlineView-Sort.png" width="22" height="22" alt="Sort Button"></td>
<td headers="description">Sort </td>
</tr>
<p><table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#DDDDDD" width="34%">
<tr>
<th style="width:19%" id="icon"><strong>Icon</strong></th>
<th style="width:81%" id="description"><strong>Description</strong></th>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/icon_collapse_all.png" alt="Collapse All Icon" width="16" height="16"></td>
<td headers="description">Collapse All</td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/alphab_sort_co.gif" alt="Sort items alphabetically Icon" width="16" height="16"></td>
<td headers="description">Sort items alphabetically</td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/fields_co.gif" alt="Hide Fields Icon" width="16" height="16"></td>
<td headers="description">Hide Fields</td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/static_co.gif" alt="Hide Static Members Icon" width="16" height="16"></td>
<td headers="description">Hide Static Members </td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/public_co.gif" alt="Hide Non-Public Members Icon" width="16" height="16"></td>
<td headers="description">Hide Non-Public Members </td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/icon_hide_inactive_includes.png" alt="Hide Inactive Elements Icon" width="16" height="16"></td>
<td headers="description">Hide Inactive Elements </td>
</tr>
</table></p>
<p>For more information about the Eclipse workbench, see <strong>Workbench User Guide &gt; Tasks &gt; Upgrading Eclipse</strong>.</p>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -27,6 +27,14 @@ open in the editor area, by listing the structural elements. </p>
<th style="width:19%" id="icon"><strong>Icon</strong></th>
<th style="width:81%" id="description"><strong>Description</strong></th>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/icon_collapse_all.png" alt="Collapse All Icon" width="16" height="16"></td>
<td headers="description">Collapse All</td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/alphab_sort_co.gif" alt="Sort items alphabetically Icon" width="16" height="16"></td>
<td headers="description">Sort items alphabetically</td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/fields_co.gif" alt="Hide Fields Icon" width="16" height="16"></td>
<td headers="description">Hide Fields</td>
@ -40,8 +48,8 @@ open in the editor area, by listing the structural elements. </p>
<td headers="description">Hide Non-Public Members </td>
</tr>
<tr>
<td style="text-align:center;" headers="icon"><img src="../images/alphab_sort_co.gif" alt="Sort items alphabetically Icon" width="16" height="16"></td>
<td headers="description">Sort items alphabetically</td>
<td style="text-align:center;" headers="icon"><img src="../images/icon_hide_inactive_includes.png" alt="Hide Inactive Elements Icon" width="16" height="16"></td>
<td headers="description">Hide Inactive Elements </td>
</tr>
</table>
@ -65,7 +73,7 @@ open in the editor area, by listing the structural elements. </p>
</tr>
<tr>
<td style="text-align:center;" headers="icon2">
<img src="../images/container_obj.gif" width="16" height="16" alt="Namespace icon"></td>
<img src="../images/namespace_obj.gif" width="16" height="16" alt="Namespace icon"></td>
<td headers="description2">Namespace</td>
</tr>
<tr>