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


001:        /*******************************************************************************
002:         * Copyright (c) 2005, 2006 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.ui.internal.cheatsheets.composite.model;
011:
012:        import java.net.URL;
013:        import java.util.HashSet;
014:        import java.util.Hashtable;
015:        import java.util.Iterator;
016:        import java.util.Map;
017:        import java.util.Observable;
018:        import java.util.Set;
019:
020:        import org.eclipse.ui.IMemento;
021:        import org.eclipse.ui.cheatsheets.ICheatSheetManager;
022:        import org.eclipse.ui.internal.cheatsheets.data.ICheatSheet;
023:        import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager;
024:        import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheet;
025:        import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask;
026:
027:        public class CompositeCheatSheetModel extends Observable implements 
028:                ICompositeCheatSheet, ICheatSheet {
029:
030:            private String name;
031:            private String description;
032:            private String explorerId;
033:            private ICompositeCheatSheetTask rootTask;
034:            private TaskDependencies dependencies;
035:            private String id;
036:            private CompositeCheatSheetSaveHelper saveHelper;
037:            private URL contentURL;
038:            private CheatSheetManager manager;
039:            private Set stateChangedSet = new HashSet();
040:
041:            public void setRootTask(ICompositeCheatSheetTask task) {
042:                rootTask = task;
043:            }
044:
045:            public CompositeCheatSheetModel(String name, String description,
046:                    String explorerId) {
047:                this .name = name;
048:                this .description = description;
049:                this .explorerId = explorerId;
050:                this .dependencies = new TaskDependencies();
051:            }
052:
053:            public String getName() {
054:                return name;
055:            }
056:
057:            public String getDescription() {
058:                return description;
059:            }
060:
061:            public String getTaskExplorerId() {
062:                return explorerId;
063:            }
064:
065:            public ICompositeCheatSheetTask getRootTask() {
066:                return rootTask;
067:            }
068:
069:            public void setDependencies(TaskDependencies dependencies) {
070:                this .dependencies = dependencies;
071:            }
072:
073:            public TaskDependencies getDependencies() {
074:                return dependencies;
075:            }
076:
077:            public URL getContentUrl() {
078:                return contentURL;
079:            }
080:
081:            public void setContentUrl(URL newUrl) {
082:                contentURL = newUrl;
083:            }
084:
085:            public void setId(String id) {
086:                this .id = id;
087:            }
088:
089:            public String getId() {
090:                return id;
091:            }
092:
093:            public void setSaveHelper(CompositeCheatSheetSaveHelper saveHelper) {
094:                this .saveHelper = saveHelper;
095:            }
096:
097:            /**
098:             * Maintain a set of tasks which have been changed which will
099:             * be used to send events to observers.
100:             * @param task
101:             */
102:            void stateChanged(ICompositeCheatSheetTask task) {
103:                if (!stateChangedSet.contains(task)) {
104:                    stateChangedSet.add(task);
105:                }
106:            }
107:
108:            /**
109:             * At this point we need to determine which blocked tasks  have 
110:             * become unblocked and which unblocked tasks are now blocked and
111:             * send events for those also.
112:             */
113:            public void sendTaskChangeEvents() {
114:                Set blockedStateChanged = new BlockedTaskFinder()
115:                        .findBlockedTaskChanges(stateChangedSet);
116:                for (Iterator iter = stateChangedSet.iterator(); iter.hasNext();) {
117:                    setChanged();
118:                    notifyObservers(iter.next());
119:                }
120:                for (Iterator iter = blockedStateChanged.iterator(); iter
121:                        .hasNext();) {
122:                    setChanged();
123:                    notifyObservers(iter.next());
124:                }
125:                stateChangedSet.clear();
126:            }
127:
128:            public IMemento getTaskMemento(String id) {
129:                return saveHelper.getTaskMemento(id);
130:            }
131:
132:            public ICheatSheetManager getCheatSheetManager() {
133:                return manager;
134:            }
135:
136:            public void setCheatSheetManager(CheatSheetManager manager) {
137:                this .manager = manager;
138:            }
139:
140:            public void loadState(Map layoutData) {
141:                saveHelper.loadCompositeState(this , layoutData);
142:            }
143:
144:            /*
145:             * Reset the state of a task and it's children
146:             */
147:            private void resetTask(ICompositeCheatSheetTask task) {
148:                if (task instanceof  EditableTask) {
149:                    EditableTask editable = (EditableTask) task;
150:                    editable.reset();
151:                    if (saveHelper != null) {
152:                        saveHelper.clearTaskMemento(task.getId());
153:                    }
154:                } else if (task instanceof  TaskGroup) {
155:                    TaskGroup group = (TaskGroup) task;
156:                    ICompositeCheatSheetTask[] subtasks = group.getSubtasks();
157:                    for (int i = 0; i < subtasks.length; i++) {
158:                        resetTask(subtasks[i]);
159:                    }
160:                    group
161:                            .setStateNoNotify(ICompositeCheatSheetTask.NOT_STARTED);
162:                }
163:            }
164:
165:            public void resetAllTasks(Map cheatSheetData) {
166:                if (manager != null) {
167:                    if (cheatSheetData == null) {
168:                        manager.setData(new Hashtable());
169:                    } else {
170:                        manager.setData(cheatSheetData);
171:                    }
172:                }
173:                saveHelper.clearTaskMementos();
174:                resetTask(getRootTask());
175:                sendTaskChangeEvents();
176:            }
177:
178:            /**
179:             * Restart one or more tasks
180:             * @param restartTasks An array of the tasks to be restarted
181:             */
182:            public void resetTasks(ICompositeCheatSheetTask[] restartTasks) {
183:                for (int i = 0; i < restartTasks.length; i++) {
184:                    resetTask(restartTasks[i]);
185:                }
186:                sendTaskChangeEvents();
187:            }
188:
189:        }
ww__w_._j__a__va_2_s___._com__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.