Source Code Cross Referenced for ContainerSelectionDialog.java in  » IDE-Eclipse » ui-ide » 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 ide » 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:         *   Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog
011:         *     font should be activated and used by other components.
012:         *******************************************************************************/package org.eclipse.ui.dialogs;
013:
014:        import java.util.ArrayList;
015:        import java.util.List;
016:
017:        import org.eclipse.core.resources.IContainer;
018:        import org.eclipse.core.runtime.IPath;
019:        import org.eclipse.swt.SWT;
020:        import org.eclipse.swt.layout.GridData;
021:        import org.eclipse.swt.widgets.Composite;
022:        import org.eclipse.swt.widgets.Control;
023:        import org.eclipse.swt.widgets.Event;
024:        import org.eclipse.swt.widgets.Label;
025:        import org.eclipse.swt.widgets.Listener;
026:        import org.eclipse.swt.widgets.Shell;
027:        import org.eclipse.ui.PlatformUI;
028:        import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
029:        import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
030:        import org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup;
031:
032:        /**
033:         * A standard selection dialog which solicits a container resource from the user.
034:         * The <code>getResult</code> method returns the selected container resource.
035:         * <p>
036:         * This class may be instantiated; it is not intended to be subclassed.
037:         * </p>
038:         * <p>
039:         * Example:
040:         * <pre>
041:         * ContainerSelectionDialog dialog =
042:         *    new ContainerSelectionDialog(getShell(), initialSelection, allowNewContainerName(), msg);
043:         *	dialog.open();
044:         *	Object[] result = dialog.getResult();
045:         * </pre> 	
046:         * </p>
047:         */
048:        public class ContainerSelectionDialog extends SelectionDialog {
049:            /**
050:             * 
051:             */
052:            private static final String EMPTY_STRING = ""; //$NON-NLS-1$
053:
054:            // the widget group;
055:            ContainerSelectionGroup group;
056:
057:            // the root resource to populate the viewer with
058:            private IContainer initialSelection;
059:
060:            // allow the user to type in a new container name
061:            private boolean allowNewContainerName = true;
062:
063:            // the validation message
064:            Label statusMessage;
065:
066:            //for validating the selection
067:            ISelectionValidator validator;
068:
069:            // show closed projects by default
070:            private boolean showClosedProjects = true;
071:
072:            /**
073:             * Creates a resource container selection dialog rooted at the given resource.
074:             * All selections are considered valid. 
075:             *
076:             * @param parentShell the parent shell
077:             * @param initialRoot the initial selection in the tree
078:             * @param allowNewContainerName <code>true</code> to enable the user to type in
079:             *  a new container name, and <code>false</code> to restrict the user to just
080:             *  selecting from existing ones
081:             * @param message the message to be displayed at the top of this dialog, or
082:             *    <code>null</code> to display a default message
083:             */
084:            public ContainerSelectionDialog(Shell parentShell,
085:                    IContainer initialRoot, boolean allowNewContainerName,
086:                    String message) {
087:                super (parentShell);
088:                setTitle(IDEWorkbenchMessages.ContainerSelectionDialog_title);
089:                this .initialSelection = initialRoot;
090:                this .allowNewContainerName = allowNewContainerName;
091:                if (message != null) {
092:                    setMessage(message);
093:                } else {
094:                    setMessage(IDEWorkbenchMessages.ContainerSelectionDialog_message);
095:                }
096:            }
097:
098:            /* (non-Javadoc)
099:             * Method declared in Window.
100:             */
101:            protected void configureShell(Shell shell) {
102:                super .configureShell(shell);
103:                PlatformUI.getWorkbench().getHelpSystem().setHelp(shell,
104:                        IIDEHelpContextIds.CONTAINER_SELECTION_DIALOG);
105:            }
106:
107:            /* (non-Javadoc)
108:             * Method declared on Dialog.
109:             */
110:            protected Control createDialogArea(Composite parent) {
111:                // create composite 
112:                Composite area = (Composite) super .createDialogArea(parent);
113:
114:                Listener listener = new Listener() {
115:                    public void handleEvent(Event event) {
116:                        if (statusMessage != null && validator != null) {
117:                            String errorMsg = validator.isValid(group
118:                                    .getContainerFullPath());
119:                            if (errorMsg == null
120:                                    || errorMsg.equals(EMPTY_STRING)) {
121:                                statusMessage.setText(EMPTY_STRING);
122:                                getOkButton().setEnabled(true);
123:                            } else {
124:                                statusMessage.setText(errorMsg);
125:                                getOkButton().setEnabled(false);
126:                            }
127:                        }
128:                    }
129:                };
130:
131:                // container selection group
132:                group = new ContainerSelectionGroup(area, listener,
133:                        allowNewContainerName, getMessage(), showClosedProjects);
134:                if (initialSelection != null) {
135:                    group.setSelectedContainer(initialSelection);
136:                }
137:
138:                statusMessage = new Label(area, SWT.WRAP);
139:                statusMessage.setLayoutData(new GridData(
140:                        GridData.FILL_HORIZONTAL));
141:                statusMessage.setText(" \n "); //$NON-NLS-1$
142:                statusMessage.setFont(parent.getFont());
143:
144:                return dialogArea;
145:            }
146:
147:            /**
148:             * The <code>ContainerSelectionDialog</code> implementation of this 
149:             * <code>Dialog</code> method builds a list of the selected resource containers
150:             * for later retrieval by the client and closes this dialog.
151:             */
152:            protected void okPressed() {
153:
154:                List chosenContainerPathList = new ArrayList();
155:                IPath returnValue = group.getContainerFullPath();
156:                if (returnValue != null) {
157:                    chosenContainerPathList.add(returnValue);
158:                }
159:                setResult(chosenContainerPathList);
160:                super .okPressed();
161:            }
162:
163:            /**
164:             * Sets the validator to use.  
165:             * 
166:             * @param validator A selection validator
167:             */
168:            public void setValidator(ISelectionValidator validator) {
169:                this .validator = validator;
170:            }
171:
172:            /**
173:             * Set whether or not closed projects should be shown
174:             * in the selection dialog.
175:             * 
176:             * @param show Whether or not to show closed projects.
177:             */
178:            public void showClosedProjects(boolean show) {
179:                this.showClosedProjects = show;
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.