diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index c3b3b42b910..930f04056d7 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -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 diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/collapseall.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/collapseall.gif new file mode 100644 index 00000000000..0bae56c346e Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/collapseall.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/collapseall.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/collapseall.gif new file mode 100644 index 00000000000..0bae56c346e Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/collapseall.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/collapseall.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/collapseall.gif new file mode 100644 index 00000000000..3409b11b330 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/collapseall.gif differ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index d2fd969ddca..3932d826b6e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -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"; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java index 3a6e18078b3..f6bf4b6e43a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java @@ -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$ + } \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java index aa7c2938187..68b871fd94a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java @@ -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); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java new file mode 100644 index 00000000000..50daaf74795 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java @@ -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); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties new file mode 100644 index 00000000000..14f45cd2779 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties @@ -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 + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java new file mode 100644 index 00000000000..d5581950851 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java @@ -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(); + } +}