View | Details | Raw Unified | Return to bug 109045 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (+6 lines)
Lines 112-114 Link Here
112
proposalCategory.jspTemplates=JSP Template Proposals
112
proposalCategory.jspTemplates=JSP Template Proposals
113
proposalCategory.jsp=JSP Proposals
113
proposalCategory.jsp=JSP Proposals
114
proposalCategory.jspJava=JSP Java Proposals
114
proposalCategory.jspJava=JSP Java Proposals
115
116
##
117
HideImportDeclaration.label=Import Directive
118
HideImportDeclaration.description=Hides Import Directives
119
HideComments.label=Comments
120
HideComments.description=Hides Comments
(-)plugin.xml (+19 lines)
Lines 1329-1332 Link Here
1329
          contentTypeID="org.eclipse.jst.jsp.core.jspsource">
1329
          contentTypeID="org.eclipse.jst.jsp.core.jspsource">
1330
    </categoriesConfiguration>
1330
    </categoriesConfiguration>
1331
 </extension>
1331
 </extension>
1332
<extension
1333
	   point="org.eclipse.wst.sse.ui.outlineFilters">
1334
	   <filter
1335
	        targetId="org.eclipse.jst.jsp.ui.OutlinePage"
1336
	        name="%HideImportDeclaration.label"
1337
	        enabled="false"
1338
	        description="%HideImportDeclaration.description"
1339
	        class="org.eclipse.jst.jsp.ui.views.contentoutline.JSPImportDirectiveFilter"
1340
	        id="org.eclipse.jst.jsp.ui.views.contentoutline.JSPImportDirectiveFilter">
1341
	   </filter>
1342
	   <filter
1343
            targetId="org.eclipse.jst.jsp.ui.OutlinePage"
1344
            name="%HideComments.label"
1345
            enabled="false"
1346
            description="%HideComments.description"
1347
            class="org.eclipse.wst.xml.ui.views.contentoutline.XMLCommentFilter"
1348
            id="org.eclipse.jst.jsp.ui.views.contentoutline.XMLCommentFilter">
1349
      </filter>
1350
</extension>
1332
</plugin>
1351
</plugin>
(-)src/org/eclipse/jst/jsp/ui/internal/views/contentoutline/TLDContentOutlineConfiguration.java (-3 / +3 lines)
Lines 278-285 Link Here
278
			update();
278
			update();
279
		}
279
		}
280
280
281
		/*
281
		
282
		 * (non-Javadoc)
282
		/* (non-Javadoc)
283
		 * 
283
		 * 
284
		 * @see org.eclipse.ui.texteditor.IUpdate#update()
284
		 * @see org.eclipse.ui.texteditor.IUpdate#update()
285
		 */
285
		 */
Lines 343-349 Link Here
343
	 * org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration
343
	 * org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration
344
	 * #getPreferenceStore()
344
	 * #getPreferenceStore()
345
	 */
345
	 */
346
	protected IPreferenceStore getPreferenceStore() {
346
	public IPreferenceStore getPreferenceStore() {
347
		return JSPUIPlugin.getDefault().getPreferenceStore();
347
		return JSPUIPlugin.getDefault().getPreferenceStore();
348
	}
348
	}
349
}
349
}
(-)src/org/eclipse/jst/jsp/ui/views/contentoutline/JSPContentOutlineConfiguration.java (-2 / +6 lines)
Lines 35-41 Link Here
35
	// be used
35
	// be used
36
	// private StructuredContentOutlineConfiguration fEmbeddedConfiguration =
36
	// private StructuredContentOutlineConfiguration fEmbeddedConfiguration =
37
	// null;
37
	// null;
38
38
	private final String OUTLINE_FILTER_PREF = "org.eclipse.jst.jsp.ui.OutlinePage"; //$NON-NLS-1$
39
	/**
39
	/**
40
	 * Create new instance of JSPContentOutlineConfiguration
40
	 * Create new instance of JSPContentOutlineConfiguration
41
	 */
41
	 */
Lines 49-59 Link Here
49
	 * 
49
	 * 
50
	 * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getPreferenceStore()
50
	 * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getPreferenceStore()
51
	 */
51
	 */
52
	protected IPreferenceStore getPreferenceStore() {
52
	public IPreferenceStore getPreferenceStore() {
53
		return JSPUIPlugin.getDefault().getPreferenceStore();
53
		return JSPUIPlugin.getDefault().getPreferenceStore();
54
	}
54
	}
55
	
55
	
56
	protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
56
	protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
57
		return new JSPNodeActionManager((IStructuredModel) treeViewer.getInput(), treeViewer);
57
		return new JSPNodeActionManager((IStructuredModel) treeViewer.getInput(), treeViewer);
58
	}
58
	}
59
	
60
	public String getOutlineFilterTarget(){
61
		return OUTLINE_FILTER_PREF ;
62
	}
59
}
63
}
(-)src/org/eclipse/jst/jsp/ui/views/contentoutline/JSPImportDirectiveFilter.java (+44 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jst.jsp.ui.views.contentoutline;
12
13
import org.eclipse.jdt.internal.ui.filters.ImportDeclarationFilter;
14
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.JSP20TLDNames;
16
import org.eclipse.jst.jsp.core.internal.provisional.JSP11Namespace;
17
import org.w3c.dom.NamedNodeMap;
18
import org.w3c.dom.Node;
19
20
public class JSPImportDirectiveFilter extends ImportDeclarationFilter {
21
22
23
	/*
24
	 * @see ViewerFilter
25
	 */
26
	public boolean select(Viewer viewer, Object parent, Object element) {
27
		if (super.select(viewer, parent, element)){
28
			if (element instanceof Node){
29
				Node node = (Node)element;
30
				if (node.getNodeName().equalsIgnoreCase(JSP11Namespace.ElementName.DIRECTIVE_PAGE)){
31
						NamedNodeMap nodeMap = node.getAttributes();
32
						for (int i=0;i <nodeMap.getLength();i++){
33
							Node attr = nodeMap.item(i);
34
							if (attr.toString().equalsIgnoreCase(JSP20TLDNames.IMPORT))
35
								return false;
36
						}
37
				}
38
			}
39
			return true;
40
		}
41
		else
42
			return false;
43
	}
44
}
(-)plugin.properties (+3 lines)
Lines 82-84 Link Here
82
82
83
proposalCategory.css=CSS Proposals
83
proposalCategory.css=CSS Proposals
84
proposalCategory.cssTemplates=CSS Template Proposals
84
proposalCategory.cssTemplates=CSS Template Proposals
85
86
HideComments.label=Comments
87
HideComments.description=Hides Comments
(-)plugin.xml (+11 lines)
Lines 738-741 Link Here
738
          contentTypeID="org.eclipse.wst.css.core.csssource">
738
          contentTypeID="org.eclipse.wst.css.core.csssource">
739
    </categoriesConfiguration>
739
    </categoriesConfiguration>
740
 </extension>
740
 </extension>
741
 <extension
742
      point="org.eclipse.wst.sse.ui.outlineFilters">
743
      <filter
744
            targetId="org.eclipse.wst.css.ui.OutlinePage"
745
            name="%HideComments.label"
746
            enabled="false"
747
            description="%HideComments.description"
748
            class="org.eclipse.wst.xml.ui.views.contentoutline.XMLCommentFilter"
749
            id="org.eclipse.wst.css.ui.views.contentoutline.XMLCommentFilter">
750
      </filter>
751
</extension>
741
</plugin>
752
</plugin>
(-)src/org/eclipse/wst/css/ui/views/contentoutline/CSSContentOutlineConfiguration.java (+6 lines)
Lines 33-38 Link Here
33
	private IContentProvider fContentProvider = null;
33
	private IContentProvider fContentProvider = null;
34
	private ILabelProvider fLabelProvider = null;
34
	private ILabelProvider fLabelProvider = null;
35
	private final String OUTLINE_SORT_PREF = "outline-sort"; //$NON-NLS-1$
35
	private final String OUTLINE_SORT_PREF = "outline-sort"; //$NON-NLS-1$
36
	private final String OUTLINE_FILTER_PREF = "org.eclipse.wst.css.ui.OutlinePage"; //$NON-NLS-1$
37
	
36
38
37
	/**
39
	/**
38
	 * Create new instance of CSSContentOutlineConfiguration
40
	 * Create new instance of CSSContentOutlineConfiguration
Lines 118-121 Link Here
118
		}
120
		}
119
		return filteredSelection;
121
		return filteredSelection;
120
	}
122
	}
123
	
124
	protected String getOutlineFilterTarget(){
125
		return OUTLINE_FILTER_PREF ;
126
	}
121
}
127
}
(-)src/org/eclipse/wst/dtd/ui/views/contentoutline/DTDContentOutlineConfiguration.java (-1 / +6 lines)
Lines 59-65 Link Here
59
	private Map fViewerContributions;
59
	private Map fViewerContributions;
60
	private final String OUTLINE_ORDER_PREF = "outline-order"; //$NON-NLS-1$
60
	private final String OUTLINE_ORDER_PREF = "outline-order"; //$NON-NLS-1$
61
	private final String OUTLINE_SORT_PREF = "outline-sort"; //$NON-NLS-1$
61
	private final String OUTLINE_SORT_PREF = "outline-sort"; //$NON-NLS-1$
62
62
	private final String OUTLINE_FILTER_PREF = "org.eclipse.wst.dtd.ui.OutlinePage"; //$NON-NLS-1$
63
	
63
	/**
64
	/**
64
	 * Default constructor for DTDContentOutlineConfiguration.
65
	 * Default constructor for DTDContentOutlineConfiguration.
65
	 */
66
	 */
Lines 279-282 Link Here
279
			fMenuHelper = null;
280
			fMenuHelper = null;
280
		}
281
		}
281
	}
282
	}
283
	
284
	protected String getOutlineFilterTarget(){
285
		return OUTLINE_FILTER_PREF ;
286
	}
282
}
287
}
(-)plugin.properties (+3 lines)
Lines 80-82 Link Here
80
80
81
proposalCategory.htmlTags=HTML Tag Proposals
81
proposalCategory.htmlTags=HTML Tag Proposals
82
proposalCategory.htmlTemplates=HTML Template Proposals
82
proposalCategory.htmlTemplates=HTML Template Proposals
83
84
HideComments.label=Comments
85
HideComments.description=Hides Comments
(-)plugin.xml (+12 lines)
Lines 700-704 Link Here
700
          contentTypeID="org.eclipse.wst.html.core.htmlsource">
700
          contentTypeID="org.eclipse.wst.html.core.htmlsource">
701
    </categoriesConfiguration>
701
    </categoriesConfiguration>
702
 </extension>
702
 </extension>
703
 
704
<extension
705
      point="org.eclipse.wst.sse.ui.outlineFilters">
706
      <filter
707
            targetId="org.eclipse.wst.html.ui.OutlinePage"
708
            name="%HideComments.label"
709
            enabled="false"
710
            description="%HideComments.description"
711
            class="org.eclipse.wst.xml.ui.views.contentoutline.XMLCommentFilter"
712
            id="org.eclipse.wst.html.ui.views.contentoutline.XMLCommentFilter">
713
      </filter>
714
</extension>
703
	
715
	
704
</plugin>
716
</plugin>
(-)src/org/eclipse/wst/html/ui/views/contentoutline/HTMLContentOutlineConfiguration.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2005 IBM Corporation and others.
2
 * Copyright (c) 2004, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 25-31 Link Here
