Source Code Cross Referenced for SplashInfo.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » core » product » 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 » IDE Eclipse » Eclipse plug in development » org.eclipse.pde.internal.core.product 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2007 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.pde.internal.core.product;
011:
012:        import java.io.PrintWriter;
013:        import java.util.StringTokenizer;
014:
015:        import org.eclipse.pde.internal.core.iproduct.IProductModel;
016:        import org.eclipse.pde.internal.core.iproduct.ISplashInfo;
017:        import org.w3c.dom.Element;
018:        import org.w3c.dom.Node;
019:
020:        public class SplashInfo extends ProductObject implements  ISplashInfo {
021:
022:            public static final int F_DEFAULT_BAR_X_OFFSET = 5;
023:            public static final int F_DEFAULT_BAR_Y_OFFSET = 275;
024:            public static final int F_DEFAULT_BAR_WIDTH = 445;
025:            public static final int F_DEFAULT_BAR_HEIGHT = 15;
026:
027:            public static final int F_DEFAULT_MESSAGE_X_OFFSET = 7;
028:            public static final int F_DEFAULT_MESSAGE_Y_OFFSET = 252;
029:            public static final int F_DEFAULT_MESSAGE_WIDTH = 445;
030:            public static final int F_DEFAULT_MESSAGE_HEIGHT = 20;
031:
032:            private static final char[] VALID_HEX_CHARS = new char[] { '0',
033:                    '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c',
034:                    'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F' };
035:            private static final long serialVersionUID = 1L;
036:            private String fLocation;
037:            private boolean fCustomizeProgressBar;
038:            private int[] fProgressGeometry;
039:            private boolean fCustomizeProgressMessage;
040:            private int[] fMessageGeometry;
041:            private boolean fCustomizeForegroundColor;
042:            private String fForegroundColor;
043:
044:            private String fFieldSplashHandlerType;
045:
046:            public SplashInfo(IProductModel model) {
047:                super (model);
048:            }
049:
050:            public void setLocation(String location, boolean blockNotification) {
051:                String old = fLocation;
052:                fLocation = location;
053:                if (!blockNotification && isEditable())
054:                    firePropertyChanged(P_LOCATION, old, fLocation);
055:            }
056:
057:            public String getLocation() {
058:                return fLocation;
059:            }
060:
061:            public void parse(Node node) {
062:                if (node.getNodeType() == Node.ELEMENT_NODE) {
063:                    Element element = (Element) node;
064:                    setLocation(element.getAttribute(P_LOCATION), true);
065:                    setProgressGeometry(getGeometryArray(element
066:                            .getAttribute(P_PROGRESS_GEOMETRY)), true);
067:                    setMessageGeometry(getGeometryArray(element
068:                            .getAttribute(P_MESSAGE_GEOMETRY)), true);
069:                    setForegroundColor(
070:                            element.getAttribute(P_FOREGROUND_COLOR), true);
071:                    // Parse the splash handler type
072:                    setFieldSplashHandlerType(element
073:                            .getAttribute(F_ATTRIBUTE_HANDLER_TYPE), true);
074:                }
075:            }
076:
077:            public void write(String indent, PrintWriter writer) {
078:                if (!hasData())
079:                    return;
080:
081:                writer.print(indent + "<splash"); //$NON-NLS-1$
082:
083:                if (fLocation != null && fLocation.length() > 0)
084:                    writeProperty(indent, writer, P_LOCATION,
085:                            getWritableString(fLocation));
086:
087:                String progres = getGeometryString(fProgressGeometry);
088:                if (fCustomizeProgressBar && progres != null)
089:                    writeProperty(indent, writer, P_PROGRESS_GEOMETRY,
090:                            getWritableString(progres));
091:
092:                String message = getGeometryString(fMessageGeometry);
093:                if (fCustomizeProgressMessage && message != null)
094:                    writeProperty(indent, writer, P_MESSAGE_GEOMETRY,
095:                            getWritableString(message));
096:
097:                if (fCustomizeForegroundColor
098:                        && isValidHexValue(fForegroundColor))
099:                    writeProperty(indent, writer, P_FOREGROUND_COLOR,
100:                            getWritableString(fForegroundColor));
101:
102:                // Write the splash handler type if it is defined
103:                if (isDefinedSplashHandlerType()) {
104:                    writeProperty(indent, writer, F_ATTRIBUTE_HANDLER_TYPE,
105:                            fFieldSplashHandlerType);
106:                }
107:
108:                writer.print(" />"); //$NON-NLS-1$
109:            }
110:
111:            private void writeProperty(String indent, PrintWriter writer,
112:                    String name, String value) {
113:                writer.println();
114:                writer.print(indent + indent + name + "=\"" + value + "\""); //$NON-NLS-1$ //$NON-NLS-2$
115:            }
116:
117:            public void setProgressGeometry(int[] geo, boolean blockNotification) {
118:                fCustomizeProgressBar = geo != null;
119:                int[] old = fProgressGeometry;
120:                fProgressGeometry = geo;
121:                if (!blockNotification && isEditable())
122:                    firePropertyChanged(P_PROGRESS_GEOMETRY, old,
123:                            fProgressGeometry);
124:            }
125:
126:            public int[] getProgressGeometry() {
127:                return fCustomizeProgressBar ? fProgressGeometry : null;
128:            }
129:
130:            public void setMessageGeometry(int[] geo, boolean blockNotification) {
131:                fCustomizeProgressMessage = geo != null;
132:                int[] old = fMessageGeometry;
133:                fMessageGeometry = geo;
134:                if (!blockNotification && isEditable())
135:                    firePropertyChanged(P_MESSAGE_GEOMETRY, old,
136:                            fMessageGeometry);
137:            }
138:
139:            public int[] getMessageGeometry() {
140:                return fCustomizeProgressMessage ? fMessageGeometry : null;
141:            }
142:
143:            public void setForegroundColor(String hexColor,
144:                    boolean blockNotification) throws IllegalArgumentException {
145:                if (hexColor != null && hexColor.length() == 0)
146:                    hexColor = null;
147:                if (hexColor != null && !isValidHexValue(hexColor))
148:                    throw new IllegalArgumentException();
149:                fCustomizeForegroundColor = hexColor != null;
150:                String old = fForegroundColor;
151:                fForegroundColor = hexColor;
152:                if (!blockNotification && isEditable())
153:                    firePropertyChanged(P_FOREGROUND_COLOR, old,
154:                            fForegroundColor);
155:            }
156:
157:            public String getForegroundColor() {
158:                return fCustomizeForegroundColor ? fForegroundColor : null;
159:            }
160:
161:            public static String getGeometryString(int[] geometry) {
162:                if (geometry == null || geometry.length < 4)
163:                    return null;
164:                return Integer.toString(geometry[0]) + "," + //$NON-NLS-1$
165:                        Integer.toString(geometry[1]) + "," + //$NON-NLS-1$
166:                        Integer.toString(geometry[2]) + "," + //$NON-NLS-1$
167:                        Integer.toString(geometry[3]);
168:            }
169:
170:            public static int[] getGeometryArray(String tokenizedValue) {
171:                if (tokenizedValue == null || tokenizedValue.length() == 0)
172:                    return null;
173:
174:                StringTokenizer tokenizer = new StringTokenizer(tokenizedValue,
175:                        ","); //$NON-NLS-1$
176:                int position = 0;
177:                int[] geo = new int[4];
178:                while (tokenizer.hasMoreTokens())
179:                    geo[position++] = Integer.parseInt(tokenizer.nextToken());
180:                return geo;
181:            }
182:
183:            private boolean isValidHexValue(String value) {
184:                if (value == null || value.length() != 6)
185:                    return false;
186:                for (int i = 0; i < value.length(); i++) {
187:                    boolean found = false;
188:                    for (int j = 0; j < VALID_HEX_CHARS.length; j++) {
189:                        if (value.charAt(i) == VALID_HEX_CHARS[j]) {
190:                            found = true;
191:                            break;
192:                        }
193:                    }
194:                    if (!found)
195:                        return false;
196:                }
197:                return true;
198:            }
199:
200:            private boolean hasData() {
201:                return (fLocation != null && fLocation.length() > 0)
202:                        || (fCustomizeForegroundColor
203:                                && fForegroundColor != null && isValidHexValue(fForegroundColor))
204:                        || isDefinedGeometry() || isDefinedSplashHandlerType();
205:            }
206:
207:            /**
208:             * @return
209:             */
210:            public boolean isDefinedSplashHandlerType() {
211:                if ((fFieldSplashHandlerType != null)
212:                        && (fFieldSplashHandlerType.length() > 0)) {
213:                    return true;
214:                }
215:                return false;
216:            }
217:
218:            public void addProgressBar(boolean add, boolean blockNotification) {
219:                boolean old = fCustomizeProgressBar;
220:                fCustomizeProgressBar = add;
221:                int[] geo = getProgressGeometry();
222:                if (add)
223:                    setProgressGeometry(geo != null ? geo : new int[] {
224:                            F_DEFAULT_BAR_X_OFFSET, F_DEFAULT_BAR_Y_OFFSET,
225:                            F_DEFAULT_BAR_WIDTH, F_DEFAULT_BAR_HEIGHT },
226:                            blockNotification);
227:                else if (!blockNotification && isEditable())
228:                    firePropertyChanged(
229:                            "", Boolean.toString(old), Boolean.toString(add)); //$NON-NLS-1$
230:            }
231:
232:            public void addProgressMessage(boolean add,
233:                    boolean blockNotification) {
234:                boolean mold = fCustomizeProgressMessage;
235:                boolean cold = fCustomizeForegroundColor;
236:                fCustomizeProgressMessage = add;
237:                fCustomizeForegroundColor = add;
238:                int[] geo = getMessageGeometry();
239:                String foreground = getForegroundColor();
240:                if (add) {
241:                    setMessageGeometry(
242:                            geo != null ? geo : new int[] {
243:                                    F_DEFAULT_MESSAGE_X_OFFSET,
244:                                    F_DEFAULT_MESSAGE_Y_OFFSET,
245:                                    F_DEFAULT_MESSAGE_WIDTH,
246:                                    F_DEFAULT_MESSAGE_HEIGHT },
247:                            blockNotification);
248:                    setForegroundColor(foreground != null ? foreground
249:                            : "000000", blockNotification); //$NON-NLS-1$
250:                } else if (!blockNotification && isEditable())
251:                    firePropertyChanged(
252:                            "", Boolean.toString(mold || cold), Boolean.toString(add)); //$NON-NLS-1$
253:            }
254:
255:            /* (non-Javadoc)
256:             * @see org.eclipse.pde.internal.core.iproduct.ISplashInfo#getFieldSplashHandlerType()
257:             */
258:            public String getFieldSplashHandlerType() {
259:                return fFieldSplashHandlerType;
260:            }
261:
262:            /* (non-Javadoc)
263:             * @see org.eclipse.pde.internal.core.iproduct.ISplashInfo#setFieldSplashHandlerType(java.lang.String)
264:             */
265:            public void setFieldSplashHandlerType(String type,
266:                    boolean blockNotification) {
267:                String old = fFieldSplashHandlerType;
268:                fFieldSplashHandlerType = type;
269:                if ((blockNotification == false) && isEditable()) {
270:                    firePropertyChanged(F_ATTRIBUTE_HANDLER_TYPE, old,
271:                            fFieldSplashHandlerType);
272:                }
273:            }
274:
275:            /* (non-Javadoc)
276:             * @see org.eclipse.pde.internal.core.iproduct.ISplashInfo#isDefinedGeometry()
277:             */
278:            public boolean isDefinedGeometry() {
279:                if ((fCustomizeProgressBar && fProgressGeometry != null)
280:                        || (fCustomizeProgressMessage && fMessageGeometry != null)) {
281:                    return true;
282:                }
283:                return false;
284:            }
285:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.