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


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 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.dialogs;
011:
012:        import org.eclipse.core.runtime.Assert;
013:        import org.eclipse.jface.preference.PreferenceDialog;
014:        import org.eclipse.jface.viewers.ISelectionProvider;
015:        import org.eclipse.jface.viewers.IStructuredSelection;
016:        import org.eclipse.jface.window.IShellProvider;
017:        import org.eclipse.jface.window.SameShellProvider;
018:        import org.eclipse.swt.widgets.Shell;
019:        import org.eclipse.ui.PlatformUI;
020:        import org.eclipse.ui.actions.SelectionProviderAction;
021:        import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
022:        import org.eclipse.ui.internal.WorkbenchMessages;
023:        import org.eclipse.ui.internal.dialogs.PropertyDialog;
024:        import org.eclipse.ui.internal.dialogs.PropertyPageContributorManager;
025:
026:        /**
027:         * Standard action for opening a Property Pages Dialog on the currently selected
028:         * element.
029:         * <p>
030:         * This class may be instantiated; it is not intended to be subclassed.
031:         * </p>
032:         * <p>
033:         * Generally speaking, this action is useful in pop-up menus because it allows
034:         * the user to browse and change properties of selected elements. When
035:         * performed, the action will bring up a Property Pages Dialog containing
036:         * property pages registered with the workbench for elements of the selected
037:         * type.
038:         * </p>
039:         * <p>
040:         * Although the action is capable of calculating if there are any applicable
041:         * pages for the current selection, this calculation is costly because it
042:         * require searching the workbench registry. Where performance is critical, the
043:         * action can simply be added to the pop-up menu. In the event of no applicable
044:         * pages, the action will just open an appropriate message dialog.
045:         * </p>
046:         */
047:        public class PropertyDialogAction extends SelectionProviderAction {
048:            /**
049:             * Provides the shell in which to open the property dialog.
050:             */
051:            private IShellProvider shellProvider;
052:
053:            /**
054:             * The id of the page to open up on.
055:             */
056:            private String initialPageId;
057:
058:            /**
059:             * Creates a new action for opening a property dialog on the elements from
060:             * the given selection provider.
061:             * 
062:             * @param shell
063:             *            the shell in which the dialog will open
064:             * @param provider
065:             *            the selection provider whose elements the property dialog will
066:             *            describe
067:             * @deprecated use PropertyDialogAction(IShellProvider, ISelectionProvider)
068:             */
069:            public PropertyDialogAction(Shell shell, ISelectionProvider provider) {
070:                this (new SameShellProvider(shell), provider);
071:            }
072:
073:            /**
074:             * Creates a new action for opening a property dialog on the elements from
075:             * the given selection provider.
076:             * 
077:             * @param shell
078:             *            provides the shell in which the dialog will open
079:             * @param provider
080:             *            the selection provider whose elements the property dialog will
081:             *            describe
082:             * @since 3.1
083:             */
084:            public PropertyDialogAction(IShellProvider shell,
085:                    ISelectionProvider provider) {
086:                super (provider, WorkbenchMessages.PropertyDialog_text);
087:                Assert.isNotNull(shell);
088:                this .shellProvider = shell;
089:                setToolTipText(WorkbenchMessages.PropertyDialog_toolTip);
090:                PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
091:                        IWorkbenchHelpContextIds.PROPERTY_DIALOG_ACTION);
092:            }
093:
094:            /**
095:             * Returns whether the provided object has pages registered in the property
096:             * page manager.
097:             * 
098:             * @param object
099:             * @return boolean
100:             */
101:            private boolean hasPropertyPagesFor(Object object) {
102:                return PropertyPageContributorManager.getManager()
103:                        .hasContributorsFor(object);
104:            }
105:
106:            /**
107:             * Returns whether this action is actually applicable to the current
108:             * selection. If this action is disabled, it will return <code>false</code>
109:             * without further calculation. If it is enabled, it will check with the
110:             * workbench's property page manager to see if there are any property pages
111:             * registered for the selected element's type.
112:             * <p>
113:             * This method is generally too expensive to use when updating the enabled
114:             * state of the action on each selection change.
115:             * </p>
116:             * 
117:             * @return <code>true</code> if the selection is of size 1 and there are
118:             *         property pages for the selected element, and <code>false</code>
119:             *         otherwise
120:             */
121:            public boolean isApplicableForSelection() {
122:                if (!isEnabled()) {
123:                    return false;
124:                }
125:                return isApplicableForSelection(getStructuredSelection());
126:            }
127:
128:            /**
129:             * Returns whether this action is applicable to the current selection. This
130:             * checks that the selection is of size 1, and checks with the workbench's
131:             * property page manager to see if there are any property pages registered
132:             * for the selected element's type.
133:             * <p>
134:             * This method is generally too expensive to use when updating the enabled
135:             * state of the action on each selection change.
136:             * </p>
137:             * 
138:             * @param selection
139:             *            The selection to test
140:             * @return <code>true</code> if the selection is of size 1 and there are
141:             *         property pages for the selected element, and <code>false</code>
142:             *         otherwise
143:             */
144:            public boolean isApplicableForSelection(
145:                    IStructuredSelection selection) {
146:                return selection.size() == 1
147:                        && hasPropertyPagesFor(selection.getFirstElement());
148:            }
149:
150:            /* (non-Javadoc)
151:             * @see org.eclipse.jface.action.IAction#run()
152:             */
153:            public void run() {
154:
155:                PreferenceDialog dialog = createDialog();
156:                if (dialog != null) {
157:                    dialog.open();
158:                }
159:            }
160:
161:            /**
162:             * Create the dialog for the receiver. If no pages are found, an informative
163:             * message dialog is presented instead.
164:             * 
165:             * @return PreferenceDialog or <code>null</code> if no applicable pages
166:             *         are found.
167:             * @since 3.1
168:             */
169:            public PreferenceDialog createDialog() {
170:
171:                Object element = getStructuredSelection().getFirstElement();
172:                if (element == null) {
173:                    return null;
174:                }
175:                return PropertyDialog.createDialogOn(shellProvider.getShell(),
176:                        initialPageId, element);
177:            }
178:
179:            /* (non-Javadoc)
180:             * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
181:             */
182:            public void selectionChanged(IStructuredSelection selection) {
183:                setEnabled(selection.size() == 1
184:                        && selection.getFirstElement() != null);
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.