25
 * @since 1.0
25
 * @since 1.0
26
 */
26
 */
27
public class HTMLContentOutlineConfiguration extends XMLContentOutlineConfiguration {
27
public class HTMLContentOutlineConfiguration extends XMLContentOutlineConfiguration {
28
28
	private final String OUTLINE_FILTER_PREF = "org.eclipse.wst.html.ui.OutlinePage"; //$NON-NLS-1$
29
	/**
29
	/**
30
	 * Create new instance of HTMLContentOutlineConfiguration
30
	 * Create new instance of HTMLContentOutlineConfiguration
31
	 */
31
	 */
Lines 41-44 Link Here
41
	protected IPreferenceStore getPreferenceStore() {
41
	protected IPreferenceStore getPreferenceStore() {
42
		return HTMLUIPlugin.getDefault().getPreferenceStore();
42
		return HTMLUIPlugin.getDefault().getPreferenceStore();
43
	}
43
	}
44
	
45
	protected String getOutlineFilterTarget(){
46
		return OUTLINE_FILTER_PREF ;
47
	}
44
}
48
}
(-)plugin.properties (+5 lines)
Lines 109-111 Link Here
109
Colors.content_assist_proposals_foreground=Content Assist Proposals Foreground
109
Colors.content_assist_proposals_foreground=Content Assist Proposals Foreground
110
Colors.content_assist_parameters_background=Content Assist Parameters Background
110
Colors.content_assist_parameters_background=Content Assist Parameters Background
111
Colors.content_assist_parameters_foreground=Content Assist Parameters Foreground
111
Colors.content_assist_parameters_foreground=Content Assist Parameters Foreground
112
113
#outline filter
114
outlineFiltersName=Outline Filters
115
116
command.outline.customFilter=Filters
(-)plugin.xml (-2 / +45 lines)
Lines 23-30 Link Here
23
		id="characterPairing"
23
		id="characterPairing"
24
		name="%Character_Pairing.name"
24
		name="%Character_Pairing.name"
25
		schema="schema/characterPairing.exsd" ></extension-point>
25
		schema="schema/characterPairing.exsd" ></extension-point>
26
26
	<extension-point
27
27
	   id="outlineFilters" 
28
	   name="%outlineFiltersName" 
29
	   schema="schema/outlineFilters.exsd">
30
	</extension-point>
31
  
28
	<!-- Make sure default preference values are set at runtime -->
32
	<!-- Make sure default preference values are set at runtime -->
29
	<extension point="org.eclipse.core.runtime.preferences">
33
	<extension point="org.eclipse.core.runtime.preferences">
30
		<initializer
34
		<initializer
Lines 679-688 Link Here
679
				</command>
683
				</command>
680
				
684
				
681
	     </menuContribution>
685
	     </menuContribution>
686
	     <!-- content outline  -->
687
	     <menuContribution locationURI="menu:org.eclipse.ui.views.ContentOutline?after=additions">
688
			<command 
689
				commandId="org.eclipse.wst.sse.ui.outline.customFilter" 
690
				id="org.eclipse.wst.sse.ui.outline.customFilter"
691
				label="%command.outline.customFilter" 
692
				icon ="icons/full/elcl16/filter_ps.gif"
693
				style="push">
694
		        <visibleWhen checkEnabled="false">
695
				   <with variable="activeEditor">
696
				   <test
697
                        property="org.eclipse.wst.sse.ui.outline.isConfigurableOutlinePage"
698
                        value="true">
699
                  </test>
700
       					
701
    				</with>
702
				</visibleWhen>
703
			</command>
704
		</menuContribution>
682
	</extension>
705
	</extension>
683
	<extension
706
	<extension
684
       point="org.eclipse.ui.commands">
707
       point="org.eclipse.ui.commands">
685
	    <command
708
	    <command
709
	          id="org.eclipse.wst.sse.ui.outline.customFilter"
710
	          name="%command.outline.customFilter">
711
	    </command>
712
	    <command
686
	          id="org.eclipse.wst.sse.ui.format"
713
	          id="org.eclipse.wst.sse.ui.format"
687
	          name="%command.format.document.name">
714
	          name="%command.format.document.name">
688
	    </command>
715
	    </command>
Lines 708-713 Link Here
708
				</iterate>
735
				</iterate>
709
			</enabledWhen>
736
			</enabledWhen>
710
		</handler>
737
		</handler>
738
		
739
		<handler
740
			class="org.eclipse.wst.sse.ui.internal.handlers.CustomFilterHandler"
741
			commandId="org.eclipse.wst.sse.ui.outline.customFilter">
742
		</handler>
743
		
711
	</extension>
744
	</extension>
712
	
745
	
713
	<extension point="org.eclipse.core.expressions.definitions">
746
	<extension point="org.eclipse.core.expressions.definitions">
Lines 768-772 Link Here
768
		</colorDefinition>
801
		</colorDefinition>
769
	</extension>
802
	</extension>
770
	
803
	
804
	<extension
805
         point="org.eclipse.core.expressions.propertyTesters">
806
      <propertyTester
807
            class="org.eclipse.wst.sse.ui.internal.handlers.CustomFilterPropertyTester"
808
            id="org.eclipse.wst.sse.ui.internal.handlers.CustomFilterPropertyTester"
809
            namespace="org.eclipse.wst.sse.ui.outline"
810
            properties="isConfigurableOutlinePage"
811
            type="org.eclipse.ui.IEditorPart">
812
      </propertyTester>
813
   </extension>
771
</plugin>
814
</plugin>
772
815
(-)schema/outlineFilters.exsd (+136 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.wst.sse.ui" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.wst.sse.ui" id="outlineFilters" name="%outlineFiltersName"/>
7
      </appInfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence>
21
            <element ref="filter" minOccurs="1" maxOccurs="unbounded"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  a fully qualified identifier of the target extension point
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  an optional identifier of the extension instance
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  an optional name of the extension instance
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="filter">
51
      <annotation>
52
         <appInfo>
53
            <meta.element labelAttribute="name"/>
54
         </appInfo>
55
      </annotation>
56
      <complexType>
57
         <attribute name="id" type="string">
58
            <annotation>
59
               <documentation>
60
                  a unique id that will be used to identify this filter
61
               </documentation>
62
            </annotation>
63
         </attribute>
64
         <attribute name="name" type="string">
65
            <annotation>
66
               <documentation>
67
                  a unique name that allows to identify this filter in the UI. This attribute should be a translated string. Though this attribute is not required for pattern filters (i.e. those using the &lt;samp&gt;pattern&lt;/samp&gt; attribute) we suggest to provide a name anyway, otherwise the pattern string itself would be used to represent the filter in the UI.
68
               </documentation>
69
               <appInfo>
70
                  <meta.attribute translatable="true"/>
71
               </appInfo>
72
            </annotation>
73
         </attribute>
74
         <attribute name="description" type="string">
75
            <annotation>
76
               <documentation>
77
                  a short description for this filter
78
               </documentation>
79
               <appInfo>
80
                  <meta.attribute translatable="true"/>
81
               </appInfo>
82
            </annotation>
83
         </attribute>
84
         <attribute name="targetId" type="string">
85
            <annotation>
86
               <documentation>
87
                  the id of the target where this filter is contributed.  If this attribute is missing, then the filter will
88
be contributed to all views which use the &lt;code&gt;org.eclipse.wst.sse.ui.actions.CustomFiltersAction&lt;/code&gt;.
89
               </documentation>
90
            </annotation>
91
         </attribute>
92
         <attribute name="enabled" type="boolean">
93
            <annotation>
94
               <documentation>
95
                  the filter will be enabled if this attribute is &quot;true&quot; or if this attribute is not present. Most likely the user will be able to override this setting in the UI.
96
               </documentation>
97
            </annotation>
98
         </attribute>
99
         <attribute name="class" type="string">
100
            <annotation>
101
               <documentation>
102
                  the name of the class used to filter the view.  The class must extend &lt;code&gt;org.eclipse.jface.viewers.ViewerFilter&lt;/code&gt;. If this attribute is here
103
then the pattern attribute must not provided.
104
               </documentation>
105
               <appInfo>
106
                  <meta.attribute kind="java" basedOn="org.eclipse.jface.viewers.ViewerFilter"/>
107
               </appInfo>
108
            </annotation>
109
         </attribute>
110
      </complexType>
111
   </element>
112
113
114
   <annotation>
115
      <appInfo>
116
         <meta.section type="examples"/>
117
      </appInfo>
118
      <documentation>
119
         Works similar to javaElementFilter definition with targetId as &quot;org.wst.sse.ui.OutlinePage&quot;.
120
         Target id can be changed for different content types to provide their own filters
121
      </documentation>
122
   </annotation>
123
124
125
126
   <annotation>
127
      <appInfo>
128
         <meta.section type="copyright"/>
129
      </appInfo>
130
      <documentation>
131
         Copyright (c) 2010 IBM Corporation and others.&lt;br&gt;
132
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 &lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
133
      </documentation>
134
   </annotation>
135
136
</schema>
(-)src/org/eclipse/wst/sse/ui/internal/contentoutline/ConfigurableContentOutlinePage.java (+1 lines)
Lines 579-584 Link Here
579
		}
579
		}
580
580
581
		fConfiguration = configuration;
581
		fConfiguration = configuration;
582
		fConfiguration.setViewer(getTreeViewer());
