Source Code Cross Referenced for ActionRunner.java in  » IDE-Eclipse » ui » org » eclipse » ui » internal » cheatsheets » 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 
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;
011:
012:        import org.eclipse.core.runtime.IStatus;
013:        import org.eclipse.core.runtime.Platform;
014:        import org.eclipse.core.runtime.Status;
015:        import org.eclipse.jface.action.IAction;
016:        import org.eclipse.jface.util.IPropertyChangeListener;
017:        import org.eclipse.jface.util.PropertyChangeEvent;
018:        import org.eclipse.osgi.util.NLS;
019:        import org.eclipse.ui.cheatsheets.ICheatSheetAction;
020:        import org.eclipse.ui.internal.cheatsheets.data.Action;
021:        import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager;
022:        import org.osgi.framework.Bundle;
023:
024:        /**
025:         * Class which can run actions and determine the outcome
026:         */
027:        public class ActionRunner {
028:            public IStatus runAction(Action cheatSheetAction,
029:                    CheatSheetManager csm) {
030:
031:                IStatus status = Status.OK_STATUS;
032:                String pluginId = cheatSheetAction.getPluginID();
033:                String className = cheatSheetAction.getActionClass();
034:                String[] params = cheatSheetAction.getParams();
035:                Bundle bundle = Platform.getBundle(pluginId);
036:                if (bundle == null) {
037:                    String message = NLS.bind(
038:                            Messages.ERROR_FINDING_PLUGIN_FOR_ACTION,
039:                            (new Object[] { pluginId }));
040:                    return new Status(IStatus.ERROR,
041:                            ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
042:                            IStatus.OK, message, null);
043:                }
044:                Class actionClass;
045:                IAction action;
046:                try {
047:                    actionClass = bundle.loadClass(className);
048:                } catch (Exception e) {
049:                    String message = NLS.bind(
050:                            Messages.ERROR_LOADING_CLASS_FOR_ACTION,
051:                            (new Object[] { className }));
052:                    return new Status(IStatus.ERROR,
053:                            ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
054:                            IStatus.OK, message, e);
055:                }
056:                try {
057:                    action = (IAction) actionClass.newInstance();
058:                } catch (Exception e) {
059:                    String message = NLS.bind(
060:                            Messages.ERROR_CREATING_CLASS_FOR_ACTION,
061:                            (new Object[] { className }));
062:                    return new Status(IStatus.ERROR,
063:                            ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
064:                            IStatus.OK, message, e);
065:                }
066:
067:                final boolean[] listenerFired = { false };
068:                final boolean[] listenerResult = { false };
069:                IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
070:                    public void propertyChange(PropertyChangeEvent event) {
071:                        if (event.getProperty().equals(IAction.RESULT)
072:                                && event.getNewValue() instanceof  Boolean) {
073:                            listenerFired[0] = true;
074:                            listenerResult[0] = ((Boolean) event.getNewValue())
075:                                    .booleanValue();
076:                        }
077:                    }
078:                };
079:
080:                // Add PropertyChangeListener to the action, so we can detemine if a action was succesfull
081:                action.addPropertyChangeListener(propertyChangeListener);
082:
083:                // Run the action for this ViewItem
084:                if (action instanceof  ICheatSheetAction) {
085:                    // Prepare parameters
086:                    String[] clonedParams = null;
087:                    if (params != null && params.length > 0) {
088:                        clonedParams = new String[params.length];
089:                        System.arraycopy(params, 0, clonedParams, 0,
090:                                params.length);
091:                        for (int i = 0; i < clonedParams.length; i++) {
092:                            String param = clonedParams[i];
093:                            if (param != null
094:                                    && param.startsWith("${") && param.endsWith("}")) { //$NON-NLS-1$ //$NON-NLS-2$
095:                                param = param.substring(2, param.length() - 1);
096:                                String value = csm.getDataQualified(param);
097:                                clonedParams[i] = value == null ? ICheatSheetResource.EMPTY_STRING
098:                                        : value;
099:                            }
100:                        }
101:                    }
102:                    ((ICheatSheetAction) action).run(clonedParams, csm);
103:                } else {
104:                    try {
105:                        action.run();
106:                    } catch (Throwable e) {
107:                        status = new Status(IStatus.ERROR,
108:                                ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
109:                                IStatus.OK, Messages.EXCEPTION_RUNNING_ACTION,
110:                                e);
111:                    }
112:                }
113:
114:                // Remove the PropertyChangeListener
115:                action.removePropertyChangeListener(propertyChangeListener);
116:
117:                if (status.isOK() && listenerFired[0]) {
118:                    if (!listenerResult[0]) {
119:                        status = new Status(IStatus.WARNING,
120:                                ICheatSheetResource.CHEAT_SHEET_PLUGIN_ID,
121:                                IStatus.OK, Messages.ACTION_FAILED, null);
122:                    }
123:                }
124:
125:                return status;
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.