Source Code Cross Referenced for WizardCheckboxTablePart.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » parts » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.parts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2007 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.pde.internal.ui.parts;
011:
012:        import org.eclipse.jface.viewers.CheckboxTableViewer;
013:        import org.eclipse.jface.viewers.StructuredViewer;
014:        import org.eclipse.osgi.util.NLS;
015:        import org.eclipse.pde.internal.ui.PDEUIMessages;
016:        import org.eclipse.pde.internal.ui.util.SWTUtil;
017:        import org.eclipse.pde.internal.ui.wizards.ListUtil;
018:        import org.eclipse.swt.SWT;
019:        import org.eclipse.swt.layout.GridData;
020:        import org.eclipse.swt.widgets.Button;
021:        import org.eclipse.swt.widgets.Composite;
022:        import org.eclipse.swt.widgets.Label;
023:        import org.eclipse.ui.forms.widgets.FormToolkit;
024:
025:        public class WizardCheckboxTablePart extends CheckboxTablePart {
026:            private int selectAllIndex = -1;
027:            private int deselectAllIndex = -1;
028:            private String tableName;
029:            private int counter;
030:            private Label counterLabel;
031:
032:            /**
033:             * Constructor for WizardCheckboxTablePart.
034:             * @param buttonLabels
035:             */
036:            public WizardCheckboxTablePart(String tableName,
037:                    String[] buttonLabels) {
038:                super (buttonLabels);
039:                this .tableName = tableName;
040:            }
041:
042:            public WizardCheckboxTablePart(String mainLabel) {
043:                this (mainLabel, new String[] {
044:                        PDEUIMessages.WizardCheckboxTablePart_selectAll,
045:                        PDEUIMessages.WizardCheckboxTablePart_deselectAll });
046:                setSelectAllIndex(0);
047:                setDeselectAllIndex(1);
048:            }
049:
050:            public void setSelectAllIndex(int index) {
051:                this .selectAllIndex = index;
052:            }
053:
054:            public void setDeselectAllIndex(int index) {
055:                this .deselectAllIndex = index;
056:            }
057:
058:            protected void buttonSelected(Button button, int index) {
059:                if (index == selectAllIndex) {
060:                    handleSelectAll(true);
061:                }
062:                if (index == deselectAllIndex) {
063:                    handleSelectAll(false);
064:                }
065:            }
066:
067:            public Object[] getSelection() {
068:                CheckboxTableViewer viewer = getTableViewer();
069:                return viewer.getCheckedElements();
070:            }
071:
072:            public void setSelection(Object[] selected) {
073:                CheckboxTableViewer viewer = getTableViewer();
074:                viewer.setCheckedElements(selected);
075:                updateCounter(viewer.getCheckedElements().length);
076:            }
077:
078:            public void createControl(Composite parent) {
079:                createControl(parent, 2);
080:            }
081:
082:            public void createControl(Composite parent, int span) {
083:                createControl(parent, SWT.NULL, span, null);
084:                counterLabel = new Label(parent, SWT.NULL);
085:                GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING
086:                        | GridData.HORIZONTAL_ALIGN_FILL);
087:                gd.horizontalSpan = span;
088:                counterLabel.setLayoutData(gd);
089:                updateCounter(0);
090:            }
091:
092:            protected Button createButton(Composite parent, String label,
093:                    int index, FormToolkit toolkit) {
094:                Button button = super .createButton(parent, label, index,
095:                        toolkit);
096:                SWTUtil.setButtonDimensionHint(button);
097:                return button;
098:            }
099:
100:            protected StructuredViewer createStructuredViewer(Composite parent,
101:                    int style, FormToolkit toolkit) {
102:                StructuredViewer viewer = super .createStructuredViewer(parent,
103:                        style, toolkit);
104:                viewer.setComparator(ListUtil.NAME_COMPARATOR);
105:                return viewer;
106:            }
107:
108:            protected void createMainLabel(Composite parent, int span,
109:                    FormToolkit toolkit) {
110:                if (tableName == null)
111:                    return;
112:                Label label = new Label(parent, SWT.NULL);
113:                label.setText(tableName);
114:                GridData gd = new GridData();
115:                gd.horizontalSpan = span;
116:                label.setLayoutData(gd);
117:            }
118:
119:            protected void updateCounter(int amount) {
120:                counter = amount;
121:                updateCounterLabel();
122:            }
123:
124:            protected void updateCounterLabel() {
125:                String number = "" + getSelectionCount(); //$NON-NLS-1$
126:                String totalNumber = "" + getTotalCount(); //$NON-NLS-1$
127:                String message = NLS.bind(
128:                        PDEUIMessages.WizardCheckboxTablePart_counter,
129:                        (new String[] { number, totalNumber }));
130:                counterLabel.setText(message);
131:            }
132:
133:            public int getSelectionCount() {
134:                return counter;
135:            }
136:
137:            public void selectAll(boolean select) {
138:                handleSelectAll(select);
139:            }
140:
141:            private int getTotalCount() {
142:                CheckboxTableViewer viewer = getTableViewer();
143:                return viewer.getTable().getItemCount();
144:            }
145:
146:            protected void handleSelectAll(boolean select) {
147:                CheckboxTableViewer viewer = getTableViewer();
148:                viewer.setAllChecked(select);
149:                int selected;
150:                if (!select) {
151:                    selected = 0;
152:                } else {
153:                    selected = getTotalCount();
154:                }
155:                updateCounter(selected);
156:            }
157:
158:            protected void elementChecked(Object element, boolean checked) {
159:                int count = getSelectionCount();
160:                updateCounter(checked ? count + 1 : count - 1);
161:            }
162:
163:            public Label getCounterLabel() {
164:                return counterLabel;
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.