582
583
583
		if (getTreeViewer() != null && getControl() != null && !getControl().isDisposed()) {
584
		if (getTreeViewer() != null && getControl() != null && !getControl().isDisposed()) {
584
			// (re)set the providers
585
			// (re)set the providers
(-)src/org/eclipse/wst/sse/ui/internal/filter/CustomFilterProcessor.java (+325 lines)
Added Link Here
1
/*******************************************************************************
2
	 * Copyright (c) 2010 IBM Corporation and others.
3
	 * All rights reserved. This program and the accompanying materials
4
	 * are made available under the terms of the Eclipse Public License v1.0
5
	 * which accompanies this distribution, and is available at
6
	 * http://www.eclipse.org/legal/epl-v10.html
7
	 *
8
	 * Contributors:
9
	 *     IBM Corporation - initial API and implementation
10
	 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
import java.util.ArrayList;
13
import java.util.HashMap;
14
import java.util.HashSet;
15
import java.util.Iterator;
16
import java.util.Map;
17
18
import org.eclipse.core.runtime.Assert;
19
import org.eclipse.jface.preference.IPreferenceStore;
20
import org.eclipse.jface.viewers.StructuredViewer;
21
import org.eclipse.jface.viewers.ViewerFilter;
22
import org.eclipse.jface.window.Window;
23
24
	/**
25
	 * Action group to add the filter action to a view part's tool bar
26
	 * menu.
27
	 * <p>
28
	 * This class may be instantiated; it is not intended to be subclassed.
29
	 * </p>
30
	 *
31
	 * @noextend This class is not intended to be subclassed by clients.
32
	 */
33
	public class CustomFilterProcessor  {
34
35
		
36
		private static final String SEPARATOR= ",";  //$NON-NLS-1$
37
		private final String TAG_USER_DEFINED_PATTERNS_ENABLED= "userDefinedPatternsEnabled"; //$NON-NLS-1$
38
		private final String TAG_USER_DEFINED_PATTERNS= "userDefinedPatterns"; //$NON-NLS-1$
39
		
40
		
41
		private static class FilterItem {
42
			boolean enabled;
43
			boolean previouslyEnabled;
44
			OutlineFilterDescriptor descriptor;
45
			String id;
46
47
			private ViewerFilter filterInstance= null;
48
49
			public FilterItem(OutlineFilterDescriptor descriptor) {
50
				this.descriptor= descriptor;
51
				this.id= descriptor.getId();
52
				this.previouslyEnabled= false;
53
				this.enabled= descriptor.isEnabled();
54
			}
55
56
			public ViewerFilter getFilterInstance() {
57
				if (filterInstance == null) {
58
					filterInstance= descriptor.createViewerFilter();
59
				}
60
				return filterInstance;
61
62
			}
63
		}
64
65
66
		private final StructuredViewer fViewer;
67
		private final OutlineNamePatternFilter fPatternFilter;
68
69
		private boolean fUserDefinedPatternsEnabled;
70
		private String[] fUserDefinedPatterns;
71
72
		private String[] fPreviousPatterns;
73
74
		private final Map fFilterItems;
75
76
77
		
78
		private final String fTargetId;
79
		private IPreferenceStore fStore;
80
		
81
82
		/**
83
		 * Creates a new <code>CustomFilterAction</code>.
84
		 *
85
		 * @param store     the preference Store 
86
		 * @param ownerId	the id of this action group's owner
87
		 * @param viewer	the viewer to be filtered
88
		 */
89
		public CustomFilterProcessor(IPreferenceStore store,String ownerId, StructuredViewer viewer) {
90
			Assert.isNotNull(ownerId);
91
			Assert.isNotNull(viewer);
92
			fStore = store;
93
			fTargetId= ownerId;
94
			fViewer= viewer;
95
			fPatternFilter= new OutlineNamePatternFilter();
96
97
			fUserDefinedPatterns= new String[0];
98
			fUserDefinedPatternsEnabled= false;
99
			fPreviousPatterns= new String[0];
100
101
			fFilterItems= new HashMap();
102
			OutlineFilterDescriptor[] filterDescriptors= OutlineFilterDescriptor.getFilterDescriptors(fTargetId);
103
			for (int i= 0; i < filterDescriptors.length; i++) {
104
				FilterItem item= new FilterItem(filterDescriptors[i]);
105
				fFilterItems.put(item.id, item);
106
				
107
			}
108
109
			initializeWithViewDefaults();
110
111
			updateViewerFilters();
112
					
113
		}
114
		
115
		
116
		
117
118
		/*
119
		 * @see org.eclipse.jface.action.IContributionItem#isDynamic()
120
		 */
121
		public boolean isDynamic() {
122
			return true;
123
		}
124
		/**
125
		 * Returns a list of currently enabled filters. The filter
126
		 * is identified by its id.
127
		 * <p>
128
		 * This method is for internal use only and should not
129
		 * be called by clients outside of JDT/UI.
130
		 * </p>
131
		 *
132
		 * @return a list of currently enabled filters
133
		 *
134
		 * @noreference This method is not intended to be referenced by clients.
135
		 */
136
		public String[] internalGetEnabledFilterIds() {
137
			ArrayList enabledFilterIds= new ArrayList();
138
			for (Iterator iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
139
				FilterItem item= (FilterItem) iterator.next();
140
				if (item.enabled) {
141
					enabledFilterIds.add(item.id);
142
				}
143
			}
144
			return (String[])enabledFilterIds.toArray(new String[enabledFilterIds.size()]);
145
		}
146
147
		private void setEnabledFilterIds(String[] enabledIds) {
148
			// set all to false
149
			fUserDefinedPatternsEnabled= false;
150
			for (Iterator iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
151
				FilterItem item= (FilterItem) iterator.next();
152
				item.enabled= false;
153
			}
154
			// set enabled to true
155
			for (int i= 0; i < enabledIds.length; i++) {
156
				FilterItem item= (FilterItem) fFilterItems.get(enabledIds[i]);
157
				if (item != null) {
158
					item.enabled= true;
159
				}
160
				if (fPatternFilter.getClass().getName().equals(enabledIds[i]))
161
					fUserDefinedPatternsEnabled= true;
162
			}
163
		}
164
165
		private void setUserDefinedPatterns(String[] patterns) {
166
			fUserDefinedPatterns= patterns;
167
		}
168
169
170
		private boolean areUserDefinedPatternsEnabled() {
171
			return fUserDefinedPatternsEnabled;
172
		}
173
174
		private void setUserDefinedPatternsEnabled(boolean state) {
175
			fUserDefinedPatternsEnabled= state;
176
		}
177
178
				
179
		// ---------- viewer filter handling ----------
180
181
		private boolean updateViewerFilters() {
182
			ViewerFilter[] installedFilters= fViewer.getFilters();
183
			ArrayList viewerFilters= new ArrayList(installedFilters.length);
184
			
185
			HashSet patterns= new HashSet();
186
187
			boolean hasChange= false;
188
			boolean patternChange= false;
189
190
			for (Iterator iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
191
				FilterItem item= (FilterItem) iterator.next();
192
				if (item.descriptor.isCustomFilter()) {
193
					if (item.enabled != item.previouslyEnabled) {
194
						hasChange = true;
195
					}
196
					if (item.enabled){
197
						ViewerFilter filter= item.getFilterInstance(); // only create when changed
198
						if (filter != null) {
199
							viewerFilters.add(filter);
200
						}
201
					}
202
				} else if (item.descriptor.isPatternFilter()) {
203
					if (item.enabled) {
204
						patterns.add(item.descriptor.getPattern());
205
					}
206
					patternChange |= (item.enabled != item.previouslyEnabled);
207
				}
208
				item.previouslyEnabled= item.enabled;
209
			}
210
211
			if (areUserDefinedPatternsEnabled()) {
212
				for (int i= 0; i < fUserDefinedPatterns.length; i++) {
213
					patterns.add(fUserDefinedPatterns[i]);
214
				}
215
			}
216
			if (!patternChange) { // no pattern change so far, test if the user patterns made a difference
217
				patternChange= hasChanges(patterns, fPreviousPatterns);
218
			}
219
220
			fPreviousPatterns= (String[]) patterns.toArray(new String[patterns.size()]);
221
			if (patternChange) {
222
				fPatternFilter.setPatterns(fPreviousPatterns);
223
				if (patterns.isEmpty()) {
224
					viewerFilters.remove(fPatternFilter);
225
				} else if (!viewerFilters.contains(fPatternFilter)) {
226
					boolean contains = false;
227
					for (int i=0; i< viewerFilters.size();i++){
228
						if (viewerFilters.get(i) instanceof OutlineNamePatternFilter){
229
							OutlineNamePatternFilter filter = (OutlineNamePatternFilter)viewerFilters.get(i);
230
							String[] a1 =filter.getPatterns();
231
							String[] a2 =fPatternFilter.getPatterns();
232
							if (a1[0].equals(a2[0]))
233
								contains= true;
234
							else {
235
								viewerFilters.remove(i);
236
							}
237
							break;
238
						}
239
					}
240
					if (!contains)
241
						viewerFilters.add(fPatternFilter);
242
				}
243
				hasChange= true;
244
			}
245
			if (hasChange) {
246
				fViewer.setFilters((ViewerFilter[]) viewerFilters.toArray(new ViewerFilter[viewerFilters.size()])); // will refresh
247
			}
248
			return hasChange;
249
		}
250
251
		private boolean hasChanges(HashSet patterns, String[] oldPatterns) {
252
			HashSet copy= (HashSet) patterns.clone();
253
			for (int i= 0; i < oldPatterns.length; i++) {
254
				boolean found= copy.remove(oldPatterns[i]);
255
				if (!found)
256
					return true;
257
			}
258
			return !copy.isEmpty();
259
		}
260
261
		// ---------- view kind/defaults persistency ----------
262
263
		private void initializeWithViewDefaults() {
264
			// get default values for view
265
			
266
			
267
			fUserDefinedPatternsEnabled= fStore.getBoolean(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED));
268
			setUserDefinedPatterns(OutlineCustomFiltersDialog.convertFromString(fStore.getString(getPreferenceKey(TAG_USER_DEFINED_PATTERNS)), SEPARATOR));
269
270
			for (Iterator iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
271
				FilterItem item= (FilterItem) iterator.next();
272
				String id= item.id;
273
				// set default to value from plugin contributions (fixes https://bugs.eclipse.org/bugs/show_bug.cgi?id=73991 ):
274
				fStore.setDefault(id, item.descriptor.isEnabled());
275
				item.enabled= fStore.getBoolean(id);
276
			}
277
		
278
		}
279
280
		private void storeViewDefaults() {
281
			// get default values for view
282
			
283
			fStore.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS_ENABLED), fUserDefinedPatternsEnabled);
284
			fStore.setValue(getPreferenceKey(TAG_USER_DEFINED_PATTERNS), OutlineCustomFiltersDialog.convertToString(fUserDefinedPatterns ,SEPARATOR));
285
286
			boolean fFilterSelected = false;
287
			for (Iterator iterator= fFilterItems.values().iterator(); iterator.hasNext();) {
288
				FilterItem item= (FilterItem) iterator.next();
289
				fStore.setValue(item.id, item.enabled);
290
				if (item.enabled)
291
					fFilterSelected = true;
292
			}
293
294
			fStore.setValue(fTargetId, fUserDefinedPatternsEnabled || fFilterSelected);
295
			
296
		}
297
298
		private String getPreferenceKey(String tag) {
299
			return "CustomFiltersActionGroup." + fTargetId + '.' + tag; //$NON-NLS-1$
300
		}
301
302
		
303
		public void openDialog() {
304
			OutlineCustomFiltersDialog dialog= new OutlineCustomFiltersDialog(
305
				fViewer.getControl().getShell(),
306
				fTargetId,
307
				areUserDefinedPatternsEnabled(),
308
				fUserDefinedPatterns,
309
				internalGetEnabledFilterIds());
310
311
			if (dialog.open() == Window.OK) {
312
313
				setEnabledFilterIds(dialog.getEnabledFilterIds());
314
				setUserDefinedPatternsEnabled(dialog.areUserDefinedPatternsEnabled());
315
				setUserDefinedPatterns(dialog.getUserDefinedPatterns());
316
				storeViewDefaults();
317
318
				updateViewerFilters();
319
			}
320
			else {
321
				storeViewDefaults();
322
			}
323
		}
324
	}
