Source Code Cross Referenced for PluginImportWizardExpressPage.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » wizards » imports » 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.imports 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2003, 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.imports;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.core.resources.IFile;
015:        import org.eclipse.core.resources.IProject;
016:        import org.eclipse.core.resources.IResource;
017:        import org.eclipse.core.runtime.CoreException;
018:        import org.eclipse.core.runtime.Path;
019:        import org.eclipse.jdt.core.IJavaProject;
020:        import org.eclipse.jface.dialogs.Dialog;
021:        import org.eclipse.jface.viewers.CheckboxTableViewer;
022:        import org.eclipse.jface.viewers.IStructuredContentProvider;
023:        import org.eclipse.jface.viewers.IStructuredSelection;
024:        import org.eclipse.jface.viewers.StructuredViewer;
025:        import org.eclipse.osgi.util.NLS;
026:        import org.eclipse.pde.core.build.IBuildEntry;
027:        import org.eclipse.pde.core.build.IBuildModel;
028:        import org.eclipse.pde.core.plugin.IPluginModelBase;
029:        import org.eclipse.pde.core.plugin.PluginRegistry;
030:        import org.eclipse.pde.internal.core.WorkspaceModelManager;
031:        import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
032:        import org.eclipse.pde.internal.ui.IHelpContextIds;
033:        import org.eclipse.pde.internal.ui.PDEPlugin;
034:        import org.eclipse.pde.internal.ui.PDEUIMessages;
035:        import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
036:        import org.eclipse.pde.internal.ui.parts.WizardCheckboxTablePart;
037:        import org.eclipse.pde.internal.ui.wizards.ListUtil;
038:        import org.eclipse.swt.SWT;
039:        import org.eclipse.swt.events.SelectionAdapter;
040:        import org.eclipse.swt.events.SelectionEvent;
041:        import org.eclipse.swt.layout.GridData;
042:        import org.eclipse.swt.layout.GridLayout;
043:        import org.eclipse.swt.widgets.Button;
044:        import org.eclipse.swt.widgets.Composite;
045:        import org.eclipse.swt.widgets.Label;
046:        import org.eclipse.ui.PlatformUI;
047:        import org.eclipse.ui.forms.widgets.FormToolkit;
048:
049:        public class PluginImportWizardExpressPage extends
050:                BaseImportWizardSecondPage {
051:
052:            private TablePart fTablePart;
053:            private IStructuredSelection fInitialSelection;
054:            private Label fCounterLabel;
055:
056:            class PluginContentProvider extends DefaultContentProvider
057:                    implements  IStructuredContentProvider {
058:                public Object[] getElements(Object parent) {
059:                    IProject[] projects = PDEPlugin.getWorkspace().getRoot()
060:                            .getProjects();
061:                    ArrayList result = new ArrayList();
062:                    for (int i = 0; i < projects.length; i++) {
063:                        if (WorkspaceModelManager.isPluginProject(projects[i])
064:                                && !WorkspaceModelManager
065:                                        .isBinaryProject(projects[i])) {
066:                            IPluginModelBase model = PluginRegistry
067:                                    .findModel(projects[i]);
068:                            if (model != null)
069:                                result.add(model);
070:                        }
071:                    }
072:                    return result.toArray();
073:                }
074:            }
075:
076:            class TablePart extends WizardCheckboxTablePart {
077:                public TablePart(String mainLabel, String[] buttonLabels) {
078:                    super (mainLabel, buttonLabels);
079:                }
080:
081:                public void updateCounter(int count) {
082:                    super .updateCounter(count);
083:                }
084:
085:                protected StructuredViewer createStructuredViewer(
086:                        Composite parent, int style, FormToolkit toolkit) {
087:                    StructuredViewer viewer = super .createStructuredViewer(
088:                            parent, style, toolkit);
089:                    return viewer;
090:                }
091:
092:                protected void elementChecked(Object element, boolean checked) {
093:                    super .elementChecked(element, checked);
094:                    pageChanged();
095:                }
096:
097:                protected void handleSelectAll(boolean select) {
098:                    super .handleSelectAll(select);
099:                    pageChanged();
100:                }
101:            }
102:
103:            public PluginImportWizardExpressPage(String pageName,
104:                    PluginImportWizardFirstPage page,
105:                    IStructuredSelection selection) {
106:                super (pageName, page);
107:                this .fInitialSelection = selection;
108:                setTitle(PDEUIMessages.ImportWizard_expressPage_title);
109:                setMessage(PDEUIMessages.ImportWizard_expressPage_desc);
110:            }
111:
112:            public void createControl(Composite parent) {
113:                Composite container = new Composite(parent, SWT.NONE);
114:                GridLayout layout = new GridLayout();
115:                layout.numColumns = 2;
116:                layout.horizontalSpacing = 5;
117:                layout.verticalSpacing = 0;
118:                container.setLayout(layout);
119:                container.setLayoutData(new GridData(GridData.FILL_BOTH));
120:
121:                createTablePart(container);
122:                createImportPart(container);
123:
124:                createButtons(container);
125:
126:                createComputationsOption(container, 2);
127:
128:                fAddFragmentsButton
129:                        .addSelectionListener(new SelectionAdapter() {
130:                            public void widgetSelected(SelectionEvent e) {
131:                                pageChanged();
132:                            }
133:                        });
134:
135:                initialize();
136:                setControl(container);
137:                PlatformUI.getWorkbench().getHelpSystem().setHelp(container,
138:                        IHelpContextIds.PLUGIN_IMPORT_EXPRESS_PAGE);
139:                Dialog.applyDialogFont(container);
140:            }
141:
142:            private void createButtons(Composite container) {
143:                Composite buttonComp = new Composite(container, SWT.NONE);
144:                GridLayout layout = new GridLayout(2, true);
145:                layout.marginHeight = 0;
146:                layout.marginBottom = 10;
147:                layout.verticalSpacing = 0;
148:                layout.marginRight = 4;
149:                buttonComp.setLayout(layout);
150:                buttonComp
151:                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
152:                Button selectAll = new Button(buttonComp, SWT.PUSH);
153:                selectAll.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
154:                selectAll
155:                        .setText(PDEUIMessages.WizardCheckboxTablePart_selectAll);
156:                selectAll.addSelectionListener(new SelectionAdapter() {
157:                    public void widgetSelected(SelectionEvent e) {
158:                        fTablePart.handleSelectAll(true);
159:                        pageChanged();
160:                    }
161:                });
162:                Button deselectAll = new Button(buttonComp, SWT.PUSH);
163:                deselectAll
164:                        .setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
165:                deselectAll
166:                        .setText(PDEUIMessages.WizardCheckboxTablePart_deselectAll);
167:                deselectAll.addSelectionListener(new SelectionAdapter() {
168:                    public void widgetSelected(SelectionEvent e) {
169:                        fTablePart.handleSelectAll(false);
170:                        pageChanged();
171:                    }
172:                });
173:
174:            }
175:
176:            private Composite createTablePart(Composite parent) {
177:                Composite container = new Composite(parent, SWT.NONE);
178:                GridLayout layout = new GridLayout();
179:                layout.numColumns = 2;
180:                container.setLayout(layout);
181:                container.setLayoutData(new GridData(GridData.FILL_BOTH));
182:
183:                fTablePart = new TablePart(
184:                        PDEUIMessages.ImportWizard_expressPage_nonBinary,
185:                        new String[] {});
186:                fTablePart.createControl(container);
187:                GridData gd = new GridData(GridData.FILL_BOTH);
188:                gd.widthHint = 225;
189:                gd.heightHint = 200;
190:                fTablePart.getControl().setLayoutData(gd);
191:
192:                CheckboxTableViewer viewer = fTablePart.getTableViewer();
193:                viewer.setLabelProvider(PDEPlugin.getDefault()
194:                        .getLabelProvider());
195:                viewer.setContentProvider(new PluginContentProvider());
196:                viewer.setComparator(ListUtil.PLUGIN_COMPARATOR);
197:                viewer.setInput(PDEPlugin.getWorkspace().getRoot());
198:
199:                return container;
200:            }
201:
202:            private void createImportPart(Composite parent) {
203:                Composite container = new Composite(parent, SWT.NONE);
204:                container.setLayout(new GridLayout());
205:                container.setLayoutData(new GridData(GridData.FILL_BOTH));
206:
207:                createImportList(container);
208:                fCounterLabel = new Label(container, SWT.NONE);
209:                fCounterLabel.setLayoutData(new GridData(
210:                        GridData.FILL_HORIZONTAL));
211:            }
212:
213:            private void initialize() {
214:                Object[] items = fInitialSelection.toArray();
215:                ArrayList list = new ArrayList();
216:                for (int i = 0; i < items.length; i++) {
217:                    Object item = items[i];
218:                    if (item instanceof  IJavaProject) {
219:                        item = ((IJavaProject) item).getProject();
220:                    }
221:                    if (item instanceof  IProject) {
222:                        IProject project = (IProject) item;
223:                        if (WorkspaceModelManager.isPluginProject(project)
224:                                && !WorkspaceModelManager
225:                                        .isBinaryProject(project)) {
226:                            IPluginModelBase model = PluginRegistry
227:                                    .findModel(project);
228:                            if (model != null)
229:                                list.add(model);
230:                        }
231:                    }
232:                }
233:                fTablePart.setSelection(list.toArray());
234:            }
235:
236:            private void computeModelsToImport() {
237:                fImportListViewer.getTable().removeAll();
238:
239:                ArrayList result = new ArrayList();
240:                Object[] wModels = fTablePart.getSelection();
241:                for (int i = 0; i < wModels.length; i++) {
242:                    IPluginModelBase model = (IPluginModelBase) wModels[i];
243:                    addDependencies(model, result, fAddFragmentsButton
244:                            .getSelection());
245:                    addExtraPrerequisites(model, result);
246:                }
247:
248:                if (wModels.length > 0) {
249:                    removeSharedModels(result);
250:                }
251:
252:                fImportListViewer.add(result.toArray());
253:            }
254:
255:            private void removeSharedModels(ArrayList result) {
256:                IPluginModelBase[] smodels = (IPluginModelBase[]) result
257:                        .toArray(new IPluginModelBase[result.size()]);
258:                for (int i = 0; i < smodels.length; i++) {
259:                    String id = smodels[i].getPluginBase().getId();
260:                    IPluginModelBase model = PluginRegistry.findModel(id);
261:                    if (model != null) {
262:                        IResource resource = model.getUnderlyingResource();
263:                        if (resource != null) {
264:                            IProject project = resource.getProject();
265:                            if (!WorkspaceModelManager
266:                                    .isUnsharedProject(project)) {
267:                                result.remove(smodels[i]);
268:                            }
269:                        }
270:                    }
271:                }
272:            }
273:
274:            private void addExtraPrerequisites(IPluginModelBase model,
275:                    ArrayList result) {
276:                try {
277:                    IBuildModel buildModel = model.getBuildModel();
278:                    if (buildModel == null) {
279:                        IFile buildFile = model.getUnderlyingResource()
280:                                .getProject().getFile("build.properties"); //$NON-NLS-1$
281:                        if (buildFile.exists()) {
282:                            buildModel = new WorkspaceBuildModel(buildFile);
283:                            buildModel.load();
284:                        }
285:                    }
286:                    if (buildModel == null)
287:                        return;
288:
289:                    IBuildEntry entry = buildModel.getBuild().getEntry(
290:                            IBuildEntry.JARS_EXTRA_CLASSPATH);
291:                    if (entry == null)
292:                        return;
293:
294:                    String[] tokens = entry.getTokens();
295:                    for (int i = 0; i < tokens.length; i++) {
296:                        Path path = new Path(tokens[i]);
297:                        if (path.segmentCount() >= 2
298:                                && path.segment(0).equals("..")) { //$NON-NLS-1$
299:                            for (int j = 0; j < fModels.length; j++) {
300:                                if (fModels[j].getPluginBase().getId().equals(
301:                                        path.segment(1))
302:                                        && !result.contains(fModels[j])) {
303:                                    result.add(fModels[j]);
304:                                }
305:                            }
306:                        }
307:                    }
308:                } catch (CoreException e) {
309:                }
310:            }
311:
312:            protected void refreshPage() {
313:                pageChanged();
314:            }
315:
316:            protected void pageChanged() {
317:                computeModelsToImport();
318:                updateCount();
319:                setPageComplete(fImportListViewer.getTable().getItemCount() > 0);
320:            }
321:
322:            private void updateCount() {
323:                fCounterLabel.setText(NLS
324:                        .bind(PDEUIMessages.ImportWizard_expressPage_total,
325:                                new Integer(fImportListViewer.getTable()
326:                                        .getItemCount()).toString()));
327:                fCounterLabel.getParent().layout();
328:            }
329:
330:        }
w__ww__.ja__v_a2_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.