Source Code Cross Referenced for VersionListDialog.java in  » Source-Control » sourcejammer » org » sourcejammer » client » gui » dialog » 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 » Source Control » sourcejammer » org.sourcejammer.client.gui.dialog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright (C) 2001, 2002 Robert MacGrogan
003:         *
004:         *  This library is free software; you can redistribute it and/or
005:         *  modify it under the terms of the GNU Lesser General Public
006:         *  License as published by the Free Software Foundation; either
007:         *  version 2.1 of the License, or (at your option) any later version.
008:         *
009:         *  This library is distributed in the hope that it will be useful,
010:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         *  Lesser General Public License for more details.
013:         *
014:         *  You should have received a copy of the GNU Lesser General Public
015:         *  License along with this library; if not, write to the Free Software
016:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:         *
018:         *
019:         * $Archive: SourceJammer$
020:         * $FileName: VersionListDialog.java$
021:         * $FileID: 4184$
022:         *
023:         * Last change:
024:         * $AuthorName: Rob MacGrogan$
025:         * $Date: 8/10/03 1:38 AM$
026:         * $Comment: Use new SourceJammerClient propery names.$
027:         */
028:
029:        package org.sourcejammer.client.gui.dialog;
030:
031:        import javax.swing.*;
032:        import java.awt.BorderLayout;
033:        import java.awt.FlowLayout;
034:        import java.awt.Font;
035:        import java.awt.GridLayout;
036:        import java.awt.Color;
037:        import java.awt.event.ActionEvent;
038:        import java.awt.event.ActionListener;
039:
040:        import javax.swing.event.ChangeEvent;
041:        import javax.swing.event.ChangeListener;
042:        import javax.swing.table.*;
043:        import org.sourcejammer.project.view.*;
044:        import org.sourcejammer.util.AppConfig;
045:        import org.sourcejammer.xml.soap.NodeInfoSerializer;
046:        import org.sourcejammer.client.gui.CommandCentral;
047:        import org.sourcejammer.client.gui.GuiUtil;
048:        import org.sourcejammer.client.gui.MessageBoxUtil;
049:        import org.sourcejammer.client.gui.listener.VersionSelectionListener;
050:        import org.sourcejammer.project.NodeIterator;
051:        import org.sourcejammer.project.NodeList;
052:        import org.sourcejammer.client.gui.VersionListTableModel;
053:        import org.sourcejammer.project.NodeExistsException;
054:        import org.sourcejammer.util.SJDate;
055:        import org.sourcejammer.client.gui.action.ActionCentral;
056:        import org.sourcejammer.client.gui.NoSelectionException;
057:        import org.sourcejammer.project.NodeDoesNotExistException;
058:        import org.sourcejammer.client.gui.listener.PopupListener;
059:        import org.sourcejammer.client.DisplayTextLibrary;
060:        import org.sourcejammer.client.SourceJammerClient;
061:
062:        import java.awt.event.MouseAdapter;
063:        import java.awt.event.MouseEvent;
064:
065:        /**
066:         * Title: $FileName: VersionListDialog.java$<br>
067:         * @author $AuthorName: Rob MacGrogan$<br>
068:         * @version $VerNum: 5$<br><br>
069:         * 
070:         * $Description: $<br>
071:         * $KeyWordsOff: $<br><br>
072:         */
073:        public class VersionListDialog extends SJDialog {
074:
075:            private VersionListDialog dialog = null;
076:            private JTextArea mjFileInfo = null;
077:            private JTable mjVersionList = null;
078:            private JTabbedPane mjFileTabs = null;
079:            private File mndFile = null;
080:            private String tree = null;
081:            private JTextArea treeArea = null;
082:
083:            public VersionListDialog(JFrame owner, File file)
084:                    throws NodeExistsException {
085:                super (owner);
086:                dialog = this ;
087:                setTitle(DisplayTextLibrary
088:                        .displayText(DisplayTextLibrary.LBL_FILE_DETAILS)
089:                        + file.getNodeName());
090:                mndFile = file;
091:                mjFileInfo = buildFileInfo();
092:                JScrollPane scrollPaneFileInfo = new JScrollPane(mjFileInfo);
093:
094:                mjVersionList = buildVersionListTable();
095:                JScrollPane scrollPaneVersionList = new JScrollPane(
096:                        mjVersionList);
097:
098:                JPanel verListPanel = new JPanel(new BorderLayout(3, 3));
099:
100:                // Button Panel on the right -------        
101:                JPanel rightButtons = new JPanel(new GridLayout(6, 1, 3, 3));
102:                if (mndFile.getFileType() == AppConfig.FileTypes.LABEL) {
103:                    rightButtons.add(buildGetLabelButton());
104:                    rightButtons.add(buildChangeListButton());
105:                }
106:
107:                rightButtons.add(buildCommentButton());
108:                rightButtons.add(buildGetButton());
109:
110:                if (mndFile.getFileType() == AppConfig.FileTypes.TEXT
111:                        || mndFile.getFileType() == AppConfig.FileTypes.LABEL) {
112:                    rightButtons.add(buildVisualDiffButton());
113:                }
114:
115:                rightButtons.add(buildRollbackButton());
116:                JPanel btnPanel = new JPanel(new BorderLayout());
117:                btnPanel.add(rightButtons, BorderLayout.NORTH);
118:
119:                verListPanel.add(scrollPaneVersionList, BorderLayout.CENTER);
120:                verListPanel.add(btnPanel, BorderLayout.EAST);
121:
122:                mjFileTabs = new JTabbedPane();
123:                mjFileTabs.add(verListPanel, DisplayTextLibrary
124:                        .displayText(DisplayTextLibrary.LBL_HISTORY));
125:                mjFileTabs.add(scrollPaneFileInfo, DisplayTextLibrary
126:                        .displayText(DisplayTextLibrary.LBL_FILE_INFO));
127:                mjFileTabs.add(buildTreeReportPanel(), DisplayTextLibrary
128:                        .displayText(DisplayTextLibrary.LBL_TREE));
129:                mjFileTabs.addChangeListener(new TreeTabClickListener(this ));
130:
131:                JPanel bottomButtons = new JPanel(new FlowLayout(
132:                        FlowLayout.CENTER));
133:                bottomButtons.add(buildDoneButton());
134:
135:                // Panel for all Elements ---------
136:                JPanel contentPanel = new JPanel(new BorderLayout(3, 3));
137:                contentPanel.add(mjFileTabs, BorderLayout.CENTER);
138:                contentPanel.add(bottomButtons, BorderLayout.SOUTH);
139:                contentPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3,
140:                        3));
141:
142:                getContentPane().add(contentPanel, BorderLayout.CENTER);
143:
144:            }
145:
146:            private JScrollPane buildTreeReportPanel() {
147:                treeArea = new JTextArea();
148:                treeArea.setEditable(false);
149:                treeArea
150:                        .setFont(SourceJammerClient.getInstance().getMonoFont());
151:                treeArea.setTabSize(SourceJammerClient.getInstance()
152:                        .getTabSize());
153:                JScrollPane pane = new JScrollPane(treeArea);
154:                return pane;
155:            }
156:
157:            public File getFile() {
158:                return mndFile;
159:            }
160:
161:            /**
162:             * Returns JTextArea with file info populated.
163:             */
164:            private JTextArea buildFileInfo() {
165:                //File Info Text area.
166:                JTextArea jFileInfo = new JTextArea();
167:                jFileInfo.setLineWrap(true);
168:                jFileInfo.setWrapStyleWord(true);
169:                jFileInfo.setDisabledTextColor(Color.black);
170:                jFileInfo.setRows(15);
171:                jFileInfo.setColumns(30);
172:                jFileInfo.setFont(SourceJammerClient.getInstance()
173:                        .getMonoFont());
174:                jFileInfo.setTabSize(SourceJammerClient.getInstance()
175:                        .getTabSize());
176:
177:                StringBuffer strInfo = new StringBuffer();
178:                long lFileSize = mndFile.getLatestVersionFileSize();
179:                long lFileSizeK = lFileSize / 1024;
180:                long lFileID = mndFile.getUniqueID();
181:                String sCreatedDate = mndFile.getCreatedDate().toString();
182:                int iHistoryType = mndFile.getHistoryStorageType();
183:                String sHistoryType = null;
184:                if (iHistoryType == AppConfig.FileHistoryStorageTypes.CURR_VERSION_SOURCE_ONLY) {
185:                    sHistoryType = DisplayTextLibrary
186:                            .displayText(DisplayTextLibrary.OPT_CURR);
187:                } else if (iHistoryType == AppConfig.FileHistoryStorageTypes.DIFF) {
188:                    sHistoryType = DisplayTextLibrary
189:                            .displayText(DisplayTextLibrary.OPT_DIFF);
190:                } else if (iHistoryType == AppConfig.FileHistoryStorageTypes.FULL_SOURCE) {
191:                    sHistoryType = DisplayTextLibrary
192:                            .displayText(DisplayTextLibrary.OPT_FULL);
193:                } else {
194:                    sHistoryType = DisplayTextLibrary
195:                            .displayText(DisplayTextLibrary.OPT_ZIP);
196:                }
197:                java.io.File test = new java.io.File("test");
198:
199:                String sFileType = null;
200:                if (mndFile.getFileType() == AppConfig.FileTypes.BINARY) {
201:                    sFileType = DisplayTextLibrary
202:                            .displayText(DisplayTextLibrary.OPT_BINARY);
203:                } else if (mndFile.getFileType() == AppConfig.FileTypes.LABEL) {
204:                    sFileType = DisplayTextLibrary
205:                            .displayText(DisplayTextLibrary.OPT_LABEL);
206:                } else {
207:                    sFileType = DisplayTextLibrary
208:                            .displayText(DisplayTextLibrary.OPT_TEXT);
209:                }
210:                strInfo
211:                        .append(
212:                                DisplayTextLibrary
213:                                        .displayText(DisplayTextLibrary.LBL_NAME))
214:                        .append(mndFile.getNodeName())
215:                        .append("\r\n")
216:                        .append(
217:                                DisplayTextLibrary
218:                                        .displayText(DisplayTextLibrary.LBL_ID))
219:                        .append(": ")
220:                        .append(lFileID)
221:                        .append("\r\n")
222:                        .append(
223:                                DisplayTextLibrary
224:                                        .displayText(DisplayTextLibrary.LBL_FILE_SIZE))
225:                        .append(lFileSizeK)
226:                        .append("k\r\n")
227:                        .append(
228:                                DisplayTextLibrary
229:                                        .displayText(DisplayTextLibrary.LBL_FILE_TYPE))
230:                        .append(sFileType)
231:                        .append("\r\n")
232:                        .append(
233:                                DisplayTextLibrary
234:                                        .displayText(DisplayTextLibrary.LBL_CREATED_DATE))
235:                        .append(sCreatedDate)
236:                        .append("\r\n")
237:                        .append(
238:                                DisplayTextLibrary
239:                                        .displayText(DisplayTextLibrary.LBL_HIST_TYPE))
240:                        .append(sHistoryType)
241:                        .append("\r\n")
242:                        .append("\r\n")
243:                        .append(
244:                                DisplayTextLibrary
245:                                        .displayText(DisplayTextLibrary.LBL_FILE_DESC))
246:                        .append("\r\n").append(mndFile.getDescription());
247:                jFileInfo.setText(strInfo.toString());
248:                jFileInfo.setEditable(false);
249:                return jFileInfo;
250:            }
251:
252:            /**
253:             * Returns JTable with version list populated.
254:             */
255:            private JTable buildVersionListTable() throws NodeExistsException {
256:                VersionListTableModel oVersionModel = GuiUtil
257:                        .getBaseVersionListTableModel();
258:                JTable jVersionList = new JTable(oVersionModel);
259:                jVersionList.setGridColor(Color.white);
260:                jVersionList.setAutoCreateColumnsFromModel(false);
261:                jVersionList.getTableHeader().setAlignmentX(LEFT_ALIGNMENT);
262:                TableColumn colV = jVersionList.getColumn(DisplayTextLibrary
263:                        .displayText(DisplayTextLibrary.COL_VER_NUMBER));
264:                colV.setPreferredWidth(20);
265:                GuiUtil
266:                        .setTableColumnToolTip(
267:                                jVersionList,
268:                                colV,
269:                                DisplayTextLibrary
270:                                        .displayText(DisplayTextLibrary.COL_VER_NUMBER),
271:                                "Version Number");
272:
273:                colV = jVersionList.getColumn(DisplayTextLibrary
274:                        .displayText(DisplayTextLibrary.LBL_ID));
275:                colV.setPreferredWidth(40);
276:                GuiUtil.setTableColumnToolTip(jVersionList, colV,
277:                        DisplayTextLibrary
278:                                .displayText(DisplayTextLibrary.LBL_ID), "ID");
279:
280:                colV = jVersionList.getColumn(DisplayTextLibrary
281:                        .displayText(DisplayTextLibrary.COL_DATE));
282:                colV.setPreferredWidth(110);
283:                GuiUtil.setTableColumnToolTip(jVersionList, colV,
284:                        DisplayTextLibrary
285:                                .displayText(DisplayTextLibrary.COL_DATE),
286:                        "Version Created Date");
287:
288:                colV = jVersionList.getColumn(DisplayTextLibrary
289:                        .displayText(DisplayTextLibrary.COL_USER));
290:                colV.setPreferredWidth(75);
291:                GuiUtil.setTableColumnToolTip(jVersionList, colV,
292:                        DisplayTextLibrary
293:                                .displayText(DisplayTextLibrary.COL_USER),
294:                        "User who created the version");
295:
296:                //Allow multi select for text only.
297:                if (mndFile.getFileType() == AppConfig.FileTypes.TEXT
298:                        || mndFile.getFileType() == AppConfig.FileTypes.LABEL) {
299:                    jVersionList
300:                            .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
301:                } else {
302:                    jVersionList
303:                            .setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
304:                }
305:                jVersionList.getSelectionModel().addListSelectionListener(
306:                        new VersionSelectionListener());
307:
308:                NodeIterator iter = mndFile.childNodes();
309:                iter = GuiUtil.sortNodeIterator(iter, true);
310:                while (iter.hasMoreNodes()) {
311:                    NodeInfo nd = (NodeInfo) iter.getNextNode();
312:                    oVersionModel.addVersionNode(nd);
313:                }
314:                jVersionList.setModel(oVersionModel);
315:                jVersionList
316:                        .setPreferredScrollableViewportSize(new java.awt.Dimension(
317:                                200, 175));
318:
319:                //Add double-click listener to get versions.
320:                jVersionList.addMouseListener(new MouseAdapter() {
321:                    public void mouseClicked(MouseEvent ev) {
322:                        if (ev.getClickCount() == 2) {
323:                            ActionEvent evGet = new ActionEvent(dialog,
324:                                    ActionEvent.ACTION_PERFORMED,
325:                                    "GetFileVersion");
326:                            ActionCentral.getInstance().fireActionThisThread(
327:                                    ActionCentral.act_GET_FILE_VERSION, evGet);
328:                        }
329:                    }
330:                } //end anon class
331:                        );
332:
333:                return jVersionList;
334:            }
335:
336:            private JButton buildDoneButton() {
337:                JButton btnDone = new JButton(DisplayTextLibrary
338:                        .displayText(DisplayTextLibrary.BTN_DONE));
339:                btnDone.addActionListener(new ActionListener() {
340:                    public void actionPerformed(ActionEvent ev) {
341:                        dialog.dispose();
342:                    }
343:                } //end anon class
344:                        );
345:                btnDone.setDefaultCapable(true);
346:                return btnDone;
347:            }
348:
349:            private JButton buildGetButton() {
350:                JButton btnGet = new JButton(DisplayTextLibrary
351:                        .displayText(DisplayTextLibrary.BTN_GET_VER));
352:                btnGet.addActionListener(new ActionListener() {
353:                    public void actionPerformed(ActionEvent ev) {
354:                        ActionEvent evGet = new ActionEvent(dialog,
355:                                ActionEvent.ACTION_PERFORMED, "GetFileVersion");
356:                        ActionCentral.getInstance().fireActionThisThread(
357:                                ActionCentral.act_GET_FILE_VERSION, evGet);
358:                    }
359:                } //end anon class
360:                );
361:                return btnGet;
362:            }
363:
364:            private JButton buildGetLabelButton() {
365:                JButton btn = new JButton(DisplayTextLibrary
366:                        .displayText(DisplayTextLibrary.BTN_GET_LABEL));
367:                btn.addActionListener(new ActionListener() {
368:                    public void actionPerformed(ActionEvent ev) {
369:                        ActionEvent evGet = new ActionEvent(dialog,
370:                                ActionEvent.ACTION_PERFORMED, "GetLabelVersion");
371:                        ActionCentral.getInstance().fireActionThisThread(
372:                                ActionCentral.act_GET_LABELED_VERSION, evGet);
373:                    }
374:                } //end anon class
375:                );
376:                return btn;
377:            }
378:
379:            private JButton buildChangeListButton() {
380:                JButton btn = new JButton(DisplayTextLibrary
381:                        .displayText(DisplayTextLibrary.BTN_CHANGE_LIST));
382:                btn.addActionListener(new ActionListener() {
383:                    public void actionPerformed(ActionEvent ev) {
384:                        ActionEvent evGet = new ActionEvent(dialog,
385:                                ActionEvent.ACTION_PERFORMED, "GetChangeList");
386:                        ActionCentral.getInstance().fireActionThisThread(
387:                                ActionCentral.act_GET_CHANGE_LIST, evGet);
388:                    }
389:                } //end anon class
390:                        );
391:                return btn;
392:            }
393:
394:            private JButton buildVisualDiffButton() {
395:                JButton btn = new JButton(DisplayTextLibrary
396:                        .displayText(DisplayTextLibrary.BTN_DIFF));
397:                btn.addActionListener(new ActionListener() {
398:                    public void actionPerformed(ActionEvent ev) {
399:                        ActionEvent evVDiff = new ActionEvent(dialog,
400:                                ActionEvent.ACTION_PERFORMED, "VisualDiff");
401:                        ActionCentral.getInstance().fireActionThisThread(
402:                                ActionCentral.act_VISUAL_DIFF, evVDiff);
403:                        dialog.dispose();
404:                    }
405:                } //end anon class
406:                        );
407:                return btn;
408:            }
409:
410:            private JButton buildRollbackButton() {
411:                JButton btn = new JButton(DisplayTextLibrary
412:                        .displayText(DisplayTextLibrary.BTN_ROLLBACK));
413:                btn.addActionListener(new ActionListener() {
414:                    public void actionPerformed(ActionEvent ev) {
415:                        ActionEvent evRoll = new ActionEvent(dialog,
416:                                ActionEvent.ACTION_PERFORMED,
417:                                "RollbackToVersion");
418:                        ActionCentral.getInstance().fireActionThisThread(
419:                                ActionCentral.act_ROLLBACK_TO_PREV_VERSION,
420:                                evRoll);
421:                    }
422:                } //end anon class
423:                        );
424:                return btn;
425:            }
426:
427:            private JButton buildCommentButton() {
428:                JButton btnComment = new JButton(DisplayTextLibrary
429:                        .displayText(DisplayTextLibrary.BTN_VIEW_COMMENT));
430:                btnComment.addActionListener(new ActionListener() {
431:                    public void actionPerformed(ActionEvent ev) {
432:                        ActionEvent evComment = new ActionEvent(dialog,
433:                                ActionEvent.ACTION_PERFORMED, "ViewComment");
434:                        ActionCentral.getInstance().fireActionThisThread(
435:                                ActionCentral.act_VIEW_VERSION_COMMENT,
436:                                evComment);
437:                    }
438:                } //end anon class
439:                        );
440:                return btnComment;
441:            }
442:
443:            public NodeInfo[] getTwoSelectedVersions()
444:                    throws NoSelectionException {
445:                if (mjVersionList.getSelectedRowCount() != 2) {
446:                    throw new NoSelectionException(
447:                            DisplayTextLibrary
448:                                    .displayText(DisplayTextLibrary.ERR_MUST_SEL_TWO_VER));
449:                }
450:                int[] selectedRows = mjVersionList.getSelectedRows();
451:                //We're going to assume that we have 2 selections because of test above.
452:                NodeInfo[] nd = new NodeInfo[2];
453:                VersionListTableModel model = (VersionListTableModel) mjVersionList
454:                        .getModel();
455:                try {
456:                    nd[0] = model.getVersionNodeAt(selectedRows[0]);
457:                    nd[1] = model.getVersionNodeAt(selectedRows[1]);
458:                } catch (NodeDoesNotExistException ex) {
459:                    throw new NoSelectionException(
460:                            DisplayTextLibrary
461:                                    .displayText(DisplayTextLibrary.ERR_CANT_DETERMINE_VER),
462:                            ex);
463:                }
464:                return nd;
465:            }
466:
467:            public int versionSelectedCount() {
468:                return mjVersionList.getSelectedRowCount();
469:            }
470:
471:            /**
472:             * Returns currently selected version as NodeInfo object.
473:             */
474:            public NodeInfo getSelectedVersion() throws NoSelectionException {
475:                if (mjVersionList.getSelectedRowCount() > 1) {
476:                    throw new NoSelectionException(
477:                            DisplayTextLibrary
478:                                    .displayText(DisplayTextLibrary.ERR_MUST_SEL_ONE_VER));
479:                }
480:                int iSelectedRow = mjVersionList.getSelectedRow();
481:                if (iSelectedRow < 0) {
482:                    throw new NoSelectionException(DisplayTextLibrary
483:                            .displayText(DisplayTextLibrary.ERR_NO_SEL_VER));
484:                }
485:                VersionListTableModel model = (VersionListTableModel) mjVersionList
486:                        .getModel();
487:                NodeInfo ndVersion = null;
488:                try {
489:                    ndVersion = model.getVersionNodeAt(iSelectedRow);
490:                } catch (NodeDoesNotExistException ex) {
491:                    throw new NoSelectionException(
492:                            DisplayTextLibrary
493:                                    .displayText(DisplayTextLibrary.ERR_CANT_DETERMINE_VER),
494:                            ex);
495:                }
496:                return ndVersion;
497:            }
498:
499:            public void showDialog(JFrame parentFrame) {
500:                this .setModal(true);
501:                this .pack();
502:                this .setLocationRelativeTo(parentFrame);
503:                this .show();
504:            }
505:
506:            private static class TreeTabClickListener implements  ChangeListener {
507:
508:                private VersionListDialog dialog = null;
509:
510:                public TreeTabClickListener(VersionListDialog dialog) {
511:                    this .dialog = dialog;
512:                }
513:
514:                public void stateChanged(ChangeEvent ev) {
515:                    Object source = ev.getSource();
516:                    if (source instanceof  JTabbedPane) {
517:                        JTabbedPane tabs = (JTabbedPane) source;
518:                        if (tabs.getSelectedIndex() == 2) {
519:                            if (dialog.tree == null) {
520:                                //We need to retrieve the report.
521:                                try {
522:                                    dialog.tree = CommandCentral.getInstance()
523:                                            .getBranchReport(
524:                                                    dialog.mndFile
525:                                                            .getUniqueID(),
526:                                                    null);
527:                                    dialog.treeArea.setText(dialog.tree);
528:                                } catch (Exception ex) {
529:                                    MessageBoxUtil.displayErrorMessage(ex
530:                                            .getMessage(), true);
531:                                }
532:                            }
533:                        }
534:                    }
535:                }
536:
537:            }
538:
539:            private static JFrame testFrame = null;
540:
541:            //
542:            public static void main(String[] args) {
543:                try {
544:                    AppConfig.getInstance(args[0]);
545:                    SourceJammerClient client = SourceJammerClient
546:                            .getInstance(args[0]);
547:                    DisplayTextLibrary.initializeInstance(client
548:                            .getDisplayTextPropertiesFileName());
549:                    testFrame = new JFrame();
550:                    JButton button = new JButton("View dialog.");
551:                    button.addActionListener(new ActionListener() {
552:                        public void actionPerformed(ActionEvent ev) {
553:                            File ndFileTest = new File();
554:                            ndFileTest.setNodeName("TestClass.java");
555:                            ndFileTest.setLatestVersionFileSize(1024);
556:                            ndFileTest.setFileType(AppConfig.FileTypes.TEXT);
557:                            ndFileTest
558:                                    .setDescription("This is a test file that does not exist.");
559:                            ndFileTest
560:                                    .setHistoryStorageType(AppConfig.FileHistoryStorageTypes.DIFF);
561:                            SJDate dt = new SJDate();
562:                            dt.setTime(new java.util.Date().getTime());
563:                            ndFileTest.setCreatedDate(dt);
564:
565:                            NodeInfo ver = new NodeInfo();
566:                            SJDate date = new SJDate();
567:                            NodeList versions = new NodeList();
568:
569:                            date.useDate(new java.util.Date());
570:
571:                            try {
572:                                ver.setNodeName("1");
573:                                ver.setCreatedDate(date);
574:                                ver.setCreatedUser("rob");
575:                                versions.addNode(ver);
576:
577:                                ver = new NodeInfo();
578:                                ver.setNodeName("2");
579:                                ver.setCreatedDate(date);
580:                                ver.setCreatedUser("joe");
581:                                versions.addNode(ver);
582:
583:                                ver = new NodeInfo();
584:                                ver.setNodeName("3");
585:                                ver.setCreatedDate(date);
586:                                ver.setCreatedUser("tim");
587:                                versions.addNode(ver);
588:
589:                                ver = new NodeInfo();
590:                                ver.setNodeName("4");
591:                                ver.setCreatedDate(date);
592:                                ver.setCreatedUser("tom");
593:                                versions.addNode(ver);
594:                                try {
595:                                    ndFileTest.useChildNodeList(versions);
596:                                    VersionListDialog jDia = new VersionListDialog(
597:                                            testFrame, ndFileTest);
598:                                    jDia.showDialog(testFrame);
599:                                } catch (NodeExistsException ex) {
600:                                    ex.printStackTrace();
601:                                }
602:                            } catch (NodeExistsException ex) {
603:                                ex.printStackTrace();
604:                            }
605:
606:                        }
607:                    });
608:                    testFrame.getContentPane().add(button);
609:                    org.sourcejammer.client.gui.GJApp.launch(testFrame, "test",
610:                            200, 200, 800, 500);
611:                } catch (Throwable thr) {
612:                    thr.printStackTrace();
613:                }
614:            }
615:
616:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.