325
(-)src/org/eclipse/wst/sse/ui/internal/filter/OutlineCustomFiltersDialog.java (+416 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
13
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Set;
19
import java.util.Stack;
20
import java.util.StringTokenizer;
21
22
import org.eclipse.core.runtime.Assert;
23
import org.eclipse.jface.dialogs.IDialogConstants;
24
import org.eclipse.jface.viewers.ArrayContentProvider;
25
import org.eclipse.jface.viewers.CheckStateChangedEvent;
26
import org.eclipse.jface.viewers.CheckboxTableViewer;
27
import org.eclipse.jface.viewers.ICheckStateListener;
28
import org.eclipse.jface.viewers.ILabelProvider;
29
import org.eclipse.jface.viewers.ISelection;
30
import org.eclipse.jface.viewers.ISelectionChangedListener;
31
import org.eclipse.jface.viewers.IStructuredSelection;
32
import org.eclipse.jface.viewers.LabelProvider;
33
import org.eclipse.jface.viewers.SelectionChangedEvent;
34
import org.eclipse.swt.SWT;
35
import org.eclipse.swt.events.SelectionAdapter;
36
import org.eclipse.swt.events.SelectionEvent;
37
import org.eclipse.swt.events.SelectionListener;
38
import org.eclipse.swt.graphics.Image;
39
import org.eclipse.swt.layout.GridData;
40
import org.eclipse.swt.layout.GridLayout;
41
import org.eclipse.swt.widgets.Button;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Control;
44
import org.eclipse.swt.widgets.Label;
45
import org.eclipse.swt.widgets.Shell;
46
import org.eclipse.swt.widgets.Text;
47
import org.eclipse.ui.PlatformUI;
48
import org.eclipse.ui.dialogs.SelectionDialog;
49
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
50
51
52
public class OutlineCustomFiltersDialog extends SelectionDialog {
53
54
	private static final String SEPARATOR= ",";  //$NON-NLS-1$
55
56
	private String fViewId;
57
	private boolean fEnablePatterns;
58
	private String[] fPatterns;
59
	private String[] fEnabledFilterIds;
60
61
	private OutlineFilterDescriptor[] fBuiltInFilters;
62
63
	private CheckboxTableViewer fCheckBoxList;
64
	private Button fEnableUserDefinedPatterns;
65
	private Text fUserDefinedPatterns;
66
67
	private Stack fFilterDescriptorChangeHistory;
68
69
70
	/**
71
	 * Creates a dialog to customize Java element filters.
72
	 *
73
	 * @param shell the parent shell
74
	 * @param viewId the id of the view
75
	 * @param enablePatterns <code>true</code> if pattern filters are enabled
76
	 * @param patterns the filter patterns
77
	 * @param enabledFilterIds the Ids of the enabled filters
78
	 */
79
	public OutlineCustomFiltersDialog(
80
			Shell shell,
81
			String viewId,
82
			boolean enablePatterns,
83
			String[] patterns,
84
			String[] enabledFilterIds) {
85
86
		super(shell);
87
		Assert.isNotNull(viewId);
88
		Assert.isNotNull(patterns);
89
		Assert.isNotNull(enabledFilterIds);
90
91
		fViewId= viewId;
92
		fPatterns= patterns;
93
		fEnablePatterns= enablePatterns;
94
		fEnabledFilterIds= enabledFilterIds;
95
96
		fBuiltInFilters= OutlineFilterDescriptor.getFilterDescriptors(fViewId);
97
		fFilterDescriptorChangeHistory= new Stack();
98
	}
99
	public static final String CUSTOM_FILTERS_DIALOG= SSEUIPlugin.ID + "." + "open_custom_filters_dialog_context"; //$NON-NLS-1$
100
	protected void configureShell(Shell shell) {
101
		setTitle(OutlineFilterMessages.CustomFiltersDialog_title);
102
		setMessage(OutlineFilterMessages.CustomFiltersDialog_filterList_label);
103
		super.configureShell(shell);
104
		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell, CUSTOM_FILTERS_DIALOG);
105
	}
106
107
	/**
108
	 * Overrides method in Dialog
109
	 *
110
	 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
111
	 */
112
	protected Control createDialogArea(Composite parent) {
113
		initializeDialogUnits(parent);
114
		// create a composite with standard margins and spacing
115
		Composite composite= new Composite(parent, SWT.NONE);
116
		GridLayout layout= new GridLayout();
117
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
118
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
119
		layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
120
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
121
		composite.setLayout(layout);
122
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
123
		composite.setFont(parent.getFont());
124
		Composite group= composite;
125
126
		// Checkbox
127
		fEnableUserDefinedPatterns= new Button(group, SWT.CHECK);
128
		fEnableUserDefinedPatterns.setFocus();
129
		fEnableUserDefinedPatterns.setText(OutlineFilterMessages.CustomFiltersDialog_enableUserDefinedPattern);
130
131
		// Pattern	field
132
		fUserDefinedPatterns= new Text(group, SWT.SINGLE | SWT.BORDER);
133
		GridData  data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
134
		data.widthHint= convertWidthInCharsToPixels(59);
135
		fUserDefinedPatterns.setLayoutData(data);
136
		String patterns= convertToString(fPatterns, SEPARATOR);
137
		fUserDefinedPatterns.setText(patterns);
138
		SWTUtil.setAccessibilityText(fUserDefinedPatterns, OutlineFilterMessages.CustomFiltersDialog_name_filter_pattern_description);
139
140
		// Info text
141
		final Label info= new Label(group, SWT.LEFT);
142
		info.setText(OutlineFilterMessages.CustomFiltersDialog_patternInfo);
143
144
		// Enabling / disabling of pattern group
145
		fEnableUserDefinedPatterns.setSelection(fEnablePatterns);
146
		fUserDefinedPatterns.setEnabled(fEnablePatterns);
147
		info.setEnabled(fEnablePatterns);
148
		fEnableUserDefinedPatterns.addSelectionListener(new SelectionAdapter() {
149
			public void widgetSelected(SelectionEvent e) {
150
				boolean state= fEnableUserDefinedPatterns.getSelection();
151
				fUserDefinedPatterns.setEnabled(state);
152
				info.setEnabled(fEnableUserDefinedPatterns.getSelection());
153
				if (state)
154
					fUserDefinedPatterns.setFocus();
155
			}
156
		});
157
158
		// Filters provided by extension point
159
		if (fBuiltInFilters.length > 0)
160
			createCheckBoxList(group);
161
162
		applyDialogFont(parent);
163
		return parent;
164
	}
165
166
	private void createCheckBoxList(Composite parent) {
167
		// Filler
168
		new Label(parent, SWT.NONE);
169
170
		Label info= new Label(parent, SWT.LEFT);
171
		info.setText(OutlineFilterMessages.CustomFiltersDialog_filterList_label);
172
173
		fCheckBoxList= CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
174
		GridData data= new GridData(GridData.FILL_BOTH);
175
		data.heightHint= fCheckBoxList.getTable().getItemHeight() * 10;
176
		fCheckBoxList.getTable().setLayoutData(data);
177
178
		fCheckBoxList.setLabelProvider(createLabelPrivder());
179
		fCheckBoxList.setContentProvider(new ArrayContentProvider());
180
		Arrays.sort(fBuiltInFilters);
181
		fCheckBoxList.setInput(fBuiltInFilters);
182
		setInitialSelections(getEnabledFilterDescriptors());
183
184
		List initialSelection= getInitialElementSelections();
185
		if (initialSelection != null && !initialSelection.isEmpty())
186
			checkInitialSelections();
187
188
		// Description
189
		info= new Label(parent, SWT.LEFT);
190
		info.setText(OutlineFilterMessages.CustomFiltersDialog_description_label);
191
		final Text description= new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL);
192
		data = new GridData(GridData.FILL_HORIZONTAL);
193
		data.heightHint= convertHeightInCharsToPixels(3);
194
		description.setLayoutData(data);
195
		fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() {
196
			public void selectionChanged(SelectionChangedEvent event) {
197
				ISelection selection= event.getSelection();
198
				if (selection instanceof IStructuredSelection) {
199
					Object selectedElement= ((IStructuredSelection)selection).getFirstElement();
200
					if (selectedElement instanceof OutlineFilterDescriptor)
201
						description.setText(((OutlineFilterDescriptor)selectedElement).getDescription());
202
				}
203
			}
204
		});
205
		fCheckBoxList.addCheckStateListener(new ICheckStateListener() {
206
			/*
207
			 * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
208
			 */
209
			public void checkStateChanged(CheckStateChangedEvent event) {
210
				Object element= event.getElement();
211
				if (element instanceof OutlineFilterDescriptor) {
212
					// renew if already touched
213
					if (fFilterDescriptorChangeHistory.contains(element))
214
						fFilterDescriptorChangeHistory.remove(element);
215
					fFilterDescriptorChangeHistory.push(element);
216
				}
217
			}});
218
219
		addSelectionButtons(parent);
220
	}
221
222
	private void addSelectionButtons(Composite composite) {
223
		Composite buttonComposite= new Composite(composite, SWT.RIGHT);
224
		GridLayout layout= new GridLayout();
225
		layout.numColumns= 2;
226
		buttonComposite.setLayout(layout);
227
		GridData data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
228
		data.grabExcessHorizontalSpace= true;
229
		composite.setData(data);
230
231
		// Select All button
232
		String label= OutlineFilterMessages.CustomFiltersDialog_SelectAllButton_label;
233
		Button selectButton= createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, label, false);
234
		SWTUtil.setButtonDimensionHint(selectButton);
235
		SelectionListener listener= new SelectionAdapter() {
236
			public void widgetSelected(SelectionEvent e) {
237
				fCheckBoxList.setAllChecked(true);
238
				fFilterDescriptorChangeHistory.clear();
239
				for (int i= 0; i < fBuiltInFilters.length; i++)
240
					fFilterDescriptorChangeHistory.push(fBuiltInFilters[i]);
241
			}
242
		};
243
		selectButton.addSelectionListener(listener);
244
245
		// De-select All button
246
		label= OutlineFilterMessages.CustomFiltersDialog_DeselectAllButton_label;
247
		Button deselectButton= createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, label, false);
248
		SWTUtil.setButtonDimensionHint(deselectButton);
249
		listener= new SelectionAdapter() {
250
			public void widgetSelected(SelectionEvent e) {
251
				fCheckBoxList.setAllChecked(false);
252
				fFilterDescriptorChangeHistory.clear();
253
				for (int i= 0; i < fBuiltInFilters.length; i++)
254
					fFilterDescriptorChangeHistory.push(fBuiltInFilters[i]);
255
			}
256
		};
257
		deselectButton.addSelectionListener(listener);
258
	}
259
260
	private void checkInitialSelections() {
261
		Iterator itemsToCheck= getInitialElementSelections().iterator();
262
		while (itemsToCheck.hasNext())
263
			fCheckBoxList.setChecked(itemsToCheck.next(),true);
264
	}
265
266
	protected void okPressed() {
267
		if (fBuiltInFilters != null) {
268
			ArrayList result= new ArrayList();
269
			for (int i= 0; i < fBuiltInFilters.length; ++i) {
270
				if (fCheckBoxList.getChecked(fBuiltInFilters[i]))
271
					result.add(fBuiltInFilters[i]);
272
			}
273
			setResult(result);
274
		}
275
		super.okPressed();
276
	}
277
278
	private ILabelProvider createLabelPrivder() {
279
		return
280
			new LabelProvider() {
281
				public Image getImage(Object element) {
282
					return null;
283
				}
284
				public String getText(Object element) {
285
					if (element instanceof OutlineFilterDescriptor)
286
						return ((OutlineFilterDescriptor)element).getName();
287
					else
288
						return null;
289
				}
290
			};
291
	}
292
293
	// ---------- result handling ----------
294
295
	protected void setResult(List newResult) {
296
		super.setResult(newResult);
297
		if (fUserDefinedPatterns.getText().length() > 0) {
298
			fEnablePatterns= fEnableUserDefinedPatterns.getSelection();
299
			fPatterns= convertFromString(fUserDefinedPatterns.getText(), SEPARATOR);
300
		} else {
301
			fEnablePatterns= false;
302
			fPatterns= new String[0];
303
		}
304
	}
305
306
307
	/**
308
	 * @return the patterns which have been entered by the user
309
	 */
