From 11c4afb8abba6f2d98b99ee506925a84c46387b8 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Mon, 24 Jan 2005 17:24:14 +0000 Subject: [PATCH] 2005-01-24 Alain Magloire PR 83514 patch form Przemek * src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties * src/org/eclipse/cdt/internal/ui/text/CoutlineInformaionControl.java * NEWS --- core/org.eclipse.cdt.ui/ChangeLog | 6 +++ core/org.eclipse.cdt.ui/NEWS | 2 +- .../ui/actions/ActionMessages.properties | 1 + .../ui/text/COutlineInformationControl.java | 44 +++++++++++++++++-- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index b81433fa8bf..8a6a32e19a5 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,9 @@ +2005-01-24 Alain Magloire + PR 83514 patch form Przemek + * src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties + * src/org/eclipse/cdt/internal/ui/text/CoutlineInformaionControl.java + * NEWS + 2005-01-22 Alain Magloire PR 38958 * src/org/eclipse/cdt/internal/ui/viewsupport/CElementImageProvider.java diff --git a/core/org.eclipse.cdt.ui/NEWS b/core/org.eclipse.cdt.ui/NEWS index 28df27656f4..31789ce5bc0 100644 --- a/core/org.eclipse.cdt.ui/NEWS +++ b/core/org.eclipse.cdt.ui/NEWS @@ -3,7 +3,7 @@ Release CDT-3.0 * C/C++ Editor: - coloring of operators, braces and numbers, - outline in selectable dialog (Ctrl O) with search input. - PR #80631 + * sorting action * Template Preference Page for C/C++ Editor \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties index b054936b057..f2643eaca29 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties @@ -283,3 +283,4 @@ IncludesGroupingAction.description=Group includes statements COutlineInformationControl.viewMenu.remember.label=Remember size and position COutlineInformationControl.viewMenu.move.label=Move outline +COutlineInformationControl.viewMenu.sort.label=Sort diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java index 484eee820ef..49d6523564f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java @@ -1,7 +1,7 @@ /* * COutlineInformationControl.java 2004-12-14 / 08:17:41 - * $Revision: 1.2 $ $Date: 2004/12/23 19:38:20 $ + * $Revision: 1.3 $ $Date: 2005/01/20 22:10:45 $ * * @author P.Tomaszewski */ @@ -21,6 +21,7 @@ import org.eclipse.cdt.ui.IWorkingCopyManager; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.text.IInformationControl; @@ -90,6 +91,8 @@ public class COutlineInformationControl implements IInformationControl, private static final String STORE_RESTORE_SIZE= "ENABLE_RESTORE_SIZE"; //$NON-NLS-1$ /** If this option is set, size is not restore. */ private static final String STORE_RESTORE_LOCATION= "ENABLE_RESTORE_LOCATION"; //$NON-NLS-1$ + /** If this option is set, sort is done. */ + private static final String STORE_SORT_ENABLED = "ENABLE_SORT"; //$NON-NLS-1$ /** Border thickness in pixels. */ private static final int BORDER = 1; @@ -112,7 +115,7 @@ public class COutlineInformationControl implements IInformationControl, IContentProvider fTreeContentProvider; /** Sorter for tree viewer. */ - private OutlineSorter fSorter; + OutlineSorter fSorter; /** Control bounds. */ Rectangle fBounds; @@ -355,6 +358,8 @@ public class COutlineInformationControl implements IInformationControl, MenuManager getViewMenuManager() { if (fViewMenuManager == null) { fViewMenuManager= new MenuManager(); + fViewMenuManager.add(new SortAction()); + fViewMenuManager.add(new Separator()); fViewMenuManager.add(new RememberBoundsAction()); fViewMenuManager.add(new MoveAction()); } @@ -408,7 +413,9 @@ public class COutlineInformationControl implements IInformationControl, fTreeContentProvider = new CContentOutlinerProvider(fTreeViewer); fSorter = new OutlineSorter(); fTreeViewer.setContentProvider(fTreeContentProvider); - fTreeViewer.setSorter(fSorter); + if (getSettings().getBoolean(STORE_SORT_ENABLED)) { + fTreeViewer.setSorter(fSorter); + } fTreeViewer.setLabelProvider(new DecoratingCLabelProvider( new StandardCElementLabelProvider(), true)); fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS); @@ -969,5 +976,36 @@ public class COutlineInformationControl implements IInformationControl, } } } + + /** + * + * The view menu's Sort action. + * + * @author P.Tomaszewski + */ + private class SortAction extends Action { + + /** + * Creates new action. + */ + SortAction() { + super(ActionMessages.getString("COutlineInformationControl.viewMenu.sort.label"), IAction.AS_CHECK_BOX); //$NON-NLS-1$ + setChecked(getSettings().getBoolean(STORE_SORT_ENABLED)); + } + + /** + * @see org.eclipse.jface.action.Action#run() + */ + public void run() { + final boolean newValue = isChecked(); + if (newValue) { + fTreeViewer.setSorter(fSorter); + } else { + fTreeViewer.setSorter(null); + } + getSettings().put(STORE_SORT_ENABLED, newValue); + fIsDeactivationActive = true; + } + } }