Source Code Cross Referenced for MarkOccurrencesConfigurationBlock.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » internal » ui » preferences » 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.preferences 
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:         *     Sebastian Davids, sdavids@gmx.de - 187316 [preferences] Mark Occurences Pref Page; Link to
011:         *******************************************************************************/package org.eclipse.jdt.internal.ui.preferences;
012:
013:        import java.util.ArrayList;
014:        import java.util.HashMap;
015:        import java.util.Iterator;
016:        import java.util.Map;
017:
018:        import org.eclipse.core.runtime.Assert;
019:        import org.eclipse.core.runtime.IStatus;
020:
021:        import org.eclipse.swt.SWT;
022:        import org.eclipse.swt.events.SelectionAdapter;
023:        import org.eclipse.swt.events.SelectionEvent;
024:        import org.eclipse.swt.events.SelectionListener;
025:        import org.eclipse.swt.layout.GridData;
026:        import org.eclipse.swt.layout.GridLayout;
027:        import org.eclipse.swt.widgets.Button;
028:        import org.eclipse.swt.widgets.Composite;
029:        import org.eclipse.swt.widgets.Control;
030:        import org.eclipse.swt.widgets.Label;
031:        import org.eclipse.swt.widgets.Link;
032:
033:        import org.eclipse.ui.dialogs.PreferencesUtil;
034:
035:        import org.eclipse.jdt.ui.PreferenceConstants;
036:
037:        import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
038:        import org.eclipse.jdt.internal.ui.util.PixelConverter;
039:
040:        /**
041:         * Configures Java Editor hover preferences.
042:         * 
043:         * @since 2.1
044:         */
045:        class MarkOccurrencesConfigurationBlock implements 
046:                IPreferenceConfigurationBlock {
047:
048:            private OverlayPreferenceStore fStore;
049:
050:            private Map fCheckBoxes = new HashMap();
051:            private SelectionListener fCheckBoxListener = new SelectionListener() {
052:                public void widgetDefaultSelected(SelectionEvent e) {
053:                }
054:
055:                public void widgetSelected(SelectionEvent e) {
056:                    Button button = (Button) e.widget;
057:                    fStore.setValue((String) fCheckBoxes.get(button), button
058:                            .getSelection());
059:                }
060:            };
061:
062:            /**
063:             * List of master/slave listeners when there's a dependency.
064:             * 
065:             * @see #createDependency(Button, String, Control)
066:             * @since 3.0
067:             */
068:            private ArrayList fMasterSlaveListeners = new ArrayList();
069:
070:            private StatusInfo fStatus;
071:
072:            public MarkOccurrencesConfigurationBlock(
073:                    OverlayPreferenceStore store) {
074:                Assert.isNotNull(store);
075:                fStore = store;
076:
077:                fStore.addKeys(createOverlayStoreKeys());
078:            }
079:
080:            private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
081:
082:                ArrayList overlayKeys = new ArrayList();
083:
084:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
085:                        OverlayPreferenceStore.BOOLEAN,
086:                        PreferenceConstants.EDITOR_MARK_OCCURRENCES));
087:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
088:                        OverlayPreferenceStore.BOOLEAN,
089:                        PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES));
090:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
091:                        OverlayPreferenceStore.BOOLEAN,
092:                        PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES));
093:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
094:                        OverlayPreferenceStore.BOOLEAN,
095:                        PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES));
096:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
097:                        OverlayPreferenceStore.BOOLEAN,
098:                        PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES));
099:                overlayKeys
100:                        .add(new OverlayPreferenceStore.OverlayKey(
101:                                OverlayPreferenceStore.BOOLEAN,
102:                                PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES));
103:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
104:                        OverlayPreferenceStore.BOOLEAN,
105:                        PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES));
106:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
107:                        OverlayPreferenceStore.BOOLEAN,
108:                        PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS));
109:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
110:                        OverlayPreferenceStore.BOOLEAN,
111:                        PreferenceConstants.EDITOR_MARK_IMPLEMENTORS));
112:                overlayKeys
113:                        .add(new OverlayPreferenceStore.OverlayKey(
114:                                OverlayPreferenceStore.BOOLEAN,
115:                                PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS));
116:                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
117:                        OverlayPreferenceStore.BOOLEAN,
118:                        PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
119:
120:                OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
121:                        .size()];
122:                overlayKeys.toArray(keys);
123:                return keys;
124:            }
125:
126:            /**
127:             * Creates page for mark occurrences preferences.
128:             * 
129:             * @param parent the parent composite
130:             * @return the control for the preference page
131:             */
132:            public Control createControl(final Composite parent) {
133:
134:                Composite composite = new Composite(parent, SWT.NONE);
135:                GridLayout layout = new GridLayout();
136:                layout.numColumns = 1;
137:                layout.marginHeight = 0;
138:                layout.marginWidth = 0;
139:                composite.setLayout(layout);
140:
141:                Link link = new Link(composite, SWT.NONE);
142:                link
143:                        .setText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link);
144:                link.addSelectionListener(new SelectionAdapter() {
145:                    public void widgetSelected(SelectionEvent e) {
146:                        PreferencesUtil.createPreferenceDialogOn(parent
147:                                .getShell(), e.text, null, null);
148:                    }
149:                });
150:                // TODO replace by link-specific tooltips when
151:                // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
152:                link
153:                        .setToolTipText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link_tooltip);
154:
155:                addFiller(composite);
156:
157:                String label;
158:
159:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markOccurrences;
160:                Button master = addCheckBox(composite, label,
161:                        PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0);
162:
163:                addFiller(composite);
164:
165:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markTypeOccurrences;
166:                Button slave = addCheckBox(composite, label,
167:                        PreferenceConstants.EDITOR_MARK_TYPE_OCCURRENCES, 0);
168:                createDependency(master,
169:                        PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
170:
171:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markMethodOccurrences;
172:                slave = addCheckBox(composite, label,
173:                        PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES, 0);
174:                createDependency(master,
175:                        PreferenceConstants.EDITOR_MARK_METHOD_OCCURRENCES,
176:                        slave);
177:
178:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markConstantOccurrences;
179:                slave = addCheckBox(composite, label,
180:                        PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES, 0);
181:                createDependency(master,
182:                        PreferenceConstants.EDITOR_MARK_CONSTANT_OCCURRENCES,
183:                        slave);
184:
185:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markFieldOccurrences;
186:                slave = addCheckBox(composite, label,
187:                        PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES, 0);
188:                createDependency(master,
189:                        PreferenceConstants.EDITOR_MARK_FIELD_OCCURRENCES,
190:                        slave);
191:
192:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markLocalVariableOccurrences;
193:                slave = addCheckBox(
194:                        composite,
195:                        label,
196:                        PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES,
197:                        0);
198:                createDependency(
199:                        master,
200:                        PreferenceConstants.EDITOR_MARK_LOCAL_VARIABLE_OCCURRENCES,
201:                        slave);
202:
203:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markExceptionOccurrences;
204:                slave = addCheckBox(composite, label,
205:                        PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES,
206:                        0);
207:                createDependency(master,
208:                        PreferenceConstants.EDITOR_MARK_EXCEPTION_OCCURRENCES,
209:                        slave);
210:
211:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markMethodExitPoints;
212:                slave = addCheckBox(composite, label,
213:                        PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS, 0);
214:                createDependency(master,
215:                        PreferenceConstants.EDITOR_MARK_METHOD_EXIT_POINTS,
216:                        slave);
217:
218:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markImplementors;
219:                slave = addCheckBox(composite, label,
220:                        PreferenceConstants.EDITOR_MARK_IMPLEMENTORS, 0);
221:                createDependency(master,
222:                        PreferenceConstants.EDITOR_MARK_IMPLEMENTORS, slave);
223:
224:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_markBreakContinueTargets;
225:                slave = addCheckBox(composite, label,
226:                        PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS,
227:                        0);
228:                createDependency(master,
229:                        PreferenceConstants.EDITOR_MARK_BREAK_CONTINUE_TARGETS,
230:                        slave);
231:
232:                addFiller(composite);
233:
234:                label = PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences;
235:                slave = addCheckBox(composite, label,
236:                        PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0);
237:                createDependency(master,
238:                        PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
239:
240:                return composite;
241:            }
242:
243:            private void addFiller(Composite composite) {
244:                PixelConverter pixelConverter = new PixelConverter(composite);
245:
246:                Label filler = new Label(composite, SWT.LEFT);
247:                GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
248:                gd.horizontalSpan = 2;
249:                gd.heightHint = pixelConverter.convertHeightInCharsToPixels(1) / 2;
250:                filler.setLayoutData(gd);
251:            }
252:
253:            private Button addCheckBox(Composite parent, String label,
254:                    String key, int indentation) {
255:                Button checkBox = new Button(parent, SWT.CHECK);
256:                checkBox.setText(label);
257:
258:                GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
259:                gd.horizontalIndent = indentation;
260:                gd.horizontalSpan = 2;
261:                checkBox.setLayoutData(gd);
262:                checkBox.addSelectionListener(fCheckBoxListener);
263:
264:                fCheckBoxes.put(checkBox, key);
265:
266:                return checkBox;
267:            }
268:
269:            private void createDependency(final Button master,
270:                    String masterKey, final Control slave) {
271:                indent(slave);
272:                boolean masterState = fStore.getBoolean(masterKey);
273:                slave.setEnabled(masterState);
274:                SelectionListener listener = new SelectionListener() {
275:                    public void widgetSelected(SelectionEvent e) {
276:                        slave.setEnabled(master.getSelection());
277:                    }
278:
279:                    public void widgetDefaultSelected(SelectionEvent e) {
280:                    }
281:                };
282:                master.addSelectionListener(listener);
283:                fMasterSlaveListeners.add(listener);
284:            }
285:
286:            private static void indent(Control control) {
287:                GridData gridData = new GridData();
288:                gridData.horizontalIndent = 10;
289:                control.setLayoutData(gridData);
290:            }
291:
292:            public void initialize() {
293:                initializeFields();
294:            }
295:
296:            void initializeFields() {
297:
298:                Iterator iter = fCheckBoxes.keySet().iterator();
299:                while (iter.hasNext()) {
300:                    Button b = (Button) iter.next();
301:                    String key = (String) fCheckBoxes.get(b);
302:                    b.setSelection(fStore.getBoolean(key));
303:                }
304:
305:                // Update slaves
306:                iter = fMasterSlaveListeners.iterator();
307:                while (iter.hasNext()) {
308:                    SelectionListener listener = (SelectionListener) iter
309:                            .next();
310:                    listener.widgetSelected(null);
311:                }
312:
313:            }
314:
315:            public void performOk() {
316:            }
317:
318:            public void performDefaults() {
319:                restoreFromPreferences();
320:                initializeFields();
321:            }
322:
323:            private void restoreFromPreferences() {
324:
325:            }
326:
327:            IStatus getStatus() {
328:                if (fStatus == null)
329:                    fStatus = new StatusInfo();
330:                return fStatus;
331:            }
332:
333:            /*
334:             * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
335:             * @since 3.0
336:             */
337:            public void dispose() {
338:            }
339:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.