mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 02:35:37 +02:00
autotools: Revive sorting action in automake/conf editor.
Remove the sorting action from the MakefileContentOutlinePage because the action was changed in a way to be addable in init method instead of deprecated setActionBars. Hooked it properly in AutomakefileContentOutlinePage. Bonus point - hooked into AutoconfContentOutlinePage as it was just too easy to get it there too. Change-Id: I873864f3978ae7cb1d8aa4143edf604244c0a4bc Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
This commit is contained in:
parent
6ba6157708
commit
81ff40486e
4 changed files with 39 additions and 26 deletions
|
@ -15,6 +15,8 @@ import java.util.Iterator;
|
|||
|
||||
import org.eclipse.cdt.autotools.ui.editors.AutoconfEditor;
|
||||
import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfElement;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.LexicalSortingAction;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
|
@ -23,6 +25,7 @@ import org.eclipse.jface.viewers.TreeViewer;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.part.IPageSite;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
|
||||
|
||||
|
@ -31,6 +34,7 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
|||
|
||||
private ITextEditor editor;
|
||||
private IEditorInput input;
|
||||
private LexicalSortingAction sortAction;
|
||||
|
||||
public AutoconfContentOutlinePage(AutoconfEditor editor) {
|
||||
super();
|
||||
|
@ -89,8 +93,10 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
|||
viewer.setLabelProvider(new AutoconfLabelProvider());
|
||||
viewer.addSelectionChangedListener(this);
|
||||
|
||||
if (input != null)
|
||||
if (input != null) {
|
||||
viewer.setInput(input);
|
||||
}
|
||||
sortAction.setTreeViewer(viewer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -120,4 +126,12 @@ public class AutoconfContentOutlinePage extends ContentOutlinePage {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IPageSite pageSite) {
|
||||
super.init(pageSite);
|
||||
IToolBarManager toolBarManager = pageSite.getActionBars().getToolBarManager();
|
||||
sortAction = new LexicalSortingAction();
|
||||
toolBarManager.add(sortAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@
|
|||
* QNX Software System
|
||||
* Red Hat Inc. - convert to use with Automake editor
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.autotools.ui.editors.automake;
|
||||
package org.eclipse.cdt.internal.autotools.ui.editors;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.internal.autotools.ui.MakeUIImages;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.ViewerSorter;
|
||||
import org.eclipse.jface.viewers.ViewerComparator;
|
||||
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class LexicalSortingAction extends Action {
|
|||
private LexicalCSorter fSorter;
|
||||
private TreeViewer fTreeViewer;
|
||||
|
||||
public LexicalSortingAction(TreeViewer treeViewer) {
|
||||
public LexicalSortingAction() {
|
||||
super(CUIPlugin.getResourceString(ACTION_NAME + ".label")); //$NON-NLS-1$
|
||||
|
||||
setDescription(CUIPlugin.getResourceString(ACTION_NAME + ".description")); //$NON-NLS-1$
|
||||
|
@ -37,13 +37,15 @@ public class LexicalSortingAction extends Action {
|
|||
|
||||
MakeUIImages.setImageDescriptors(this, MakeUIImages.T_TOOL, MakeUIImages.IMG_TOOLS_ALPHA_SORTING);
|
||||
|
||||
fTreeViewer= treeViewer;
|
||||
fSorter= new LexicalCSorter();
|
||||
|
||||
boolean checked= CUIPlugin.getDefault().getDialogSettings().getBoolean(DIALOG_STORE_KEY);
|
||||
valueChanged(checked, false);
|
||||
}
|
||||
|
||||
public void setTreeViewer(TreeViewer treeViewer) {
|
||||
fTreeViewer = treeViewer;
|
||||
boolean checked = CUIPlugin.getDefault().getDialogSettings().getBoolean(DIALOG_STORE_KEY);
|
||||
valueChanged(checked, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
valueChanged(isChecked(), true);
|
||||
|
@ -51,7 +53,7 @@ public class LexicalSortingAction extends Action {
|
|||
|
||||
private void valueChanged(boolean on, boolean store) {
|
||||
setChecked(on);
|
||||
fTreeViewer.setSorter(on ? fSorter : null);
|
||||
fTreeViewer.setComparator(on ? fSorter : null);
|
||||
|
||||
String key= ACTION_NAME + ".tooltip" + (on ? ".on" : ".off"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
setToolTipText(CUIPlugin.getResourceString(key));
|
||||
|
@ -61,12 +63,7 @@ public class LexicalSortingAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
private static class LexicalCSorter extends ViewerSorter {
|
||||
@SuppressWarnings("unused")
|
||||
public boolean isSorterProperty(Object element, Object property) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class LexicalCSorter extends ViewerComparator {
|
||||
@Override
|
||||
public int category(Object obj) {
|
||||
if (obj instanceof ICElement) {
|
|
@ -16,6 +16,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.autotools.ui.MakeUIImages;
|
||||
import org.eclipse.cdt.internal.autotools.ui.editors.LexicalSortingAction;
|
||||
import org.eclipse.cdt.make.core.makefile.IBadDirective;
|
||||
import org.eclipse.cdt.make.core.makefile.ICommand;
|
||||
import org.eclipse.cdt.make.core.makefile.IComment;
|
||||
|
@ -30,6 +31,7 @@ import org.eclipse.cdt.make.core.makefile.ITargetRule;
|
|||
import org.eclipse.cdt.make.core.makefile.gnu.IInclude;
|
||||
import org.eclipse.cdt.make.core.makefile.gnu.ITerminal;
|
||||
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
|
@ -38,6 +40,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.part.IPageSite;
|
||||
import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
|
||||
|
||||
|
||||
|
@ -45,6 +48,7 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage {
|
|||
|
||||
protected IMakefile makefile;
|
||||
protected IMakefile nullMakefile = new NullMakefile();
|
||||
private LexicalSortingAction sortAction;
|
||||
|
||||
private class AutomakefileContentProvider implements ITreeContentProvider {
|
||||
|
||||
|
@ -251,6 +255,7 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage {
|
|||
if (fInput != null) {
|
||||
viewer.setInput(fInput);
|
||||
}
|
||||
sortAction.setTreeViewer(viewer);
|
||||
}
|
||||
|
||||
public void inputChanged(Object oldInput, Object newInput) {
|
||||
|
@ -267,4 +272,12 @@ public class AutomakefileContentOutlinePage extends ContentOutlinePage {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(IPageSite pageSite) {
|
||||
super.init(pageSite);
|
||||
IToolBarManager toolBarManager = pageSite.getActionBars().getToolBarManager();
|
||||
sortAction = new LexicalSortingAction();
|
||||
toolBarManager.add(sortAction);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.cdt.make.core.makefile.gnu.IInclude;
|
|||
import org.eclipse.cdt.make.core.makefile.gnu.ITerminal;
|
||||
import org.eclipse.cdt.make.ui.IWorkingCopyManager;
|
||||
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.viewers.ITreeContentProvider;
|
||||
|
@ -42,7 +41,6 @@ import org.eclipse.swt.graphics.Image;
|
|||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||
import org.eclipse.ui.part.IPageSite;
|
||||
|
@ -282,13 +280,4 @@ public class MakefileContentOutlinePage extends ContentOutlinePage {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActionBars(IActionBars actionBars) {
|
||||
super.setActionBars(actionBars);
|
||||
IToolBarManager toolBarManager= actionBars.getToolBarManager();
|
||||
|
||||
LexicalSortingAction action= new LexicalSortingAction(getTreeViewer());
|
||||
toolBarManager.add(action);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue