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


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 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.progress;
011:
012:        import org.eclipse.core.runtime.IProgressMonitor;
013:        import org.eclipse.osgi.util.NLS;
014:
015:        /**
016:         * The TaskInfo is the info on a task with a job. It is assumed that there is
017:         * only one task running at a time - any previous tasks in a Job will be
018:         * deleted.
019:         */
020:        public class TaskInfo extends SubTaskInfo {
021:            double preWork = 0;
022:
023:            int totalWork = 0;
024:
025:            /**
026:             * Create a new instance of the receiver with the supplied total work and
027:             * task name.
028:             * 
029:             * @param parentJobInfo
030:             * @param infoName
031:             * @param total
032:             */
033:            TaskInfo(JobInfo parentJobInfo, String infoName, int total) {
034:                super (parentJobInfo, infoName);
035:                totalWork = total;
036:            }
037:
038:            /**
039:             * Add the work increment to the total.
040:             * 
041:             * @param workIncrement
042:             */
043:            void addWork(double workIncrement) {
044:
045:                // Don't bother if we are indeterminate
046:                if (totalWork == IProgressMonitor.UNKNOWN) {
047:                    return;
048:                }
049:                preWork += workIncrement;
050:
051:            }
052:
053:            /**
054:             * Add the amount of work to the recevier. Update a parent monitor by the
055:             * increment scaled to the amount of ticks this represents.
056:             * 
057:             * @param workIncrement
058:             *            int the amount of work in the receiver
059:             * @param parentMonitor
060:             *            The IProgressMonitor that is also listening
061:             * @param parentTicks
062:             *            the number of ticks this monitor represents
063:             */
064:            void addWork(double workIncrement, IProgressMonitor parentMonitor,
065:                    int parentTicks) {
066:                // Don't bother if we are indeterminate
067:                if (totalWork == IProgressMonitor.UNKNOWN) {
068:                    return;
069:                }
070:
071:                addWork(workIncrement);
072:                parentMonitor.internalWorked(workIncrement * parentTicks
073:                        / totalWork);
074:            }
075:
076:            /*
077:             * (non-Javadoc)
078:             * 
079:             * @see org.eclipse.ui.internal.progress.JobTreeElement#getDisplayString(boolean)
080:             */
081:            String getDisplayString(boolean showProgress) {
082:
083:                if (totalWork == IProgressMonitor.UNKNOWN) {
084:                    return unknownProgress();
085:                }
086:
087:                if (taskName == null) {
088:                    return getDisplayStringWithoutTask(showProgress);
089:                }
090:
091:                if (showProgress) {
092:                    String[] messageValues = new String[3];
093:                    messageValues[0] = String.valueOf(getPercentDone());
094:                    messageValues[1] = jobInfo.getJob().getName();
095:                    messageValues[2] = taskName;
096:
097:                    return NLS.bind(ProgressMessages.JobInfo_DoneMessage,
098:                            messageValues);
099:                }
100:                String[] messageValues = new String[2];
101:                messageValues[0] = jobInfo.getJob().getName();
102:                messageValues[1] = taskName;
103:
104:                return NLS.bind(ProgressMessages.JobInfo_DoneNoProgressMessage,
105:                        messageValues);
106:
107:            }
108:
109:            /**
110:             * Get the display String without the task name.
111:             * 
112:             * @param showProgress
113:             *            Whether or not we are showing progress
114:             * 
115:             * @return String
116:             */
117:            String getDisplayStringWithoutTask(boolean showProgress) {
118:
119:                if (!showProgress || totalWork == IProgressMonitor.UNKNOWN) {
120:                    return jobInfo.getJob().getName();
121:                }
122:
123:                return NLS.bind(ProgressMessages.JobInfo_NoTaskNameDoneMessage,
124:                        jobInfo.getJob().getName(), String
125:                                .valueOf(getPercentDone()));
126:            }
127:
128:            /**
129:             * Return an integer representing the amount of work completed. If progress
130:             * is indeterminate return IProgressMonitor.UNKNOWN.
131:             * 
132:             * @return int IProgressMonitor.UNKNOWN or a value between 0 and 100.
133:             */
134:            int getPercentDone() {
135:                if (totalWork == IProgressMonitor.UNKNOWN) {
136:                    return IProgressMonitor.UNKNOWN;
137:                }
138:
139:                return Math.min((int) (preWork * 100 / totalWork), 100);
140:            }
141:
142:            /**
143:             * Return the progress for a monitor whose totalWork is
144:             * <code>IProgressMonitor.UNKNOWN</code>.
145:             * 
146:             * @return String
147:             */
148:            private String unknownProgress() {
149:                if (taskName == null) {
150:                    return jobInfo.getJob().getName();
151:                }
152:                String[] messageValues = new String[2];
153:                messageValues[0] = jobInfo.getJob().getName();
154:                messageValues[1] = taskName;
155:                return NLS.bind(ProgressMessages.JobInfo_UnknownProgress,
156:                        messageValues);
157:
158:            }
159:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.