Source Code Cross Referenced for SaveParticipantConfigurationBlock.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) 2006, 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.jdt.internal.ui.preferences;
011:
012:        import com.ibm.icu.text.Collator;
013:
014:        import java.util.ArrayList;
015:        import java.util.Arrays;
016:        import java.util.Comparator;
017:
018:        import org.eclipse.core.runtime.Assert;
019:        import org.eclipse.core.runtime.IAdaptable;
020:        import org.eclipse.core.runtime.preferences.IScopeContext;
021:
022:        import org.eclipse.swt.SWT;
023:        import org.eclipse.swt.layout.GridData;
024:        import org.eclipse.swt.layout.GridLayout;
025:        import org.eclipse.swt.widgets.Composite;
026:        import org.eclipse.swt.widgets.Control;
027:
028:        import org.eclipse.jface.preference.IPreferencePageContainer;
029:        import org.eclipse.jface.preference.PreferencePage;
030:
031:        import org.eclipse.jdt.internal.ui.JavaPlugin;
032:        import org.eclipse.jdt.internal.ui.javaeditor.saveparticipant.ISaveParticipantPreferenceConfiguration;
033:        import org.eclipse.jdt.internal.ui.javaeditor.saveparticipant.SaveParticipantDescriptor;
034:        import org.eclipse.jdt.internal.ui.javaeditor.saveparticipant.SaveParticipantRegistry;
035:
036:        /**
037:         * Configures Java Editor save participants.
038:         * 
039:         * @since 3.3
040:         */
041:        class SaveParticipantConfigurationBlock implements 
042:                IPreferenceAndPropertyConfigurationBlock {
043:
044:            private interface IDelegateOperation {
045:                public void run(ISaveParticipantPreferenceConfiguration block);
046:            }
047:
048:            private final PreferencePage fPreferencePage;
049:            private final IScopeContext fContext;
050:            private final ArrayList fConfigurations;
051:
052:            public SaveParticipantConfigurationBlock(IScopeContext context,
053:                    PreferencePage preferencePage) {
054:                Assert.isNotNull(context);
055:                Assert.isNotNull(preferencePage);
056:
057:                fContext = context;
058:                fPreferencePage = preferencePage;
059:                fConfigurations = new ArrayList();
060:            }
061:
062:            /*
063:             * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#createControl(org.eclipse.swt.widgets.Composite)
064:             * @since 3.3
065:             */
066:            public Control createControl(Composite parent) {
067:                Composite composite = new Composite(parent, SWT.NONE);
068:                composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true,
069:                        false));
070:                GridLayout gridLayout = new GridLayout(2, false);
071:                gridLayout.marginHeight = 0;
072:                gridLayout.marginWidth = 0;
073:                composite.setLayout(gridLayout);
074:
075:                SaveParticipantRegistry registry = JavaPlugin.getDefault()
076:                        .getSaveParticipantRegistry();
077:                SaveParticipantDescriptor[] descriptors = registry
078:                        .getSaveParticipantDescriptors();
079:
080:                if (descriptors.length == 0)
081:                    return composite;
082:
083:                Arrays.sort(descriptors, new Comparator() {
084:                    public int compare(Object o1, Object o2) {
085:                        SaveParticipantDescriptor d1 = (SaveParticipantDescriptor) o1;
086:                        SaveParticipantDescriptor d2 = (SaveParticipantDescriptor) o2;
087:                        return Collator.getInstance().compare(
088:                                d1.getPostSaveListener().getName(),
089:                                d2.getPostSaveListener().getName());
090:                    }
091:                });
092:
093:                IPreferencePageContainer container = fPreferencePage
094:                        .getContainer();
095:                for (int i = 0; i < descriptors.length; i++) {
096:                    final SaveParticipantDescriptor descriptor = descriptors[i];
097:                    ISaveParticipantPreferenceConfiguration configuration = descriptor
098:                            .createPreferenceConfiguration();
099:                    configuration.createControl(composite, container);
100:                    fConfigurations.add(configuration);
101:                }
102:
103:                return composite;
104:            }
105:
106:            /*
107:             * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
108:             */
109:            public void dispose() {
110:                delegateToPreferenceConfiguration(new IDelegateOperation() {
111:                    public void run(
112:                            ISaveParticipantPreferenceConfiguration block) {
113:                        block.dispose();
114:                    }
115:                });
116:            }
117:
118:            /*
119:             * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#initialize()
120:             */
121:            public void initialize() {
122:                delegateToPreferenceConfiguration(new IDelegateOperation() {
123:                    public void run(
124:                            ISaveParticipantPreferenceConfiguration block) {
125:                        IAdaptable element = null;
126:                        if (fPreferencePage instanceof  PropertyAndPreferencePage) {
127:                            element = ((PropertyAndPreferencePage) fPreferencePage)
128:                                    .getElement();
129:                        }
130:                        block.initialize(fContext, element);
131:                    }
132:                });
133:            }
134:
135:            /*
136:             * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#performDefaults()
137:             */
138:            public void performDefaults() {
139:                delegateToPreferenceConfiguration(new IDelegateOperation() {
140:                    public void run(
141:                            ISaveParticipantPreferenceConfiguration block) {
142:                        block.performDefaults();
143:                    }
144:                });
145:            }
146:
147:            /*
148:             * @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk()
149:             */
150:            public void performOk() {
151:                delegateToPreferenceConfiguration(new IDelegateOperation() {
152:                    public void run(
153:                            ISaveParticipantPreferenceConfiguration block) {
154:                        block.performOk();
155:                    }
156:                });
157:            }
158:
159:            /**
160:             * {@inheritDoc}
161:             */
162:            public void enableProjectSettings() {
163:                delegateToPreferenceConfiguration(new IDelegateOperation() {
164:                    public void run(
165:                            ISaveParticipantPreferenceConfiguration block) {
166:                        block.enableProjectSettings();
167:                    }
168:                });
169:            }
170:
171:            /**
172:             * {@inheritDoc}
173:             */
174:            public void disableProjectSettings() {
175:                delegateToPreferenceConfiguration(new IDelegateOperation() {
176:                    public void run(
177:                            ISaveParticipantPreferenceConfiguration block) {
178:                        block.disableProjectSettings();
179:                    }
180:                });
181:            }
182:
183:            private void delegateToPreferenceConfiguration(IDelegateOperation op) {
184:                for (int i = 0; i < fConfigurations.size(); i++) {
185:                    ISaveParticipantPreferenceConfiguration block = (ISaveParticipantPreferenceConfiguration) fConfigurations
186:                            .get(i);
187:                    op.run(block);
188:                }
189:            }
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.