Source Code Cross Referenced for DescriptionPanel.java in  » IDE-Eclipse » ui » org » eclipse » ui » internal » cheatsheets » composite » views » 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.views 
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.ui.internal.cheatsheets.composite.views;
011:
012:        import org.eclipse.jface.resource.JFaceResources;
013:        import org.eclipse.osgi.util.NLS;
014:        import org.eclipse.swt.SWT;
015:        import org.eclipse.swt.layout.GridData;
016:        import org.eclipse.swt.layout.GridLayout;
017:        import org.eclipse.swt.widgets.Composite;
018:        import org.eclipse.swt.widgets.Control;
019:        import org.eclipse.ui.forms.IFormColors;
020:        import org.eclipse.ui.forms.ManagedForm;
021:        import org.eclipse.ui.forms.events.IHyperlinkListener;
022:        import org.eclipse.ui.forms.widgets.FormText;
023:        import org.eclipse.ui.forms.widgets.FormToolkit;
024:        import org.eclipse.ui.forms.widgets.ScrolledForm;
025:        import org.eclipse.ui.forms.widgets.TableWrapData;
026:        import org.eclipse.ui.forms.widgets.TableWrapLayout;
027:        import org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin;
028:        import org.eclipse.ui.internal.cheatsheets.ICheatSheetResource;
029:        import org.eclipse.ui.internal.cheatsheets.Messages;
030:        import org.eclipse.ui.internal.cheatsheets.composite.model.AbstractTask;
031:        import org.eclipse.ui.internal.cheatsheets.composite.model.SuccesorTaskFinder;
032:        import org.eclipse.ui.internal.cheatsheets.composite.model.TaskStateUtilities;
033:        import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags;
034:        import org.eclipse.ui.internal.cheatsheets.composite.parser.MarkupParser;
035:        import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask;
036:        import org.eclipse.ui.internal.provisional.cheatsheets.IEditableTask;
037:        import org.eclipse.ui.internal.provisional.cheatsheets.ITaskGroup;
038:
039:        /**
040:         * The description panel of a composite cheat sheet panel. This panel shows the introduction
041:         * message and depending upon the type and state of the task a selection of the following:
042:         * Completion message
043:         * A message indicating that the task has been skipped.
044:         * A message indicating that a parent task has been skipped.
045:         * A message indicating that the task is blocked.
046:         * A message indicationg that a parent choice is already satisfied.
047:         * A link to a successor task.
048:         * All tasks completed message.
049:         */
050:
051:        public class DescriptionPanel {
052:
053:            public static final String REVIEW_IMAGE = "review"; //$NON-NLS-1$
054:            private static final String GOTO_IMAGE = "goto"; //$NON-NLS-1$
055:            private static final String SKIP_IMAGE = "skip"; //$NON-NLS-1$
056:            private static final String START_IMAGE = "start"; //$NON-NLS-1$
057:            private static final String WARNING_IMAGE = "warning"; //$NON-NLS-1$
058:            private static final String INFORMATION_IMAGE = "info"; //$NON-NLS-1$	
059:            private Composite panel;
060:            private Composite control;
061:            private FormText upperText;
062:            private FormText lowerText;
063:            private ScrolledForm form;
064:
065:            protected DescriptionPanel() {
066:            }
067:
068:            public DescriptionPanel(ManagedForm mform, Composite parent) {
069:
070:                FormToolkit toolkit = mform.getToolkit();
071:                control = new Composite(parent, SWT.NULL);
072:                final GridLayout controlLayout = new GridLayout();
073:                controlLayout.marginHeight = 0;
074:                controlLayout.marginWidth = 0;
075:                control.setLayout(controlLayout);
076:                form = toolkit.createScrolledForm(control);
077:                panel = form.getBody();
078:                form.setLayoutData(new GridData(GridData.FILL_BOTH));
079:                toolkit.adapt(panel);
080:
081:                TableWrapLayout layout = new TableWrapLayout();
082:                panel.setLayout(layout);
083:
084:                upperText = mform.getToolkit().createFormText(panel, false);
085:                mform.getToolkit().adapt(upperText, false, false);
086:
087:                Composite separator = toolkit.createCompositeSeparator(panel);
088:
089:                TableWrapData data = new TableWrapData();
090:                data.align = TableWrapData.FILL;
091:                data.grabHorizontal = true;
092:                data.maxHeight = 1;
093:                separator.setLayoutData(data);
094:
095:                lowerText = mform.getToolkit().createFormText(panel, false);
096:                mform.getToolkit().adapt(lowerText, false, false);
097:
098:                upperText.marginWidth = 5;
099:                upperText.marginHeight = 5;
100:                upperText.setFont("header", JFaceResources.getHeaderFont()); //$NON-NLS-1$
101:                upperText
102:                        .setColor(
103:                                "title", toolkit.getColors().getColor(IFormColors.TITLE)); //$NON-NLS-1$
104:                lowerText.marginWidth = 5;
105:                lowerText.marginHeight = 5;
106:                lowerText.setImage(START_IMAGE, CheatSheetPlugin.getPlugin()
107:                        .getImage(ICheatSheetResource.COMPOSITE_TASK_START));
108:                lowerText.setImage(SKIP_IMAGE, CheatSheetPlugin.getPlugin()
109:                        .getImage(ICheatSheetResource.COMPOSITE_TASK_SKIP));
110:                lowerText.setImage(GOTO_IMAGE, CheatSheetPlugin.getPlugin()
111:                        .getImage(ICheatSheetResource.COMPOSITE_GOTO_TASK));
112:                lowerText.setImage(REVIEW_IMAGE, CheatSheetPlugin.getPlugin()
113:                        .getImage(ICheatSheetResource.COMPOSITE_TASK_REVIEW));
114:                lowerText.setImage(WARNING_IMAGE, CheatSheetPlugin.getPlugin()
115:                        .getImage(ICheatSheetResource.WARNING));
116:                lowerText.setImage(INFORMATION_IMAGE, CheatSheetPlugin
117:                        .getPlugin().getImage(ICheatSheetResource.INFORMATION));
118:            }
119:
120:            public Control getControl() {
121:                return control;
122:            }
123:
124:            public void addHyperlinkListener(IHyperlinkListener listener) {
125:                lowerText.addHyperlinkListener(listener);
126:            }
127:
128:            public void showDescription(final ICompositeCheatSheetTask task) {
129:                StringBuffer upperMessage = new StringBuffer();
130:                upperMessage.append("<form>"); //$NON-NLS-1$
131:                upperMessage
132:                        .append("<p><span color=\"title\" font=\"header\">"); //$NON-NLS-1$
133:                upperMessage.append(MarkupParser.escapeText(task.getName()));
134:                upperMessage.append("</span></p>"); //$NON-NLS-1$		
135:                upperMessage.append(MarkupParser.createParagraph(task
136:                        .getDescription(), null));
137:                upperMessage.append("</form>"); //$NON-NLS-1$
138:                upperText.setText(upperMessage.toString(), true, false);
139:
140:                StringBuffer buf = new StringBuffer();
141:                buf.append("<form>"); //$NON-NLS-1$
142:
143:                boolean startable = false;
144:                boolean isBlocked = false;
145:                boolean isSkippable = ((AbstractTask) task).isSkippable();
146:
147:                if (task.getState() == ICompositeCheatSheetTask.COMPLETED) {
148:                    buf.append(MarkupParser.createParagraph(task
149:                            .getCompletionMessage(), null));
150:                    isSkippable = false;
151:                } else if (task.getState() == ICompositeCheatSheetTask.SKIPPED) {
152:                    buf.append(MarkupParser.createParagraph(
153:                            Messages.THIS_TASK_SKIPPED, INFORMATION_IMAGE));
154:                    isSkippable = false;
155:                } else if (TaskStateUtilities.findSkippedAncestor(task) != null) {
156:                    ICompositeCheatSheetTask skipped = TaskStateUtilities
157:                            .findSkippedAncestor(task);
158:                    String skipParentMsg = NLS.bind(Messages.PARENT_SKIPPED,
159:                            (new Object[] { MarkupParser.escapeText((skipped
160:                                    .getName())) }));
161:                    buf.append(MarkupParser.createParagraph(skipParentMsg,
162:                            WARNING_IMAGE));
163:                    isSkippable = false;
164:                } else if (TaskStateUtilities.findCompletedAncestor(task) != null) {
165:                    ICompositeCheatSheetTask completed = TaskStateUtilities
166:                            .findCompletedAncestor(task);
167:                    String completedParentMsg = NLS.bind(
168:                            Messages.PARENT_COMPLETED,
169:                            (new Object[] { MarkupParser.escapeText(completed
170:                                    .getName()) }));
171:                    buf.append(MarkupParser.createParagraph(completedParentMsg,
172:                            WARNING_IMAGE));
173:                    isSkippable = false;
174:                } else if (!task.requiredTasksCompleted()) {
175:                    isBlocked = true;
176:                    showBlockingTasks(Messages.COMPOSITE_PAGE_BLOCKED, task,
177:                            buf);
178:                } else if (TaskStateUtilities.findBlockedAncestor(task) != null) {
179:                    isBlocked = true;
180:                    ICompositeCheatSheetTask blockedAncestor = TaskStateUtilities
181:                            .findBlockedAncestor(task);
182:                    String blockingAncestorMsg = NLS.bind(
183:                            Messages.PARENT_BLOCKED,
184:                            (new Object[] { MarkupParser
185:                                    .escapeText(blockedAncestor.getName()) }));
186:                    showBlockingTasks(blockingAncestorMsg, blockedAncestor, buf);
187:                } else {
188:                    startable = task instanceof  IEditableTask
189:                            && task.getState() == ICompositeCheatSheetTask.NOT_STARTED;
190:                }
191:
192:                if (startable) {
193:                    addHyperlink(buf, CompositeCheatSheetPage.START_HREF,
194:                            START_IMAGE, Messages.COMPOSITE_PAGE_START_TASK);
195:                }
196:
197:                if (task instanceof  IEditableTask
198:                        && task.getState() == ICompositeCheatSheetTask.COMPLETED) {
199:                    addHyperlink(buf, CompositeCheatSheetPage.REVIEW_TAG,
200:                            REVIEW_IMAGE, Messages.COMPOSITE_PAGE_REVIEW_TASK);
201:                }
202:
203:                if (isSkippable) {
204:                    String skipMessage;
205:                    if (task instanceof  ITaskGroup) {
206:                        skipMessage = Messages.COMPOSITE_PAGE_SKIP_TASK_GROUP;
207:                    } else {
208:                        skipMessage = Messages.COMPOSITE_PAGE_SKIP_TASK;
209:                    }
210:                    addHyperlink(buf, CompositeCheatSheetPage.SKIP_HREF,
211:                            SKIP_IMAGE, skipMessage);
212:                }
213:
214:                if (!startable && !isBlocked) {
215:                    showSuccesorTaskLinks(task, buf);
216:                }
217:
218:                buf.append("</form>"); //$NON-NLS-1$
219:
220:                lowerText.setText(buf.toString(), true, false);
221:                getControl().setData(ICompositeCheatsheetTags.TASK, task);
222:                form.reflow(true);
223:            }
224:
225:            private void showBlockingTasks(String message,
226:                    final ICompositeCheatSheetTask task, StringBuffer buf) {
227:                buf.append("<p/>"); //$NON-NLS-1$
228:                buf.append("<p>"); //$NON-NLS-1$
229:                buf.append("<img href=\""); //$NON-NLS-1$
230:                buf.append(WARNING_IMAGE);
231:                buf.append("\"/> "); //$NON-NLS-1$
232:                buf.append(message);
233:                buf.append("</p>"); //$NON-NLS-1$// Add the list of blocking tasks
234:
235:                ICompositeCheatSheetTask[] requiredTasks = task
236:                        .getRequiredTasks();
237:                for (int i = 0; i < requiredTasks.length; i++) {
238:                    warnOfIncompleteTask(buf, requiredTasks[i]);
239:                }
240:                buf.append("<p>"); //$NON-NLS-1$
241:                buf.append("</p>"); //$NON-NLS-1$
242:            }
243:
244:            private void addHyperlink(StringBuffer buf, String href,
245:                    String imageRef, String message) {
246:                buf.append("<p><a href=\""); //$NON-NLS-1$
247:                buf.append(href);
248:                buf.append("\">"); //$NON-NLS-1$
249:                buf.append("<img href=\""); //$NON-NLS-1$
250:                buf.append(imageRef);
251:                buf.append("\"/> "); //$NON-NLS-1$
252:                buf.append(message);
253:                buf.append("</a></p>"); //$NON-NLS-1$
254:            }
255:
256:            /*
257:             * If this task is incomplete create a message to that effect
258:             */
259:            private void warnOfIncompleteTask(StringBuffer buf,
260:                    ICompositeCheatSheetTask task) {
261:                if (task.getState() != ICompositeCheatSheetTask.COMPLETED
262:                        && task.getState() != ICompositeCheatSheetTask.SKIPPED) {
263:                    buf.append("<li>"); //$NON-NLS-1$
264:                    buf.append("<a href=\""); //$NON-NLS-1$
265:                    buf.append(CompositeCheatSheetPage.GOTO_TASK_TAG);
266:                    buf.append(task.getId());
267:                    buf.append("\">"); //$NON-NLS-1$	
268:                    buf.append(NLS.bind(
269:                            Messages.COMPOSITE_PAGE_TASK_NOT_COMPLETE,
270:                            (new Object[] { MarkupParser.escapeText(task
271:                                    .getName()) })));
272:                    buf.append("</a>"); //$NON-NLS-1$	
273:                    buf.append("</li>"); //$NON-NLS-1$
274:                }
275:            }
276:
277:            private void showSuccesorTaskLinks(ICompositeCheatSheetTask task,
278:                    StringBuffer buf) {
279:                // Add the links to the next tasks
280:                ICompositeCheatSheetTask[] successorTasks = new SuccesorTaskFinder(
281:                        task).getRecommendedSuccessors();
282:                for (int i = 0; i < successorTasks.length; i++) {
283:                    ICompositeCheatSheetTask successor = successorTasks[i];
284:                    String message = NLS.bind(
285:                            Messages.COMPOSITE_PAGE_GOTO_TASK,
286:                            (new Object[] { MarkupParser.escapeText(successor
287:                                    .getName()) }));
288:                    addHyperlink(buf, CompositeCheatSheetPage.GOTO_TASK_TAG
289:                            + successor.getId(), GOTO_IMAGE, message);
290:                }
291:            }
292:
293:        }
w__w__w___.j_a__v__a_2__s_.__c___om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.