Source Code Cross Referenced for OpenAnnotationUtil.java in  » Workflow-Engines » osbl-1_0 » newprocess » diagram » cust » annotations » utils » 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 » Workflow Engines » osbl 1_0 » newprocess.diagram.cust.annotations.utils 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package newprocess.diagram.cust.annotations.utils;
004:
005:        import java.net.MalformedURLException;
006:        import java.net.URL;
007:
008:        import org.eclipse.core.resources.IFile;
009:        import org.eclipse.core.runtime.IStatus;
010:        import org.eclipse.jface.dialogs.ErrorDialog;
011:        import org.eclipse.jface.dialogs.MessageDialog;
012:        import org.eclipse.osgi.util.NLS;
013:        import org.eclipse.swt.widgets.Shell;
014:        import org.eclipse.ui.IWorkbenchPage;
015:        import org.eclipse.ui.IWorkbenchWindow;
016:        import org.eclipse.ui.PartInitException;
017:        import org.eclipse.ui.PlatformUI;
018:        import org.eclipse.ui.browser.IWebBrowser;
019:        import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
020:        import org.eclipse.ui.ide.IDE;
021:        import org.eclipse.ui.internal.WorkbenchMessages;
022:        import org.eclipse.ui.internal.WorkbenchPlugin;
023:
024:        /**
025:         * Utility Class for open the Annotations
026:         * @author sh
027:         */
028:
029:        public class OpenAnnotationUtil {
030:
031:            /*
032:             * Constructor
033:             */
034:            public OpenAnnotationUtil() {
035:            }
036:
037:            /**
038:             * opens the given url in the internal browser, if possible.
039:             */
040:            public void openWebsite(String href) {
041:                // open the Website in the browser
042:                IWorkbenchBrowserSupport support = PlatformUI.getWorkbench()
043:                        .getBrowserSupport();
044:                try {
045:                    IWebBrowser browser = null;
046:                    if (support.isInternalWebBrowserAvailable())
047:                        browser = support.createBrowser(null);
048:                    else
049:                        browser = support.getExternalBrowser();
050:                    browser.openURL(new URL(urlEncodeForSpaces(href
051:                            .toCharArray())));
052:                } catch (MalformedURLException e) {
053:                    openWebBrowserError(href, e);
054:                } catch (PartInitException e) {
055:                    openWebBrowserError(href, e);
056:                }
057:            }
058:
059:            private String urlEncodeForSpaces(char[] input) {
060:                StringBuffer retu = new StringBuffer(input.length);
061:                for (int i = 0; i < input.length; i++) {
062:                    if (input[i] == ' ')
063:                        retu.append("%20");
064:                    else
065:                        retu.append(input[i]);
066:                }
067:                return retu.toString();
068:            }
069:
070:            /**
071:             * display an error message
072:             */
073:            private void openWebBrowserError(final String href,
074:                    final Throwable t) {
075:                final Shell shell = PlatformUI.getWorkbench()
076:                        .getActiveWorkbenchWindow().getShell();
077:                shell.getDisplay().asyncExec(new Runnable() {
078:                    public void run() {
079:                        String title = WorkbenchMessages.ProductInfoDialog_errorTitle;
080:                        String msg = NLS
081:                                .bind(
082:                                        WorkbenchMessages.ProductInfoDialog_unableToOpenWebBrowser,
083:                                        href);
084:                        IStatus status = WorkbenchPlugin.getStatus(t);
085:                        ErrorDialog.openError(shell, title, msg, status);
086:                    }
087:                });
088:            }
089:
090:            /**
091:             * Opens the the selected Annotation from the
092:             * TableViewer in its program 
093:             * @param path
094:             * @param projectName
095:             */
096:            public void openAnnotation(String path, String projectName) {
097:                // if it is a Website, open in the 
098:                // Annotation in the browser
099:                if ((path.startsWith("http://"))
100:                        || (path.startsWith("https://"))) {
101:                    openWebsite(path);
102:                    return;
103:                }
104:
105:                // if it is a file from the workspace, open it in
106:                // its editor
107:                openFile(path, projectName);
108:            }
109:
110:            /**
111:             * Opens the the selected Annotation from the
112:             * TableViewer in its program 
113:             * @param path
114:             * @param projectName
115:             */
116:            private void openFile(String path, String projectName) {
117:                // get the file for the path
118:                IFile file = new URIConvertUtil().getFileforPath(path,
119:                        projectName);
120:
121:                // check if the file has been found
122:                if ((file == null) || (!file.isAccessible())
123:                        || (!file.exists()))
124:                    return;
125:
126:                // open the favourite Annotation in its Editor
127:                IWorkbenchWindow dw = PlatformUI.getWorkbench()
128:                        .getActiveWorkbenchWindow();
129:                try {
130:                    if (dw != null) {
131:                        IWorkbenchPage page = dw.getActivePage();
132:                        if (page != null) {
133:                            IDE.openEditor(page, file, true);
134:                        }
135:                    }
136:                } catch (PartInitException e) {
137:                    MessageDialog.openError(dw.getShell(), "Error",
138:                            "file could not be opened");
139:                }
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.