Source Code Cross Referenced for VersionEntry.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.event.*;
024:
025:        import javax.swing.*;
026:
027:        import org.openharmonise.commons.xml.namespace.*;
028:        import org.openharmonise.him.configuration.*;
029:        import org.openharmonise.him.editors.*;
030:        import org.openharmonise.him.harmonise.*;
031:        import org.openharmonise.him.window.menus.*;
032:        import org.openharmonise.him.window.messages.*;
033:        import org.openharmonise.swing.FontManager;
034:        import org.openharmonise.vfs.*;
035:        import org.openharmonise.vfs.context.*;
036:        import org.openharmonise.vfs.event.*;
037:        import org.openharmonise.vfs.gui.*;
038:        import org.openharmonise.vfs.metadata.*;
039:        import org.openharmonise.vfs.metadata.value.*;
040:
041:        /**
042:         * Component for displaying resource information in an expanded table
043:         * entry.
044:         * 
045:         * @author Matthew Large
046:         * @version $Revision: 1.3 $
047:         *
048:         */
049:        public class VersionEntry extends JPanel implements  MouseListener,
050:                VirtualFileListener, ContextListener {
051:
052:            /**
053:             * 
054:             */
055:            protected VersionEntry() {
056:                super ();
057:            }
058:
059:            /**
060:             * Table.
061:             */
062:            private TableView m_table = null;
063:
064:            /**
065:             * Expanded table entry that this is part of.
066:             */
067:            private TableEntry m_parentEntry = null;
068:
069:            /**
070:             * Full path to resource that this entry represents.
071:             */
072:            private String m_sFilepath = null;
073:
074:            /**
075:             * Virtual file system for this entry.
076:             */
077:            private AbstractVirtualFileSystem m_vfs = null;
078:
079:            /**
080:             * Selected highlight colour.
081:             */
082:            private Color m_selectedColor = new Color(173, 169, 143);
083:
084:            /**
085:             * Icon on the right.
086:             */
087:            private JLabel m_rightIcon = null;
088:
089:            /**
090:             * Title.
091:             */
092:            private JLabel m_title = null;
093:
094:            /**
095:             * Constructs a new verison entry.
096:             * 
097:             * @param parentEntry Expanded table entry that this is part of
098:             * @param vfs Virtual file system for this entry
099:             * @param sFilepath Full path to resource that this entry represents
100:             * @param sTitle Title
101:             */
102:            public VersionEntry(TableEntry parentEntry,
103:                    AbstractVirtualFileSystem vfs, String sFilepath,
104:                    String sTitle) {
105:                super ();
106:                this .m_sFilepath = sFilepath;
107:                this .m_vfs = vfs;
108:                this .m_parentEntry = parentEntry;
109:                this .m_table = parentEntry.getTableView();
110:                this .setup(sTitle, true);
111:            }
112:
113:            /**
114:             * Constructs a new verison entry.
115:             * 
116:             * @param parentEntry Expanded table entry that this is part of
117:             * @param vfs Virtual file system for this entry
118:             * @param sFilepath Full path to resource that this entry represents
119:             * @param sTitle Title
120:             * @param bDisplayIcon Display Icon
121:             */
122:            public VersionEntry(TableEntry parentEntry,
123:                    AbstractVirtualFileSystem vfs, String sFilepath,
124:                    String sTitle, boolean bDisplayIcon) {
125:                super ();
126:                this .m_sFilepath = sFilepath;
127:                this .m_vfs = vfs;
128:                this .m_parentEntry = parentEntry;
129:                this .m_table = parentEntry.getTableView();
130:                this .setup(sTitle, bDisplayIcon);
131:            }
132:
133:            /**
134:             * Returns the expanded table entry that this is part of.
135:             * 
136:             * @return Table entry
137:             */
138:            public TableEntry getParentTableEntry() {
139:                return this .m_parentEntry;
140:            }
141:
142:            /**
143:             * Clears all resources that this class is holding onto making it
144:             * ready to be destroyed.
145:             *
146:             */
147:            public void clearToDestroy() {
148:                ContextHandler.getInstance().removeListener(
149:                        ContextType.CONTEXT_FILENAME_DISPLAY, this );
150:                VirtualFile vfFile = this .m_vfs
151:                        .getVirtualFile(this .m_sFilepath).getResource();
152:                if (vfFile != null) {
153:                    vfFile.removeVirtualFileListener(this );
154:                }
155:            }
156:
157:            /**
158:             * Configures the table view.
159:             * 
160:             * @param sTitle Title
161:             * @param bDisplayIcon true if there is a display icon available
162:             */
163:            private void setup(String sTitle, boolean bDisplayIcon) {
164:                ContextHandler.getInstance().addListener(
165:                        ContextType.CONTEXT_FILENAME_DISPLAY, this );
166:                this .addMouseListener(this );
167:
168:                VirtualFile vfFile = this .m_vfs
169:                        .getVirtualFile(this .m_sFilepath).getResource();
170:                VirtualFileSystemView vfsView = this .m_vfs
171:                        .getVirtualFileSystemView();
172:
173:                vfFile.addVirtualFileListener(this );
174:
175:                Icon iIcon = null;
176:                if (bDisplayIcon) {
177:                    iIcon = vfsView.getIcon(vfFile);
178:                } else {
179:                    iIcon = IconManager.getInstance().getIcon("16-blank.gif");
180:                }
181:                String sRawDate = vfsView.getModificationDate(vfFile);
182:                //
183:                //		String fontName = "Arial Unicode MS";
184:                //		int fontSize = 11;
185:                //		Font font = new Font(fontName, Font.PLAIN, fontSize);
186:                //		Font fontBold = new Font(fontName, Font.BOLD, fontSize);
187:
188:                this .setPreferredSize(new Dimension(160, 40));
189:                this .setSize(new Dimension(160, 40));
190:                this .setBackground(Color.WHITE);
191:                FlowLayout fl2 = new FlowLayout(FlowLayout.LEFT);
192:                fl2.setHgap(0);
193:                fl2.setVgap(0);
194:                this .setLayout(fl2);
195:
196:                String sDisplayName = this .m_vfs.getVirtualFileSystemView()
197:                        .getDisplayName(vfFile);
198:                String sValue = ConfigStore.getInstance().getPropertyValue(
199:                        "FILENAME_DISPLAY");
200:                if (sValue != null
201:                        && sValue.length() > 0
202:                        && (sValue.equals("FILENAME") || this .m_sFilepath
203:                                .startsWith(HarmonisePaths.PATH_USERS))) {
204:                    String sFilename = this .m_vfs.getVirtualFileSystemView()
205:                            .getLogicalFileName(
206:                                    this .m_vfs.getVirtualFile(this .m_sFilepath)
207:                                            .getResource());
208:                    m_title = new JLabel(sFilename);
209:                } else if (sValue != null && sValue.length() > 0
210:                        && (sValue.equals("ID"))) {
211:                    String sFilename = this .m_vfs.getVirtualFileSystemView()
212:                            .getLogicalFileName(
213:                                    this .m_vfs.getVirtualFile(this .m_sFilepath)
214:                                            .getResource());
215:                    String sID = "";
216:
217:                    PropertyInstance propInst = this .m_vfs.getVirtualFile(
218:                            this .m_sFilepath).getResource().getProperty(
219:                            NamespaceType.OHRM.getURI(), "harmonise-id");
220:                    if (propInst != null && propInst.getValues().size() > 0) {
221:                        if (propInst.getValues().get(0) instanceof  StringValue) {
222:                            StringValue value = (StringValue) propInst
223:                                    .getValues().get(0);
224:                            if (value.getValue() != null
225:                                    && value.getValue().length() > 0) {
226:                                sID = value.getValue() + ": ";
227:                            }
228:                        }
229:                    }
230:                    this .m_title = new JLabel(sID + sFilename);
231:                } else {
232:                    m_title = new JLabel(sDisplayName);
233:                }
234:                if (vfFile.getState().equals(VirtualFile.STATE_LIVE)) {
235:                    m_title.setFont(FontManager.getInstance().getFont(
236:                            FontManager.FONT_RESOURCE_TITLE_BOLD));
237:                } else {
238:                    m_title.setFont(FontManager.getInstance().getFont(
239:                            FontManager.FONT_RESOURCE_TITLE));
240:                }
241:
242:                m_title.setPreferredSize(new Dimension(129, 16));
243:                m_title.setIcon(iIcon);
244:                if (vfFile.getState().equals(VirtualFile.STATE_LIVE)) {
245:                    m_title.setToolTipText(sDisplayName + " (published)");
246:                } else if (vfFile.getState().equals(
247:                        VirtualFile.STATE_HISTORICAL)) {
248:                    m_title.setToolTipText(sDisplayName + " (historical)");
249:                } else {
250:                    m_title.setToolTipText(sDisplayName);
251:                }
252:                m_title.addMouseListener(this );
253:                this .add(m_title);
254:
255:                m_rightIcon = new JLabel();
256:                m_rightIcon.setPreferredSize(new Dimension(16, 16));
257:                if (vfFile.isChanged()) {
258:                    m_rightIcon.setIcon(IconManager.getInstance().getIcon(
259:                            "16-command-sync-all.gif"));
260:                } else {
261:                    m_rightIcon.setIcon(IconManager.getInstance().getIcon(
262:                            "16-blank.gif"));
263:                }
264:                m_rightIcon.addMouseListener(this );
265:                this .add(m_rightIcon);
266:
267:                JLabel date = new JLabel(sRawDate);
268:                date.setFont(FontManager.getInstance().getFont(
269:                        FontManager.FONT_STANDARD));
270:                date.setPreferredSize(new Dimension(145, 16));
271:                date.setIcon(IconManager.getInstance().getIcon("16-blank.gif"));
272:                date.addMouseListener(this );
273:                this .add(date);
274:                this .doLayout();
275:            }
276:
277:            /* (non-Javadoc)
278:             * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
279:             */
280:            public void mouseClicked(MouseEvent me) {
281:                if (me.getClickCount() > 1) {
282:                    VirtualFile vfFile = this .m_vfs.getVirtualFile(
283:                            this .m_sFilepath).getResource();
284:                    if (vfFile.isDirectory()) {
285:                        if (vfFile.isVersionable()
286:                                && vfFile.getState().equals(
287:                                        VirtualFile.STATE_PENDING)
288:                                && ((VersionedVirtualFile) vfFile)
289:                                        .getLiveVersionPath() != null) {
290:                            this .m_table
291:                                    .openPathInTree(((VersionedVirtualFile) vfFile)
292:                                            .getLiveVersionPath());
293:                        } else {
294:                            this .m_table.openPathInTree(this .m_sFilepath);
295:                        }
296:                    } else if (vfFile.getFullPath().startsWith(
297:                            HarmonisePaths.PATH_REPORTS_OUTPUT)) {
298:                        EditorController.getInstance().preview(
299:                                this .m_sFilepath, this .m_vfs);
300:                    } else if (vfFile.isLocked()
301:                            && vfFile.getVFS().getVirtualFile(
302:                                    vfFile.getLockOwner()) != null
303:                            && !vfFile.getVFS().getVirtualFile(
304:                                    vfFile.getLockOwner()).getResource()
305:                                    .getFileName().trim().equals(
306:                                            vfFile.getVFS().getAuthentication()
307:                                                    .getUsername().trim())) {
308:                        MessageHandler
309:                                .getInstance()
310:                                .fireMessageEvent(
311:                                        "Cannot open resource \""
312:                                                + vfFile
313:                                                        .getVFS()
314:                                                        .getVirtualFileSystemView()
315:                                                        .getDisplayName(vfFile)
316:                                                + "\" for editing, previewing instead.",
317:                                        MessageHandler.TYPE_INFORMATION);
318:                        EditorController.getInstance().preview(
319:                                this .m_sFilepath, this .m_vfs);
320:                    } else if (vfFile.isVersionable()
321:                            && vfFile.getState().equals(VirtualFile.STATE_LIVE)
322:                            && ((VersionedVirtualFile) vfFile)
323:                                    .getPendingVersionPath() != null) {
324:                        MessageHandler
325:                                .getInstance()
326:                                .fireMessageEvent(
327:                                        "Cannot open resource \""
328:                                                + vfFile
329:                                                        .getVFS()
330:                                                        .getVirtualFileSystemView()
331:                                                        .getDisplayName(vfFile)
332:                                                + "\" for editing, previewing instead.",
333:                                        MessageHandler.TYPE_INFORMATION);
334:                        EditorController.getInstance().preview(
335:                                this .m_sFilepath, this .m_vfs);
336:                    } else {
337:                        EditorController.getInstance().open(this .m_sFilepath,
338:                                this .m_vfs);
339:                    }
340:                } else {
341:                    if (me.getSource() == this 
342:                            || this 
343:                                    .isChildComponent((Component) me
344:                                            .getSource())) {
345:                        if (this .getBackground() == m_selectedColor) {
346:                            this .selectEntry();
347:                        } else {
348:                            this .selectEntry();
349:                        }
350:                        this .m_table.entrySelected(this );
351:                    }
352:                }
353:                if (me.getButton() == MouseEvent.BUTTON3) {
354:                    FileContextMenu menu = new FileContextMenu(
355:                            this .m_sFilepath, this .m_vfs);
356:                    Point pt = me.getPoint();
357:                    menu.show(this , pt.x, pt.y);
358:                }
359:            }
360:
361:            /**
362:             * Selects this entry.
363:             *
364:             */
365:            protected void selectEntry() {
366:                this .setBackground(m_selectedColor);
367:                this .setBorder(BorderFactory.createLineBorder(Color.BLACK));
368:                this .m_parentEntry.deselectOtherEntries(this );
369:            }
370:
371:            /**
372:             * Unselects this entry.
373:             *
374:             */
375:            protected void deselectEntry() {
376:                this .setBackground(Color.WHITE);
377:
378:                this .setBorder(BorderFactory.createLineBorder(Color.WHITE));
379:            }
380:
381:            /**
382:             * Checks if this is a child of a given component.
383:             * 
384:             * @param comp Component to check against
385:             * @return true if this is a child of the given component
386:             */
387:            private boolean isChildComponent(Component comp) {
388:                Component[] comps = this .getComponents();
389:                for (int i = 0; i < comps.length; i++) {
390:                    if (comp == comps[i]) {
391:                        return true;
392:                    }
393:                }
394:                return false;
395:            }
396:
397:            /**
398:             * Returns the full path for the resource this entry represents.
399:             * 
400:             * @return Full path
401:             */
402:            public String getPath() {
403:                return this .m_sFilepath;
404:            }
405:
406:            /**
407:             * Returns the virtual file system for the resource this entry represents.
408:             * 
409:             * @return Virtual file system
410:             */
411:            public AbstractVirtualFileSystem getVFS() {
412:                return this .m_vfs;
413:            }
414:
415:            /* (non-Javadoc)
416:             * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
417:             */
418:            public void mouseEntered(MouseEvent arg0) {
419:            }
420:
421:            /* (non-Javadoc)
422:             * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
423:             */
424:            public void mouseExited(MouseEvent arg0) {
425:            }
426:
427:            /* (non-Javadoc)
428:             * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
429:             */
430:            public void mousePressed(MouseEvent arg0) {
431:            }
432:
433:            /* (non-Javadoc)
434:             * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
435:             */
436:            public void mouseReleased(MouseEvent arg0) {
437:            }
438:
439:            /* (non-Javadoc)
440:             * @see com.simulacramedia.vfs.event.VirtualFileListener#virtualFileChanged(com.simulacramedia.vfs.event.VirtualFileEvent)
441:             */
442:            public void virtualFileChanged(VirtualFileEvent vfe) {
443:                if (vfe.getEventType() == VirtualFileEvent.FILE_CONTENT_CHANGED
444:                        || vfe.getEventType() == VirtualFileEvent.FILE_METADATA_CHANGED) {
445:                    if (this .m_vfs.getVirtualFile(this .m_sFilepath)
446:                            .getResource().isChanged()) {
447:                        this .m_rightIcon.setIcon(IconManager.getInstance()
448:                                .getIcon("16-command-sync-all.gif"));
449:                        ContextEvent ce = new ContextEvent(
450:                                ContextType.CONTEXT_FILES, null, this .m_vfs,
451:                                this .m_sFilepath);
452:                        ContextHandler.getInstance().fireContextEvent(ce);
453:                    }
454:                } else if (vfe.getEventType() == VirtualFileEvent.FILE_SYNCHED) {
455:                    this .m_rightIcon.setIcon(IconManager.getInstance().getIcon(
456:                            "16-blank.gif"));
457:                } else if (vfe.getEventType() == VirtualFileEvent.FILE_CHANGES_DISCARDED) {
458:                    this .m_rightIcon.setIcon(IconManager.getInstance().getIcon(
459:                            "16-blank.gif"));
460:                }
461:                this .validate();
462:            }
463:
464:            /* (non-Javadoc)
465:             * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
466:             */
467:            public void contextMessage(ContextEvent ce) {
468:                if (ce.CONTEXT_TYPE == ContextType.CONTEXT_FILENAME_DISPLAY) {
469:                    String sValue = ConfigStore.getInstance().getPropertyValue(
470:                            "FILENAME_DISPLAY");
471:                    if (sValue != null
472:                            && sValue.length() > 0
473:                            && (sValue.equals("FILENAME") || this .m_sFilepath
474:                                    .startsWith(HarmonisePaths.PATH_USERS))) {
475:                        String sFilename = this .m_vfs
476:                                .getVirtualFileSystemView()
477:                                .getLogicalFileName(
478:                                        this .m_vfs.getVirtualFile(
479:                                                this .m_sFilepath).getResource());
480:                        this .m_title.setText(sFilename);
481:                    } else if (sValue != null && sValue.length() > 0
482:                            && sValue.equals("ID")) {
483:                        String sFilename = this .m_vfs
484:                                .getVirtualFileSystemView()
485:                                .getLogicalFileName(
486:                                        this .m_vfs.getVirtualFile(
487:                                                this .m_sFilepath).getResource());
488:                        String sID = "";
489:
490:                        PropertyInstance propInst = this .m_vfs.getVirtualFile(
491:                                this .m_sFilepath).getResource().getProperty(
492:                                NamespaceType.OHRM.getURI(), "harmonise-id");
493:                        if (propInst != null && propInst.getValues().size() > 0) {
494:                            if (propInst.getValues().get(0) instanceof  StringValue) {
495:                                StringValue value = (StringValue) propInst
496:                                        .getValues().get(0);
497:                                if (value.getValue() != null
498:                                        && value.getValue().length() > 0) {
499:                                    sID = value.getValue() + ": ";
500:                                }
501:                            }
502:                        }
503:                        this .m_title.setText(sID + sFilename);
504:                    } else {
505:                        String sDisplayName = this.m_vfs
506:                                .getVirtualFileSystemView()
507:                                .getDisplayName(
508:                                        this.m_vfs.getVirtualFile(
509:                                                this.m_sFilepath).getResource());
510:                        this.m_title.setText(sDisplayName);
511:                    }
512:                    this.revalidate();
513:                    this.repaint();
514:                }
515:            }
516:
517:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.