001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 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.tools;
011:
012: import org.eclipse.jface.dialogs.Dialog;
013: import org.eclipse.jface.viewers.CheckboxTableViewer;
014: import org.eclipse.jface.viewers.IStructuredContentProvider;
015: import org.eclipse.jface.viewers.StructuredViewer;
016: import org.eclipse.jface.wizard.WizardPage;
017: import org.eclipse.pde.core.plugin.IPluginModelBase;
018: import org.eclipse.pde.internal.ui.IHelpContextIds;
019: import org.eclipse.pde.internal.ui.PDEPlugin;
020: import org.eclipse.pde.internal.ui.PDEUIMessages;
021: import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
022: import org.eclipse.pde.internal.ui.parts.WizardCheckboxTablePart;
023: import org.eclipse.pde.internal.ui.wizards.ListUtil;
024: import org.eclipse.swt.SWT;
025: import org.eclipse.swt.layout.GridData;
026: import org.eclipse.swt.layout.GridLayout;
027: import org.eclipse.swt.widgets.Composite;
028: import org.eclipse.ui.PlatformUI;
029: import org.eclipse.ui.forms.widgets.FormToolkit;
030:
031: public class UpdateBuildpathWizardPage extends WizardPage {
032: private IPluginModelBase[] fSelected;
033: private IPluginModelBase[] fUnmigrated;
034: private CheckboxTableViewer pluginListViewer;
035: private TablePart tablePart;
036:
037: public class BuildpathContentProvider extends
038: DefaultContentProvider implements
039: IStructuredContentProvider {
040: public Object[] getElements(Object parent) {
041: if (fUnmigrated != null)
042: return fUnmigrated;
043: return new Object[0];
044: }
045: }
046:
047: class TablePart extends WizardCheckboxTablePart {
048: public TablePart(String mainLabel) {
049: super (mainLabel);
050: }
051:
052: public void updateCounter(int count) {
053: super .updateCounter(count);
054: dialogChanged();
055: }
056:
057: protected StructuredViewer createStructuredViewer(
058: Composite parent, int style, FormToolkit toolkit) {
059: StructuredViewer viewer = super .createStructuredViewer(
060: parent, style, toolkit);
061: viewer.setComparator(ListUtil.PLUGIN_COMPARATOR);
062: return viewer;
063: }
064: }
065:
066: public UpdateBuildpathWizardPage(IPluginModelBase[] models,
067: IPluginModelBase[] selected) {
068: super ("UpdateBuildpathWizardPage"); //$NON-NLS-1$
069: setTitle(PDEUIMessages.UpdateBuildpathWizard_title);
070: setDescription(PDEUIMessages.UpdateBuildpathWizard_desc);
071: this .fUnmigrated = models;
072: this .fSelected = selected;
073: tablePart = new TablePart(
074: PDEUIMessages.UpdateBuildpathWizard_availablePlugins);
075: PDEPlugin.getDefault().getLabelProvider().connect(this );
076: }
077:
078: public void dispose() {
079: super .dispose();
080: PDEPlugin.getDefault().getLabelProvider().disconnect(this );
081: }
082:
083: public void createControl(Composite parent) {
084: Composite container = new Composite(parent, SWT.NONE);
085: GridLayout layout = new GridLayout();
086: layout.numColumns = 2;
087: layout.marginHeight = 0;
088: layout.marginWidth = 5;
089: container.setLayout(layout);
090:
091: tablePart.createControl(container);
092:
093: pluginListViewer = tablePart.getTableViewer();
094: pluginListViewer
095: .setContentProvider(new BuildpathContentProvider());
096: pluginListViewer.setLabelProvider(PDEPlugin.getDefault()
097: .getLabelProvider());
098:
099: GridData gd = (GridData) tablePart.getControl().getLayoutData();
100: gd.heightHint = 300;
101: gd.widthHint = 300;
102:
103: pluginListViewer.setInput(PDEPlugin.getDefault());
104: tablePart.setSelection(fSelected);
105:
106: setControl(container);
107: Dialog.applyDialogFont(container);
108: PlatformUI.getWorkbench().getHelpSystem().setHelp(container,
109: IHelpContextIds.UPDATE_CLASSPATH);
110: }
111:
112: public void storeSettings() {
113: }
114:
115: public Object[] getSelected() {
116: return tablePart.getSelection();
117: }
118:
119: private void dialogChanged() {
120: setPageComplete(tablePart.getSelectionCount() > 0);
121: }
122:
123: /* (non-Javadoc)
124: * @see org.eclipse.jface.wizard.WizardPage#isPageComplete()
125: */
126: public boolean isPageComplete() {
127: return tablePart.getSelectionCount() > 0;
128: }
129: }
|