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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 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.actions;
011:
012:        import org.eclipse.core.resources.IFile;
013:        import org.eclipse.jface.util.OpenStrategy;
014:        import org.eclipse.ui.IEditorDescriptor;
015:        import org.eclipse.ui.IWorkbenchPage;
016:        import org.eclipse.ui.PartInitException;
017:        import org.eclipse.ui.PlatformUI;
018:        import org.eclipse.ui.ide.IDE;
019:        import org.eclipse.ui.internal.ide.DialogUtil;
020:        import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
021:        import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
022:        import org.eclipse.ui.part.FileEditorInput;
023:
024:        /**
025:         * Standard action for opening an editor on the currently selected file 
026:         * resource(s).
027:         * <p>
028:         * Note that there is a different action for opening closed projects:
029:         * <code>OpenResourceAction</code>.
030:         * </p>
031:         * <p>
032:         * This class may be instantiated; it is not intended to be subclassed.
033:         * </p>
034:         */
035:        public class OpenFileAction extends OpenSystemEditorAction {
036:
037:            /**
038:             * The id of this action.
039:             */
040:            public static final String ID = PlatformUI.PLUGIN_ID
041:                    + ".OpenFileAction";//$NON-NLS-1$
042:
043:            /**
044:             * The editor to open.
045:             */
046:            private IEditorDescriptor editorDescriptor;
047:
048:            /**
049:             * Creates a new action that will open editors on the then-selected file 
050:             * resources. Equivalent to <code>OpenFileAction(page,null)</code>.
051:             *
052:             * @param page the workbench page in which to open the editor
053:             */
054:            public OpenFileAction(IWorkbenchPage page) {
055:                this (page, null);
056:            }
057:
058:            /**
059:             * Creates a new action that will open instances of the specified editor on 
060:             * the then-selected file resources.
061:             *
062:             * @param page the workbench page in which to open the editor
063:             * @param descriptor the editor descriptor, or <code>null</code> if unspecified
064:             */
065:            public OpenFileAction(IWorkbenchPage page,
066:                    IEditorDescriptor descriptor) {
067:                super (page);
068:                setText(descriptor == null ? IDEWorkbenchMessages.OpenFileAction_text
069:                        : descriptor.getLabel());
070:                PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
071:                        IIDEHelpContextIds.OPEN_FILE_ACTION);
072:                setToolTipText(IDEWorkbenchMessages.OpenFileAction_toolTip);
073:                setId(ID);
074:                this .editorDescriptor = descriptor;
075:            }
076:
077:            /**
078:             * Ensures that the contents of the given file resource are local.
079:             *
080:             * @param file the file resource
081:             * @return <code>true</code> if the file is local, and <code>false</code> if
082:             *   it could not be made local for some reason
083:             */
084:            boolean ensureFileLocal(final IFile file) {
085:                //Currently fails due to Core PR.  Don't do it for now
086:                //1G5I6PV: ITPCORE:WINNT - IResource.setLocal() attempts to modify immutable tree
087:                //file.setLocal(true, IResource.DEPTH_ZERO);
088:                return true;
089:            }
090:
091:            /**
092:             * Opens an editor on the given file resource.
093:             *
094:             * @param file the file resource
095:             */
096:            void openFile(IFile file) {
097:                try {
098:                    boolean activate = OpenStrategy.activateOnOpen();
099:                    if (editorDescriptor == null) {
100:                        IDE.openEditor(getWorkbenchPage(), file, activate);
101:                    } else {
102:                        if (ensureFileLocal(file)) {
103:                            getWorkbenchPage().openEditor(
104:                                    new FileEditorInput(file),
105:                                    editorDescriptor.getId(), activate);
106:                        }
107:                    }
108:                } catch (PartInitException e) {
109:                    DialogUtil
110:                            .openError(
111:                                    getWorkbenchPage().getWorkbenchWindow()
112:                                            .getShell(),
113:                                    IDEWorkbenchMessages.OpenFileAction_openFileShellTitle,
114:                                    e.getMessage(), e);
115:                }
116:            }
117:
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.