Source Code Cross Referenced for FragmentContentPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » plugin » 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.wizards.plugin 
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:         *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.plugin;
011:
012:        import org.eclipse.core.runtime.IStatus;
013:        import org.eclipse.jface.dialogs.Dialog;
014:        import org.eclipse.jface.window.Window;
015:        import org.eclipse.pde.core.plugin.IPlugin;
016:        import org.eclipse.pde.core.plugin.IPluginModel;
017:        import org.eclipse.pde.core.plugin.PluginRegistry;
018:        import org.eclipse.pde.internal.core.util.VersionUtil;
019:        import org.eclipse.pde.internal.ui.IHelpContextIds;
020:        import org.eclipse.pde.internal.ui.PDEUIMessages;
021:        import org.eclipse.pde.internal.ui.parts.PluginVersionPart;
022:        import org.eclipse.pde.internal.ui.util.SWTUtil;
023:        import org.eclipse.pde.internal.ui.wizards.IProjectProvider;
024:        import org.eclipse.pde.internal.ui.wizards.PluginSelectionDialog;
025:        import org.eclipse.swt.SWT;
026:        import org.eclipse.swt.custom.BusyIndicator;
027:        import org.eclipse.swt.custom.StackLayout;
028:        import org.eclipse.swt.events.ModifyEvent;
029:        import org.eclipse.swt.events.ModifyListener;
030:        import org.eclipse.swt.events.SelectionAdapter;
031:        import org.eclipse.swt.events.SelectionEvent;
032:        import org.eclipse.swt.layout.GridData;
033:        import org.eclipse.swt.layout.GridLayout;
034:        import org.eclipse.swt.widgets.Button;
035:        import org.eclipse.swt.widgets.Combo;
036:        import org.eclipse.swt.widgets.Composite;
037:        import org.eclipse.swt.widgets.Control;
038:        import org.eclipse.swt.widgets.Group;
039:        import org.eclipse.swt.widgets.Label;
040:        import org.eclipse.swt.widgets.Text;
041:        import org.eclipse.ui.PlatformUI;
042:        import org.osgi.framework.Version;
043:
044:        public class FragmentContentPage extends ContentPage {
045:
046:            private Text fPluginIdText_newV;
047:            private Text fPluginIdText_oldV;
048:            private Text fPluginVersion;
049:            private Combo fMatchCombo;
050:            private boolean fNewVersion;
051:            private Composite fNotebook;
052:            private StackLayout fNotebookLayout;
053:            private Composite fOldComp;
054:            private Composite fNewComp;
055:            private PluginVersionPart fVersionPart;
056:
057:            protected ModifyListener listener = new ModifyListener() {
058:                public void modifyText(ModifyEvent e) {
059:                    validatePage();
060:                }
061:            };
062:
063:            public FragmentContentPage(String pageName,
064:                    IProjectProvider provider, NewProjectCreationPage page,
065:                    AbstractFieldData data) {
066:                super (pageName, provider, page, data);
067:                setTitle(PDEUIMessages.ContentPage_ftitle);
068:                setDescription(PDEUIMessages.ContentPage_fdesc);
069:                updateVersion(false);
070:                fVersionPart = new PluginVersionPart(fNewVersion);
071:            }
072:
073:            /* (non-Javadoc)
074:             * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#createControl(org.eclipse.swt.widgets.Composite)
075:             */
076:            public void createControl(Composite parent) {
077:                Composite container = new Composite(parent, SWT.NONE);
078:                GridLayout layout = new GridLayout();
079:                layout.verticalSpacing = 15;
080:                container.setLayout(layout);
081:
082:                createFragmentPropertiesGroup(container);
083:                createParentPluginGroup(container);
084:
085:                Dialog.applyDialogFont(container);
086:                setControl(container);
087:                PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
088:                        IHelpContextIds.NEW_FRAGMENT_REQUIRED_DATA);
089:            }
090:
091:            public void createFragmentPropertiesGroup(Composite container) {
092:                Group propertiesGroup = new Group(container, SWT.NONE);
093:                propertiesGroup.setLayout(new GridLayout(2, false));
094:                propertiesGroup.setLayoutData(new GridData(
095:                        GridData.FILL_HORIZONTAL));
096:                propertiesGroup.setText(PDEUIMessages.ContentPage_fGroup);
097:
098:                Label label = new Label(propertiesGroup, SWT.NONE);
099:                label.setText(PDEUIMessages.ContentPage_fid);
100:                fIdText = createText(propertiesGroup, propertiesListener);
101:
102:                label = new Label(propertiesGroup, SWT.NONE);
103:                label.setText(PDEUIMessages.ContentPage_fversion);
104:                fVersionText = createText(propertiesGroup, propertiesListener);
105:
106:                label = new Label(propertiesGroup, SWT.NONE);
107:                label.setText(PDEUIMessages.ContentPage_fname);
108:                fNameText = createText(propertiesGroup, propertiesListener);
109:
110:                label = new Label(propertiesGroup, SWT.NONE);
111:                label.setText(PDEUIMessages.ContentPage_fprovider);
112:                fProviderText = createText(propertiesGroup, propertiesListener);
113:
114:                fLibraryLabel = new Label(propertiesGroup, SWT.NONE);
115:                fLibraryLabel
116:                        .setText(PDEUIMessages.ProjectStructurePage_library);
117:                fLibraryText = createText(propertiesGroup, propertiesListener);
118:            }
119:
120:            private void createParentPluginGroup(Composite container) {
121:                Group parentGroup = new Group(container, SWT.NONE);
122:                parentGroup.setLayout(new GridLayout(2, false));
123:                parentGroup
124:                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
125:                parentGroup
126:                        .setText(PDEUIMessages.ContentPage_parentPluginGroup);
127:
128:                fNotebook = new Composite(parentGroup, SWT.NONE);
129:                GridData gd = new GridData(GridData.FILL_BOTH);
130:                gd.horizontalSpan = 2;
131:                fNotebook.setLayoutData(gd);
132:                fNotebookLayout = new StackLayout();
133:                fNotebook.setLayout(fNotebookLayout);
134:
135:                fNewComp = createNewVersionComp(fNotebook);
136:                fOldComp = createOldVersionComp(fNotebook);
137:                fNotebookLayout.topControl = fNewVersion ? fNewComp : fOldComp;
138:
139:            }
140:
141:            private Composite createNewVersionComp(Composite notebook) {
142:                Composite comp = new Composite(notebook, SWT.NONE);
143:                GridLayout layout = new GridLayout(3, false);
144:                layout.marginHeight = layout.marginWidth = 0;
145:                comp.setLayout(layout);
146:
147:                Label label = new Label(comp, SWT.NONE);
148:                label.setText(PDEUIMessages.FragmentContentPage_pid);
149:                fPluginIdText_newV = createPluginIdContainer(comp, true, 2);
150:
151:                fVersionPart.createVersionFields(comp, false, true);
152:                fVersionPart.addListeners(listener, listener);
153:                return comp;
154:            }
155:
156:            private Composite createOldVersionComp(Composite notebook) {
157:                Composite comp = new Composite(notebook, SWT.NONE);
158:                GridLayout layout = new GridLayout(2, false);
159:                layout.marginHeight = layout.marginWidth = 0;
160:                comp.setLayout(layout);
161:
162:                Label label = new Label(comp, SWT.NONE);
163:                label.setText(PDEUIMessages.FragmentContentPage_pid);
164:
165:                Composite container = new Composite(comp, SWT.NONE);
166:                layout = new GridLayout(2, false);
167:                layout.marginHeight = layout.marginWidth = 0;
168:                container.setLayout(layout);
169:                container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
170:
171:                fPluginIdText_oldV = createPluginIdContainer(container, false,
172:                        1);
173:
174:                label = new Label(comp, SWT.NONE);
175:                label.setText(PDEUIMessages.FragmentContentPage_pversion);
176:                fPluginVersion = createText(comp, listener);
177:
178:                label = new Label(comp, SWT.NONE);
179:                label.setText(PDEUIMessages.ContentPage_matchRule);
180:
181:                fMatchCombo = new Combo(comp, SWT.READ_ONLY | SWT.BORDER);
182:                fMatchCombo
183:                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
184:                fMatchCombo.setItems(new String[] {
185:                        "", //$NON-NLS-1$
186:                        PDEUIMessages.ManifestEditor_MatchSection_equivalent,
187:                        PDEUIMessages.ManifestEditor_MatchSection_compatible,
188:                        PDEUIMessages.ManifestEditor_MatchSection_perfect,
189:                        PDEUIMessages.ManifestEditor_MatchSection_greater });
190:                fMatchCombo.setText(fMatchCombo.getItem(0));
191:                return comp;
192:            }
193:
194:            private Text createPluginIdContainer(Composite parent,
195:                    final boolean validateRange, int span) {
196:                final Text pluginText = createText(parent, listener);
197:
198:                Button browse = new Button(parent, SWT.PUSH);
199:                browse.setText(PDEUIMessages.ContentPage_browse);
200:                browse.setLayoutData(new GridData());
201:                browse.addSelectionListener(new SelectionAdapter() {
202:                    public void widgetSelected(SelectionEvent e) {
203:                        BusyIndicator.showWhile(pluginText.getDisplay(),
204:                                new Runnable() {
205:                                    public void run() {
206:                                        PluginSelectionDialog dialog = new PluginSelectionDialog(
207:                                                pluginText.getShell(), false,
208:                                                false);
209:                                        dialog.create();
210:                                        if (dialog.open() == Window.OK) {
211:                                            IPluginModel model = (IPluginModel) dialog
212:                                                    .getFirstResult();
213:                                            IPlugin plugin = model.getPlugin();
214:                                            String version = computeInitialPluginVersion(plugin
215:                                                    .getVersion());
216:                                            if (validateRange) {
217:                                                fVersionPart
218:                                                        .setVersion(version);
219:                                                fVersionPart.preloadFields();
220:                                            } else {
221:                                                fPluginVersion.setText(version);
222:                                            }
223:                                            pluginText.setText(plugin.getId());
224:                                        }
225:                                    }
226:                                });
227:                    }
228:                });
229:                SWTUtil.setButtonDimensionHint(browse);
230:                return pluginText;
231:            }
232:
233:            private String computeInitialPluginVersion(String pluginVersion) {
234:                if (pluginVersion != null
235:                        && VersionUtil.validateVersion(pluginVersion).isOK()) {
236:                    Version pvi = Version.parseVersion(pluginVersion);
237:                    return pvi.getMajor() + "." + pvi.getMinor() //$NON-NLS-1$
238:                            + "." + pvi.getMicro(); //$NON-NLS-1$
239:                }
240:
241:                return pluginVersion;
242:            }
243:
244:            public void updateData() {
245:                super .updateData();
246:                String version;
247:                if (fNewVersion) {
248:                    version = fVersionPart.getVersion();
249:                    ((FragmentFieldData) fData).setPluginId(fPluginIdText_newV
250:                            .getText().trim());
251:                } else {
252:                    version = fPluginVersion.getText().trim();
253:                    ((FragmentFieldData) fData).setPluginId(fPluginIdText_oldV
254:                            .getText().trim());
255:                    ((FragmentFieldData) fData).setMatch(fMatchCombo
256:                            .getSelectionIndex());
257:                }
258:                ((FragmentFieldData) fData).setPluginVersion(version);
259:            }
260:
261:            /* (non-Javadoc)
262:             * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#validatePage()
263:             */
264:            protected void validatePage() {
265:                String errorMessage = validateProperties();
266:
267:                if (errorMessage == null) {
268:                    String pluginID = fNewVersion ? fPluginIdText_newV
269:                            .getText().trim() : fPluginIdText_oldV.getText()
270:                            .trim();
271:                    if (pluginID.length() == 0) {
272:                        errorMessage = PDEUIMessages.ContentPage_nopid;
273:                    } else if (!(PluginRegistry.findModel(pluginID) instanceof  IPluginModel)) {
274:                        errorMessage = PDEUIMessages.ContentPage_pluginNotFound;
275:                    } else {
276:                        if (fNewVersion) {
277:                            IStatus status = fVersionPart
278:                                    .validateFullVersionRangeText(false);
279:                            if (status.getSeverity() != IStatus.OK) {
280:                                errorMessage = status.getMessage();
281:                            }
282:                        } else {
283:                            errorMessage = validateVersion(fPluginVersion);
284:                        }
285:                    }
286:                }
287:                if (fInitialized)
288:                    setErrorMessage(errorMessage);
289:                setPageComplete(errorMessage == null);
290:            }
291:
292:            /* (non-Javadoc)
293:             * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#getNameFieldQualifier()
294:             */
295:            protected String getNameFieldQualifier() {
296:                return PDEUIMessages.ContentPage_fragment;
297:            }
298:
299:            /* (non-Javadoc)
300:             * @see org.eclipse.pde.internal.ui.wizards.plugin.ContentPage#setVisible(boolean)
301:             */
302:            public void setVisible(boolean visible) {
303:                if (visible) {
304:                    fMainPage.updateData();
305:                    updateVersion(true);
306:                }
307:                super .setVisible(visible);
308:            }
309:
310:            private void updateVersion(boolean updateComposite) {
311:                fNewVersion = Double.parseDouble(fData.getTargetVersion()) > 3.0;
312:                if (updateComposite) {
313:                    Control oldPage = fNotebookLayout.topControl;
314:                    if (fNewVersion)
315:                        fNotebookLayout.topControl = fNewComp;
316:                    else
317:                        fNotebookLayout.topControl = fOldComp;
318:                    if (oldPage != fNotebookLayout.topControl)
319:                        fNotebook.layout();
320:                }
321:            }
322:        }
w__w_w___.j__a___v___a_2___s_.___c__o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.