Source Code Cross Referenced for Setup.java in  » IDE-Netbeans » subversion » org » netbeans » modules » subversion » ui » diff » 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 » subversion » org.netbeans.modules.subversion.ui.diff 
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.subversion.ui.diff;
043:
044:        import org.netbeans.api.diff.StreamSource;
045:        import org.netbeans.api.diff.DiffController;
046:        import org.netbeans.modules.subversion.*;
047:        import org.netbeans.modules.subversion.client.PropertiesClient;
048:        import org.openide.util.NbBundle;
049:
050:        import java.io.File;
051:        import java.io.IOException;
052:        import java.util.*;
053:        import java.text.MessageFormat;
054:
055:        /**
056:         * Represents on DIFF setup.
057:         *
058:         * @author Maros Sandor
059:         */
060:        public final class Setup {
061:
062:            /**
063:             * What was locally changed? The right pane contains local file.
064:             *
065:             * <p>Local addition, removal or change is displayed in
066:             * the right pane as addition, removal or change respectively
067:             * (i.e. not reversed as removal, addition or change).
068:             *
069:             * <pre>
070:             * diff from-BASE to-LOCAL
071:             * </pre>
072:             */
073:            public static final int DIFFTYPE_LOCAL = 0;
074:
075:            /**
076:             * What was remotely changed? The right pane contains remote file.
077:             *
078:             * <p>Remote addition, removal or change is displayed in
079:             * the right pane as addition, removal or change respectively
080:             * (i.e. not reversed as removal, addition or change).
081:             *
082:             * <pre>
083:             * diff from-BASE to-HEAD
084:             * </pre>
085:             */
086:            public static final int DIFFTYPE_REMOTE = 1;
087:
088:            /**
089:             * What was locally changed comparing to recent head?
090:             * The Right pane contains local file.
091:             *
092:             * <p> Local addition, removal or change is displayed in
093:             * the right pane as addition, removal or change respectively
094:             * (i.e. not reversed as removal, addition or change).
095:             *
096:             * <pre>
097:             * diff from-HEAD to-LOCAL
098:             * </pre>
099:             */
100:            public static final int DIFFTYPE_ALL = 2;
101:
102:            public static final String REVISION_PRISTINE = "PRISTINE"; // NOI18N
103:            public static final String REVISION_BASE = "BASE"; // NOI18N
104:            public static final String REVISION_CURRENT = "LOCAL"; // NOI18N
105:            public static final String REVISION_HEAD = "HEAD"; // NOI18N
106:
107:            private final File baseFile;
108:
109:            /**
110:             * Name of the file's property if the setup represents a property diff setup, null otherwise. 
111:             */
112:            private final String propertyName;
113:
114:            private String firstRevision;
115:            private final String secondRevision;
116:            private FileInformation info;
117:
118:            private DiffStreamSource firstSource;
119:            private DiffStreamSource secondSource;
120:
121:            private DiffController view;
122:            private DiffNode node;
123:
124:            private String title;
125:
126:            public Setup(File baseFile, String propertyName, int type) {
127:                this .baseFile = baseFile;
128:                this .propertyName = propertyName;
129:                info = Subversion.getInstance().getStatusCache().getStatus(
130:                        baseFile);
131:                int status = info.getStatus();
132:
133:                ResourceBundle loc = NbBundle.getBundle(Setup.class);
134:                String firstTitle;
135:                String secondTitle;
136:
137:                // the first source
138:
139:                switch (type) {
140:                case DIFFTYPE_LOCAL:
141:                case DIFFTYPE_REMOTE:
142:
143:                    // from-BASE
144:
145:                    if (match(
146:                            status,
147:                            FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY
148:                                    | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) {
149:                        firstRevision = REVISION_BASE;
150:                        firstTitle = loc.getString("MSG_DiffPanel_LocalNew");
151:                    } else if (match(status,
152:                            FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) {
153:                        firstRevision = null;
154:                        firstTitle = NbBundle.getMessage(Setup.class,
155:                                "LBL_Diff_NoLocalFile"); // NOI18N
156:                    } else if (match(
157:                            status,
158:                            FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
159:                                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) {
160:                        firstRevision = REVISION_BASE;
161:                        firstTitle = MessageFormat.format(loc
162:                                .getString("MSG_DiffPanel_BaseRevision"),
163:                                new Object[] { firstRevision });
164:                    } else {
165:                        firstRevision = REVISION_BASE;
166:                        firstTitle = MessageFormat.format(loc
167:                                .getString("MSG_DiffPanel_BaseRevision"),
168:                                new Object[] { firstRevision });
169:                    }
170:
171:                    break;
172:
173:                case DIFFTYPE_ALL:
174:
175:                    // from-HEAD
176:
177:                    if (match(status,
178:                            FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) {
179:                        firstRevision = REVISION_HEAD;
180:                        firstTitle = loc.getString("MSG_DiffPanel_RemoteNew");
181:                    } else if (match(
182:                            status,
183:                            FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY
184:                                    | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) {
185:                        firstRevision = null;
186:                        firstTitle = loc
187:                                .getString("MSG_DiffPanel_NoBaseRevision");
188:                    } else if (match(
189:                            status,
190:                            FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY)) {
191:                        firstRevision = null;
192:                        firstTitle = loc
193:                                .getString("MSG_DiffPanel_RemoteDeleted");
194:                    } else {
195:                        firstRevision = REVISION_HEAD;
196:                        firstTitle = MessageFormat.format(loc
197:                                .getString("MSG_DiffPanel_RemoteModified"),
198:                                new Object[] { firstRevision });
199:                    }
200:                    break;
201:
202:                default:
203:                    throw new IllegalArgumentException("Unknow diff type: "
204:                            + type); // NOI18N
205:                }
206:
207:                // the second source
208:
209:                switch (type) {
210:                case DIFFTYPE_LOCAL:
211:                case DIFFTYPE_ALL:
212:
213:                    // to-LOCAL
214:
215:                    if (match(status, FileInformation.STATUS_VERSIONED_CONFLICT)) {
216:                        secondRevision = REVISION_CURRENT;
217:                        secondTitle = MessageFormat.format(loc
218:                                .getString("MSG_DiffPanel_LocalConflict"),
219:                                new Object[] { secondRevision });
220:                    } else if (match(
221:                            status,
222:                            FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY
223:                                    | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) {
224:                        secondRevision = REVISION_CURRENT;
225:                        secondTitle = loc.getString("MSG_DiffPanel_LocalNew");
226:                    } else if (match(status,
227:                            FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) {
228:                        secondRevision = null;
229:                        secondTitle = NbBundle.getMessage(Setup.class,
230:                                "LBL_Diff_NoLocalFile"); // NOI18N
231:                    } else if (match(
232:                            status,
233:                            FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
234:                                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) {
235:                        secondRevision = null;
236:                        secondTitle = loc
237:                                .getString("MSG_DiffPanel_LocalDeleted");
238:                    } else {
239:                        secondRevision = REVISION_CURRENT;
240:                        secondTitle = MessageFormat.format(loc
241:                                .getString("MSG_DiffPanel_LocalModified"),
242:                                new Object[] { secondRevision });
243:                    }
244:                    break;
245:
246:                case DIFFTYPE_REMOTE:
247:
248:                    // to-HEAD
249:
250:                    if (match(
251:                            status,
252:                            FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY
253:                                    | FileInformation.STATUS_VERSIONED_ADDEDLOCALLY)) {
254:                        secondRevision = null;
255:                        secondTitle = loc.getString("MSG_DiffPanel_LocalNew");
256:                    } else if (match(status,
257:                            FileInformation.STATUS_VERSIONED_NEWINREPOSITORY)) {
258:                        secondRevision = REVISION_HEAD;
259:                        secondTitle = loc.getString("MSG_DiffPanel_RemoteNew");
260:                    } else if (match(
261:                            status,
262:                            FileInformation.STATUS_VERSIONED_REMOVEDINREPOSITORY)) {
263:                        secondRevision = null;
264:                        secondTitle = loc
265:                                .getString("MSG_DiffPanel_RemoteDeleted");
266:                    } else {
267:                        secondRevision = REVISION_HEAD;
268:                        secondTitle = MessageFormat.format(loc
269:                                .getString("MSG_DiffPanel_RemoteModified"),
270:                                new Object[] { secondRevision });
271:                    }
272:                    break;
273:
274:                default:
275:                    throw new IllegalArgumentException("Unknow diff type: "
276:                            + type); // NOI18N
277:                }
278:
279:                if (propertyName != null) {
280:                    if (REVISION_HEAD.equals(firstRevision)) {
281:                        firstRevision = REVISION_BASE;
282:                    }
283:                }
284:
285:                firstSource = new DiffStreamSource(baseFile, propertyName,
286:                        firstRevision, firstTitle);
287:                secondSource = new DiffStreamSource(baseFile, propertyName,
288:                        secondRevision, secondTitle);
289:                title = "<html>"
290:                        + Subversion.getInstance().getAnnotator()
291:                                .annotateNameHtml(baseFile, info); // NOI18N
292:            }
293:
294:            /**
295:             * Text file setup for arbitrary revisions.
296:             * @param firstRevision first revision or <code>null</code> for inital.
297:             * @param secondRevision second revision
298:             */
299:            public Setup(File baseFile, String firstRevision,
300:                    String secondRevision) {
301:                this .baseFile = baseFile;
302:                this .propertyName = null;
303:                this .firstRevision = firstRevision;
304:                this .secondRevision = secondRevision;
305:                firstSource = new DiffStreamSource(baseFile, propertyName,
306:                        firstRevision, firstRevision);
307:                secondSource = new DiffStreamSource(baseFile, propertyName,
308:                        secondRevision, secondRevision);
309:            }
310:
311:            public String getPropertyName() {
312:                return propertyName;
313:            }
314:
315:            public File getBaseFile() {
316:                return baseFile;
317:            }
318:
319:            public FileInformation getInfo() {
320:                return info;
321:            }
322:
323:            public void setView(DiffController view) {
324:                this .view = view;
325:            }
326:
327:            public DiffController getView() {
328:                return view;
329:            }
330:
331:            public StreamSource getFirstSource() {
332:                return firstSource;
333:            }
334:
335:            public StreamSource getSecondSource() {
336:                return secondSource;
337:            }
338:
339:            public void setNode(DiffNode node) {
340:                this .node = node;
341:            }
342:
343:            public DiffNode getNode() {
344:                return node;
345:            }
346:
347:            public String toString() {
348:                return title;
349:            }
350:
351:            /**
352:             * Loads data over network
353:             */
354:            void initSources() throws IOException {
355:                if (firstSource != null)
356:                    firstSource.init();
357:                if (secondSource != null)
358:                    secondSource.init();
359:            }
360:
361:            private static boolean match(int status, int mask) {
362:                return (status & mask) != 0;
363:            }
364:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.