Source Code Cross Referenced for StringButtonStatusDialogField.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » wizards » dialogfields » 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 » jdt » org.eclipse.jdt.internal.ui.wizards.dialogfields 
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.jdt.internal.ui.wizards.dialogfields;
011:
012:        import org.eclipse.swt.SWT;
013:        import org.eclipse.swt.graphics.GC;
014:        import org.eclipse.swt.graphics.Image;
015:        import org.eclipse.swt.widgets.Button;
016:        import org.eclipse.swt.widgets.Composite;
017:        import org.eclipse.swt.widgets.Control;
018:        import org.eclipse.swt.widgets.Label;
019:        import org.eclipse.swt.widgets.Text;
020:
021:        import org.eclipse.swt.layout.GridData;
022:
023:        import org.eclipse.jface.resource.JFaceResources;
024:
025:        /**
026:         * Dialog field containing a label, text control, status label and a button control.
027:         * The status label can be either a image or text label, and can be usd to give
028:         * additional information about the current element chosen.
029:         */
030:        public class StringButtonStatusDialogField extends
031:                StringButtonDialogField {
032:
033:            private Label fStatusLabelControl;
034:            private Object fStatus; // String or ImageDescriptor
035:
036:            private String fWidthHintString;
037:            private int fWidthHint;
038:
039:            public StringButtonStatusDialogField(IStringButtonAdapter adapter) {
040:                super (adapter);
041:                fStatus = null;
042:                fWidthHintString = null;
043:                fWidthHint = -1;
044:            }
045:
046:            // ------ set status
047:
048:            /**
049:             * Sets the status string.
050:             */
051:            public void setStatus(String status) {
052:                if (isOkToUse(fStatusLabelControl)) {
053:                    fStatusLabelControl.setText(status);
054:                }
055:                fStatus = status;
056:            }
057:
058:            /**
059:             * Sets the status image.
060:             * Caller is responsible to dispose image
061:             */
062:            public void setStatus(Image image) {
063:                if (isOkToUse(fStatusLabelControl)) {
064:                    if (image == null) {
065:                        fStatusLabelControl.setImage(null);
066:                    } else {
067:                        fStatusLabelControl.setImage(image);
068:                    }
069:                }
070:                fStatus = image;
071:            }
072:
073:            /**
074:             * Sets the staus string hint of the status label.
075:             * The string is used to calculate the size of the status label.
076:             */
077:            public void setStatusWidthHint(String widthHintString) {
078:                fWidthHintString = widthHintString;
079:                fWidthHint = -1;
080:            }
081:
082:            /**
083:             * Sets the width hint of the status label.
084:             */
085:            public void setStatusWidthHint(int widthHint) {
086:                fWidthHint = widthHint;
087:                fWidthHintString = null;
088:            }
089:
090:            // ------- layout helpers	
091:
092:            /*
093:             * @see DialogField#doFillIntoGrid
094:             */
095:            public Control[] doFillIntoGrid(Composite parent, int nColumns) {
096:                assertEnoughColumns(nColumns);
097:
098:                Label label = getLabelControl(parent);
099:                label.setLayoutData(gridDataForLabel(1));
100:                Text text = getTextControl(parent);
101:                text.setLayoutData(gridDataForText(nColumns - 3));
102:                Label status = getStatusLabelControl(parent);
103:                status.setLayoutData(gridDataForStatusLabel(parent, 1));
104:                Button button = getChangeControl(parent);
105:                button.setLayoutData(gridDataForButton(button, 1));
106:
107:                return new Control[] { label, text, status, button };
108:            }
109:
110:            /*
111:             * @see DialogField#getNumberOfControls
112:             */
113:            public int getNumberOfControls() {
114:                return 4;
115:            }
116:
117:            protected GridData gridDataForStatusLabel(Control aControl, int span) {
118:                GridData gd = new GridData();
119:                gd.horizontalAlignment = GridData.BEGINNING;
120:                gd.grabExcessHorizontalSpace = false;
121:                gd.horizontalIndent = 0;
122:                if (fWidthHintString != null) {
123:                    GC gc = new GC(aControl);
124:                    gc.setFont(JFaceResources.getDialogFont());
125:                    gd.widthHint = gc.textExtent(fWidthHintString).x;
126:                    gc.dispose();
127:                } else if (fWidthHint != -1) {
128:                    gd.widthHint = fWidthHint;
129:                } else {
130:                    gd.widthHint = SWT.DEFAULT;
131:                }
132:                return gd;
133:            }
134:
135:            // ------- ui creation	
136:
137:            /**
138:             * Creates or returns the created status label widget.
139:             * @param parent The parent composite or <code>null</code> when the widget has
140:             * already been created.
141:             */
142:            public Label getStatusLabelControl(Composite parent) {
143:                if (fStatusLabelControl == null) {
144:                    assertCompositeNotNull(parent);
145:                    fStatusLabelControl = new Label(parent, SWT.LEFT);
146:                    fStatusLabelControl.setFont(parent.getFont());
147:                    fStatusLabelControl.setEnabled(isEnabled());
148:                    if (fStatus instanceof  Image) {
149:                        fStatusLabelControl.setImage((Image) fStatus);
150:                    } else if (fStatus instanceof  String) {
151:                        fStatusLabelControl.setText((String) fStatus);
152:                    } else {
153:                        // must be null
154:                    }
155:                }
156:                return fStatusLabelControl;
157:            }
158:
159:            // ------ enable / disable management
160:
161:            /*
162:             * @see DialogField#updateEnableState
163:             */
164:            protected void updateEnableState() {
165:                super .updateEnableState();
166:                if (isOkToUse(fStatusLabelControl)) {
167:                    fStatusLabelControl.setEnabled(isEnabled());
168:                }
169:            }
170:
171:            /* (non-Javadoc)
172:             * @see org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField#refresh()
173:             */
174:            public void refresh() {
175:                super .refresh();
176:                if (fStatus instanceof  String) {
177:                    setStatus((String) fStatus);
178:                } else {
179:                    setStatus((Image) fStatus);
180:                }
181:            }
182:        }
w__w__w___.__ja___v___a___2s_.__c_o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.