View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.theplugin.idea.crucible;
18  
19  import com.atlassian.theplugin.idea.crucible.tree.ModelProvider;
20  import com.atlassian.theplugin.idea.ui.tree.FilteredModelProvider;
21  import com.intellij.util.Icons;
22  
23  import javax.swing.*;
24  
25  public abstract class CrucibleFilteredModelProvider extends FilteredModelProvider<CrucibleFilteredModelProvider.FILTER> {
26  	protected CrucibleFilteredModelProvider(ModelProvider provider, final FILTER initialFiltering) {
27  		super(provider, initialFiltering);
28  	}
29  
30  	public enum FILTER {
31  		FILES_WITH_COMMENTS_ONLY(Icons.ABSTRACT_CLASS_ICON, "Files with comments only") {
32  			@Override
33  			public FILTER getNextState() {
34  				return FILES_ALL;
35  			}},
36  
37  		FILES_ALL(Icons.ANONYMOUS_CLASS_ICON, "All files from review") {
38  			@Override
39  			public FILTER getNextState() {
40  				return FILES_WITH_COMMENTS_ONLY;
41  			}};
42  		private Icon icon;
43  		private String string;
44  
45  		FILTER(final Icon icon, final String string) {
46  			this.icon = icon;
47  			this.string = string;
48  		}
49  
50  		public abstract FILTER getNextState();
51  
52  		public Icon getIcon() {
53  			return icon;
54  		}
55  
56  		@Override
57  		public String toString() {
58  			return string;
59  		}
60  
61  	}
62  }