310
	public String[] getUserDefinedPatterns() {
311
		return fPatterns;
312
	}
313
314
	/**
315
	 * @return the Ids of the enabled built-in filters
316
	 */
317
	public String[] getEnabledFilterIds() {
318
		Object[] result= getResult();
319
		Set enabledIds= new HashSet(result.length);
320
		for (int i= 0; i < result.length; i++)
321
			enabledIds.add(((OutlineFilterDescriptor)result[i]).getId());
322
		return (String[]) enabledIds.toArray(new String[enabledIds.size()]);
323
	}
324
325
	/**
326
	 * @return <code>true</code> if the user-defined patterns are disabled
327
	 */
328
	public boolean areUserDefinedPatternsEnabled() {
329
		return fEnablePatterns;
330
	}
331
332
	/**
333
	 * @return a stack with the filter descriptor check history
334
	 */
335
	public Stack getFilterDescriptorChangeHistory() {
336
		return fFilterDescriptorChangeHistory;
337
	}
338
339
	private OutlineFilterDescriptor[] getEnabledFilterDescriptors() {
340
		OutlineFilterDescriptor[] filterDescs= fBuiltInFilters;
341
		List result= new ArrayList(filterDescs.length);
342
		List enabledFilterIds= Arrays.asList(fEnabledFilterIds);
343
		for (int i= 0; i < filterDescs.length; i++) {
344
			String id= filterDescs[i].getId();
345
			if (enabledFilterIds.contains(id))
346
				result.add(filterDescs[i]);
347
		}
348
		return (OutlineFilterDescriptor[])result.toArray(new OutlineFilterDescriptor[result.size()]);
349
	}
350
351
352
	public static String[] convertFromString(String patterns, String separator) {
353
		StringTokenizer tokenizer= new StringTokenizer(patterns, separator, true);
354
		int tokenCount= tokenizer.countTokens();
355
		List result= new ArrayList(tokenCount);
356
		boolean escape= false;
357
		boolean append= false;
358
		while (tokenizer.hasMoreTokens()) {
359
			String token= tokenizer.nextToken().trim();
360
			if (separator.equals(token)) {
361
				if (!escape)
362
					escape= true;
363
				else {
364
					addPattern(result, separator);
365
					append= true;
366
				}
367
			} else  {
368
				if (!append)
369
 					result.add(token);
370
				else
371
					addPattern(result, token);
372
				append= false;
373
				escape= false;
374
			}
375
		}
376
		return (String[])result.toArray(new String[result.size()]);
377
	}
378
379
	private static void addPattern(List list, String pattern) {
380
		if (list.isEmpty())
381
			list.add(pattern);
382
		else {
383
			int index= list.size() - 1;
384
			list.set(index, ((String)list.get(index)) + pattern);
385
		}
386
	}
387
388
	public static String convertToString(String[] patterns, String separator) {
389
		int length= patterns.length;
390
		StringBuffer strBuf= new StringBuffer();
391
		if (length > 0)
392
			strBuf.append(escapeSeparator(patterns[0], separator));
393
		else
394
			return ""; //$NON-NLS-1$
395
		int i= 1;
396
		while (i < length) {
397
			strBuf.append(separator);
398
			strBuf.append(" "); //$NON-NLS-1$
399
			strBuf.append(escapeSeparator(patterns[i++], separator));
400
		}
401
		return strBuf.toString();
402
	}
403
404
	private static String escapeSeparator(String pattern, String separator) {
405
		int length= pattern.length();
406
		StringBuffer buf= new StringBuffer(length);
407
		for (int i= 0; i < length; i++) {
408
			char ch= pattern.charAt(i);
409
			if (separator.equals(String.valueOf(ch)))
410
				buf.append(ch);
411
			buf.append(ch);
412
		}
413
		return buf.toString();
414
415
	}
