Source Code Cross Referenced for SelectionStatusDialog.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:         *     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.Arrays;
015:
016:        import org.eclipse.core.runtime.IStatus;
017:        import org.eclipse.jface.dialogs.IDialogConstants;
018:        import org.eclipse.swt.SWT;
019:        import org.eclipse.swt.graphics.Font;
020:        import org.eclipse.swt.graphics.Image;
021:        import org.eclipse.swt.layout.GridData;
022:        import org.eclipse.swt.layout.GridLayout;
023:        import org.eclipse.swt.widgets.Button;
024:        import org.eclipse.swt.widgets.Composite;
025:        import org.eclipse.swt.widgets.Control;
026:        import org.eclipse.swt.widgets.Shell;
027:        import org.eclipse.ui.internal.MessageLine;
028:
029:        /**
030:         * An abstract base class for dialogs with a status bar and ok/cancel buttons.
031:         * The status message must be passed over as StatusInfo object and can be
032:         * an error, warning or ok. The OK button is enabled or disabled depending
033:         * on the status.
034:         * 
035:         * @since 2.0
036:         */
037:        public abstract class SelectionStatusDialog extends SelectionDialog {
038:
039:            private MessageLine fStatusLine;
040:
041:            private IStatus fLastStatus;
042:
043:            private Image fImage;
044:
045:            private boolean fStatusLineAboveButtons = false;
046:
047:            /**
048:             * Creates an instance of a <code>SelectionStatusDialog</code>.
049:             * @param parent
050:             */
051:            public SelectionStatusDialog(Shell parent) {
052:                super (parent);
053:            }
054:
055:            /**
056:             * Controls whether status line appears to the left of the buttons (default)
057:             * or above them.
058:             *
059:             * @param aboveButtons if <code>true</code> status line is placed above buttons; if
060:             * 	<code>false</code> to the right
061:             */
062:            public void setStatusLineAboveButtons(boolean aboveButtons) {
063:                fStatusLineAboveButtons = aboveButtons;
064:            }
065:
066:            /**
067:             * Sets the image for this dialog.
068:             * @param image the image.
069:             */
070:            public void setImage(Image image) {
071:                fImage = image;
072:            }
073:
074:            /**
075:             * Returns the first element from the list of results. Returns <code>null</code>
076:             * if no element has been selected.
077:             *
078:             * @return the first result element if one exists. Otherwise <code>null</code> is
079:             *  returned.
080:             */
081:            public Object getFirstResult() {
082:                Object[] result = getResult();
083:                if (result == null || result.length == 0) {
084:                    return null;
085:                }
086:                return result[0];
087:            }
088:
089:            /**
090:             * Sets a result element at the given position.
091:             * @param position
092:             * @param element
093:             */
094:            protected void setResult(int position, Object element) {
095:                Object[] result = getResult();
096:                result[position] = element;
097:                setResult(Arrays.asList(result));
098:            }
099:
100:            /**
101:             * Compute the result and return it.
102:             */
103:            protected abstract void computeResult();
104:
105:            /*
106:             * @see Window#configureShell(shell)
107:             */
108:            protected void configureShell(Shell shell) {
109:                super .configureShell(shell);
110:                if (fImage != null) {
111:                    shell.setImage(fImage);
112:                }
113:            }
114:
115:            /**
116:             * Update the dialog's status line to reflect the given status. It is safe to call
117:             * this method before the dialog has been opened.
118:             * @param status
119:             */
120:            protected void updateStatus(IStatus status) {
121:                fLastStatus = status;
122:                if (fStatusLine != null && !fStatusLine.isDisposed()) {
123:                    updateButtonsEnableState(status);
124:                    fStatusLine.setErrorStatus(status);
125:                }
126:            }
127:
128:            /**
129:             * Update the status of the ok button to reflect the given status. Subclasses
130:             * may override this method to update additional buttons.
131:             * @param status
132:             */
133:            protected void updateButtonsEnableState(IStatus status) {
134:                Button okButton = getOkButton();
135:                if (okButton != null && !okButton.isDisposed()) {
136:                    okButton.setEnabled(!status.matches(IStatus.ERROR));
137:                }
138:            }
139:
140:            /*
141:             * @see Dialog#okPressed()
142:             */
143:            protected void okPressed() {
144:                computeResult();
145:                super .okPressed();
146:            }
147:
148:            /*
149:             * @see Window#create()
150:             */
151:            public void create() {
152:                super .create();
153:                if (fLastStatus != null) {
154:                    updateStatus(fLastStatus);
155:                }
156:            }
157:
158:            /*
159:             * @see Dialog#createButtonBar(Composite)
160:             */
161:            protected Control createButtonBar(Composite parent) {
162:                Font font = parent.getFont();
163:                Composite composite = new Composite(parent, SWT.NULL);
164:                GridLayout layout = new GridLayout();
165:                if (!fStatusLineAboveButtons) {
166:                    layout.numColumns = 2;
167:                }
168:                layout.marginHeight = 0;
169:                layout.marginLeft = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
170:                layout.marginWidth = 0;
171:                composite.setLayout(layout);
172:                composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
173:                composite.setFont(font);
174:
175:                if (!fStatusLineAboveButtons && isHelpAvailable()) {
176:                    createHelpControl(composite);
177:                }
178:                fStatusLine = new MessageLine(composite);
179:                fStatusLine.setAlignment(SWT.LEFT);
180:                GridData statusData = new GridData(GridData.FILL_HORIZONTAL);
181:                fStatusLine.setErrorStatus(null);
182:                fStatusLine.setFont(font);
183:                if (fStatusLineAboveButtons && isHelpAvailable()) {
184:                    statusData.horizontalSpan = 2;
185:                    createHelpControl(composite);
186:                }
187:                fStatusLine.setLayoutData(statusData);
188:
189:                /*
190:                 * Create the rest of the button bar, but tell it not to
191:                 * create a help button (we've already created it).
192:                 */
193:                boolean helpAvailable = isHelpAvailable();
194:                setHelpAvailable(false);
195:                super.createButtonBar(composite);
196:                setHelpAvailable(helpAvailable);
197:                return composite;
198:            }
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.