diff options
author | ustieber | 2011-06-14 13:30:56 +0000 |
---|---|---|
committer | ustieber | 2011-06-14 13:30:56 +0000 |
commit | 6da38090a67db60b8d4edff78fea76122d26f63a (patch) | |
tree | b6e7a3711bb8202ab2594c26c6a900f5c77a4d3a | |
parent | 77e9298aa33c6470bab57447f65677bf8b35a384 (diff) | |
download | org.eclipse.tcf-6da38090a67db60b8d4edff78fea76122d26f63a.tar.gz org.eclipse.tcf-6da38090a67db60b8d4edff78fea76122d26f63a.tar.xz org.eclipse.tcf-6da38090a67db60b8d4edff78fea76122d26f63a.zip |
Target Explorer: Add filter for hidden and protected system files
5 files changed, 101 insertions, 2 deletions
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.properties b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.properties index 1cb3db872..648ef0ec3 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.properties @@ -14,3 +14,8 @@ providerName = Eclipse.org # ***** Editor Pages ***** FSExplorerEditorPage.name=File System + +# ***** Filter ***** + +FSTreeViewerFilter.hiddenFiles=Hidden files and folders (File System (TCF)) +FSTreeViewerFilter.systemFiles=Protected operating system files (File System (TCF)) diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.xml index b11f17de1..e1aa1a351 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/plugin.xml @@ -39,6 +39,20 @@ id="org.eclipse.tm.te.tcf.filesystem.navigator.sorter"> </commonSorter> </navigatorContent> + <commonFilter + activeByDefault="true" + class="org.eclipse.tm.te.tcf.filesystem.filters.HiddenFilesViewerFilter" + id="org.eclipse.tm.te.tcf.filesystem.navigator.filter.hiddenFiles" + name="%FSTreeViewerFilter.hiddenFiles" + visibleInUI="true"> + </commonFilter> + <commonFilter + activeByDefault="true" + class="org.eclipse.tm.te.tcf.filesystem.filters.SystemFilesViewerFilter" + id="org.eclipse.tm.te.tcf.filesystem.navigator.filter.systemFiles" + name="%FSTreeViewerFilter.systemFiles" + visibleInUI="true"> + </commonFilter> </extension> <!-- Target Explorer Details Editor page contributions --> diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/filters/HiddenFilesViewerFilter.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/filters/HiddenFilesViewerFilter.java new file mode 100644 index 000000000..fd381e2d4 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/filters/HiddenFilesViewerFilter.java @@ -0,0 +1,40 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Uwe Stieber (Wind River) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.tcf.filesystem.filters;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.tm.te.tcf.filesystem.interfaces.IWindowsFileAttributes;
+import org.eclipse.tm.te.tcf.filesystem.model.FSTreeNode;
+
+/**
+ * Target Explorer: A filter implementation filtering hidden files or directories.
+ */
+public class HiddenFilesViewerFilter extends ViewerFilter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ // The element needs to be a tree node, but not a root node
+ if (element instanceof FSTreeNode && !"FSRootDirNode".equals(((FSTreeNode)element).type)) { //$NON-NLS-1$
+ FSTreeNode node = (FSTreeNode)element;
+ // Check if the tree node has attributes associated
+ if (node.attr != null && node.attr.attributes.get("Win32Attrs") instanceof Integer) { //$NON-NLS-1$
+ Integer win32Attrs = (Integer)node.attr.attributes.get("Win32Attrs"); //$NON-NLS-1$
+ return (win32Attrs.intValue() & IWindowsFileAttributes.FILE_ATTRIBUTE_HIDDEN) == 0;
+ }
+ }
+ // Let pass all other elements unharmed
+ return true;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/filters/SystemFilesViewerFilter.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/filters/SystemFilesViewerFilter.java new file mode 100644 index 000000000..7b1e32978 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/filters/SystemFilesViewerFilter.java @@ -0,0 +1,40 @@ +/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Uwe Stieber (Wind River) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tm.te.tcf.filesystem.filters;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.tm.te.tcf.filesystem.interfaces.IWindowsFileAttributes;
+import org.eclipse.tm.te.tcf.filesystem.model.FSTreeNode;
+
+/**
+ * Target Explorer: A filter implementation filtering system files or directories.
+ */
+public class SystemFilesViewerFilter extends ViewerFilter {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ // The element needs to be a tree node, but not a root node
+ if (element instanceof FSTreeNode && !"FSRootDirNode".equals(((FSTreeNode)element).type)) { //$NON-NLS-1$
+ FSTreeNode node = (FSTreeNode)element;
+ // Check if the tree node has attributes associated
+ if (node.attr != null && node.attr.attributes.get("Win32Attrs") instanceof Integer) { //$NON-NLS-1$
+ Integer win32Attrs = (Integer)node.attr.attributes.get("Win32Attrs"); //$NON-NLS-1$
+ return (win32Attrs.intValue() & IWindowsFileAttributes.FILE_ATTRIBUTE_SYSTEM) == 0;
+ }
+ }
+ // Let pass all other elements unharmed
+ return true;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/interfaces/preferences/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/interfaces/preferences/IPreferenceKeys.java index 18c9fa6f9..47c68bbdd 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/interfaces/preferences/IPreferenceKeys.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.filesystem/src/org/eclipse/tm/te/tcf/filesystem/interfaces/preferences/IPreferenceKeys.java @@ -3,7 +3,7 @@ * 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: * Uwe Stieber (Wind River) - initial API and implementation *******************************************************************************/ @@ -20,7 +20,7 @@ public interface IPreferenceKeys { /** * If set to <code>true</code>, the file system content contribution to the target - * explorer details editor will be activaed and visible to the user. + * explorer details editor will be activated and visible to the user. */ public final String PREF_FEATURE_ENABLE_EDITOR_CONTENT_CONTRIBUTION = PREFIX + "feature.editor.content.enable"; //$NON-NLS-1$ } |