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


001:        /*
002:         * Created on 27-Oct-2003
003:         *
004:         * To change the template for this generated file go to
005:         * Window>Preferences>Java>Code Generation>Code and Comments
006:         */
007:        package org.openharmonise.him.metadata.swing;
008:
009:        import java.awt.*;
010:        import java.util.*;
011:
012:        import javax.swing.*;
013:        import javax.swing.event.*;
014:
015:        import org.openharmonise.commons.xml.namespace.*;
016:        import org.openharmonise.him.*;
017:        import org.openharmonise.him.authentication.*;
018:        import org.openharmonise.him.harmonise.*;
019:        import org.openharmonise.him.metadata.range.swing.*;
020:        import org.openharmonise.him.metadata.range.swing.resourcehandling.*;
021:        import org.openharmonise.vfs.*;
022:        import org.openharmonise.vfs.gui.*;
023:        import org.openharmonise.vfs.metadata.*;
024:        import org.openharmonise.vfs.metadata.range.*;
025:        import org.openharmonise.vfs.metadata.value.*;
026:        import org.openharmonise.vfs.servers.ServerList;
027:
028:        /**
029:         * <p>Title: MetadataTabs</p>
030:         * <p>Description: </p>
031:         * <p>Copyright: SimulacraMedia 2003</p>
032:         * <p>Company: Simulacra</p>
033:         * @author Matthew Large
034:         *
035:         */
036:        public class MetadataTabs extends JTabbedPane implements 
037:                ChangeListener, Runnable {
038:
039:            private AbstractVirtualFileSystem m_vfs = null;
040:            private String m_sFilepath = null;
041:
042:            private HashMap m_PathToTab = new HashMap(5);
043:
044:            private ArrayList m_tabPanels = new ArrayList();
045:
046:            private String m_sSelectedTabTitle = null;
047:
048:            /**
049:             * 
050:             */
051:            public MetadataTabs(AbstractVirtualFileSystem vfs, String sFilepath) {
052:                super ();
053:                this .m_vfs = vfs;
054:                this .m_sFilepath = sFilepath;
055:                this .setup();
056:            }
057:
058:            protected void clearToDestroy() {
059:                Iterator itor = this .m_tabPanels.iterator();
060:                while (itor.hasNext()) {
061:                    MetadataTabPanel tab = (MetadataTabPanel) itor.next();
062:                    tab.clearToDestroy();
063:                }
064:                this .m_tabPanels.clear();
065:                this .m_vfs = null;
066:                this .m_sFilepath = null;
067:                this .m_PathToTab.clear();
068:                this .removeAll();
069:            }
070:
071:            /**
072:             * @param arg0
073:             */
074:            private MetadataTabs(int arg0) {
075:                super (arg0);
076:            }
077:
078:            /**
079:             * @param arg0
080:             * @param arg1
081:             */
082:            private MetadataTabs(int arg0, int arg1) {
083:                super (arg0, arg1);
084:            }
085:
086:            private void setup() {
087:
088:                this .addChangeListener(this );
089:
090:                String fontName = "Dialog";
091:                int fontSize = 11;
092:                Font font = new Font(fontName, Font.PLAIN, fontSize);
093:                this .setFont(font);
094:
095:                VirtualFile vfFile = this .m_vfs
096:                        .getVirtualFile(this .m_sFilepath).getResource();
097:                Iterator itor = vfFile.getProperties().iterator();
098:                while (itor.hasNext()) {
099:                    PropertyInstance propInstance = (PropertyInstance) itor
100:                            .next();
101:                    Property prop = propInstance.getDefinition();
102:                    this .addPropToPanel(vfFile, prop, propInstance);
103:                }
104:
105:                PropertyInstance propInst = new PropertyInstance(
106:                        NamespaceType.OHRM.getURI(), "harmonise-path");
107:                propInst.setVirtualFile(vfFile);
108:                StringValue value = (StringValue) propInst
109:                        .getNewValueInstance();
110:                value.setValue(vfFile.getFullPath());
111:                propInst.addValueWithoutFiringVirtualFileEvent(value);
112:                this .addPropToPanel(vfFile, propInst.getDefinition(), propInst);
113:
114:                this .validateTree();
115:                Iterator itor2 = this .m_tabPanels.iterator();
116:                while (itor2.hasNext()) {
117:                    MetadataTabPanel tab = (MetadataTabPanel) itor2.next();
118:                    tab.checkValid();
119:                }
120:            }
121:
122:            private void addPropToPanel(VirtualFile vfFile, Property prop,
123:                    PropertyInstance propInstance) {
124:                if (prop != null
125:                        && !(prop.getNamespace().equals(
126:                                NamespaceType.DAV.getURI()) && !(prop.getName()
127:                                .equals("domain") || prop.getName().equals(
128:                                "range")))
129:                        && !prop.getName().equals("creator-displayname")) {
130:                    // Setup tab
131:                    String sPropPath = prop.getHREF();
132:                    String sTabName = prop.getHREF();
133:
134:                    VirtualFile vfPropGroup = null;
135:
136:                    if (prop.getHREF().startsWith(
137:                            HarmonisePaths.PATH_WORKFLOW_PROPS)) {
138:                        sTabName = "Workflow";
139:                    } else if (prop.getName().equals("REPORT_EXE_ROLES")) {
140:                        sTabName = "Execute Permissions";
141:                    } else if (prop.getRange() instanceof  ResourceRange
142:                            || prop.getRange() instanceof  CollectionRange) {
143:                        sTabName = "Relationships";
144:                    } else if (prop.getNamespace().equals(
145:                            NamespaceType.DAV.getURI())
146:                            && prop.getName().equals("domain")) {
147:                        sTabName = "Domain";
148:                    } else if (((vfFile.isVersionable() && ((VersionedVirtualFile) vfFile)
149:                            .getLogicalPath().startsWith(
150:                                    HarmonisePaths.PATH_WORKFLOW_PROPS)) || vfFile
151:                            .getFullPath().startsWith(
152:                                    HarmonisePaths.PATH_WORKFLOW_PROPS))
153:                            && prop.getNamespace().equals(
154:                                    NamespaceType.DAV.getURI())
155:                            && prop.getName().equals("range")) {
156:                        sTabName = "EXCLUDE";
157:                    } else if (prop.getNamespace().equals(
158:                            NamespaceType.DAV.getURI())
159:                            && prop.getName().equals("range")) {
160:                        sTabName = "Range";
161:                    } else if (prop.getName().startsWith("WORKFLOW_")
162:                            && prop.getHREF()
163:                                    .startsWith("/webdav/SYSTEM_PROPS")) {
164:                        sTabName = "Workflow Details";
165:                    } else if (prop.getNamespace().equals(
166:                            NamespaceType.OHRM.getURI())
167:                            && (prop.getName().equals("harmonise-id") || prop
168:                                    .getName().equals("harmonise-path"))) {
169:                        sTabName = "Resource Information";
170:                    } else if (prop.getNamespace().equals(
171:                            NamespaceType.OHRM.getURI())
172:                            && prop.getName().equals("OUTPUT")) {
173:                        sTabName = "Resource Information";
174:                    } else if (prop.getNamespace().equals(
175:                            NamespaceType.OHRM.getURI())
176:                            && prop.getName().equals("title")) {
177:                        sTabName = "Resource Information";
178:                    } else if (prop.getNamespace().equals(
179:                            NamespaceType.OHRM.getURI())
180:                            && prop.getName().equals("description")) {
181:                        sTabName = "Resource Information";
182:                    } else if (prop.getNamespace().equals(
183:                            NamespaceType.OHRM.getURI())
184:                            && prop.getName().equals("thumbnail")) {
185:                        sTabName = "EXCLUDE";
186:                    } else {
187:
188:                        AbstractVirtualFileSystem vfsProps = ServerList
189:                                .getInstance().getHarmoniseServer().getVFS();
190:                        VirtualFile vfPropFile = vfsProps.getVirtualFile(
191:                                sPropPath).getResource();
192:
193:                        if (vfPropFile != null
194:                                && vfsProps.getVirtualFile(vfPropFile
195:                                        .getFilePath()) != null) {
196:                            vfPropGroup = vfsProps.getVirtualFile(
197:                                    vfPropFile.getFilePath()).getResource();
198:                            sTabName = vfsProps.getVirtualFileSystemView()
199:                                    .getDisplayName(vfPropGroup);
200:                        } else {
201:                            if (sTabName.endsWith("/")) {
202:                                sTabName = sTabName.substring(0, sTabName
203:                                        .length() - 1);
204:                            }
205:                            if (sTabName.endsWith("/" + prop.getName().trim())) {
206:                                sTabName = sTabName.substring(0, sTabName
207:                                        .length()
208:                                        - (1 + prop.getName().length()));
209:                            }
210:                        }
211:                    }
212:
213:                    sTabName = sTabName
214:                            .substring(sTabName.lastIndexOf("/") + 1);
215:                    // To add system tab back in comment && section out
216:                    if (this .indexOfTab(sTabName) == -1
217:                            && !sTabName.equals("System")
218:                            && !sTabName.equals("EXCLUDE")
219:                            && !sTabName.equals("default")
220:                            && !((sTabName.equals("RBS_PROPS") || sTabName
221:                                    .equals("Security")) && !HarmoniseAuthenticationStore
222:                                    .isSuperUser())) {
223:                        MetadataTabPanel panel = null;
224:                        if (vfPropGroup != null) {
225:                            panel = new MetadataTabPanel(vfPropGroup);
226:                        } else {
227:                            panel = new MetadataTabPanel();
228:                        }
229:                        JScrollPane scoller = null;
230:
231:                        if (sTabName.equalsIgnoreCase("Domain")
232:                                || sTabName.equalsIgnoreCase("Range")) {
233:                            scoller = new JScrollPane(panel,
234:                                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
235:                                    JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
236:                        } else {
237:                            scoller = new JScrollPane(panel,
238:                                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
239:                                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
240:                        }
241:
242:                        JScrollBar hBar = new JScrollBar(JScrollBar.HORIZONTAL);
243:                        hBar.setUnitIncrement(20);
244:                        hBar.setFocusable(false);
245:                        scoller.setHorizontalScrollBar(hBar);
246:                        JScrollBar vBar = new JScrollBar(JScrollBar.VERTICAL);
247:                        vBar.setUnitIncrement(20);
248:                        vBar.setFocusable(false);
249:                        scoller.setVerticalScrollBar(vBar);
250:                        scoller.setFocusable(false);
251:
252:                        this .m_tabPanels.add(panel);
253:                        this .addTab(sTabName, IconManager.getInstance()
254:                                .getIcon("16-message-confirm.gif"), scoller);
255:                        this .m_PathToTab.put(sPropPath, sTabName);
256:                    }
257:                    // Setup property
258:
259:                    if (sTabName.equals("RBS_PROPS")
260:                            && !HarmoniseAuthenticationStore.isSuperUser()) {
261:                        //			// To add system tab back in comment && section out
262:                    } else if (sTabName.equals("EXCLUDE")
263:                            || sTabName.equals("System")
264:                            || sTabName.equals("default")) {
265:                    } else {
266:                        PropertyPanel propPanel = null;
267:
268:                        RangeDisplay display = RangeDisplayFactory
269:                                .getRangeDisplay(propInstance);
270:
271:                        propPanel = new PropertyPanel(propInstance, display
272:                                .isResizeWidthEnabled());
273:
274:                        try {
275:                            JScrollPane scroller = (JScrollPane) this 
276:                                    .getComponentAt(this .indexOfTab(sTabName));
277:                            scroller.setFocusable(false);
278:                            MetadataTabPanel metaPane = (MetadataTabPanel) scroller
279:                                    .getViewport().getComponent(0);
280:                            propPanel.setSize(200, 100);
281:
282:                            if (display != null
283:                                    && !(display instanceof  ResourceRangeDisplay)) {
284:                                metaPane.addPropertyPanel(propPanel);
285:                                propPanel.add(display.getPanel());
286:                            } else if ((display instanceof  ResourceRangeDisplay)
287:                                    && !metaPane.hasRelationships()) {
288:                                metaPane
289:                                        .setRelationships((ResourceRangeDisplay) display);
290:                            } else if ((display instanceof  ResourceRangeDisplay)
291:                                    && metaPane.hasRelationships()) {
292:                                metaPane
293:                                        .addRelationship((ResourceRangeDisplay) display);
294:                            }
295:                        } catch (ArrayIndexOutOfBoundsException indexEx) {
296:                            System.err
297:                                    .println("Array index exception for TAB: "
298:                                            + sTabName + " and prop: "
299:                                            + prop.getDisplayName());
300:                            indexEx.printStackTrace();
301:                        }
302:                    }
303:
304:                }
305:            }
306:
307:            public void setSelectedTab(String sSelectedTabTitle) {
308:                if (sSelectedTabTitle != null) {
309:                    for (int i = 0; i < this .getTabCount(); i++) {
310:                        if (this .getTitleAt(i).equals(sSelectedTabTitle)) {
311:                            this .setSelectedIndex(i);
312:                            break;
313:                        }
314:                    }
315:                }
316:            }
317:
318:            public String getSelectedTabTitle() {
319:                return this .m_sSelectedTabTitle;
320:            }
321:
322:            public void setValid(boolean bValid, MetadataTabPanel panel) {
323:                int nIndex = -1;
324:                for (int i = 0; i < this .getTabCount(); i++) {
325:                    if (panel == ((JScrollPane) this .getComponentAt(i))
326:                            .getViewport().getComponent(0)) {
327:                        nIndex = i;
328:                        break;
329:                    }
330:                }
331:                if (nIndex != -1) {
332:                    if (bValid) {
333:                        this .setIconAt(nIndex, IconManager.getInstance()
334:                                .getIcon("16-message-confirm.gif"));
335:                    } else {
336:                        this .setIconAt(nIndex, IconManager.getInstance()
337:                                .getIcon("16-message-error.gif"));
338:                    }
339:                }
340:
341:            }
342:
343:            /* (non-Javadoc)
344:             * @see java.awt.Component#setEnabled(boolean)
345:             */
346:            public void setEnabled(boolean bEnabled) {
347:                for (Iterator iter = this .m_tabPanels.iterator(); iter
348:                        .hasNext();) {
349:                    MetadataTabPanel element = (MetadataTabPanel) iter.next();
350:                    element.setEnabled(bEnabled);
351:                }
352:            }
353:
354:            /* (non-Javadoc)
355:             * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
356:             */
357:            public void stateChanged(ChangeEvent ce) {
358:                int nSelectedIndex = this .getSelectedIndex();
359:                if (nSelectedIndex > -1 && nSelectedIndex <= this .getTabCount()) {
360:                    this .m_sSelectedTabTitle = this .getTitleAt(this 
361:                            .getSelectedIndex());
362:                } else {
363:                }
364:            }
365:
366:            public void validateAllComponents() {
367:                this .layout();
368:                SwingUtilities.invokeLater(this );
369:            }
370:
371:            /* (non-Javadoc)
372:             * @see java.lang.Runnable#run()
373:             */
374:            public void run() {
375:                this.repaint();
376:            }
377:
378:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.