Source Code Cross Referenced for DefaultCommandGroup.java in  » Report » pentaho-report » org » pentaho » reportdesigner » lib » client » commands » 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 » Report » pentaho report » org.pentaho.reportdesigner.lib.client.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007:         *
008:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
010:         * the license for the specific language governing your rights and limitations.
011:         *
012:         * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013:         */
014:        package org.pentaho.reportdesigner.lib.client.commands;
015:
016:        import org.jetbrains.annotations.NonNls;
017:        import org.jetbrains.annotations.NotNull;
018:        import org.jetbrains.annotations.Nullable;
019:
020:        import javax.swing.*;
021:        import java.util.ArrayList;
022:        import java.util.Arrays;
023:
024:        /**
025:         * User: Martin
026:         * Date: 21.11.2004
027:         * Time: 10:59:24
028:         */
029:        public class DefaultCommandGroup implements  CommandGroup {
030:            @NotNull
031:            private static final Command[] EMPTY_ARRAY = new Command[0];
032:
033:            @NotNull
034:            private TemplatePresentation templatePresentation;
035:
036:            @NotNull
037:            private Command[] children;
038:
039:            @NotNull
040:            private Type type;
041:            @NotNull
042:            private String name;
043:
044:            public DefaultCommandGroup(@NotNull
045:            String name) {
046:                this .name = name;
047:
048:                templatePresentation = new TemplatePresentation(this ,
049:                        "DefaultCommandGroup", "DefaultCommandGroup", false,
050:                        true);//NON-NLS
051:                templatePresentation.setIcon(CommandSettings.SIZE_16,
052:                        new ImageIcon(AbstractCommand.class
053:                                .getResource("Empty16.png")));//NON-NLS
054:                templatePresentation.setIcon(CommandSettings.SIZE_32,
055:                        new ImageIcon(AbstractCommand.class
056:                                .getResource("Empty32.png")));//NON-NLS
057:                templatePresentation.setIcon(CommandSettings.SIZE_64,
058:                        new ImageIcon(AbstractCommand.class
059:                                .getResource("Empty64.png")));//NON-NLS
060:                children = EMPTY_ARRAY;
061:                type = Type.NORMAL;
062:            }
063:
064:            public DefaultCommandGroup(@NotNull
065:            String text, @NotNull
066:            String description, @NotNull
067:            @NonNls
068:            String name, boolean enabled) {
069:                this .name = name;
070:
071:                templatePresentation = new TemplatePresentation(this , text,
072:                        description, enabled, true);
073:                templatePresentation.setIcon(CommandSettings.SIZE_16,
074:                        new ImageIcon(AbstractCommand.class
075:                                .getResource("Empty16.png")));//NON-NLS
076:                templatePresentation.setIcon(CommandSettings.SIZE_32,
077:                        new ImageIcon(AbstractCommand.class
078:                                .getResource("Empty32.png")));//NON-NLS
079:                templatePresentation.setIcon(CommandSettings.SIZE_64,
080:                        new ImageIcon(AbstractCommand.class
081:                                .getResource("Empty64.png")));//NON-NLS
082:                children = EMPTY_ARRAY;
083:                type = Type.NORMAL;
084:            }
085:
086:            public void addChild(@NotNull
087:            Command child, @Nullable
088:            CommandConstraint commandConstraint) {
089:                ArrayList<Command> commands = new ArrayList<Command>(Arrays
090:                        .asList(children));
091:
092:                if (!commands.contains(child)) {
093:                    if (commandConstraint == null
094:                            || CommandConstraint.LAST.equals(commandConstraint)) {
095:                        commands.add(child);
096:                    } else if (CommandConstraint.FIRST
097:                            .equals(commandConstraint)) {
098:                        commands.add(0, child);
099:                    } else if (commandConstraint.getConstraintType() == CommandConstraint.ConstraintType.AFTER) {
100:                        int index = getIndexOfCommand(commandConstraint
101:                                .getReference(), commands);
102:                        if (index == -1) {
103:                            //we did not find the command --> add as last
104:                            commands.add(child);
105:                        } else {
106:                            commands.add(index + 1, child);
107:                        }
108:                    } else if (commandConstraint.getConstraintType() == CommandConstraint.ConstraintType.BEFORE) {
109:                        int index = getIndexOfCommand(commandConstraint
110:                                .getReference(), commands);
111:                        if (index == -1) {
112:                            //we did not find the command --> add as last
113:                            commands.add(child);
114:                        } else {
115:                            commands.add(index, child);
116:                        }
117:                    } else {
118:                        commands.add(child);//nothing that makes sense->add as last command
119:                    }
120:                }
121:
122:                children = commands.toArray(new Command[commands.size()]);
123:
124:                for (Presentation presentation : templatePresentation
125:                        .getCreatedPresentations()) {
126:                    presentation.fireStructureChanged();
127:                }
128:            }
129:
130:            private int getIndexOfCommand(@NotNull
131:            String reference, @NotNull
132:            ArrayList<Command> commands) {
133:                for (int i = 0; i < commands.size(); i++) {
134:                    Command command = commands.get(i);
135:                    if (command.getName().equals(reference)) {
136:                        return i;
137:                    }
138:                }
139:                return -1;
140:            }
141:
142:            public void removeChild(@NotNull
143:            Command child) {
144:                ArrayList<Command> commands = new ArrayList<Command>(Arrays
145:                        .asList(children));
146:                commands.remove(child);
147:
148:                children = commands.toArray(new Command[commands.size()]);
149:
150:                for (Presentation presentation : templatePresentation
151:                        .getCreatedPresentations()) {
152:                    presentation.fireStructureChanged();
153:                }
154:            }
155:
156:            public void removeAllChildren() {
157:                children = EMPTY_ARRAY;
158:
159:                for (Presentation presentation : templatePresentation
160:                        .getCreatedPresentations()) {
161:                    presentation.fireStructureChanged();
162:                }
163:            }
164:
165:            public void setChildren(@NotNull
166:            Command[] commands) {
167:                children = commands;
168:
169:                for (Presentation presentation : templatePresentation
170:                        .getCreatedPresentations()) {
171:                    presentation.fireStructureChanged();
172:                }
173:            }
174:
175:            @NotNull
176:            public Command[] getChildren() {
177:                return children;
178:            }
179:
180:            public void setType(@NotNull
181:            Type type) {
182:                this .type = type;
183:            }
184:
185:            @NotNull
186:            public Type getType() {
187:                return type;
188:            }
189:
190:            public void update(@NotNull
191:            CommandEvent event) {
192:            }
193:
194:            @NotNull
195:            public String getName() {
196:                return name;
197:            }
198:
199:            public void execute(@NotNull
200:            CommandEvent event) {
201:            }
202:
203:            @NotNull
204:            public TemplatePresentation getTemplatePresentation() {
205:                return templatePresentation;
206:            }
207:
208:            @Nullable
209:            public JComponent getCustomComponent(@NotNull
210:            Presentation presentation) {
211:                return null;
212:            }
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.