Source Code Cross Referenced for TableEntry.java in  » Content-Management-System » harmonise » org » openharmonise » him » displaycomponents » table » 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 » Content Management System » harmonise » org.openharmonise.him.displaycomponents.table 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:
020:        package org.openharmonise.him.displaycomponents.table;
021:
022:        import java.awt.*;
023:        import java.awt.dnd.*;
024:        import java.awt.event.*;
025:        import java.util.*;
026:
027:        import javax.swing.*;
028:
029:        import org.openharmonise.commons.xml.namespace.*;
030:        import org.openharmonise.him.configuration.*;
031:        import org.openharmonise.him.context.StateHandler;
032:        import org.openharmonise.him.dnd.*;
033:        import org.openharmonise.him.editors.*;
034:        import org.openharmonise.him.harmonise.*;
035:        import org.openharmonise.him.window.menus.*;
036:        import org.openharmonise.him.window.messages.*;
037:        import org.openharmonise.swing.FontManager;
038:        import org.openharmonise.vfs.*;
039:        import org.openharmonise.vfs.context.*;
040:        import org.openharmonise.vfs.event.*;
041:        import org.openharmonise.vfs.gui.*;
042:        import org.openharmonise.vfs.metadata.*;
043:        import org.openharmonise.vfs.metadata.value.*;
044:
045:        /**
046:         * Component for displaying resource information in the table view.
047:         * 
048:         * @author Matthew Large
049:         * @version $Revision: 1.3 $
050:         *
051:         */
052:        public class TableEntry extends JPanel implements  MouseListener,
053:                VirtualFileListener, ContextListener {
054:
055:            /**
056:             * Expand entry icon.
057:             */
058:            private JLabel m_expandIcon = null;
059:
060:            /**
061:             * Icon in the top right.
062:             */
063:            private JLabel m_topRightIcon = null;
064:
065:            /**
066:             * Title.
067:             */
068:            private JLabel m_title = null;
069:
070:            /**
071:             * Icon in the bottom right.
072:             */
073:            private JLabel m_bottomRightIcon = null;
074:
075:            /**
076:             * Name and date panel.
077:             */
078:            private JPanel m_dateInfo = null;
079:
080:            /**
081:             * Version information panel.
082:             */
083:            private JPanel m_versionInfo = null;
084:
085:            /**
086:             * Version panel in scroller.
087:             */
088:            private JPanel m_versionInnerPane = null;
089:
090:            /**
091:             * true if the table entry has been expaned to show version information.
092:             */
093:            private boolean m_bExpanded = false;
094:
095:            /**
096:             * Virtual file system for resource.
097:             */
098:            private AbstractVirtualFileSystem m_vfs = null;
099:
100:            /**
101:             * Full path to resource.
102:             */
103:            private String m_sFilePath;
104:
105:            /**
106:             * Resource name.
107:             */
108:            private String m_sFilename;
109:
110:            /**
111:             * Resource icon.
112:             */
113:            private Icon m_iFileIcon;
114:
115:            /**
116:             * Resource date.
117:             */
118:            private String m_sFileDate;
119:
120:            /**
121:             * Table view that this entry is in.
122:             */
123:            private TableView m_table = null;
124:
125:            /**
126:             * Selected highlight colour.
127:             */
128:            private Color m_selectedColor = new Color(173, 169, 143);
129:
130:            /**
131:             * List of {@link VersionEntry} objects.
132:             */
133:            private ArrayList m_versionEntries = new ArrayList();
134:
135:            /**
136:             * true if the resource has been deleted.
137:             */
138:            private boolean m_bDeleted = false;
139:
140:            private boolean m_bArchive = false;
141:
142:            /**
143:             * 
144:             */
145:            private TableEntry() {
146:                super ();
147:            }
148:
149:            /**
150:             * @param arg0
151:             */
152:            private TableEntry(boolean arg0) {
153:                super (arg0);
154:            }
155:
156:            /**
157:             * @param arg0
158:             */
159:            private TableEntry(LayoutManager arg0) {
160:                super (arg0);
161:            }
162:
163:            /**
164:             * @param arg0
165:             * @param arg1
166:             */
167:            private TableEntry(LayoutManager arg0, boolean arg1) {
168:                super (arg0, arg1);
169:            }
170:
171:            /**
172:             * Constructs a new table entry.
173:             * 
174:             * @param vfs Virtual file system for resource
175:             * @param sFilePath Full path to resource
176:             * @param table Table view this entry is in
177:             */
178:            public TableEntry(AbstractVirtualFileSystem vfs, String sFilePath,
179:                    TableView table) {
180:                super (true);
181:                this .m_vfs = vfs;
182:                this .m_sFilePath = sFilePath;
183:                this .m_table = table;
184:                VirtualFile vfFile = this .m_vfs
185:                        .getVirtualFile(this .m_sFilePath).getResource();
186:
187:                if (vfFile.isVersionable()
188:                        && vfFile.getState().equals(VirtualFile.STATE_LIVE)
189:                        && ((VersionedVirtualFile) vfFile).hasPendingVersion()) {
190:                    vfFile = vfFile.getVFS().getVirtualFile(
191:                            ((VersionedVirtualFile) vfFile)
192:                                    .getPendingVersionPath()).getResource();
193:                    this .m_vfs = vfFile.getVFS();
194:                    this .m_sFilePath = vfFile.getFullPath();
195:                }
196:
197:                vfFile.addVirtualFileListener(this );
198:                this .setup();
199:            }
200:
201:            /**
202:             * Clears all resources that this class is holding onto making it
203:             * ready to be destroyed.
204:             *
205:             */
206:            public void clearToDestroy() {
207:                ContextHandler.getInstance().removeListener(
208:                        ContextType.CONTEXT_FILENAME_DISPLAY, this );
209:                if (!this .m_bDeleted) {
210:                    VirtualFile vfFile = this .m_vfs.getVirtualFile(
211:                            this .m_sFilePath).getResource();
212:                    if (vfFile != null) {
213:                        vfFile.removeVirtualFileListener(this );
214:                    }
215:                    for (Iterator iter = this .m_versionEntries.iterator(); iter
216:                            .hasNext();) {
217:                        VersionEntry element = (VersionEntry) iter.next();
218:                        element.clearToDestroy();
219:                    }
220:                }
221:            }
222:
223:            /**
224:             * Returns the logical path, which is what we need to use when
225:             * dragging a resource.
226:             * 
227:             * @return Full path
228:             */
229:            public String getDragVirtualFilePath() {
230:                String sPath = null;
231:
232:                VirtualFile vfFile = this .m_vfs
233:                        .getVirtualFile(this .m_sFilePath).getResource();
234:                sPath = vfFile.getFullPath();
235:                if (vfFile.isVersionable()
236:                        && vfFile.getState().equals(VirtualFile.STATE_PENDING)
237:                        && ((VersionedVirtualFile) vfFile).getLiveVersionPath() != null) {
238:                    sPath = ((VersionedVirtualFile) vfFile)
239:                            .getLiveVersionPath();
240:                }
241:
242:                return sPath;
243:            }
244:
245:            /**
246:             * Configures this table entry.
247:             *
248:             */
249:            private void setup() {
250:                ContextHandler.getInstance().addListener(
251:                        ContextType.CONTEXT_FILENAME_DISPLAY, this );
252:
253:                VirtualFile vfFile = this .m_vfs
254:                        .getVirtualFile(this .m_sFilePath).getResource();
255:                VirtualFile vfActualFile = vfFile;
256:                if (vfFile.getFullPath()
257:                        .startsWith(HarmonisePaths.PATH_ARCHIVE)) {
258:                    m_bArchive = true;
259:                }
260:
261:                if (vfFile.isVersionable()
262:                        && vfFile.getState().equals(VirtualFile.STATE_PENDING)
263:                        && ((VersionedVirtualFile) vfFile).getLiveVersionPath() != null) {
264:                    vfFile = vfFile.getVFS().getVirtualFile(
265:                            ((VersionedVirtualFile) vfFile)
266:                                    .getLiveVersionPath()).getResource();
267:                }
268:
269:                VirtualFileSystemView vfsView = this .m_vfs
270:                        .getVirtualFileSystemView();
271:                this .m_sFilename = vfsView.getDisplayName(vfFile);
272:                this .m_iFileIcon = vfsView.getIcon(vfFile);
273:                if (m_bArchive) {
274:                    m_sFileDate = vfsView.getArchiveDate(vfActualFile);
275:                } else {
276:                    m_sFileDate = vfsView.getModificationDate(vfActualFile);
277:                }
278:
279:                this .setBackground(Color.WHITE);
280:                this .setBorder(BorderFactory.createLineBorder(Color.BLACK));
281:                this .addMouseListener(this );
282:
283:                FlowLayout fl = new FlowLayout(FlowLayout.LEFT);
284:                fl.setHgap(5);
285:                fl.setVgap(1);
286:                this .setLayout(fl);
287:
288:                this .setMinimumSize(new Dimension(200, 50));
289:                this .setMaximumSize(new Dimension(200, 50));
290:                this .setPreferredSize(new Dimension(200, 50));
291:                //
292:                //		String fontName = "Arial Unicode MS";
293:                //		int fontSize = 11;
294:                //		Font font = new Font(fontName, Font.PLAIN, fontSize);
295:                //		Font boldFont = new Font(fontName, Font.BOLD, fontSize);
296:
297:                if (vfFile.isVersionable()) {
298:                    m_expandIcon = new JLabel();
299:                    m_expandIcon.setPreferredSize(new Dimension(10, 20));
300:                    m_expandIcon.setIcon(IconManager.getInstance().getIcon(
301:                            "16-tree-collapsed.gif"));
302:                    m_expandIcon.addMouseListener(this );
303:                    m_expandIcon.setToolTipText("Expand/collapse versions");
304:                    this .add(m_expandIcon);
305:                } else {
306:                    m_expandIcon = new JLabel();
307:                    m_expandIcon.setPreferredSize(new Dimension(10, 20));
308:                    m_expandIcon.setIcon(IconManager.getInstance().getIcon(
309:                            "16-blank.gif"));
310:                    m_expandIcon.addMouseListener(this );
311:                    this .add(m_expandIcon);
312:                }
313:                TableDragSource source = new TableDragSource(this ,
314:                        m_expandIcon, DnDConstants.ACTION_COPY_OR_MOVE);
315:
316:                String sDisplayName = this .m_vfs.getVirtualFileSystemView()
317:                        .getDisplayName(
318:                                this .m_vfs.getVirtualFile(this .m_sFilePath)
319:                                        .getResource());
320:
321:                String sValue = ConfigStore.getInstance().getPropertyValue(
322:                        "FILENAME_DISPLAY");
323:
324:                if (sValue != null
325:                        && sValue.length() > 0
326:                        && (sValue.equals("FILENAME") || this .m_sFilePath
327:                                .startsWith(HarmonisePaths.PATH_USERS))) {
328:                    String sFilename = this .m_vfs.getVirtualFileSystemView()
329:                            .getLogicalFileName(
330:                                    this .m_vfs.getVirtualFile(this .m_sFilePath)
331:                                            .getResource());
332:                    m_title = new JLabel(sFilename);
333:                } else if (sValue != null && sValue.length() > 0
334:                        && (sValue.equals("ID"))) {
335:                    String sFilename = this .m_vfs.getVirtualFileSystemView()
336:                            .getLogicalFileName(
337:                                    this .m_vfs.getVirtualFile(this .m_sFilePath)
338:                                            .getResource());
339:                    String sID = "";
340:
341:                    PropertyInstance propInst = this .m_vfs.getVirtualFile(
342:                            this .m_sFilePath).getResource().getProperty(
343:                            NamespaceType.OHRM.getURI(), "harmonise-id");
344:                    if (propInst != null && propInst.getValues().size() > 0) {
345:                        if (propInst.getValues().get(0) instanceof  StringValue) {
346:                            StringValue value = (StringValue) propInst
347:                                    .getValues().get(0);
348:                            if (value.getValue() != null
349:                                    && value.getValue().length() > 0) {
350:                                sID = value.getValue() + ": ";
351:                            }
352:                        }
353:                    }
354:                    this .m_title = new JLabel(sID + sFilename);
355:                } else {
356:                    m_title = new JLabel(sDisplayName);
357:                }
358:                m_title.setFont(FontManager.getInstance().getFont(
359:                        FontManager.FONT_RESOURCE_TITLE_BOLD));
360:                m_title.setPreferredSize(new Dimension(149, 20));
361:                m_title.addMouseListener(this );
362:                m_title.setToolTipText(sDisplayName);
363:                source = new TableDragSource(this , m_title,
364:                        DnDConstants.ACTION_COPY_OR_MOVE);
365:                this .add(m_title);
366:
367:                m_topRightIcon = new JLabel();
368:                source = new TableDragSource(this , m_topRightIcon,
369:                        DnDConstants.ACTION_COPY_OR_MOVE);
370:                if (vfActualFile.getState().equals(VirtualFile.STATE_LIVE)) {
371:                    m_topRightIcon.setIcon(IconManager.getInstance().getIcon(
372:                            "16-command-sync-file.gif"));
373:                    m_topRightIcon.setToolTipText("Published Version");
374:                } else if (vfActualFile.isVersionable()) {
375:                    if (vfActualFile.getState().equals(
376:                            VirtualFile.STATE_PENDING)
377:                            && ((VersionedVirtualFile) vfActualFile)
378:                                    .getLiveVersionPath() != null) {
379:                        m_topRightIcon.setIcon(IconManager.getInstance()
380:                                .getIcon("16-command-sync-file.gif"));
381:                        m_topRightIcon.setEnabled(false);
382:                        String sText = "Published";
383:                        if (m_bArchive) {
384:                            sText = "Archived";
385:                        }
386:                        m_topRightIcon.setToolTipText(sText);
387:                    } else {
388:                        m_topRightIcon.setIcon(IconManager.getInstance()
389:                                .getIcon("16-blank.gif"));
390:                    }
391:                } else {
392:                    m_topRightIcon.setIcon(IconManager.getInstance().getIcon(
393:                            "16-blank.gif"));
394:                }
395:                m_topRightIcon.addMouseListener(this );
396:                this .add(m_topRightIcon);
397:
398:                this .m_dateInfo = new JPanel();
399:                this .m_dateInfo.setPreferredSize(new Dimension(190, 20));
400:                this .m_dateInfo.setBackground(Color.WHITE);
401:                FlowLayout fl2 = new FlowLayout(FlowLayout.LEFT);
402:                fl2.setHgap(0);
403:                fl2.setVgap(0);
404:                this .m_dateInfo.setLayout(fl2);
405:                this .m_dateInfo.addMouseListener(this );
406:                source = new TableDragSource(this , m_dateInfo,
407:                        DnDConstants.ACTION_COPY_OR_MOVE);
408:
409:                String sDate = "mod date";
410:                if (m_sFileDate != null) {
411:                    sDate = m_sFileDate;
412:                }
413:
414:                if (vfActualFile.isVersionable()) {
415:                    String text = "";
416:                    if (this .m_bArchive) {
417:                        text = "Archived";
418:                    } else if (vfActualFile.getState().equals(
419:                            VirtualFile.STATE_PENDING)) {
420:                        if (((VersionedVirtualFile) vfActualFile)
421:                                .getLiveVersionPath() == null) {
422:                            text = "New";
423:                        } else {
424:                            text = "Draft";
425:                        }
426:                    } else if (vfActualFile.getState().equals(
427:                            VirtualFile.STATE_LIVE)) {
428:                        text = "Published";
429:                    }
430:                    sDate = text + " (" + sDate + ")";
431:                }
432:
433:                JLabel dateIcon = new JLabel(sDate);
434:                dateIcon.setFont(FontManager.getInstance().getFont(
435:                        FontManager.FONT_STANDARD));
436:                dateIcon.setPreferredSize(new Dimension(165, 20));
437:                dateIcon.setIcon(this .m_iFileIcon);
438:                this .m_dateInfo.add(dateIcon);
439:
440:                m_bottomRightIcon = new JLabel();
441:                source = new TableDragSource(this , m_bottomRightIcon,
442:                        DnDConstants.ACTION_COPY_OR_MOVE);
443:                if (vfActualFile.isChanged()) {
444:                    m_bottomRightIcon.setIcon(IconManager.getInstance()
445:                            .getIcon("16-command-sync-all.gif"));
446:                    m_bottomRightIcon
447:                            .setToolTipText("Resource has changed, ready to submit");
448:                } else {
449:                    m_bottomRightIcon.setIcon(IconManager.getInstance()
450:                            .getIcon("16-blank.gif"));
451:                }
452:                m_bottomRightIcon.addMouseListener(this );
453:                this .m_dateInfo.add(m_bottomRightIcon);
454:
455:                this .add(this .m_dateInfo);
456:            }
457:
458:            /**
459:             * Expands table entry to show version information.
460:             *
461:             */
462:            private synchronized void expand() {
463:                StateHandler.getInstance().addWait("TABLE-ENTRY-EXPAND");
464:
465:                try {
466:                    this .deselectEntry();
467:
468:                    this .m_bExpanded = true;
469:                    this .m_expandIcon.setIcon(IconManager.getInstance()
470:                            .getIcon("16-tree-expanded.gif"));
471:                    this .remove(this .m_dateInfo);
472:                    this .addVersionInfo();
473:                    this .doLayout();
474:                    this .m_table.entryHeightChange(this );
475:                } catch (Exception e) {
476:                    e.printStackTrace(System.err);
477:                } finally {
478:                    StateHandler.getInstance().removeWait("TABLE-ENTRY-EXPAND");
479:                }
480:            }
481:
482:            /**
483:             * Collapses table entry to hide version information.
484:             *
485:             */
486:            private synchronized void collapse() {
487:                StateHandler.getInstance().addWait("TABLE-ENTRY-COLLAPSE");
488:
489:                try {
490:                    this .deselectEntry();
491:
492:                    this .m_bExpanded = false;
493:                    this .m_expandIcon.setIcon(IconManager.getInstance()
494:                            .getIcon("16-tree-collapsed.gif"));
495:                    this .removeVersionInfo();
496:                    this .add(this .m_dateInfo);
497:                    this .doLayout();
498:                    this .m_table.entryHeightChange(this );
499:
500:                    this .selectEntry();
501:                    this .m_table.entrySelected(this );
502:                } catch (Exception e) {
503:                    e.printStackTrace(System.err);
504:                } finally {
505:                    StateHandler.getInstance().removeWait(
506:                            "TABLE-ENTRY-COLLAPSE");
507:                }
508:            }
509:
510:            /**
511:             * Returns the table view this entry is in.
512:             * 
513:             * @return Table view
514:             */
515:            protected TableView getTableView() {
516:                return this .m_table;
517:            }
518:
519:            /**
520:             * Adds the version information to this entry.
521:             *
522:             */
523:            private void addVersionInfo() {
524:                int nVersionCount = 4;
525:
526:                VersionedVirtualFile vfLiveFile = (VersionedVirtualFile) this .m_vfs
527:                        .getVirtualFile(this .m_sFilePath).getResource();
528:
529:                if (vfLiveFile.isVersionable()
530:                        && vfLiveFile.getState().equals(
531:                                VirtualFile.STATE_PENDING)
532:                        && ((VersionedVirtualFile) vfLiveFile)
533:                                .getLiveVersionPath() != null) {
534:                    vfLiveFile = (VersionedVirtualFile) vfLiveFile.getVFS()
535:                            .getVirtualFile(
536:                                    ((VersionedVirtualFile) vfLiveFile)
537:                                            .getLiveVersionPath())
538:                            .getResource();
539:                }
540:
541:                this .m_versionInfo = new JPanel();
542:                this .m_versionInfo
543:                        .setPreferredSize(new Dimension(190, (5 * 40)));
544:                this .m_versionInfo.setSize(new Dimension(190, (5 * 40)));
545:                this .m_versionInfo.setBackground(Color.WHITE);
546:
547:                this .setPreferredSize(new Dimension(200, (40 + ((5) * 40))));
548:                this .setSize(new Dimension(200, (40 + ((5) * 40))));
549:
550:                VersionEntry pendingVersion = null;
551:
552:                if (vfLiveFile.hasPendingVersion()) {
553:                    pendingVersion = new VersionEntry(this , this .m_vfs,
554:                            vfLiveFile.getPendingVersionPath(), "Draft version");
555:                    this .m_versionInfo.add(pendingVersion);
556:                } else {
557:                    pendingVersion = new BlankVersionEntry("No draft version");
558:                    this .m_versionInfo.add(pendingVersion);
559:                }
560:                VersionEntry liveEntry = new VersionEntry(this , this .m_vfs,
561:                        vfLiveFile.getFullPath(), "Published version");
562:                this .m_versionInfo.add(liveEntry);
563:
564:                m_versionInnerPane = new JPanel();
565:                m_versionInnerPane.setBackground(Color.WHITE);
566:                FlowLayout fl2 = new FlowLayout(FlowLayout.LEFT);
567:                fl2.setHgap(0);
568:                fl2.setVgap(0);
569:                m_versionInnerPane.setLayout(fl2);
570:
571:                if (vfLiveFile.getHistoricalVersions().size() > 0) {
572:
573:                    Iterator itor = vfLiveFile.getHistoricalVersions()
574:                            .iterator();
575:                    while (itor.hasNext()) {
576:                        String sHistoricalPath = (String) itor.next();
577:                        m_versionInnerPane.add(new VersionEntry(this ,
578:                                this .m_vfs, sHistoricalPath,
579:                                "Historic version ("
580:                                        + this .m_vfs.getVirtualFile(
581:                                                sHistoricalPath).getResource()
582:                                                .getFileName() + ")", false));
583:                    }
584:                } else {
585:                    m_versionInnerPane.add(new BlankVersionEntry(
586:                            "No historical versions"));
587:                }
588:
589:                m_versionInnerPane.setPreferredSize(new Dimension(190,
590:                        (10 * 40)));
591:
592:                JScrollPane scroll = new JScrollPane(m_versionInnerPane);
593:                scroll
594:                        .setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
595:                scroll
596:                        .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
597:                JScrollBar vBar = new JScrollBar(JScrollBar.VERTICAL);
598:                vBar.setUnitIncrement(20);
599:                scroll.setVerticalScrollBar(vBar);
600:                scroll.getViewport().setPreferredSize(
601:                        new Dimension(140, (3 * 40) - 20));
602:                this .m_versionInfo.add(scroll);
603:
604:                this .m_versionInfo.revalidate();
605:
606:                this .add(this .m_versionInfo);
607:                if (pendingVersion != null
608:                        && !(pendingVersion instanceof  BlankVersionEntry)) {
609:                    pendingVersion.selectEntry();
610:                    this .m_table.entrySelected(pendingVersion);
611:                } else {
612:                    liveEntry.selectEntry();
613:                    this .m_table.entrySelected(liveEntry);
614:                }
615:            }
616:
617:            /**
618:             * Removes the version information from this entry.
619:             */
620:            private void removeVersionInfo() {
621:                this .remove(this .m_versionInfo);
622:                this .setPreferredSize(new Dimension(200, 50));
623:                this .setSize(new Dimension(200, 50));
624:            }
625:
626:            /* (non-Javadoc)
627:             * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
628:             */
629:            public void mouseClicked(MouseEvent me) {
630:                if (me.getClickCount() > 1) {
631:                    VirtualFile vfFile = this .m_vfs.getVirtualFile(
632:                            this .m_sFilePath).getResource();
633:                    if (vfFile.isDirectory()) {
634:                        if (vfFile.isVersionable()
635:                                && vfFile.getState() == VirtualFile.STATE_PENDING
636:                                && ((VersionedVirtualFile) vfFile)
637:                                        .getLiveVersionPath() != null) {
638:                            this .m_table
639:                                    .openPathInTree(((VersionedVirtualFile) vfFile)
640:                                            .getLiveVersionPath());
641:                        } else {
642:                            this .m_table.openPathInTree(this .m_sFilePath);
643:                        }
644:                    } else if (vfFile.getFullPath().startsWith(
645:                            HarmonisePaths.PATH_REPORTS_OUTPUT)) {
646:                        EditorController.getInstance().preview(
647:                                this .m_sFilePath, this .m_vfs);
648:                    } else if (vfFile.isLocked()
649:                            && vfFile.getVFS().getVirtualFile(
650:                                    vfFile.getLockOwner()) != null
651:                            && !vfFile.getVFS().getVirtualFile(
652:                                    vfFile.getLockOwner()).getResource()
653:                                    .getFileName().trim().equals(
654:                                            vfFile.getVFS().getAuthentication()
655:                                                    .getUsername().trim())) {
656:                        MessageHandler
657:                                .getInstance()
658:                                .fireMessageEvent(
659:                                        "Cannot open resource \""
660:                                                + vfFile
661:                                                        .getVFS()
662:                                                        .getVirtualFileSystemView()
663:                                                        .getDisplayName(vfFile)
664:                                                + "\" for editing, previewing instead.",
665:                                        MessageHandler.TYPE_INFORMATION);
666:                        EditorController.getInstance().preview(
667:                                this .m_sFilePath, this .m_vfs);
668:                    } else {
669:                        EditorController.getInstance().open(this .m_sFilePath,
670:                                this .m_vfs);
671:                    }
672:                } else {
673:                    if (this .m_vfs.getVirtualFile(this .m_sFilePath)
674:                            .getResource().isVersionable()
675:                            && me.getSource() == this .m_expandIcon) {
676:                        if (this .m_bExpanded) {
677:                            this .collapse();
678:                        } else {
679:                            this .expand();
680:                        }
681:                    } else if (!this .m_bExpanded
682:                            && (me.getSource() == this 
683:                                    || me.getSource() == this .m_dateInfo
684:                                    || me.getSource() == this .m_title
685:                                    || me.getSource() == this .m_bottomRightIcon || me
686:                                    .getSource() == this .m_topRightIcon)) {
687:                        if (this .getBackground() == m_selectedColor) {
688:                            this .selectEntry();
689:                        } else {
690:                            this .selectEntry();
691:                        }
692:                        this .m_table.entrySelected(this );
693:                    }
694:                }
695:                if (me.getButton() == MouseEvent.BUTTON3) {
696:                    FileContextMenu menu = new FileContextMenu(
697:                            this .m_sFilePath, this .m_vfs);
698:                    Point pt = me.getPoint();
699:                    menu.show(this , pt.x, pt.y);
700:                }
701:            }
702:
703:            /**
704:             * Returns the resource name.
705:             * 
706:             * @return Name
707:             */
708:            public String getName() {
709:                return this .m_sFilename;
710:            }
711:
712:            /**
713:             * Returns the resource date.
714:             * 
715:             * @return Date
716:             */
717:            public String getDate() {
718:                return this .m_sFileDate;
719:            }
720:
721:            /**
722:             * Returns the full path to the resource.
723:             * 
724:             * @return Full path
725:             */
726:            public String getPath() {
727:                return this .m_sFilePath;
728:            }
729:
730:            /**
731:             * Returns the virtual file system for the resource.
732:             * 
733:             * @return Virtual file system
734:             */
735:            public AbstractVirtualFileSystem getVFS() {
736:                return this .m_vfs;
737:            }
738:
739:            /**
740:             * Selects this entry.
741:             *
742:             */
743:            protected void selectEntry() {
744:                this .setBackground(m_selectedColor);
745:                this .m_dateInfo.setBackground(m_selectedColor);
746:            }
747:
748:            /**
749:             * Deselects this entry.
750:             *
751:             */
752:            protected void deselectEntry() {
753:                this .setBackground(Color.WHITE);
754:                this .m_dateInfo.setBackground(Color.WHITE);
755:
756:                if (this .m_versionInfo != null) {
757:                    for (int i = 0; i < this .m_versionInfo.getComponentCount(); i++) {
758:                        if (this .m_versionInfo.getComponent(i) instanceof  VersionEntry) {
759:                            VersionEntry entry = (VersionEntry) this .m_versionInfo
760:                                    .getComponent(i);
761:                            entry.deselectEntry();
762:                        }
763:                    }
764:                    if (this .m_versionInnerPane != null) {
765:                        for (int i = 0; i < this .m_versionInnerPane
766:                                .getComponentCount(); i++) {
767:                            if (this .m_versionInnerPane.getComponent(i) instanceof  VersionEntry) {
768:                                VersionEntry currentEntry = (VersionEntry) this .m_versionInnerPane
769:                                        .getComponent(i);
770:                                currentEntry.deselectEntry();
771:                            }
772:                        }
773:                    }
774:                }
775:            }
776:
777:            /**
778:             * Deselects all version entries except this one given.
779:             * 
780:             * @param entry Version entry
781:             */
782:            protected void deselectOtherEntries(VersionEntry entry) {
783:                for (int i = 0; i < this .m_versionInfo.getComponentCount(); i++) {
784:                    if (this .m_versionInfo.getComponent(i) instanceof  VersionEntry) {
785:                        VersionEntry currentEntry = (VersionEntry) this .m_versionInfo
786:                                .getComponent(i);
787:                        if (currentEntry != entry) {
788:                            currentEntry.deselectEntry();
789:                        }
790:                    }
791:                }
792:                for (int i = 0; i < this .m_versionInnerPane.getComponentCount(); i++) {
793:                    if (this .m_versionInnerPane.getComponent(i) instanceof  VersionEntry) {
794:                        VersionEntry currentEntry = (VersionEntry) this .m_versionInnerPane
795:                                .getComponent(i);
796:                        if (currentEntry != entry) {
797:                            currentEntry.deselectEntry();
798:                        }
799:                    }
800:                }
801:            }
802:
803:            /* (non-Javadoc)
804:             * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
805:             */
806:            public void mouseEntered(MouseEvent arg0) {
807:            }
808:
809:            /* (non-Javadoc)
810:             * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
811:             */
812:            public void mouseExited(MouseEvent arg0) {
813:            }
814:
815:            /* (non-Javadoc)
816:             * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
817:             */
818:            public void mousePressed(MouseEvent arg0) {
819:            }
820:
821:            /* (non-Javadoc)
822:             * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
823:             */
824:            public void mouseReleased(MouseEvent arg0) {
825:            }
826:
827:            /* (non-Javadoc)
828:             * @see com.simulacramedia.vfs.event.VirtualFileListener#virtualFileChanged(com.simulacramedia.vfs.event.VirtualFileEvent)
829:             */
830:            public void virtualFileChanged(VirtualFileEvent vfe) {
831:                if (vfe.getEventType() == VirtualFileEvent.FILE_CONTENT_CHANGED
832:                        || vfe.getEventType() == VirtualFileEvent.FILE_METADATA_CHANGED) {
833:                    if (this .m_vfs.getVirtualFile(this .m_sFilePath)
834:                            .getResource().isChanged()) {
835:                        this .m_bottomRightIcon.setIcon(IconManager
836:                                .getInstance().getIcon(
837:                                        "16-command-sync-all.gif"));
838:                        m_bottomRightIcon
839:                                .setToolTipText("Resource has changed, ready to submit");
840:                        ContextEvent ce = new ContextEvent(
841:                                ContextType.CONTEXT_FILES, null, this .m_vfs,
842:                                this .m_sFilePath);
843:                        ContextHandler.getInstance().fireContextEvent(ce);
844:                    }
845:                } else if (vfe.getEventType() == VirtualFileEvent.FILE_SYNCHED) {
846:                    this .m_bottomRightIcon.setIcon(IconManager.getInstance()
847:                            .getIcon("16-blank.gif"));
848:                    m_bottomRightIcon.setToolTipText("");
849:                    ContextEvent ce = new ContextEvent(
850:                            ContextType.CONTEXT_FILES, null, this .m_vfs,
851:                            this .m_sFilePath);
852:                    ContextHandler.getInstance().fireContextEvent(ce);
853:                } else if (vfe.getEventType() == VirtualFileEvent.FILE_CHANGES_DISCARDED) {
854:                    this .m_bottomRightIcon.setIcon(IconManager.getInstance()
855:                            .getIcon("16-blank.gif"));
856:                    m_bottomRightIcon.setToolTipText("");
857:                    this .m_bottomRightIcon
858:                            .paintImmediately(this .m_bottomRightIcon
859:                                    .getBounds());
860:                    ContextEvent ce = new ContextEvent(
861:                            ContextType.CONTEXT_FILES, null, this .m_vfs,
862:                            this .m_sFilePath);
863:                    ContextHandler.getInstance().fireContextEvent(ce);
864:                } else if (vfe.getEventType() == VirtualFileEvent.FILE_CHECKED_IN) {
865:
866:                } else if (vfe.getEventType() == VirtualFileEvent.FILE_DELETED) {
867:                    this .m_bDeleted = true;
868:                }
869:                this .revalidate();
870:                this .doLayout();
871:            }
872:
873:            /* (non-Javadoc)
874:             * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
875:             */
876:            public void contextMessage(ContextEvent ce) {
877:                if (ce.CONTEXT_TYPE == ContextType.CONTEXT_FILENAME_DISPLAY) {
878:                    String sValue = ConfigStore.getInstance().getPropertyValue(
879:                            "FILENAME_DISPLAY");
880:                    if (sValue != null
881:                            && sValue.length() > 0
882:                            && (sValue.equals("FILENAME") || this .m_sFilePath
883:                                    .startsWith(HarmonisePaths.PATH_USERS))) {
884:                        String sFilename = this .m_vfs
885:                                .getVirtualFileSystemView()
886:                                .getLogicalFileName(
887:                                        this .m_vfs.getVirtualFile(
888:                                                this .m_sFilePath).getResource());
889:                        this .m_title.setText(sFilename);
890:                    } else if (sValue != null && sValue.length() > 0
891:                            && sValue.equals("ID")) {
892:                        String sFilename = this .m_vfs
893:                                .getVirtualFileSystemView()
894:                                .getLogicalFileName(
895:                                        this .m_vfs.getVirtualFile(
896:                                                this .m_sFilePath).getResource());
897:                        String sID = "";
898:
899:                        PropertyInstance propInst = this .m_vfs.getVirtualFile(
900:                                this .m_sFilePath).getResource().getProperty(
901:                                NamespaceType.OHRM.getURI(), "harmonise-id");
902:                        if (propInst != null && propInst.getValues().size() > 0) {
903:                            if (propInst.getValues().get(0) instanceof  StringValue) {
904:                                StringValue value = (StringValue) propInst
905:                                        .getValues().get(0);
906:                                if (value.getValue() != null
907:                                        && value.getValue().length() > 0) {
908:                                    sID = value.getValue() + ": ";
909:                                }
910:                            }
911:                        }
912:                        this .m_title.setText(sID + sFilename);
913:                    } else {
914:                        String sDisplayName = this.m_vfs
915:                                .getVirtualFileSystemView()
916:                                .getDisplayName(
917:                                        this.m_vfs.getVirtualFile(
918:                                                this.m_sFilePath).getResource());
919:                        this.m_title.setText(sDisplayName);
920:                    }
921:                    this.revalidate();
922:                    this.repaint();
923:                }
924:            }
925:
926:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.