Source Code Cross Referenced for IPTemplateArrayEditor.java in  » Web-Server » Jigsaw » org » w3c » jigadmin » attributes » 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 » Web Server » Jigsaw » org.w3c.jigadmin.attributes 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // IPTemplateArrayEditor.java
002:        // $Id: IPTemplateArrayEditor.java,v 1.3 2000/08/16 21:37:29 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1997.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigadmin.attributes;
007:
008:        import java.awt.Component;
009:        import java.awt.Dimension;
010:
011:        import java.util.Properties;
012:        import java.util.StringTokenizer;
013:
014:        import org.w3c.tools.resources.Attribute;
015:
016:        import org.w3c.jigadm.RemoteResourceWrapper;
017:        import org.w3c.jigadm.editors.EditorFeeder;
018:
019:        import org.w3c.jigsaw.admin.RemoteResource;
020:        import org.w3c.jigsaw.admin.RemoteAccessException;
021:
022:        import org.w3c.tools.widgets.IPTextField;
023:        import org.w3c.tools.widgets.TextEditable;
024:
025:        /**
026:         * IPTemplateArrayEditor : 
027:         * @author Benoit Mahe <bmahe@sophia.inria.fr>
028:         */
029:
030:        public class IPTemplateArrayEditor extends StringArrayEditor {
031:
032:            protected short oldshortarray[][] = null;
033:
034:            private String shortsToIPString(short one, short two, short three,
035:                    short four) {
036:                return (((one == 256) ? "*" : String.valueOf((int) one)) + "."
037:                        + ((two == 256) ? "*" : String.valueOf((int) two))
038:                        + "."
039:                        + ((three == 256) ? "*" : String.valueOf((int) three))
040:                        + "." + ((four == 256) ? "*" : String
041:                        .valueOf((int) four)));
042:            }
043:
044:            protected String[] toStringArray(short selectedItems[][]) {
045:                if (selectedItems == null)
046:                    return null;
047:                String selected[] = new String[selectedItems.length];
048:                for (int i = 0; i < selectedItems.length; i++)
049:                    selected[i] = shortsToIPString(selectedItems[i][0],
050:                            selectedItems[i][1], selectedItems[i][2],
051:                            selectedItems[i][3]);
052:                return selected;
053:            }
054:
055:            protected void setSelectedItems(short selectedItems[][]) {
056:                comp.setSelectedItems(toStringArray(selectedItems));
057:            }
058:
059:            /**
060:             * reset the changes (if any)
061:             */
062:            public void resetChanges() {
063:                hasChanged = false;
064:                setSelectedItems(oldshortarray);
065:            }
066:
067:            /**
068:             * Get the current value of the edited value
069:             * @return an object or <strong>null</strong> if the object was not
070:             * initialized
071:             */
072:            public Object getValue() {
073:                StringTokenizer st = null;
074:                String stvalue[] = comp.getSelectedItems();
075:                short shvalue[][] = new short[stvalue.length][4];
076:                for (int i = 0; i < stvalue.length; i++) {
077:                    st = new StringTokenizer(stvalue[i], ".");
078:                    int j = 0;
079:                    while (j < 4 && st.hasMoreTokens()) {
080:                        String tok = st.nextToken();
081:                        if (tok.equals("*"))
082:                            shvalue[i][j] = (short) 256;
083:                        else {
084:                            try {
085:                                shvalue[i][j] = Short.parseShort(tok);
086:                            } catch (NumberFormatException ex) {
087:                                ex.printStackTrace();
088:                                shvalue[i][j] = (short) 0;
089:                            }
090:                        }
091:                        j++;
092:                    }
093:                }
094:                return shvalue;
095:            }
096:
097:            /**
098:             * Set the value of the edited value
099:             * @param o the new value.
100:             */
101:            public void setValue(Object o) {
102:                this .oldshortarray = (short[][]) o;
103:                setSelectedItems(oldshortarray);
104:            }
105:
106:            protected TextEditable getTextEditor() {
107:                return new IPTextField();
108:            }
109:
110:            protected Dimension getPopupSize() {
111:                return new Dimension(350, 250);
112:            }
113:
114:            /**
115:             * Initialize the editor
116:             * @param w the ResourceWrapper father of the attribute
117:             * @param a the Attribute we are editing
118:             * @param o the value of the above attribute
119:             * @param p some Properties, used to fine-tune the editor
120:             * @exception RemoteAccessException if a remote access error occurs.
121:             */
122:            public void initialize(RemoteResourceWrapper w, Attribute a,
123:                    Object o, Properties p) throws RemoteAccessException {
124:                // Get the feeder class fromproperties:
125:                EditorFeeder feeder = null;
126:                String feederClass = null;
127:
128:                feederClass = (String) p.get(FEEDER_CLASS_P);
129:                if (feederClass == null)
130:                    throw new RuntimeException(
131:                            "StringArrayEditor mis-configuration: "
132:                                    + FEEDER_CLASS_P + " property undefined.");
133:                try {
134:                    Class c = Class.forName(feederClass);
135:                    feeder = (EditorFeeder) c.newInstance();
136:                    feeder.initialize(w, p);
137:                } catch (Exception ex) {
138:                    ex.printStackTrace();
139:                    throw new RuntimeException(
140:                            "StringArrayEditor mis-configured: "
141:                                    + " unable to instantiate " + feederClass
142:                                    + ".");
143:                }
144:                this .frame = ((org.w3c.jigadmin.RemoteResourceWrapper) w)
145:                        .getServerBrowser().getFrame();
146:
147:                oldshortarray = (short[][]) o;
148:                createComponent(feeder, toStringArray(oldshortarray));
149:            }
150:
151:            public IPTemplateArrayEditor() {
152:                super();
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.