Source Code Cross Referenced for MarkerResolutionSelectionDialog.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, 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:         *   Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog font should be activated and used by other components.
011:         *******************************************************************************/package org.eclipse.ui.dialogs;
012:
013:        import org.eclipse.jface.viewers.DoubleClickEvent;
014:        import org.eclipse.jface.viewers.IDoubleClickListener;
015:        import org.eclipse.jface.viewers.ISelectionChangedListener;
016:        import org.eclipse.jface.viewers.IStructuredSelection;
017:        import org.eclipse.jface.viewers.LabelProvider;
018:        import org.eclipse.jface.viewers.ListViewer;
019:        import org.eclipse.jface.viewers.SelectionChangedEvent;
020:        import org.eclipse.jface.viewers.StructuredSelection;
021:        import org.eclipse.swt.SWT;
022:        import org.eclipse.swt.layout.GridData;
023:        import org.eclipse.swt.widgets.Composite;
024:        import org.eclipse.swt.widgets.Control;
025:        import org.eclipse.swt.widgets.Shell;
026:        import org.eclipse.ui.IMarkerResolution;
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.dialogs.SimpleListContentProvider;
031:
032:        /**
033:         * Dialog to allow the user to select from a list of marker
034:         * resolutions.
035:         * <p>
036:         * This dialog may be instantiated, it is not intented to 
037:         * be subclassed.
038:         * </p>
039:         * 
040:         * @since 2.0
041:         */
042:        public class MarkerResolutionSelectionDialog extends SelectionDialog {
043:            /**
044:             * List width in characters.
045:             */
046:            private final static int LIST_WIDTH = 60;
047:
048:            /**
049:             * List height in characters.
050:             */
051:            private final static int LIST_HEIGHT = 10;
052:
053:            /**
054:             * The marker resolutions.
055:             */
056:            private IMarkerResolution[] resolutions;
057:
058:            /**
059:             * List to display the resolutions.
060:             */
061:            private ListViewer listViewer;
062:
063:            /**
064:             * Creates an instance of this dialog to display
065:             * the given resolutions.
066:             * <p>
067:             * There must be at least one resolution.
068:             * </p>
069:             * 
070:             * @param shell the parent shell
071:             * @param markerResolutions the resolutions to display
072:             */
073:            public MarkerResolutionSelectionDialog(Shell shell,
074:                    IMarkerResolution[] markerResolutions) {
075:                super (shell);
076:                if (markerResolutions == null || markerResolutions.length == 0) {
077:                    throw new IllegalArgumentException();
078:                }
079:                resolutions = markerResolutions;
080:                setTitle(IDEWorkbenchMessages.MarkerResolutionSelectionDialog_title);
081:                setMessage(IDEWorkbenchMessages.MarkerResolutionSelectionDialog_messageLabel);
082:                setInitialSelections(new Object[] { markerResolutions[0] });
083:            }
084:
085:            /* (non-Javadoc)
086:             * Method declared on Window.
087:             */
088:            protected void configureShell(Shell newShell) {
089:                super .configureShell(newShell);
090:                PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell,
091:                        IIDEHelpContextIds.MARKER_RESOLUTION_SELECTION_DIALOG);
092:            }
093:
094:            /* (non-Javadoc)
095:             * Method declared on Dialog.
096:             */
097:            protected Control createDialogArea(Composite parent) {
098:                Composite composite = (Composite) super 
099:                        .createDialogArea(parent);
100:
101:                // Create label
102:                createMessageArea(composite);
103:                // Create list viewer	
104:                listViewer = new ListViewer(composite, SWT.SINGLE
105:                        | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
106:                GridData data = new GridData(GridData.FILL_BOTH);
107:                data.heightHint = convertHeightInCharsToPixels(LIST_HEIGHT);
108:                data.widthHint = convertWidthInCharsToPixels(LIST_WIDTH);
109:                listViewer.getList().setLayoutData(data);
110:                listViewer.getList().setFont(parent.getFont());
111:                // Set the label provider		
112:                listViewer.setLabelProvider(new LabelProvider() {
113:                    public String getText(Object element) {
114:                        // Return the resolution's label.
115:                        return element == null ? "" : ((IMarkerResolution) element).getLabel(); //$NON-NLS-1$
116:                    }
117:                });
118:
119:                // Set the content provider
120:                SimpleListContentProvider cp = new SimpleListContentProvider();
121:                cp.setElements(resolutions);
122:                listViewer.setContentProvider(cp);
123:                listViewer.setInput(new Object()); // it is ignored but must be non-null
124:
125:                // Set the initial selection
126:                listViewer.setSelection(new StructuredSelection(
127:                        getInitialElementSelections()), true);
128:
129:                // Add a selection change listener
130:                listViewer
131:                        .addSelectionChangedListener(new ISelectionChangedListener() {
132:                            public void selectionChanged(
133:                                    SelectionChangedEvent event) {
134:                                // Update OK button enablement
135:                                getOkButton().setEnabled(
136:                                        !event.getSelection().isEmpty());
137:                            }
138:                        });
139:
140:                // Add double-click listener
141:                listViewer.addDoubleClickListener(new IDoubleClickListener() {
142:                    public void doubleClick(DoubleClickEvent event) {
143:                        okPressed();
144:                    }
145:                });
146:                return composite;
147:            }
148:
149:            /* (non-Javadoc)
150:             * Method declared on Dialog.
151:             */
152:            protected void okPressed() {
153:                IStructuredSelection selection = (IStructuredSelection) listViewer
154:                        .getSelection();
155:                setResult(selection.toList());
156:                super.okPressed();
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.