Source Code Cross Referenced for DecorationBuilder.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » decorators » 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 » ui workbench » org.eclipse.ui.internal.decorators 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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:         *     Sascha Zelzer <zelzer@mathi.uni-heidelberg.de> -
011:         *     	Fix for Bug 152927 [Decorators] ArrayOutOfBoundsException in DecorationBuilder.java
012:         *******************************************************************************/package org.eclipse.ui.internal.decorators;
013:
014:        import java.util.ArrayList;
015:        import java.util.List;
016:
017:        import org.eclipse.jface.resource.ImageDescriptor;
018:        import org.eclipse.jface.viewers.DecorationContext;
019:        import org.eclipse.jface.viewers.IDecoration;
020:        import org.eclipse.jface.viewers.IDecorationContext;
021:        import org.eclipse.swt.graphics.Color;
022:        import org.eclipse.swt.graphics.Font;
023:        import org.eclipse.ui.internal.WorkbenchPlugin;
024:
025:        /**
026:         * The Decoration builder is the object that builds a decoration.
027:         */
028:        public class DecorationBuilder implements  IDecoration {
029:
030:            private static int DECORATOR_ARRAY_SIZE = 5;
031:
032:            private List prefixes = new ArrayList();
033:
034:            private List suffixes = new ArrayList();
035:
036:            private ImageDescriptor[] descriptors = new ImageDescriptor[DECORATOR_ARRAY_SIZE];
037:
038:            private Color foregroundColor;
039:
040:            private Color backgroundColor;
041:
042:            private Font font;
043:
044:            LightweightDecoratorDefinition currentDefinition;
045:
046:            //A flag set if a value has been added
047:            private boolean valueSet = false;
048:
049:            private final IDecorationContext context;
050:
051:            /**
052:             * Default constructor.
053:             */
054:            DecorationBuilder() {
055:                this (DecorationContext.DEFAULT_CONTEXT);
056:            }
057:
058:            /**
059:             * Create a decoration builder for the given context
060:             * @param context a decoration context
061:             */
062:            public DecorationBuilder(IDecorationContext context) {
063:                this .context = context;
064:            }
065:
066:            /**
067:             * Set the value of the definition we are currently working on.
068:             * 
069:             * @param definition
070:             */
071:            void setCurrentDefinition(LightweightDecoratorDefinition definition) {
072:                this .currentDefinition = definition;
073:            }
074:
075:            /**
076:             * @see org.eclipse.jface.viewers.IDecoration#addOverlay(org.eclipse.jface.resource.ImageDescriptor)
077:             */
078:            public void addOverlay(ImageDescriptor overlay) {
079:                int quadrant = currentDefinition.getQuadrant();
080:                if (descriptors[quadrant] == null) {
081:                    descriptors[quadrant] = overlay;
082:                }
083:                valueSet = true;
084:            }
085:
086:            /**
087:             * @see org.eclipse.jface.viewers.IDecoration#addOverlay(org.eclipse.jface.resource.ImageDescriptor)
088:             */
089:            public void addOverlay(ImageDescriptor overlay, int quadrant) {
090:                if (quadrant >= 0 && quadrant < DECORATOR_ARRAY_SIZE) {
091:                    if (descriptors[quadrant] == null) {
092:                        descriptors[quadrant] = overlay;
093:                    }
094:                    valueSet = true;
095:                } else {
096:                    WorkbenchPlugin
097:                            .log("Unable to apply decoration for " + currentDefinition.getId() + " invalid quadrant: " + quadrant); //$NON-NLS-1$ //$NON-NLS-2$
098:                }
099:            }
100:
101:            /**
102:             * @see org.eclipse.jface.viewers.IDecoration#addPrefix(java.lang.String)
103:             */
104:            public void addPrefix(String prefixString) {
105:                prefixes.add(prefixString);
106:                valueSet = true;
107:            }
108:
109:            /**
110:             * @see org.eclipse.jface.viewers.IDecoration#addSuffix(java.lang.String)
111:             */
112:            public void addSuffix(String suffixString) {
113:                suffixes.add(suffixString);
114:                valueSet = true;
115:            }
116:
117:            /**
118:             * Clear the current values and return a DecorationResult.
119:             * @return DecorationResult
120:             */
121:            DecorationResult createResult() {
122:                DecorationResult newResult = new DecorationResult(
123:                        new ArrayList(prefixes), new ArrayList(suffixes),
124:                        descriptors, foregroundColor, backgroundColor, font);
125:
126:                return newResult;
127:            }
128:
129:            /**
130:             * Clear the contents of the result so it can be reused.
131:             */
132:            void clearContents() {
133:                this .prefixes.clear();
134:                this .suffixes.clear();
135:                this .descriptors = new ImageDescriptor[DECORATOR_ARRAY_SIZE];
136:                valueSet = false;
137:            }
138:
139:            /**
140:             * Return whether or not a value has been set.
141:             * 
142:             * @return boolean
143:             */
144:            boolean hasValue() {
145:                return valueSet;
146:            }
147:
148:            /**
149:             * Apply the previously calculates result to the receiver.
150:             * 
151:             * @param result
152:             */
153:            void applyResult(DecorationResult result) {
154:                prefixes.addAll(result.getPrefixes());
155:                suffixes.addAll(result.getSuffixes());
156:                ImageDescriptor[] resultDescriptors = result.getDescriptors();
157:                if (resultDescriptors != null) {
158:                    for (int i = 0; i < descriptors.length; i++) {
159:                        if (resultDescriptors[i] != null) {
160:                            descriptors[i] = resultDescriptors[i];
161:                        }
162:                    }
163:                }
164:
165:                setForegroundColor(result.getForegroundColor());
166:                setBackgroundColor(result.getBackgroundColor());
167:                setFont(result.getFont());
168:                valueSet = true;
169:            }
170:
171:            /*
172:             *  (non-Javadoc)
173:             * @see org.eclipse.jface.viewers.IDecoration#setBackgroundColor(org.eclipse.swt.graphics.Color)
174:             */
175:
176:            public void setBackgroundColor(Color bgColor) {
177:                this .backgroundColor = bgColor;
178:                valueSet = true;
179:            }
180:
181:            /*
182:             *  (non-Javadoc)
183:             * @see org.eclipse.jface.viewers.IDecoration#setFont(org.eclipse.swt.graphics.Font)
184:             */
185:            public void setFont(Font newFont) {
186:                this .font = newFont;
187:                valueSet = true;
188:            }
189:
190:            /*
191:             *  (non-Javadoc)
192:             * @see org.eclipse.jface.viewers.IDecoration#setForegroundColor(org.eclipse.swt.graphics.Color)
193:             */
194:            public void setForegroundColor(Color fgColor) {
195:                this .foregroundColor = fgColor;
196:                valueSet = true;
197:            }
198:
199:            /* (non-Javadoc)
200:             * @see org.eclipse.jface.viewers.IDecoration#getDecorationContext()
201:             */
202:            public IDecorationContext getDecorationContext() {
203:                return context;
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.