Source Code Cross Referenced for ProjectSettings.java in  » Code-Analyzer » findbugs » edu » umd » cs » findbugs » gui2 » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » findbugs » edu.umd.cs.findbugs.gui2 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * FindBugs - Find Bugs in Java programs
003:         * Copyright (C) 2006, University of Maryland
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307, USA
018:         */
019:
020:        package edu.umd.cs.findbugs.gui2;
021:
022:        import java.io.IOException;
023:        import java.io.InputStream;
024:        import java.io.ObjectInputStream;
025:        import java.io.ObjectOutputStream;
026:        import java.io.OutputStream;
027:        import java.io.Serializable;
028:        import java.util.ArrayList;
029:        import java.util.List;
030:
031:        import edu.umd.cs.findbugs.Project;
032:        import edu.umd.cs.findbugs.filter.Filter;
033:        import edu.umd.cs.findbugs.filter.LastVersionMatcher;
034:        import edu.umd.cs.findbugs.gui2.BugTreeModel.BranchOperationException;
035:
036:        /**
037:         * This is the .fas file stored when projects are saved
038:         * All project related information goes here.  Anything that would be shared between multiple projects goes into GUISaveState instead
039:         */
040:        @Deprecated
041:        public class ProjectSettings implements  Serializable {
042:            private static final long serialVersionUID = 6505872267795979672L;
043:
044:            // Singleton
045:            private ProjectSettings() {
046:                allMatchers = new CompoundMatcher();
047:                filters = new ArrayList<FilterMatcher>();
048:            }
049:
050:            private static ProjectSettings instance;
051:
052:            public static ProjectSettings newInstance() {
053:                instance = new ProjectSettings();
054:                LastVersionMatcher dbf = LastVersionMatcher.DEAD_BUG_MATCHER;
055:
056:                //Important: add the deadbug filter directly to filters and allmatchers, dont go through addFilter, otherwise it causes a
057:                //tree to rebuild.
058:                MainFrame.getInstance().getProject().getSuppressionFilter()
059:                        .addChild(dbf);
060:                PreferencesFrame.getInstance().updateFilterPanel();
061:                return instance;
062:            }
063:
064:            public static synchronized ProjectSettings getInstance() {
065:                if (instance == null)
066:                    instance = new ProjectSettings();
067:                return instance;
068:            }
069:
070:            /**
071:             * The list of all defined filters
072:             */
073:            private ArrayList<FilterMatcher> filters;
074:
075:            /**
076:             * The CompoundMatcher enveloping all enabled matchers.
077:             */
078:            private CompoundMatcher allMatchers;
079:
080:            /**
081:             * Max number of previous comments stored.
082:             */
083:            private int maxSizeOfPreviousComments;
084:
085:            public static void loadInstance(InputStream in) {
086:                try {
087:                    instance = (ProjectSettings) new ObjectInputStream(in)
088:                            .readObject();
089:                    PreferencesFrame.getInstance().updateFilterPanel();
090:                    in.close();
091:                } catch (ClassNotFoundException e) {
092:                    if (MainFrame.DEBUG)
093:                        System.err.println("Error in deserializing Settings:");
094:                    Debug.println(e);
095:                } catch (IOException e) {
096:                    if (MainFrame.DEBUG)
097:                        System.err
098:                                .println("IO error in deserializing Settings:");
099:                    Debug.println(e);
100:                    instance = newInstance();
101:                }
102:            }
103:
104:            public void save(OutputStream out) {
105:                try {
106:                    new ObjectOutputStream(out).writeObject(this );
107:                } catch (IOException e) {
108:                    if (MainFrame.DEBUG)
109:                        System.err.println("Error serializing Settings:");
110:                    Debug.println(e);
111:                } finally {
112:                    try {
113:                        out.close();
114:                    } catch (IOException e) {
115:                        // nothing to do
116:                        assert true;
117:                    }
118:                }
119:            }
120:
121:            @Deprecated
122:            Filter getSuppressionFilter() {
123:                Project project = MainFrame.getInstance().getProject();
124:                if (project == null)
125:                    throw new NullPointerException("project is null");
126:                return project.getSuppressionFilter();
127:            }
128:
129:            public void addFilter(FilterMatcher filter) {
130:                filters.add(filter);
131:                allMatchers.add(filter);
132:                if (!(filter instanceof  StackedFilterMatcher))
133:                    FilterActivity.notifyListeners(
134:                            FilterListener.Action.FILTERING, null);
135:                else {
136:                    StackedFilterMatcher theSame = (StackedFilterMatcher) filter;
137:                    FilterMatcher[] filtersInStack = theSame.getFilters();
138:                    ArrayList<Sortables> order = MainFrame.getInstance()
139:                            .getSorter().getOrder();
140:                    int sizeToCheck = filtersInStack.length;
141:                    List<Sortables> sortablesToCheck = order.subList(0,
142:                            sizeToCheck);
143:                    Debug.println("Size to check" + sizeToCheck
144:                            + " checking list" + sortablesToCheck);
145:                    Debug.println("checking filters");
146:                    ArrayList<String> almostPath = new ArrayList<String>();
147:                    ArrayList<Sortables> almostPathSortables = new ArrayList<Sortables>();
148:                    for (int x = 0; x < sortablesToCheck.size(); x++) {
149:                        Sortables s = sortablesToCheck.get(x);
150:                        for (FilterMatcher fm : filtersInStack) {
151:                            if (s.equals(fm.getFilterBy())) {
152:                                almostPath.add(fm.getValue());
153:                                almostPathSortables.add(fm.getFilterBy());
154:                            }
155:                        }
156:                    }
157:                    if (almostPath.size() == filtersInStack.length) {
158:                        ArrayList<String> finalPath = new ArrayList<String>();
159:                        for (int x = 0; x < almostPath.size(); x++) {
160:                            Sortables s = almostPathSortables.get(x);
161:                            if (MainFrame.getInstance().getSorter()
162:                                    .getOrderBeforeDivider().contains(s))
163:                                finalPath.add(almostPath.get(x));
164:                        }
165:                        BugTreeModel model = (MainFrame.getInstance()
166:                                .getBugTreeModel());
167:                        try {
168:                            model.sendEvent(model.removeBranch(finalPath),
169:                                    BugTreeModel.TreeModification.REMOVE);
170:                        } catch (BranchOperationException e) {
171:                            throw new IllegalStateException(
172:                                    "They added a stacked filter on a branch that doesn't exist... Whaa?");
173:                        }
174:                    } else {
175:                        FilterActivity.notifyListeners(
176:                                FilterListener.Action.FILTERING, null);
177:                        throw new IllegalStateException(
178:                                "What huh?  How'd they add a stacked filter matcher bigger than the number of branches in the tree?!");
179:                    }
180:                }
181:                PreferencesFrame.getInstance().updateFilterPanel();
182:                MainFrame.getInstance().updateStatusBar();
183:            }
184:
185:            public void addFilters(FilterMatcher[] newFilters) {
186:                for (FilterMatcher i : newFilters)
187:                    if (!filters.contains(i)) {
188:                        filters.add(i);
189:                        allMatchers.add(i);
190:                    } else //if filters contains i
191:                    {
192:                        filters.get(filters.indexOf(i)).setActive(true);
193:                        //FIXME Do I need to do this for allMatchers too?  Or are the filters all the same, with both just holding references?
194:                    }
195:                FilterActivity.notifyListeners(FilterListener.Action.FILTERING,
196:                        null);
197:                PreferencesFrame.getInstance().updateFilterPanel();
198:                MainFrame.getInstance().updateStatusBar();
199:            }
200:
201:            public boolean removeFilter(FilterMatcher filter) {
202:                boolean result = filters.remove(filter)
203:                        && allMatchers.remove(filter);
204:                FilterActivity.notifyListeners(
205:                        FilterListener.Action.UNFILTERING, null);
206:                PreferencesFrame.getInstance().updateFilterPanel();
207:                MainFrame.getInstance().updateStatusBar();
208:                return result;
209:            }
210:
211:            ArrayList<FilterMatcher> getAllFilters() {
212:                return filters;
213:            }
214:
215:            /**
216:             * @return Returns the maximum number of previous comments stored.
217:             */
218:            public int getMaxSizeOfPreviousComments() {
219:                return maxSizeOfPreviousComments;
220:            }
221:
222:            /**
223:             * Sets the maximum number of previous comments stored.
224:             * @param num
225:             */
226:            public void setMaxSizeOfPreviousComments(int num) {
227:                maxSizeOfPreviousComments = num;
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.