Source Code Cross Referenced for CvsModuleConfig.java in  » IDE-Netbeans » versioning » org » netbeans » modules » versioning » system » cvss » 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 » IDE Netbeans » versioning » org.netbeans.modules.versioning.system.cvss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.versioning.system.cvss;
043:
044:        import java.util.regex.Pattern;
045:        import java.util.*;
046:        import java.lang.String;
047:        import java.util.prefs.Preferences;
048:        import java.io.File;
049:
050:        import org.openide.util.NbPreferences;
051:        import org.netbeans.modules.versioning.util.Utils;
052:        import org.netbeans.modules.versioning.util.FileCollection;
053:        import org.netbeans.lib.cvsclient.CVSRoot;
054:
055:        /**
056:         * Stores CVS module configuration.
057:         *
058:         * @author Maros Sandor
059:         */
060:        public class CvsModuleConfig {
061:
062:            public static final String PROP_IGNORED_FILEPATTERNS = "ignoredFilePatterns"; // NOI18N
063:            public static final String PROP_COMMIT_EXCLUSIONS = "commitExclusions"; // NOI18N
064:            public static final String PROP_SEARCHHISTORY_FETCHTAGS = "searchHistory.fetchTags"; // NOI18N
065:            public static final String PROP_EXCLUDE_NEW_FILES = "excludeNewFiles"; // NOI18N
066:            public static final String ROOTS_CONFIG = "rootsConfig"; // NOI18N
067:            public static final String PROP_ANNOTATIONS_FORMAT = "annotationsFormat"; // NOI18N
068:            private static final String PROP_WRAP_COMMIT_MESSAGE_LENGTH = "wrapCommitMessageLength"; // NOI18N
069:
070:            public static final String DEFAULT_ANNOTATIONS_FORMAT = "[{status}; {tag}]";
071:
072:            private static final String FIELD_SEPARATOR = "<~>";
073:
074:            private static final CvsModuleConfig INSTANCE = new CvsModuleConfig();
075:
076:            public static CvsModuleConfig getDefault() {
077:                return INSTANCE;
078:            }
079:
080:            private FileCollection excludedFiles;
081:
082:            private Map<String, RootSettings> rootsMap;
083:
084:            public CvsModuleConfig() {
085:                excludedFiles = new FileCollection();
086:                excludedFiles.load(getPreferences(), PROP_COMMIT_EXCLUSIONS);
087:            }
088:
089:            /**
090:             * @return 0 = do NOT wrap commit message
091:             */
092:            public int getWrapCommitMessagelength() {
093:                return getPreferences().getInt(PROP_WRAP_COMMIT_MESSAGE_LENGTH,
094:                        0);
095:            }
096:
097:            /**
098:             * @param length 0 = do NOT wrap commit message
099:             */
100:            public void setWrapCommitMessagelength(int length) {
101:                if (length < 0)
102:                    throw new IllegalArgumentException();
103:                getPreferences()
104:                        .putInt(PROP_WRAP_COMMIT_MESSAGE_LENGTH, length);
105:            }
106:
107:            public Pattern[] getIgnoredFilePatterns() {
108:                return getDefaultFilePatterns();
109:            }
110:
111:            public boolean isExcludedFromCommit(File file) {
112:                return excludedFiles.contains(file);
113:            }
114:
115:            /**
116:             * @param file file to exclude from commit
117:             */
118:            public void addExclusion(File file) {
119:                excludedFiles.add(file);
120:                excludedFiles.save(getPreferences(), PROP_COMMIT_EXCLUSIONS);
121:            }
122:
123:            /**
124:             * @param file file to include in commit
125:             */
126:            public void removeExclusion(File file) {
127:                excludedFiles.remove(file);
128:                excludedFiles.save(getPreferences(), PROP_COMMIT_EXCLUSIONS);
129:            }
130:
131:            // clients code ~~~~~~~~~~~~~~~~~~~~~~~~~
132:
133:            public synchronized boolean hasExtSettingsFor(CVSRoot root) {
134:                assert "ext".equals(root.getMethod()); // NOI18N
135:                Map<String, RootSettings> rootsMap = getRootsMap();
136:                String rootString = root.toString();
137:                RootSettings rootSettings = (RootSettings) rootsMap
138:                        .get(rootString);
139:                if (rootSettings != null) {
140:                    ExtSettings extSettings = rootSettings.extSettings;
141:                    return extSettings != null;
142:                }
143:                return false;
144:            }
145:
146:            /**
147:             * Loads a value set by {@link #setExtSettingsFor}.
148:             *
149:             * @param root cvs root with <code>:ext:</code> connection method
150:             * @return  additional ext settings or their default value
151:             */
152:            public synchronized ExtSettings getExtSettingsFor(CVSRoot root) {
153:                assert "ext".equals(root.getMethod()); // NOI18N
154:                Map<String, RootSettings> rootsMap = getRootsMap();
155:                String rootString = root.toString();
156:                RootSettings rootSettings = (RootSettings) rootsMap
157:                        .get(rootString);
158:                if (rootSettings != null) {
159:                    ExtSettings extSettings = rootSettings.extSettings;
160:                    if (extSettings != null) {
161:                        if (extSettings.extUseInternalSsh == false
162:                                && extSettings.extCommand == null) {
163:                            extSettings.extCommand = System.getenv("CVS_RSH"); // NOI18N
164:                        }
165:                        return extSettings;
166:                    }
167:                }
168:
169:                // hardcoded default value
170:                ExtSettings defaults = new ExtSettings();
171:                defaults.extRememberPassword = false;
172:                defaults.extCommand = System.getenv("CVS_RSH"); // NOI18N
173:                defaults.extUseInternalSsh = true;
174:                defaults.extPassword = null;
175:                return defaults;
176:            }
177:
178:            public synchronized void setExtSettingsFor(CVSRoot root,
179:                    ExtSettings extSettings) {
180:                assert "ext".equals(root.getMethod()); // NOI18N
181:                Map<String, RootSettings> map = getRootsMap();
182:                String key = root.toString();
183:                RootSettings settings = (RootSettings) map.get(key);
184:                if (settings == null) {
185:                    settings = new RootSettings();
186:                }
187:                settings.extSettings = extSettings;
188:                map.put(key, settings);
189:
190:                storeRootsMap();
191:            }
192:
193:            private Map<String, RootSettings> getRootsMap() {
194:                if (rootsMap == null) {
195:                    rootsMap = loadRootsMap();
196:                }
197:                return rootsMap;
198:            }
199:
200:            private Map<String, RootSettings> loadRootsMap() {
201:                List<String> smap = Utils.getStringList(getPreferences(),
202:                        "cvsRootSettings");
203:                Map<String, RootSettings> map = new HashMap<String, RootSettings>(
204:                        smap.size());
205:                for (String s : smap) {
206:                    String[] fields = s.split(FIELD_SEPARATOR);
207:                    if (fields.length >= 8) {
208:                        // TODO: old settings, remove this block after 6.0
209:                        RootSettings rs = new RootSettings();
210:                        map.put(fields[0], rs);
211:                        if (fields.length >= 11) {
212:                            ExtSettings es = new ExtSettings();
213:                            rs.extSettings = es;
214:                            es.extUseInternalSsh = Boolean.valueOf(fields[8]);
215:                            es.extRememberPassword = Boolean.valueOf(fields[9]);
216:                            es.extCommand = fields[10];
217:                            if (fields.length >= 12) {
218:                                es.extPassword = fields[11];
219:                            }
220:                        }
221:                    } else {
222:                        if (fields.length >= 4) {
223:                            RootSettings rs = new RootSettings();
224:                            map.put(fields[0], rs);
225:                            ExtSettings es = new ExtSettings();
226:                            rs.extSettings = es;
227:                            es.extUseInternalSsh = Boolean.valueOf(fields[1]);
228:                            es.extRememberPassword = Boolean.valueOf(fields[2]);
229:                            es.extCommand = fields[3];
230:                            if (fields.length >= 5) {
231:                                es.extPassword = fields[4];
232:                            }
233:                        }
234:                    }
235:                }
236:                return map;
237:            }
238:
239:            private void storeRootsMap() {
240:                List<String> smap = new ArrayList<String>();
241:                for (Map.Entry<String, RootSettings> entry : rootsMap
242:                        .entrySet()) {
243:                    StringBuffer es = new StringBuffer(100);
244:                    es.append(entry.getKey());
245:                    RootSettings settings = entry.getValue();
246:                    if (settings.extSettings != null) {
247:                        es.append(FIELD_SEPARATOR);
248:                        es.append(settings.extSettings.extUseInternalSsh);
249:                        es.append(FIELD_SEPARATOR);
250:                        es.append(settings.extSettings.extRememberPassword);
251:                        es.append(FIELD_SEPARATOR);
252:                        es.append(settings.extSettings.extCommand);
253:                        if (settings.extSettings.extRememberPassword) {
254:                            es.append(FIELD_SEPARATOR);
255:                            es.append(settings.extSettings.extPassword);
256:                        }
257:                    }
258:                    smap.add(es.toString());
259:                }
260:                Utils.put(getPreferences(), "cvsRootSettings", smap);
261:            }
262:
263:            /**
264:             * Gets the backing store of module preferences, use this to store and retrieve simple properties and stored values. 
265:             *  
266:             * @return Preferences backing store
267:             */
268:            public Preferences getPreferences() {
269:                return NbPreferences.forModule(CvsModuleConfig.class);
270:            }
271:
272:            // private methods ~~~~~~~~~~~~~~~~~~
273:
274:            private static final Pattern[] defaultIgnoredPatterns = new Pattern[] {
275:                    Pattern.compile("cvslog\\..*"), // NOI18N
276:                    Pattern.compile("\\.make\\.state"), // NOI18N
277:                    Pattern.compile("\\.nse_depinfo"), // NOI18N
278:                    Pattern.compile(".*~"), // NOI18N
279:                    Pattern.compile("#.*"), // NOI18N
280:                    Pattern.compile("\\.#.*"), // NOI18N
281:                    Pattern.compile(",.*"), // NOI18N
282:                    Pattern.compile("_\\$.*"), // NOI18N
283:                    Pattern.compile(".*\\$"), // NOI18N
284:                    Pattern.compile(".*\\.old"), // NOI18N
285:                    Pattern.compile(".*\\.bak"), // NOI18N
286:                    Pattern.compile(".*\\.BAK"), // NOI18N
287:                    Pattern.compile(".*\\.orig"), // NOI18N
288:                    Pattern.compile(".*\\.rej"), // NOI18N
289:                    Pattern.compile(".*\\.del-.*"), // NOI18N
290:                    Pattern.compile(".*\\.a"), // NOI18N
291:                    Pattern.compile(".*\\.olb"), // NOI18N
292:                    Pattern.compile(".*\\.o"), // NOI18N
293:                    Pattern.compile(".*\\.obj"), // NOI18N
294:                    Pattern.compile(".*\\.so"), // NOI18N
295:                    Pattern.compile(".*\\.exe"), // NOI18N
296:                    Pattern.compile(".*\\.Z"), // NOI18N
297:                    Pattern.compile(".*\\.elc"), // NOI18N
298:                    Pattern.compile(".*\\.ln"), // NOI18N
299:            };
300:
301:            private Pattern[] getDefaultFilePatterns() {
302:                return defaultIgnoredPatterns;
303:            }
304:
305:            /**
306:             * Holds associated settings.
307:             */
308:            private final static class RootSettings {
309:
310:                private ExtSettings extSettings;
311:            }
312:
313:            /** External method additional settings */
314:            public final static class ExtSettings {
315:
316:                public boolean extUseInternalSsh;
317:
318:                /** Makes sense if extUseInternalSsh == true */
319:                public boolean extRememberPassword;
320:
321:                /** Makes sense if extUseInternalSsh == true */
322:                public String extPassword;
323:
324:                /** Makes sense if extUseInternalSsh == false */
325:                public String extCommand;
326:            }
327:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.