summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2012-01-29 09:27:24 (EST)
committer Benjamin CabeĢ2012-01-29 09:28:49 (EST)
commit46496e3dc3f81ecf853ea8b7f1d469031ef44ac5 (patch)
treea2035f6df8c95ed39d8013773fa459c2ef815be5
parent3734c59f61e34d21164c8627911eb4eae3eea76a (diff)
downloadorg.eclipse.koneki.ldt-46496e3dc3f81ecf853ea8b7f1d469031ef44ac5.zip
org.eclipse.koneki.ldt-46496e3dc3f81ecf853ea8b7f1d469031ef44ac5.tar.gz
org.eclipse.koneki.ldt-46496e3dc3f81ecf853ea8b7f1d469031ef44ac5.tar.bz2
Bug 369986 - [Outline] Add 'Hide Local Functions' filter
-rwxr-xr-xplugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaEditor.java15
-rw-r--r--plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaOutlinePage.java78
-rw-r--r--plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.java35
-rw-r--r--plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.properties15
4 files changed, 140 insertions, 3 deletions
diff --git a/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaEditor.java b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaEditor.java
index bbca51e..ae224c3 100755
--- a/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaEditor.java
+++ b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaEditor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 Sierra Wireless and others.
+ * Copyright (c) 2009, 2012 Sierra Wireless 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
@@ -12,9 +12,11 @@
package org.eclipse.koneki.ldt.editor;
import org.eclipse.dltk.core.IDLTKLanguageToolkit;
-import org.eclipse.dltk.internal.ui.editor.BracketInserter;import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.internal.ui.editor.BracketInserter;
import org.eclipse.dltk.internal.ui.editor.ScriptEditor;
+import org.eclipse.dltk.internal.ui.editor.ScriptOutlinePage;
import org.eclipse.dltk.ui.DLTKUIPlugin;
import org.eclipse.dltk.ui.PreferenceConstants;
import org.eclipse.dltk.ui.text.ScriptTextTools;
@@ -121,7 +123,9 @@ public class LuaEditor extends ScriptEditor {
super.initializeEditor();
setEditorContextMenuId(EDITOR_CONTEXT);
}
- /** * @see org.eclipse.ui.part.EditorPart#setPartName(java.lang.String)
+
+ /**
+ * @see org.eclipse.ui.part.EditorPart#setPartName(java.lang.String)
*/
@Override
protected void setPartName(String partName) {
@@ -149,6 +153,11 @@ public class LuaEditor extends ScriptEditor {
}
@Override
+ protected ScriptOutlinePage doCreateOutlinePage() {
+ return new LuaOutlinePage(this, Activator.getDefault().getPreferenceStore());
+ }
+
+ @Override
public void createPartControl(final Composite parent) {
super.createPartControl(parent);
final ISourceViewer sourceViewer = getSourceViewer();
diff --git a/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaOutlinePage.java b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaOutlinePage.java
new file mode 100644
index 0000000..d727bda
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/LuaOutlinePage.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Marc-Andre Laperle 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc-Andre Laperle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.koneki.ldt.editor;
+
+import java.util.ArrayList;
+
+import org.eclipse.dltk.core.Flags;
+import org.eclipse.dltk.core.IMember;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.internal.ui.editor.IScriptEditor;
+import org.eclipse.dltk.internal.ui.editor.ScriptOutlinePage;
+import org.eclipse.dltk.ui.DLTKPluginImages;
+import org.eclipse.dltk.ui.actions.MemberFilterActionGroup;
+import org.eclipse.dltk.ui.viewsupport.AbstractModelElementFilter;
+import org.eclipse.dltk.ui.viewsupport.MemberFilterAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.ui.IActionBars;
+
+public class LuaOutlinePage extends ScriptOutlinePage {
+
+ public LuaOutlinePage(IScriptEditor editor, IPreferenceStore store) {
+ super(editor, store);
+ }
+
+ private class LocalFunctionFilter extends AbstractModelElementFilter {
+
+ public String getFilteringType() {
+ return "LocalFunctionFilter"; //$NON-NLS-1$
+ }
+
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ if (element instanceof IMember) {
+ IMember member = (IMember) element;
+ try {
+ if (member.getElementType() == IModelElement.METHOD && Flags.isPrivate(member.getFlags())) {
+ return false;
+ }
+ } catch (ModelException e) {
+ Activator.logError(Messages.MemberFilterActionGroup_hide_local_functions_error, e);
+ }
+ }
+ return true;
+ }
+ }
+
+ @Override
+ protected void registerSpecialToolbarActions(IActionBars actionBars) {
+ IToolBarManager toolBarManager = actionBars.getToolBarManager();
+
+ MemberFilterActionGroup memberFilterActionGroup = new MemberFilterActionGroup(fOutlineViewer, fStore);
+ ArrayList<MemberFilterAction> actions = new ArrayList<MemberFilterAction>(1);
+
+ // Hide local functions
+ String title = Messages.MemberFilterActionGroup_hide_local_functions_label;
+ LocalFunctionFilter filter = new LocalFunctionFilter();
+ MemberFilterAction hideLocalFunctionsAction = new MemberFilterAction(memberFilterActionGroup, title, filter, "", true); //$NON-NLS-1$
+ hideLocalFunctionsAction.setDescription(Messages.MemberFilterActionGroup_hide_local_functions_description);
+ hideLocalFunctionsAction.setToolTipText(Messages.MemberFilterActionGroup_hide_local_functions_tooltip);
+ DLTKPluginImages.setLocalImageDescriptors(hideLocalFunctionsAction, "filter_methods.gif"); //$NON-NLS-1$
+ actions.add(hideLocalFunctionsAction);
+
+ MemberFilterAction[] filterActions = (MemberFilterAction[]) actions.toArray(new MemberFilterAction[actions.size()]);
+ memberFilterActionGroup.setActions(filterActions);
+ memberFilterActionGroup.contributeToToolBar(toolBarManager);
+ }
+
+}
diff --git a/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.java b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.java
new file mode 100644
index 0000000..0f173e4
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Marc-Andre Laperle 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc-Andre Laperle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.koneki.ldt.editor;
+
+import org.eclipse.osgi.util.NLS;
+
+//CHECKSTYLE NLS: OFF
+public final class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.koneki.ldt.editor.Messages";//$NON-NLS-1$
+
+ private Messages() {
+ // Do not instantiate
+ }
+
+ public static String MemberFilterActionGroup_hide_local_functions_label;
+ public static String MemberFilterActionGroup_hide_local_functions_tooltip;
+ public static String MemberFilterActionGroup_hide_local_functions_description;
+
+ public static String MemberFilterActionGroup_hide_local_functions_error;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+}
+// CHECKSTYLE NLS: ON
diff --git a/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.properties b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.properties
new file mode 100644
index 0000000..84b6c9e
--- /dev/null
+++ b/plugins/org.eclipse.koneki.ldt.editor/src/org/eclipse/koneki/ldt/editor/Messages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2012 Marc-Andre Laperle 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
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Marc-Andre Laperle - initial API and implementation
+###############################################################################
+
+MemberFilterActionGroup_hide_local_functions_label= Hide Local &Functions
+MemberFilterActionGroup_hide_local_functions_tooltip= Hide Local Functions
+MemberFilterActionGroup_hide_local_functions_description= Toggles the visibility of local functions
+MemberFilterActionGroup_hide_local_functions_error=Error filtering local functions