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


001:        /*******************************************************************************
002:         * Copyright (c) 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.ui.internal.dialogs;
011:
012:        import java.util.Iterator;
013:        import java.util.List;
014:        import java.util.Set;
015:
016:        import org.eclipse.jface.dialogs.Dialog;
017:        import org.eclipse.jface.dialogs.IDialogConstants;
018:        import org.eclipse.jface.viewers.ArrayContentProvider;
019:        import org.eclipse.jface.viewers.CheckboxTableViewer;
020:        import org.eclipse.jface.viewers.ISelection;
021:        import org.eclipse.jface.viewers.ISelectionChangedListener;
022:        import org.eclipse.jface.viewers.IStructuredSelection;
023:        import org.eclipse.jface.viewers.SelectionChangedEvent;
024:        import org.eclipse.jface.viewers.Viewer;
025:        import org.eclipse.jface.viewers.ViewerFilter;
026:        import org.eclipse.swt.SWT;
027:        import org.eclipse.swt.layout.GridData;
028:        import org.eclipse.swt.layout.GridLayout;
029:        import org.eclipse.swt.widgets.Composite;
030:        import org.eclipse.swt.widgets.Control;
031:        import org.eclipse.swt.widgets.Shell;
032:        import org.eclipse.ui.IWorkingSet;
033:        import org.eclipse.ui.PlatformUI;
034:        import org.eclipse.ui.internal.WorkbenchMessages;
035:
036:        /**
037:         * Base implementation for a simple working set dialog that doesn't contain
038:         * references to non-editable/non-visible working sets.
039:         * 
040:         * @since 3.4
041:         * 
042:         */
043:        public class SimpleWorkingSetSelectionDialog extends
044:                AbstractWorkingSetDialog {
045:
046:            private class Filter extends ViewerFilter {
047:
048:                public boolean select(Viewer viewer, Object parentElement,
049:                        Object element) {
050:                    return isCompatible((IWorkingSet) element);
051:                }
052:
053:                private boolean isCompatible(IWorkingSet set) {
054:                    if (set.isAggregateWorkingSet())
055:                        return false;
056:
057:                    // original JDT code had the catch for self-updating sets that no
058:                    // one can explain. There doesn't seem to
059:                    // be a good reason to exclude these sets so the clause has been
060:                    // removed.
061:
062:                    // if (set.isAggregateWorkingSet() || !set.isSelfUpdating())
063:                    // return false;
064:
065:                    if (!set.isVisible())
066:                        return false;
067:
068:                    if (!set.isEditable())
069:                        return false;
070:
071:                    Set workingSetTypeIds = getSupportedWorkingSetIds();
072:                    if (workingSetTypeIds == null)
073:                        return true;
074:
075:                    for (Iterator i = workingSetTypeIds.iterator(); i.hasNext();) {
076:                        String workingSetTypeId = (String) i.next();
077:                        if (workingSetTypeId.equals(set.getId()))
078:                            return true;
079:                    }
080:
081:                    return false;
082:                }
083:            }
084:
085:            private final static int SIZING_SELECTION_WIDGET_HEIGHT = 200;
086:
087:            private final static int SIZING_SELECTION_WIDGET_WIDTH = 50;
088:
089:            private CheckboxTableViewer viewer;
090:
091:            private IWorkingSet[] initialSelection;
092:
093:            /**
094:             * Create a new instance of this class.
095:             * 
096:             * @param shell
097:             *            the shell to parent this dialog on
098:             * @param workingSetTypeIds
099:             *            the types of working set IDs that will be shown in this dialog
100:             * @param selectedWorkingSets
101:             *            the currently selected working sets (if any)
102:             * @param canEdit
103:             *            whether or not this dialog will display edit controls
104:             */
105:            public SimpleWorkingSetSelectionDialog(Shell shell,
106:                    String[] workingSetTypeIds,
107:                    IWorkingSet[] selectedWorkingSets, boolean canEdit) {
108:                super (shell, workingSetTypeIds, canEdit);
109:                this .initialSelection = selectedWorkingSets;
110:                setTitle(WorkbenchMessages.WorkingSetSelectionDialog_title_multiSelect);
111:                setMessage(WorkbenchMessages.WorkingSetSelectionDialog_message_multiSelect);
112:            }
113:
114:            protected Control createDialogArea(Composite parent) {
115:                initializeDialogUnits(parent);
116:
117:                Composite composite = (Composite) super 
118:                        .createDialogArea(parent);
119:
120:                Composite viewerComposite = new Composite(composite, SWT.NONE);
121:                GridLayout layout = new GridLayout(2, false);
122:                layout.marginHeight = layout.marginWidth = 0;
123:                layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
124:                layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
125:                viewerComposite.setLayout(layout);
126:
127:                GridData data = new GridData(GridData.FILL_BOTH);
128:                data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
129:                data.widthHint = SIZING_SELECTION_WIDGET_WIDTH + 300; // fudge? I like
130:                // fudge.
131:                viewerComposite.setLayoutData(data);
132:
133:                viewer = CheckboxTableViewer.newCheckList(viewerComposite,
134:                        SWT.BORDER);
135:                viewer.getControl().setLayoutData(
136:                        new GridData(GridData.FILL_BOTH));
137:                viewer.setLabelProvider(new WorkingSetLabelProvider());
138:                viewer.setContentProvider(new ArrayContentProvider());
139:                viewer.addFilter(new WorkingSetFilter(null));
140:                viewer.setInput(PlatformUI.getWorkbench()
141:                        .getWorkingSetManager().getWorkingSets());
142:                viewer.setFilters(new ViewerFilter[] { new Filter() });
143:
144:                viewer
145:                        .addSelectionChangedListener(new ISelectionChangedListener() {
146:                            public void selectionChanged(
147:                                    SelectionChangedEvent event) {
148:                                handleSelectionChanged();
149:                            }
150:                        });
151:                viewer.setCheckedElements(initialSelection);
152:
153:                data = new GridData(GridData.FILL_BOTH);
154:                data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
155:                data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
156:
157:                viewer.getControl().setLayoutData(data);
158:                addModifyButtons(viewerComposite);
159:
160:                addSelectionButtons(composite);
161:
162:                availableWorkingSetsChanged();
163:
164:                Dialog.applyDialogFont(composite);
165:
166:                return composite;
167:            }
168:
169:            protected void okPressed() {
170:                Object[] checked = viewer.getCheckedElements();
171:                IWorkingSet[] workingSets = new IWorkingSet[checked.length];
172:                System.arraycopy(checked, 0, workingSets, 0, checked.length);
173:                setSelection(workingSets);
174:                super .okPressed();
175:            }
176:
177:            protected List getSelectedWorkingSets() {
178:                ISelection selection = viewer.getSelection();
179:                if (selection instanceof  IStructuredSelection) {
180:                    return ((IStructuredSelection) selection).toList();
181:                }
182:                return null;
183:            }
184:
185:            protected void availableWorkingSetsChanged() {
186:                viewer.setInput(PlatformUI.getWorkbench()
187:                        .getWorkingSetManager().getWorkingSets());
188:                super .availableWorkingSetsChanged();
189:            }
190:
191:            /**
192:             * Called when the selection has changed.
193:             */
194:            void handleSelectionChanged() {
195:                updateButtonAvailability();
196:            }
197:
198:            protected void selectAllSets() {
199:                viewer.setCheckedElements(PlatformUI.getWorkbench()
200:                        .getWorkingSetManager().getWorkingSets());
201:                updateButtonAvailability();
202:            }
203:
204:            protected void deselectAllSets() {
205:                viewer.setCheckedElements(new Object[0]);
206:                updateButtonAvailability();
207:            }
208:
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.