416
}
(-)src/org/eclipse/wst/sse/ui/internal/filter/OutlineFilterDescriptor.java (+277 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
13
import java.util.ArrayList;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Set;
17
18
import com.ibm.icu.text.Collator;
19
20
import org.eclipse.core.runtime.Assert;
21
import org.eclipse.core.runtime.IConfigurationElement;
22
import org.eclipse.core.runtime.IExtensionRegistry;
23
import org.eclipse.core.runtime.ISafeRunnable;
24
import org.eclipse.core.runtime.Platform;
25
import org.eclipse.core.runtime.SafeRunner;
26
27
import org.eclipse.jface.util.SafeRunnable;
28
import org.eclipse.jface.viewers.ViewerFilter;
29
30
import org.eclipse.ui.IPluginContribution;
31
import org.eclipse.ui.activities.WorkbenchActivityHelper;
32
import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
33
34
35
36
/**
37
 * Represents a custom filter which is provided by the
38
 * "org.eclipse.sse.ui.outlineFilters" extension point.
39
 *
40
 */
41
public class OutlineFilterDescriptor implements Comparable, IPluginContribution {
42
43
	private static String PATTERN_FILTER_ID_PREFIX= "_patternFilterId_"; //$NON-NLS-1$
44
45
46
	private static final String EXTENSION_POINT_NAME= "outlineFilters"; //$NON-NLS-1$
47
48
	private static final String FILTER_TAG= "filter"; //$NON-NLS-1$
49
50
	private static final String PATTERN_ATTRIBUTE= "pattern"; //$NON-NLS-1$
51
	private static final String ID_ATTRIBUTE= "id"; //$NON-NLS-1$
52
	private static final String TARGET_ID_ATTRIBUTE= "targetId"; //$NON-NLS-1$
53
	private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
54
	private static final String NAME_ATTRIBUTE= "name"; //$NON-NLS-1$
55
	private static final String ENABLED_ATTRIBUTE= "enabled"; //$NON-NLS-1$
56
	private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$
57
	
58
	private static OutlineFilterDescriptor[] fgFilterDescriptors;
59
60
61
	private IConfigurationElement fElement;
62
63
	/**
64
	 * Returns all contributed Java element filters.
65
	 * @return all contributed Java element filters
66
	 */
67
	public static OutlineFilterDescriptor[] getFilterDescriptors() {
68
		if (fgFilterDescriptors == null) {
69
			IExtensionRegistry registry= Platform.getExtensionRegistry();
70
			IConfigurationElement[] elements= registry.getConfigurationElementsFor(SSEUIPlugin.ID, EXTENSION_POINT_NAME);
71
			fgFilterDescriptors= createFilterDescriptors(elements);
72
		}
73
		return fgFilterDescriptors;
74
	}
75
	/**
76
	 * Returns all Java element filters which
77
	 * are contributed to the given view.
78
	 * @param targetId the target id
79
	 * @return all contributed Java element filters for the given view
80
	 */
81
	public static OutlineFilterDescriptor[] getFilterDescriptors(String targetId) {
82
		OutlineFilterDescriptor[] filterDescs= OutlineFilterDescriptor.getFilterDescriptors();
83
		List result= new ArrayList(filterDescs.length);
84
		for (int i= 0; i < filterDescs.length; i++) {
85
			String tid= filterDescs[i].getTargetId();
86
			if (WorkbenchActivityHelper.filterItem(filterDescs[i]))
87
				continue;
88
			if (tid == null || tid.equals(targetId))
89
				result.add(filterDescs[i]);
90
		}
91
		return (OutlineFilterDescriptor[])result.toArray(new OutlineFilterDescriptor[result.size()]);
92
	}
93
94
	/**
95
	 * Creates a new filter descriptor for the given configuration element.
96
	 * @param element configuration element
97
	 */
98
	private OutlineFilterDescriptor(IConfigurationElement element) {
99
		fElement= element;
100
		// it is either a pattern filter or a custom filter
101
		Assert.isTrue(isPatternFilter() ^ isCustomFilter(), "An extension for extension-point org.eclipse.sse.ui.outlineFilters does not specify a correct filter"); //$NON-NLS-1$
102
		Assert.isNotNull(getId(), "An extension for extension-point org.eclipse.sse.ui.outlineFilters does not provide a valid ID"); //$NON-NLS-1$
103
		Assert.isNotNull(getName(), "An extension for extension-point org.eclipse.sse.ui.outlineFilters does not provide a valid name"); //$NON-NLS-1$
104
	}
105
106
	/**
107
	 * Creates a new <code>ViewerFilter</code>.
108
	 * This method is only valid for viewer filters.
109
	 * @return a new <code>ViewerFilter</code>
110
	 */
111
	public ViewerFilter createViewerFilter() {
112
		if (!isCustomFilter())
113
			return null;
114
115
		final ViewerFilter[] result= new ViewerFilter[1];
116
		String message = OutlineFilterMessages.FilterDescriptor_filterCreationError_message;
117
		ISafeRunnable code= new SafeRunnable(message) {
118
			/*
119
			 * @see org.eclipse.core.runtime.ISafeRunnable#run()
120
			 */
121
			public void run() throws Exception {
122
				result[0]= (ViewerFilter)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
123
			}
124
125
		};
126
		SafeRunner.run(code);
127
		return result[0];
128
	}
129
130
	//---- XML Attribute accessors ---------------------------------------------
131
132
	/**
133
	 * Returns the filter's id.
134
	 * <p>
135
	 * This attribute is mandatory for custom filters.
136
	 * The ID for pattern filters is
137
	 * PATTERN_FILTER_ID_PREFIX plus the pattern itself.
138
	 * </p>
139
	 * @return the filter id
140
	 */
141
	public String getId() {
142
		if (isPatternFilter()) {
143
			String targetId= getTargetId();
144
			if (targetId == null)
145
				return PATTERN_FILTER_ID_PREFIX + getPattern();
146
			else
147
				return targetId + PATTERN_FILTER_ID_PREFIX + getPattern();
148
		} else
149
			return fElement.getAttribute(ID_ATTRIBUTE);
150
	}
151
152
	/**
153
	 * Returns the filter's name.
154
	 * <p>
155
	 * If the name of a pattern filter is missing
156
	 * then the pattern is used as its name.
157
	 * </p>
158
	 * @return the filter's name
159
	 */
160
	public String getName() {
161
		String name= fElement.getAttribute(NAME_ATTRIBUTE);
162
		if (name == null && isPatternFilter())
163
			name= getPattern();
164
		return name;
165
	}
166
167
	/**
168
	 * Returns the filter's pattern.
169
	 *
170
	 * @return the pattern string or <code>null</code> if it's not a pattern filter
171
	 */
172
	public String getPattern() {
173
		return fElement.getAttribute(PATTERN_ATTRIBUTE);
174
	}
175
176
	/**
177
	 * Returns the filter's viewId.
178
	 *
179
	 * @return the view ID or <code>null</code> if the filter is for all views
180
	 */
181
	public String getTargetId() {
182
		String tid= fElement.getAttribute(TARGET_ID_ATTRIBUTE);
183
184
		if (tid != null)
185
			return tid;
186
187
		// Backwards compatibility code
188
		return null;
189
190
	}
191
192
	/**
193
	 * Returns the filter's description.
194
	 *
195
	 * @return the description or <code>null</code> if no description is provided
196
	 */
197
	public String getDescription() {
198
		String description= fElement.getAttribute(DESCRIPTION_ATTRIBUTE);
199
		if (description == null)
200
			description= ""; //$NON-NLS-1$
201
		return description;
202
	}
203
204
	/**
205
	 * @return <code>true</code> if this filter is a custom filter.
206
	 */
207
	public boolean isPatternFilter() {
208
		return getPattern() != null;
209
	}
210
211
	/**
212
	 * @return <code>true</code> if this filter is a pattern filter.
213
	 */
214
	public boolean isCustomFilter() {
215
		return fElement.getAttribute(CLASS_ATTRIBUTE) != null;
216
	}
217
218
	/**
219
	 * Returns <code>true</code> if the filter
220
	 * is initially enabled.
221
	 *
222
	 * This attribute is optional and defaults to <code>true</code>.
223
	 * @return returns <code>true</code> if the filter is initially enabled
224
	 */
225
	public boolean isEnabled() {
226
		String strVal= fElement.getAttribute(ENABLED_ATTRIBUTE);
227
		return strVal == null || Boolean.valueOf(strVal).booleanValue();
228
	}
229
230
	/*
231
	 * Implements a method from IComparable
232
	 */
233
	public int compareTo(Object o) {
234
		if (o instanceof OutlineFilterDescriptor)
235
			return Collator.getInstance().compare(getName(), ((OutlineFilterDescriptor)o).getName());
236
		else
237
			return Integer.MIN_VALUE;
238
	}
239
240
	//---- initialization ---------------------------------------------------
241
242
	/**
243
	 * Creates the filter descriptors.
244
	 * @param elements the configuration elements
245
	 * @return new filter descriptors
246
	 */
247
	private static OutlineFilterDescriptor[] createFilterDescriptors(IConfigurationElement[] elements) {
248
		List result= new ArrayList(5);
249
		Set descIds= new HashSet(5);
250
		for (int i= 0; i < elements.length; i++) {
251
			final IConfigurationElement element= elements[i];
252
			if (FILTER_TAG.equals(element.getName())) {
253
254
				final OutlineFilterDescriptor[] desc= new OutlineFilterDescriptor[1];
255
				SafeRunner.run(new SafeRunnable(OutlineFilterMessages.FilterDescriptor_filterDescriptionCreationError_message) {
256
					public void run() throws Exception {
257
						desc[0]= new OutlineFilterDescriptor(element);
258
					}
259
				});
260
261
				if (desc[0] != null && !descIds.contains(desc[0].getId())) {
262
					result.add(desc[0]);
263
					descIds.add(desc[0].getId());
264
				}
265
			}
266
		}
267
		return (OutlineFilterDescriptor[])result.toArray(new OutlineFilterDescriptor[result.size()]);
268
	}
269
270
	public String getLocalId() {
271
		return fElement.getAttribute(ID_ATTRIBUTE);
272
	}
273
274
    public String getPluginId() {
275
        return fElement.getContributor().getName();
276
    }
277
}
(-)src/org/eclipse/wst/sse/ui/internal/filter/OutlineFilterMessages.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
13
import org.eclipse.osgi.util.NLS;
14
15
public final class OutlineFilterMessages extends NLS {
16
17
	private static final String BUNDLE_NAME= "org.eclipse.wst.sse.ui.internal.filter.OutlineFilterMessages";//$NON-NLS-1$
18
19
	private OutlineFilterMessages() {
20
		// Do not instantiate
21
	}
22
23
	public static String CustomFiltersDialog_title;
24
	public static String CustomFiltersDialog_patternInfo;
25
	public static String CustomFiltersDialog_enableUserDefinedPattern;
26
	public static String CustomFiltersDialog_filterList_label;
27
	public static String CustomFiltersDialog_description_label;
28
	public static String CustomFiltersDialog_SelectAllButton_label;
29
	public static String CustomFiltersDialog_DeselectAllButton_label;
30
	public static String CustomFiltersDialog_name_filter_pattern_description;
31
	public static String OpenCustomFiltersDialogAction_text;
32
	public static String FilterDescriptor_filterDescriptionCreationError_message;
33
	public static String FilterDescriptor_filterCreationError_message;
34
35
	static {
36
		NLS.initializeMessages(BUNDLE_NAME, OutlineFilterMessages.class);
37
	}
38
}
(-)src/org/eclipse/wst/sse/ui/internal/filter/OutlineFilterMessages.properties (+24 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2010 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
CustomFiltersDialog_title= Java Element Filters
13
CustomFiltersDialog_patternInfo= The patterns are separated by comma, where\n* = any string, ? = any character, ,, = ,
14
CustomFiltersDialog_enableUserDefinedPattern= &Name filter patterns (matching names will be hidden):
15
CustomFiltersDialog_filterList_label= S&elect the elements to exclude from the view:
16
CustomFiltersDialog_description_label= Filter description:
17
CustomFiltersDialog_SelectAllButton_label= &Select All
18
CustomFiltersDialog_DeselectAllButton_label= &Deselect All
19
CustomFiltersDialog_name_filter_pattern_description=Name filter patterns. The patterns are separated by comma, where star is any string
20
21
OpenCustomFiltersDialogAction_text= &Filters...
22
23
FilterDescriptor_filterDescriptionCreationError_message= One of the extensions for extension-point org.eclipse.wst.sse.ui.outlineFilters is incorrect.
24
FilterDescriptor_filterCreationError_message= The org.eclipse.wst.sse.ui.outlineFilters plug-in extension "{0}" specifies a viewer filter class which does not exist.
(-)src/org/eclipse/wst/sse/ui/internal/filter/OutlineNamePatternFilter.java (+80 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
13
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.jface.viewers.ViewerFilter;
15
import org.w3c.dom.Node;
16
17
/**
18
 * The NamePatternFilter selects the elements which
19
 * match the given string patterns.
20
 * <p>
21
 * The following characters have special meaning:
22
 *   ? => any character
23
 *   * => any string
24
 * </p>
25
 *
26
 */
27
public class OutlineNamePatternFilter extends ViewerFilter {
28
	private String[] fPatterns;
29
	private StringMatcher[] fMatchers;
30
31
32
	/**
33
	 * Gets the patterns for the receiver.
34
	 * @return returns the patterns to be filtered for
35
	 */
36
	public String[] getPatterns() {
37
		return fPatterns;
38
	}
39
40
41
	/* (non-Javadoc)
42
	 * Method declared on ViewerFilter.
43
	 */
44
	public boolean select(Viewer viewer, Object parentElement, Object element) {
45
		if (getPatterns().length == 0) {
46
			return true;
47
		}
48
		String matchName= null;
49
		if (element instanceof Node){
50
			matchName =((Node)element).getNodeName();
51
		}
52
		if (matchName != null && matchName.length() > 0) {
53
			String[] fPatterns = getPatterns();
54
			for (int i = 0; i < fPatterns.length; i++) {
55
				if (new StringMatcher(fPatterns[i], true, false).match(matchName))
56
					return false;
57
			}
58
			return true;
59
		}
60
		return true;
61
	}
62
63
	/**
64
	 * Sets the patterns to filter out for the receiver.
65
	 * <p>
66
	 * The following characters have special meaning:
67
	 *   ? => any character
68
	 *   * => any string
69
	 * </p>
70
	 * @param newPatterns the new patterns
71
	 */
72
	public void setPatterns(String[] newPatterns) {
73
		fPatterns = newPatterns;
74
		fMatchers = new StringMatcher[newPatterns.length];
75
		for (int i = 0; i < newPatterns.length; i++) {
76
			//Reset the matchers to prevent constructor overhead
77
			fMatchers[i]= new StringMatcher(newPatterns[i], true, false);
78
		}
79
	}
80
}
(-)src/org/eclipse/wst/sse/ui/internal/filter/SWTUtil.java (+156 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.accessibility.AccessibleAdapter;
15
import org.eclipse.swt.accessibility.AccessibleEvent;
16
import org.eclipse.swt.dnd.DragSource;
17
import org.eclipse.swt.dnd.DropTarget;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.layout.GridLayout;
20
import org.eclipse.swt.widgets.Button;
21
import org.eclipse.swt.widgets.Caret;
22
import org.eclipse.swt.widgets.Combo;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.swt.widgets.Menu;
26
import org.eclipse.swt.widgets.ScrollBar;
27
import org.eclipse.swt.widgets.Shell;
28
import org.eclipse.swt.widgets.Table;
29
import org.eclipse.swt.widgets.Widget;
30
31
import org.eclipse.core.runtime.Assert;
32
33
import org.eclipse.jface.dialogs.IDialogConstants;
34
import org.eclipse.jface.layout.PixelConverter;
35
import org.eclipse.jface.resource.JFaceResources;
36
37
38
/**
39
 * Utility class to simplify access to some SWT resources.
40
 */
41
public class SWTUtil {
42
43
44
	public static final int COMBO_VISIBLE_ITEM_COUNT= 30;
45
46
	/**
47
	 * Returns the standard display to be used. The method first checks, if
48
	 * the thread calling this method has an associated display. If so, this
49
	 * display is returned. Otherwise the method returns the default display.
50
	 * @return returns the standard display to be used
51
	 */
52
	public static Display getStandardDisplay() {
53
		Display display;
54
		display= Display.getCurrent();
55
		if (display == null)
56
			display= Display.getDefault();
57
		return display;
58
	}
59
60
	/**
61
	 * Returns the shell for the given widget. If the widget doesn't represent
62
	 * a SWT object that manage a shell, <code>null</code> is returned.
63
	 * @param widget the widget
64
	 *
65
	 * @return the shell for the given widget
66
	 */
67
	public static Shell getShell(Widget widget) {
68
		if (widget instanceof Control)
69
			return ((Control)widget).getShell();
70
		if (widget instanceof Caret)
71
			return ((Caret)widget).getParent().getShell();
72
		if (widget instanceof DragSource)
73
			return ((DragSource)widget).getControl().getShell();
74
		if (widget instanceof DropTarget)
75
			return ((DropTarget)widget).getControl().getShell();
76
		if (widget instanceof Menu)
77
			return ((Menu)widget).getParent().getShell();
78
		if (widget instanceof ScrollBar)
79
			return ((ScrollBar)widget).getParent().getShell();
80
81
		return null;
82
	}
83
84
85
	/**
86
	 * Returns a width hint for a button control.
87
	 * @param button the button
88
	 * @return the width hint
89
	 */
90
	public static int getButtonWidthHint(Button button) {
91
		button.setFont(JFaceResources.getDialogFont());
92
		PixelConverter converter= new PixelConverter(button);
93
		int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
94
		return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
95
	}
96
97
	/**
98
	 * Sets width and height hint for the button control.
99
	 * <b>Note:</b> This is a NOP if the button's layout data is not
100
	 * an instance of <code>GridData</code>.
101
	 *
102
	 * @param button	the button for which to set the dimension hint
103
	 */
104
	public static void setButtonDimensionHint(Button button) {
105
		Assert.isNotNull(button);
106
		Object gd= button.getLayoutData();
107
		if (gd instanceof GridData) {
108
			((GridData)gd).widthHint= getButtonWidthHint(button);
109
			((GridData)gd).horizontalAlignment = GridData.FILL;
110
		}
111
	}
112
113
	public static int getTableHeightHint(Table table, int rows) {
114
		if (table.getFont().equals(JFaceResources.getDefaultFont()))
115
			table.setFont(JFaceResources.getDialogFont());
116
		int result= table.getItemHeight() * rows + table.getHeaderHeight();
117
		if (table.getLinesVisible())
118
			result+= table.getGridLineWidth() * (rows - 1);
119
		return result;
120
	}
121
122
	/**
123
	 * Adds an accessibility listener returning the given fixed name.
124
	 *
125
	 * @param control the control to add the accessibility support to
126
	 * @param text the name
127
	 */
128
	public static void setAccessibilityText(Control control, final String text) {
129
		control.getAccessible().addAccessibleListener(new AccessibleAdapter() {
130
			public void getName(AccessibleEvent e) {
131
				e.result= text;
132
			}
133
		});
134
	}
135
136
	/**
137
	 *
138
	 * @param combo the combo
139
	 *
140
	 * @see Combo#setVisibleItemCount(int)
141
	 * @see #COMBO_VISIBLE_ITEM_COUNT
142
	 *
143
	 */
144
	public static void setDefaultVisibleItemCount(Combo combo) {
145
		combo.setVisibleItemCount(COMBO_VISIBLE_ITEM_COUNT);
146
	}
147
148
	public static GridLayout newLayoutNoMargins(int columns) {
149
		GridLayout layout= new GridLayout(columns, false);
150
		layout.marginWidth= 0;
151
		layout.marginHeight= 0;
152
		return layout;
153
	}
154
155
156
}
(-)src/org/eclipse/wst/sse/ui/internal/filter/StringMatcher.java (+384 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.filter;
12
13
import java.util.Vector;
14
15
/**
16
 * A string pattern matcher. Supports '*' and '?' wildcards.
17
 */
18
public class StringMatcher {
19
	protected String fPattern;
20
	protected int fLength; // pattern length
21
	protected boolean fIgnoreWildCards;
22
	protected boolean fIgnoreCase;
23
	protected boolean fHasLeadingStar;
24
	protected boolean fHasTrailingStar;
25
	protected String fSegments[]; //the given pattern is split into * separated segments
26
27
	/* boundary value beyond which we don't need to search in the text */
28
	protected int fBound= 0;
29
30
31
	protected static final char fSingleWildCard= '\u0000';
32
33
	public static class Position {
34
		int start; //inclusive
35
		int end; //exclusive
36
		public Position(int start, int end) {
37
			this.start= start;
38
			this.end= end;
39
		}
40
		public int getStart() {
41
			return start;
42
		}
43
		public int getEnd() {
44
			return end;
45
		}
46
	}
47
	/**
48
	 * StringMatcher constructor takes in a String object that is a simple
49
	 * pattern. The pattern may contain '*' for 0 and many characters and
50
	 * '?' for exactly one character.
51
	 *
52
	 * Literal '*' and '?' characters must be escaped in the pattern
53
	 * e.g., "\*" means literal "*", etc.
54
	 *
55
	 * Escaping any other character (including the escape character itself),
56
	 * just results in that character in the pattern.
57
	 * e.g., "\a" means "a" and "\\" means "\"
58
	 *
59
	 * If invoking the StringMatcher with string literals in Java, don't forget
60
	 * escape characters are represented by "\\".
61
	 *
62
	 * @param pattern the pattern to match text against
63
	 * @param ignoreCase if true, case is ignored
64
	 * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
65
	 * 		  (everything is taken literally).
66
	 */
67
	public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
68
		if (pattern == null)
69
			throw new IllegalArgumentException();
70
		fIgnoreCase= ignoreCase;
71
		fIgnoreWildCards= ignoreWildCards;
72
		fPattern= pattern;
73
		fLength= pattern.length();
74
75
		if (fIgnoreWildCards) {
76
			parseNoWildCards();
77
		} else {
78
			parseWildCards();
79
		}
80
	}
81
	/**
82
	 * Find the first occurrence of the pattern between <code>start</code)(inclusive)
83
	 * and <code>end</code>(exclusive).
84
	 * @param text the String object to search in
85
	 * @param start the starting index of the search range, inclusive
86
	 * @param end the ending index of the search range, exclusive
87
	 * @return an <code>StringMatcher.Position</code> object that keeps the starting
88
	 * (inclusive) and ending positions (exclusive) of the first occurrence of the
89
	 * pattern in the specified range of the text; return null if not found or subtext
90
	 * is empty (start==end). A pair of zeros is returned if pattern is empty string
91
	 * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
92
	 * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
93
	 */
94
	public StringMatcher.Position find(String text, int start, int end) {
95
		if (text == null)
96
			throw new IllegalArgumentException();
97
98
		int tlen= text.length();
99
		if (start < 0)
100
			start= 0;
101
		if (end > tlen)
102
			end= tlen;
103
		if (end < 0 ||start >= end )
104
			return null;
105
		if (fLength == 0)
106
			return new Position(start, start);
107
		if (fIgnoreWildCards) {
108
			int x= posIn(text, start, end);
109
			if (x < 0)
110
				return null;
111
			return new Position(x, x+fLength);
112
		}
113
114
		int segCount= fSegments.length;
115
		if (segCount == 0)//pattern contains only '*'(s)
116
			return new Position (start, end);
117
118
		int curPos= start;
119
		int matchStart= -1;
120
		int i;
121
		for (i= 0; i < segCount && curPos < end; ++i) {
122
			String current= fSegments[i];
123
			int nextMatch= regExpPosIn(text, curPos, end, current);
124
			if (nextMatch < 0 )
125
				return null;
126
			if(i == 0)
127
				matchStart= nextMatch;
128
			curPos= nextMatch + current.length();
129
		}
130
		if (i < segCount)
131
			return null;
132
		return new Position(matchStart, curPos);
133
	}
134
	/**
135
	 * match the given <code>text</code> with the pattern
136
	 * @return true if matched eitherwise false
137
	 * @param text a String object
138
	 */
139
	public boolean match(String text) {
140
		return match(text, 0, text.length());
141
	}
142
	/**
143
	 * Given the starting (inclusive) and the ending (exclusive) positions in the
144
	 * <code>text</code>, determine if the given substring matches with aPattern
145
	 * @return true if the specified portion of the text matches the pattern
146
	 * @param text a String object that contains the substring to match
147
	 * @param start marks the starting position (inclusive) of the substring
148
	 * @param end marks the ending index (exclusive) of the substring
149
	 */
150
	public boolean match(String text, int start, int end) {
151
		if (null == text)
152
			throw new IllegalArgumentException();
153
154
		if (start > end)
155
			return false;
156
157
		if (fIgnoreWildCards)
158
			return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
159
		int segCount= fSegments.length;
160
		if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar))  // pattern contains only '*'(s)
161
			return true;
162
		if (start == end)
163
			return fLength == 0;
164
		if (fLength == 0)
165
			return start == end;
166
167
		int tlen= text.length();
168
		if (start < 0)
169
			start= 0;
170
		if (end > tlen)
171
			end= tlen;
172
173
		int tCurPos= start;
174
		int bound= end - fBound;
175
		if ( bound < 0)
176
			return false;
177
		int i=0;
178
		String current= fSegments[i];
179
		int segLength= current.length();
180
181
		/* process first segment */
182
		if (!fHasLeadingStar){
183
			if(!regExpRegionMatches(text, start, current, 0, segLength)) {
184
				return false;
185
			} else {
186
				++i;
187
				tCurPos= tCurPos + segLength;
188
			}
189
		}
190
		if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
191
			// only one segment to match, no wildcards specified
192
			return tCurPos == end;
193
		}
194
		/* process middle segments */
195
		while (i < segCount) {
196
			current= fSegments[i];
197
			int currentMatch;
198
			int k= current.indexOf(fSingleWildCard);
199
			if (k < 0) {
200
				currentMatch= textPosIn(text, tCurPos, end, current);
201
				if (currentMatch < 0)
202
					return false;
203
			} else {
204
				currentMatch= regExpPosIn(text, tCurPos, end, current);
205
				if (currentMatch < 0)
206
					return false;
207
			}
208
			tCurPos= currentMatch + current.length();
209
			i++;
210
		}
211
212
		/* process final segment */
213
		if (!fHasTrailingStar && tCurPos != end) {
214
			int clen= current.length();
215
			return regExpRegionMatches(text, end - clen, current, 0, clen);
216
		}
217
		return i == segCount ;
218
	}
219
220
	/**
221
	 * This method parses the given pattern into segments seperated by wildcard '*' characters.
222
	 * Since wildcards are not being used in this case, the pattern consists of a single segment.
223
	 */
224
	private void parseNoWildCards() {
225
		fSegments= new String[1];
226
		fSegments[0]= fPattern;
227
		fBound= fLength;
228
	}
229
	/**
230
	 * Parses the given pattern into segments seperated by wildcard '*' characters.
231
	 */
232
	private void parseWildCards() {
233
		if(fPattern.startsWith("*"))//$NON-NLS-1$
234
			fHasLeadingStar= true;
235
		if(fPattern.endsWith("*")) {//$NON-NLS-1$
236
			/* make sure it's not an escaped wildcard */
237
			if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
238
				fHasTrailingStar= true;
239
			}
240
		}
241
242
		Vector temp= new Vector();
243
244
		int pos= 0;
245
		StringBuffer buf= new StringBuffer();
246
		while (pos < fLength) {
247
			char c= fPattern.charAt(pos++);
248
			switch (c) {
249
				case '\\':
250
					if (pos >= fLength) {
251
						buf.append(c);
252
					} else {
253
						char next= fPattern.charAt(pos++);
254
						/* if it's an escape sequence */
255
						if (next == '*' || next == '?' || next == '\\') {
256
							buf.append(next);
257
						} else {
258
							/* not an escape sequence, just insert literally */
259
							buf.append(c);
260
							buf.append(next);
261
						}
262
					}
263
				break;
264
				case '*':
265
					if (buf.length() > 0) {
266
						/* new segment */
267
						temp.addElement(buf.toString());
268
						fBound += buf.length();
269
						buf.setLength(0);
270
					}
271
				break;
272
				case '?':
273
					/* append special character representing single match wildcard */
274
					buf.append(fSingleWildCard);
275
				break;
276
				default:
277
					buf.append(c);
278
			}
279
		}
280
281
		/* add last buffer to segment list */
282
		if (buf.length() > 0) {
283
			temp.addElement(buf.toString());
284
			fBound += buf.length();
285
		}
286
287
		fSegments= new String[temp.size()];
288
		temp.copyInto(fSegments);
289
	}
290
	/**
291
	 * @param text a string which contains no wildcard
292
	 * @param start the starting index in the text for search, inclusive
293
	 * @param end the stopping point of search, exclusive
294
	 * @return the starting index in the text of the pattern , or -1 if not found
295
	 */
296
	protected int posIn(String text, int start, int end) {//no wild card in pattern
297
		int max= end - fLength;
298
299
		if (!fIgnoreCase) {
300
			int i= text.indexOf(fPattern, start);
301
			if (i == -1 || i > max)
302
				return -1;
303
			return i;
304
		}
305
306
		for (int i= start; i <= max; ++i) {
307
			if (text.regionMatches(true, i, fPattern, 0, fLength))
308
				return i;
309
		}
310
311
		return -1;
312
	}
313
	/**
314
	 * @param text a simple regular expression that may only contain '?'(s)
315
	 * @param start the starting index in the text for search, inclusive
316
	 * @param end the stopping point of search, exclusive
317
	 * @param p a simple regular expression that may contains '?'
318
	 * @return the starting index in the text of the pattern , or -1 if not found
319
	 */
320
	protected int regExpPosIn(String text, int start, int end, String p) {
321
		int plen= p.length();
322
323
		int max= end - plen;
324
		for (int i= start; i <= max; ++i) {
325
			if (regExpRegionMatches(text, i, p, 0, plen))
326
				return i;
327
		}
328
		return -1;
329
	}
330
331
332
	protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
333
		while (plen-- > 0) {
334
			char tchar= text.charAt(tStart++);
335
			char pchar= p.charAt(pStart++);
336
337
			/* process wild cards */
338
			if (!fIgnoreWildCards) {
339
				/* skip single wild cards */
340
				if (pchar == fSingleWildCard) {
341
					continue;
342
				}
343
			}
344
			if (pchar == tchar)
345
				continue;
346
			if (fIgnoreCase) {
347
				if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar))
348
					continue;
349
				// comparing after converting to upper case doesn't handle all cases;
350
				// also compare after converting to lower case
351
				if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar))
