Source Code Cross Referenced for SynchronizePropertiesWizardPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » site » 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.editor.site 
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:         *     Bartosz Michalik <bartosz.michalik@gmail.com> - bug 181878
011:         *******************************************************************************/package org.eclipse.pde.internal.ui.editor.site;
012:
013:        import java.lang.reflect.InvocationTargetException;
014:
015:        import org.eclipse.core.runtime.CoreException;
016:        import org.eclipse.core.runtime.IProgressMonitor;
017:        import org.eclipse.jface.dialogs.Dialog;
018:        import org.eclipse.jface.dialogs.IDialogSettings;
019:        import org.eclipse.jface.operation.IRunnableWithProgress;
020:        import org.eclipse.jface.wizard.WizardPage;
021:        import org.eclipse.pde.internal.core.PDECore;
022:        import org.eclipse.pde.internal.core.ifeature.IFeature;
023:        import org.eclipse.pde.internal.core.ifeature.IFeatureImport;
024:        import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
025:        import org.eclipse.pde.internal.core.isite.ISiteFeature;
026:        import org.eclipse.pde.internal.core.isite.ISiteModel;
027:        import org.eclipse.pde.internal.ui.IHelpContextIds;
028:        import org.eclipse.pde.internal.ui.PDEPlugin;
029:        import org.eclipse.pde.internal.ui.PDEUIMessages;
030:        import org.eclipse.swt.SWT;
031:        import org.eclipse.swt.layout.GridData;
032:        import org.eclipse.swt.layout.GridLayout;
033:        import org.eclipse.swt.widgets.Button;
034:        import org.eclipse.swt.widgets.Composite;
035:        import org.eclipse.swt.widgets.Group;
036:        import org.eclipse.ui.PlatformUI;
037:        import org.eclipse.ui.actions.WorkspaceModifyOperation;
038:
039:        public class SynchronizePropertiesWizardPage extends WizardPage {
040:
041:            public static final int ALL_FEATURES = 2;
042:
043:            public static final int SELECTED_FEATURES = 1;
044:
045:            private static final String PREFIX = PDEPlugin.getPluginId()
046:                    + ".synchronizeFeatueEnvironment."; //$NON-NLS-1$
047:
048:            private static final String PROP_SYNCHRO_MODE = PREFIX + "mode"; //$NON-NLS-1$
049:
050:            private Button fAllFeaturesButton;
051:
052:            private ISiteModel fModel;
053:
054:            private Button fSelectedFeaturesButton;
055:
056:            private ISiteFeature[] fSiteFeatures;
057:
058:            /**
059:             * 
060:             * @param siteFeatures
061:             *            selected feature or null
062:             */
063:            public SynchronizePropertiesWizardPage(ISiteFeature[] siteFeatures,
064:                    ISiteModel model) {
065:                super ("featureSelection"); //$NON-NLS-1$
066:                setTitle(PDEUIMessages.SynchronizePropertiesWizardPage_title);
067:                setDescription(PDEUIMessages.SynchronizePropertiesWizardPage_desc);
068:                fSiteFeatures = siteFeatures != null ? siteFeatures
069:                        : new ISiteFeature[0];
070:                fModel = model;
071:            }
072:
073:            public void createControl(Composite parent) {
074:                Composite container = new Composite(parent, SWT.NULL);
075:                GridLayout layout = new GridLayout();
076:                container.setLayout(layout);
077:
078:                Group group = new Group(container, SWT.SHADOW_ETCHED_IN);
079:                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
080:                layout = new GridLayout();
081:                group.setLayout(layout);
082:                group.setLayoutData(gd);
083:                group
084:                        .setText(PDEUIMessages.SynchronizePropertiesWizardPage_group);
085:
086:                fSelectedFeaturesButton = new Button(group, SWT.RADIO);
087:                fSelectedFeaturesButton
088:                        .setText(PDEUIMessages.SynchronizePropertiesWizardPage_selectedFeatures);
089:                gd = new GridData(GridData.FILL_HORIZONTAL);
090:                fSelectedFeaturesButton.setLayoutData(gd);
091:
092:                fAllFeaturesButton = new Button(group, SWT.RADIO);
093:                fAllFeaturesButton
094:                        .setText(PDEUIMessages.SynchronizePropertiesWizardPage_allFeatures);
095:                gd = new GridData(GridData.FILL_HORIZONTAL);
096:                fAllFeaturesButton.setLayoutData(gd);
097:
098:                setControl(container);
099:                Dialog.applyDialogFont(container);
100:                loadSettings();
101:                // TODO add own F1 context
102:                PlatformUI.getWorkbench().getHelpSystem().setHelp(container,
103:                        IHelpContextIds.FEATURE_SYNCHRONIZE_VERSIONS);
104:            }
105:
106:            public boolean finish() {
107:                final int mode = saveSettings();
108:
109:                IRunnableWithProgress operation = new WorkspaceModifyOperation() {
110:                    public void execute(IProgressMonitor monitor) {
111:                        try {
112:                            runOperation(mode, monitor);
113:                        } catch (CoreException e) {
114:                            PDEPlugin.logException(e);
115:                        } catch (InvocationTargetException e) {
116:                            PDEPlugin.logException(e);
117:                        } finally {
118:                            monitor.done();
119:                        }
120:                    }
121:                };
122:                try {
123:                    getContainer().run(true, true, operation);
124:                } catch (InvocationTargetException e) {
125:                    PDEPlugin.logException(e);
126:                    return false;
127:                } catch (InterruptedException e) {
128:                    return false;
129:                }
130:                return true;
131:            }
132:
133:            /**
134:             * 
135:             * @param siteFeature
136:             * @return IFeatureModel or null
137:             */
138:            private IFeature getFeature(ISiteFeature siteFeature) {
139:                IFeatureModel model = PDECore.getDefault()
140:                        .getFeatureModelManager().findFeatureModel(
141:                                siteFeature.getId(), siteFeature.getVersion());
142:                if (model != null)
143:                    return model.getFeature();
144:                return null;
145:            }
146:
147:            private void importEnvironment(final ISiteFeature siteFeature) {
148:                final IFeature feature = getFeature(siteFeature);
149:                if (feature == null) {
150:                    return;
151:                }
152:                boolean patch = false;
153:                IFeatureImport[] imports = feature.getImports();
154:                for (int i = 0; i < imports.length; i++) {
155:                    if (imports[i].isPatch()) {
156:                        patch = true;
157:                        break;
158:                    }
159:                }
160:                final boolean isPatch = patch;
161:                getShell().getDisplay().syncExec(new Runnable() {
162:                    public void run() {
163:                        try {
164:                            siteFeature.setNL(feature.getNL());
165:                            siteFeature.setOS(feature.getOS());
166:                            siteFeature.setWS(feature.getWS());
167:                            siteFeature.setArch(feature.getArch());
168:                            siteFeature.setIsPatch(isPatch);
169:                        } catch (CoreException ce) {
170:                            PDEPlugin.log(ce);
171:                        }
172:                    }
173:                });
174:            }
175:
176:            private void importEnvironment(ISiteFeature[] siteFeatures,
177:                    IProgressMonitor monitor) {
178:                for (int i = 0; i < siteFeatures.length; i++) {
179:                    if (monitor.isCanceled()) {
180:                        return;
181:                    }
182:                    monitor.subTask(siteFeatures[i].getId()
183:                            + "_" + siteFeatures[i].getVersion()); //$NON-NLS-1$
184:                    importEnvironment(siteFeatures[i]);
185:                    monitor.worked(1);
186:                }
187:            }
188:
189:            private void loadSettings() {
190:                if (fSiteFeatures != null) {
191:                    IDialogSettings settings = getDialogSettings();
192:                    if (settings.get(PROP_SYNCHRO_MODE) != null) {
193:                        int mode = settings.getInt(PROP_SYNCHRO_MODE);
194:                        switch (mode) {
195:                        case SELECTED_FEATURES:
196:                            fSelectedFeaturesButton.setSelection(true);
197:                            break;
198:                        case ALL_FEATURES:
199:                            fAllFeaturesButton.setSelection(true);
200:                            break;
201:                        default:
202:                            fSelectedFeaturesButton.setSelection(true);
203:                        }
204:                    } else
205:                        fSelectedFeaturesButton.setSelection(true);
206:                } else {
207:                    fSelectedFeaturesButton.setEnabled(false);
208:                    fAllFeaturesButton.setSelection(true);
209:                }
210:            }
211:
212:            private void runOperation(int mode, IProgressMonitor monitor)
213:                    throws CoreException, InvocationTargetException {
214:                ISiteFeature[] siteFeatures;
215:                if (mode == SELECTED_FEATURES) {
216:                    siteFeatures = fSiteFeatures;
217:                } else {
218:                    siteFeatures = fModel.getSite().getFeatures();
219:                }
220:                int size = siteFeatures.length;
221:                monitor
222:                        .beginTask(
223:                                PDEUIMessages.SynchronizePropertiesWizardPage_synchronizing,
224:                                size);
225:                importEnvironment(siteFeatures, monitor);
226:            }
227:
228:            private int saveSettings() {
229:                IDialogSettings settings = getDialogSettings();
230:
231:                int mode = SELECTED_FEATURES;
232:
233:                if (fAllFeaturesButton.getSelection())
234:                    mode = ALL_FEATURES;
235:                settings.put(PROP_SYNCHRO_MODE, mode);
236:                return mode;
237:            }
238:        }
w___w___w___.__j_a___v__a__2s._co___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.