352
					continue;
353
			}
354
			return false;
355
		}
356
		return true;
357
	}
358
	/**
359
	 * @param text the string to match
360
	 * @param start the starting index in the text for search, inclusive
361
	 * @param end the stopping point of search, exclusive
362
	 * @param p a string that has no wildcard
363
	 * @return the starting index in the text of the pattern , or -1 if not found
364
	 */
365
	protected int textPosIn(String text, int start, int end, String p) {
366
367
		int plen= p.length();
368
		int max= end - plen;
369
370
		if (!fIgnoreCase) {
371
			int i= text.indexOf(p, start);
372
			if (i == -1 || i > max)
373
				return -1;
374
			return i;
375
		}
376
377
		for (int i= start; i <= max; ++i) {
378
			if (text.regionMatches(true, i, p, 0, plen))
379
				return i;
380
		}
381
382
		return -1;
383
	}
384
}
(-)src/org/eclipse/wst/sse/ui/internal/handlers/CustomFilterHandler.java (+32 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.handlers;
12
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.ui.IEditorPart;
17
import org.eclipse.ui.handlers.HandlerUtil;
18
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
19
import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage;
20
21
public class CustomFilterHandler extends AbstractHandler {
22
	public Object execute(ExecutionEvent event) throws ExecutionException {
23
24
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
25
		ConfigurableContentOutlinePage page = (ConfigurableContentOutlinePage) editor.getAdapter(IContentOutlinePage.class);
26
		if (page != null) {
27
			page.getConfiguration().handleCustomFilter();
28
		}
29
		return null;
30
	}
31
	
32
}
(-)src/org/eclipse/wst/sse/ui/internal/handlers/CustomFilterPropertyTester.java (+38 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.sse.ui.internal.handlers;
12
13
import org.eclipse.core.expressions.PropertyTester;
14
import org.eclipse.ui.IEditorPart;
15
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
16
import org.eclipse.wst.sse.ui.internal.contentoutline.ConfigurableContentOutlinePage;
17
18
public class CustomFilterPropertyTester extends PropertyTester {
19
	/*
20
	 * (non-Javadoc)
21
	 * 
22
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object,
23
	 *      java.lang.String, java.lang.Object[], java.lang.Object)
24
	 */
25
	public boolean test(Object receiver, String property, Object[] args,
26
			Object expectedValue) {
27
		if (receiver instanceof IEditorPart){
28
			IEditorPart editor = (IEditorPart)receiver;
29
			Object page = editor.getAdapter(IContentOutlinePage.class);
30
			if (page instanceof ConfigurableContentOutlinePage) {
31
				Boolean val = (Boolean)expectedValue;
32
				return val.booleanValue();
33
			}
34
		}
35
		return false;
36
	}
37
	
38
}
(-)src/org/eclipse/wst/sse/ui/views/contentoutline/ContentOutlineConfiguration.java (+18 lines)
Lines 32-37 Link Here
32
import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateActionContributionItem;
32
import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateActionContributionItem;
33
import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
33
import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
34
import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
34
import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
35
import org.eclipse.wst.sse.ui.internal.filter.CustomFilterProcessor;
35
36
36
/**
37
/**
37
 * Basic Configuration class for Outline Pages
38
 * Basic Configuration class for Outline Pages
Lines 39-44 Link Here
39
 * @since 1.0
40
 * @since 1.0
40
 */
41
 */
41
public abstract class ContentOutlineConfiguration {
42
public abstract class ContentOutlineConfiguration {
43
	
44
	private TreeViewer fTreeViewer;
42
	/**
45
	/**
43
	 * Add a collapse action to help with navigation.
46
	 * Add a collapse action to help with navigation.
44
	 */
47
	 */
Lines 86-91 Link Here
86
	private IContributionItem[] fMenuContributions = null;
89
	private IContributionItem[] fMenuContributions = null;
87
	private IContributionItem[] fToolbarContributions = null;
90
	private IContributionItem[] fToolbarContributions = null;
88
	private final String OUTLINE_LINK_PREF = "outline-link-editor"; //$NON-NLS-1$
91
	private final String OUTLINE_LINK_PREF = "outline-link-editor"; //$NON-NLS-1$
92
    private final String OUTLINE_FILTER_PREF = "org.eclipse.wst.sse.ui.OutlinePage"; //$NON-NLS-1$
93
	private String fOutlineFilterPref = OUTLINE_FILTER_PREF; //$NON-NLS-1$
89
	ImageDescriptor SYNCED_D = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_DLCL_SYNCED);
94
	ImageDescriptor SYNCED_D = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_DLCL_SYNCED);
90
	ImageDescriptor SYNCED_E = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_ELCL_SYNCED);
95
	ImageDescriptor SYNCED_E = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_ELCL_SYNCED);
91
96
Lines 313-316 Link Here
313
			fMenuContributions = null;
318
			fMenuContributions = null;
314
		}
319
		}
315
	}
320
	}
321
	
322
	protected String getOutlineFilterTarget(){
323
		return fOutlineFilterPref ;
324
	}
325
	
326
	public void setViewer(TreeViewer viewer){
327
		fTreeViewer = viewer;
328
	}
329
	
330
	public void handleCustomFilter(){
331
		CustomFilterProcessor filterProcessor = new CustomFilterProcessor(getPreferenceStore(), getOutlineFilterTarget(), fTreeViewer);
332
        filterProcessor.openDialog();
333
	}
316
}
334
}
(-)plugin.properties (+8 lines)
Lines 154-156 Link Here
154
154
155
# XML Documentation view
155
# XML Documentation view
156
xmlannotations=Documentation
156
xmlannotations=Documentation
157
158
# outline filter
159
HideComments.label=Comments
160
HideComments.description=Hides Comments
161
HideProcessingInstruction.label=Processing Instructions
162
HideProcessingInstruction.description=Hides Processing Instructions
163
HideCDATASection.label=CDATA
164
HideCDATASection.description=Hides CDATA Section Tags
(-)plugin.xml (+27 lines)
Lines 1782-1785 Link Here
1782
			</state>
1782
			</state>
1783
		</command>
1783
		</command>
1784
	</extension>  
1784
	</extension>  
1785
		 <extension
1786
       point="org.eclipse.wst.sse.ui.outlineFilters">
1787
       <filter
1788
            targetId="org.eclipse.wst.xml.ui.OutlinePage"
1789
            name="%HideComments.label"
1790
            enabled="false"
1791
            description="%HideComments.description"
1792
            class="org.eclipse.wst.xml.ui.views.contentoutline.XMLCommentFilter"
1793
            id="org.eclipse.wst.xml.ui.views.contentoutline.XMLCommentFilter">
1794
      </filter>
1795
      <filter
1796
            targetId="org.eclipse.wst.xml.ui.OutlinePage"
1797
            name="%HideProcessingInstruction.label"
1798
            enabled="false"
1799
            description="%HideProcessingInstruction.description"
1800
            class="org.eclipse.wst.xml.ui.views.contentoutline.XMLProcessingInstructionFilter"
1801
            id="org.eclipse.wst.xml.ui.views.contentoutline.XMLProcessingInstructionFilter">
1802
      </filter>
1803
      <filter
1804
            targetId="org.eclipse.wst.xml.ui.OutlinePage"
1805
            name="%HideCDATASection.label"
1806
            enabled="false"
1807
            description="%HideCDATASection.description"
1808
            class="org.eclipse.wst.xml.ui.views.contentoutline.XMLCDATASectionFilter"
1809
            id="org.eclipse.wst.xml.ui.views.contentoutline.XMLCDATASectionFilter">
1810
      </filter>
1811
</extension>
1785
</plugin>
1812
</plugin>
(-)src/org/eclipse/wst/xml/ui/views/contentoutline/XMLCDATASectionFilter.java (+27 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     
11
 *******************************************************************************/
12
package org.eclipse.wst.xml.ui.views.contentoutline;
13
14
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.jface.viewers.ViewerFilter;
16
import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
17
18
public class XMLCDATASectionFilter extends ViewerFilter {
19
20
	public boolean select(Viewer viewer, Object parent, Object element) {
21
		if (element instanceof CDATASectionImpl){
22
			return false;
23
		}
24
		return true;
25
	}
26
27
}
(-)src/org/eclipse/wst/xml/ui/views/contentoutline/XMLCommentFilter.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.xml.ui.views.contentoutline;
12
13
14
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.jface.viewers.ViewerFilter;
16
import org.eclipse.wst.xml.core.internal.document.CommentImpl;
17
18
19
/**
20
 * Filters package declarations
21
 */
22
public class XMLCommentFilter extends ViewerFilter {
23
24
	/*
25
	 * @see ViewerFilter
26
	 */
27
	public boolean select(Viewer viewer, Object parent, Object element) {
28
		if (element instanceof CommentImpl){
29
			return false;
30
		}
31
		return true;
32
	}
33
}
(-)src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2001, 2008 IBM Corporation and others.
2
 * Copyright (c) 2001, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 266-272 Link Here
266
	 * Preference key for Show Attributes
266
	 * Preference key for Show Attributes
267
	 */
267
	 */
268
	private final String OUTLINE_SHOW_ATTRIBUTE_PREF = "outline-show-attribute"; //$NON-NLS-1$
268
	private final String OUTLINE_SHOW_ATTRIBUTE_PREF = "outline-show-attribute"; //$NON-NLS-1$
269
269
	private final String OUTLINE_FILTER_PREF = "org.eclipse.wst.xml.ui.OutlinePage"; //$NON-NLS-1$
270
	 
270
	/**
271
	/**
271
	 * Create new instance of XMLContentOutlineConfiguration
272
	 * Create new instance of XMLContentOutlineConfiguration
272
	 */
273
	 */
Lines 408-411 Link Here
408
		}
409
		}
409
		return filteredSelection;
410
		return filteredSelection;
410
	}
411
	}
412
	
413
	protected String getOutlineFilterTarget(){
414
		return OUTLINE_FILTER_PREF ;
415
	}
411
}
416
}
(-)src/org/eclipse/wst/xml/ui/views/contentoutline/XMLProcessingInstructionFilter.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.wst.xml.ui.views.contentoutline;
12
13
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.jface.viewers.ViewerFilter;
15
import org.eclipse.wst.xml.core.internal.document.ProcessingInstructionImpl;
16
17
public class XMLProcessingInstructionFilter extends ViewerFilter {
18
19
	public boolean select(Viewer viewer, Object parent, Object element) {
20
		if (element instanceof ProcessingInstructionImpl){
21
			return false;
22
		}
23
		return true;
24
	}
25
26
}

Return to bug 109045