### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/pderesources.properties =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v retrieving revision 1.1034 diff -u -r1.1034 pderesources.properties --- src/org/eclipse/pde/internal/ui/pderesources.properties 3 Feb 2009 19:55:58 -0000 1.1034 +++ src/org/eclipse/pde/internal/ui/pderesources.properties 4 Feb 2009 22:54:16 -0000 @@ -1512,6 +1512,7 @@ ExportWizard_dialog_message = Select a destination directory for the export operation: ExportWizard_status_noselection = No items selected. ExportWizard_status_nodirectory = Destination directory must be specified. +ExportWizard_status_invaliddirectory = Destination directory must be a valid location. ExportWizard_status_nofile = Archive file must be specified. ExportWizard_status_noantfile = An Ant build file must be specified. ExtensionsPage_title=Extensions Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v retrieving revision 1.407 diff -u -r1.407 PDEUIMessages.java --- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 3 Feb 2009 19:55:58 -0000 1.407 +++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 4 Feb 2009 22:54:14 -0000 @@ -1684,6 +1684,7 @@ public static String ExportWizard_dialog_message; public static String ExportWizard_status_noselection; public static String ExportWizard_status_nodirectory; + public static String ExportWizard_status_invaliddirectory; public static String ExportWizard_status_nofile; public static String ExportWizard_status_noantfile; public static String ExtensionsPage_title; Index: src/org/eclipse/pde/internal/ui/wizards/exports/ExportDestinationTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ExportDestinationTab.java,v retrieving revision 1.6 diff -u -r1.6 ExportDestinationTab.java --- src/org/eclipse/pde/internal/ui/wizards/exports/ExportDestinationTab.java 21 Nov 2008 18:08:09 -0000 1.6 +++ src/org/eclipse/pde/internal/ui/wizards/exports/ExportDestinationTab.java 4 Feb 2009 22:54:22 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -96,6 +96,12 @@ hookListeners(); } + protected void initializeCombo(IDialogSettings settings, String key, Combo combo) { + super.initializeCombo(settings, key, combo); + if (!isValidLocation(combo.getText().trim())) // If default value is invalid, make it blank + combo.setText(""); //$NON-NLS-1$ + } + protected void updateExportType() { fArchiveCombo.setEnabled(fArchiveFileButton.getSelection()); fBrowseFile.setEnabled(fArchiveFileButton.getSelection()); @@ -186,12 +192,25 @@ } protected String validate() { - if (fArchiveFileButton.getSelection() && fArchiveCombo.getText().trim().length() == 0) - return PDEUIMessages.ExportWizard_status_nofile; - if (fDirectoryButton.getSelection() && fDirectoryCombo.getText().trim().length() == 0) - return PDEUIMessages.ExportWizard_status_nodirectory; - if (fInstallButton.getSelection() && fInstallCombo.getText().trim().length() == 0) - return PDEUIMessages.ExportWizard_status_nodirectory; + if (fArchiveFileButton.getSelection()) { + if (fArchiveCombo.getText().trim().length() == 0) + return PDEUIMessages.ExportWizard_status_nofile; + else if (!isValidLocation(fArchiveCombo.getText().trim())) + return PDEUIMessages.ExportWizard_status_invaliddirectory; + } + if (fDirectoryButton.getSelection()) { + if (fDirectoryCombo.getText().trim().length() == 0) + return PDEUIMessages.ExportWizard_status_nodirectory; + else if (!isValidLocation(fDirectoryCombo.getText().trim())) + return PDEUIMessages.ExportWizard_status_invaliddirectory; + } + if (fInstallButton.getSelection()) { + if (fInstallCombo.getText().trim().length() == 0) + return PDEUIMessages.ExportWizard_status_nodirectory; + else if (!isValidLocation(fInstallCombo.getText().trim())) + return PDEUIMessages.ExportWizard_status_invaliddirectory; + } + return null; } Index: src/org/eclipse/pde/internal/ui/wizards/exports/AbstractExportTab.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/AbstractExportTab.java,v retrieving revision 1.4 diff -u -r1.4 AbstractExportTab.java --- src/org/eclipse/pde/internal/ui/wizards/exports/AbstractExportTab.java 16 Jan 2008 17:08:25 -0000 1.4 +++ src/org/eclipse/pde/internal/ui/wizards/exports/AbstractExportTab.java 4 Feb 2009 22:54:22 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.wizards.exports; +import java.io.File; +import java.io.IOException; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.swt.SWT; @@ -66,4 +68,16 @@ } } + protected boolean isValidLocation(String location) { + try { + String destinationPath = new File(location).getCanonicalPath(); + if (destinationPath == null || destinationPath.length() == 0) + return false; + } catch (IOException e) { + return false; + } + + return true; + } + } Index: src/org/eclipse/pde/internal/ui/wizards/exports/ProductDestinationGroup.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ProductDestinationGroup.java,v retrieving revision 1.5 diff -u -r1.5 ProductDestinationGroup.java --- src/org/eclipse/pde/internal/ui/wizards/exports/ProductDestinationGroup.java 6 Oct 2008 18:49:50 -0000 1.5 +++ src/org/eclipse/pde/internal/ui/wizards/exports/ProductDestinationGroup.java 4 Feb 2009 22:54:22 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. + * Copyright (c) 2005, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -96,6 +96,12 @@ } } + protected void initializeCombo(IDialogSettings settings, String key, Combo combo) { + super.initializeCombo(settings, key, combo); + if (!isValidLocation(combo.getText().trim())) // If default value is invalid, make it blank + combo.setText(""); //$NON-NLS-1$ + } + protected void updateDestination(IFile file) { try { if (file == null) @@ -197,10 +203,18 @@ } protected String validate() { - if (fArchiveFileButton.getSelection() && fArchiveCombo.getText().trim().length() == 0) - return PDEUIMessages.ExportWizard_status_nofile; - if (fDirectoryButton.getSelection() && fDirectoryCombo.getText().trim().length() == 0) - return PDEUIMessages.ExportWizard_status_nodirectory; + if (fArchiveFileButton.getSelection()) { + if (fArchiveCombo.getText().trim().length() == 0) + return PDEUIMessages.ExportWizard_status_nofile; + else if (!isValidLocation(fArchiveCombo.getText().trim())) + return PDEUIMessages.ExportWizard_status_invaliddirectory; + } + if (fDirectoryButton.getSelection()) { + if (fDirectoryCombo.getText().trim().length() == 0) + return PDEUIMessages.ExportWizard_status_nodirectory; + else if (!isValidLocation(fDirectoryCombo.getText().trim())) + return PDEUIMessages.ExportWizard_status_invaliddirectory; + } return null; } Index: src/org/eclipse/pde/internal/ui/wizards/exports/ProductExportWizardPage.java =================================================================== RCS file: /cvsroot/eclipse/pde/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/wizards/exports/ProductExportWizardPage.java,v retrieving revision 1.26 diff -u -r1.26 ProductExportWizardPage.java --- src/org/eclipse/pde/internal/ui/wizards/exports/ProductExportWizardPage.java 3 Feb 2009 19:55:58 -0000 1.26 +++ src/org/eclipse/pde/internal/ui/wizards/exports/ProductExportWizardPage.java 4 Feb 2009 22:54:22 -0000 @@ -1,258 +1,260 @@ -/******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.pde.internal.ui.wizards.exports; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.wizard.IWizardPage; -import org.eclipse.pde.internal.ui.IHelpContextIds; -import org.eclipse.pde.internal.ui.PDEUIMessages; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.*; -import org.eclipse.ui.PlatformUI; - -public class ProductExportWizardPage extends AbstractExportWizardPage { - - private static final String S_SYNC_PRODUCT = "syncProduct"; //$NON-NLS-1$ - private static final String S_EXPORT_SOURCE = "exportSource"; //$NON-NLS-1$ - private static final String S_EXPORT_SOURCE_FORMAT = "exportSourceFormat"; //$NON-NLS-1$ - private static final String S_ALLOW_BINARY_CYCLES = "allowBinaryCycles"; //$NON-NLS-1$ - private static final String S_MULTI_PLATFORM = "multiplatform"; //$NON-NLS-1$ - private static final String S_EXPORT_METADATA = "p2metadata"; //$NON-NLS-1$ - - private Button fSyncButton; - private IStructuredSelection fSelection; - private ProductDestinationGroup fExportGroup; - private ProductConfigurationSection fConfigurationGroup; - private Button fExportSourceButton; - private Combo fExportSourceCombo; - private Button fMultiPlatform; - private Button fExportMetadata; - private Button fAllowBinaryCycles; - - public ProductExportWizardPage(IStructuredSelection selection) { - super("productExport"); //$NON-NLS-1$ - fSelection = selection; - setTitle(PDEUIMessages.ProductExportWizardPage_title); - setDescription(PDEUIMessages.ProductExportWizardPage_desc); - } - - public void createControl(Composite parent) { - Composite container = new Composite(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.verticalSpacing = 10; - container.setLayout(layout); - - createConfigurationSection(container); - createSynchronizationSection(container); - createDestinationSection(container); - createOptionsSection(container); - - initialize(); - pageChanged(); - if (getErrorMessage() != null) { - setMessage(getErrorMessage()); - setErrorMessage(null); - } - setControl(container); - hookHelpContext(container); - Dialog.applyDialogFont(container); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.PRODUCT_EXPORT_WIZARD); - } - - private void createConfigurationSection(Composite parent) { - fConfigurationGroup = new ProductConfigurationSection(this); - fConfigurationGroup.createControl(parent); - } - - private void createSynchronizationSection(Composite parent) { - Group group = new Group(parent, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.verticalSpacing = 7; - group.setLayout(layout); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - group.setText(PDEUIMessages.ProductExportWizardPage_sync); - - Label label = new Label(group, SWT.WRAP); - label.setText(PDEUIMessages.ProductExportWizardPage_syncText); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.widthHint = 400; - label.setLayoutData(gd); - - fSyncButton = new Button(group, SWT.CHECK); - fSyncButton.setText(PDEUIMessages.ProductExportWizardPage_syncButton); - gd = new GridData(); - gd.horizontalIndent = 20; - fSyncButton.setLayoutData(gd); - } - - private void createDestinationSection(Composite container) { - fExportGroup = new ProductDestinationGroup(this); - fExportGroup.createControl(container); - } - - private void createOptionsSection(Composite container) { - Group group = new Group(container, SWT.NONE); - group.setText(PDEUIMessages.ProductExportWizardPage_exportOptionsGroup); - group.setLayout(new GridLayout()); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite composite = new Composite(group, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - layout.marginHeight = layout.marginWidth = 0; - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - fExportSourceButton = new Button(composite, SWT.CHECK); - fExportSourceButton.setText(PDEUIMessages.ExportWizard_includeSource); - - fExportSourceCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER); - fExportSourceCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); - - fExportMetadata = new Button(group, SWT.CHECK); - fExportMetadata.setText(PDEUIMessages.ExportWizard_includesMetadata); - - if (getWizard().getPages().length > 1) { - fMultiPlatform = new Button(group, SWT.CHECK); - fMultiPlatform.setText(PDEUIMessages.ExportWizard_multi_platform); - fMultiPlatform.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - getContainer().updateButtons(); - } - }); - } - - fAllowBinaryCycles = new Button(group, SWT.CHECK); - fAllowBinaryCycles.setText(PDEUIMessages.ExportOptionsTab_allowBinaryCycles); - } - - protected void initialize() { - IDialogSettings settings = getDialogSettings(); - fConfigurationGroup.initialize(fSelection, settings); - - String value = settings.get(S_SYNC_PRODUCT); - fSyncButton.setSelection(value == null ? true : settings.getBoolean(S_SYNC_PRODUCT)); - - fExportGroup.initialize(settings, fConfigurationGroup.getProductFile()); - - fExportSourceButton.setSelection(settings.getBoolean(S_EXPORT_SOURCE)); - fExportSourceCombo.setItems(new String[] {PDEUIMessages.ExportWizard_generateAssociatedSourceBundles, PDEUIMessages.ExportWizard_includeSourceInBinaryBundles}); - String sourceComboValue = settings.get(S_EXPORT_SOURCE_FORMAT) != null ? settings.get(S_EXPORT_SOURCE_FORMAT) : PDEUIMessages.ExportWizard_generateAssociatedSourceBundles; - fExportSourceCombo.setText(sourceComboValue); - fExportSourceCombo.setEnabled(fExportSourceButton.getSelection()); - - fExportMetadata.setSelection(settings.getBoolean(S_EXPORT_METADATA)); - - String selected = settings.get(S_ALLOW_BINARY_CYCLES); - fAllowBinaryCycles.setSelection(selected == null ? true : "true".equals(selected)); //$NON-NLS-1$ - - if (fMultiPlatform != null) - fMultiPlatform.setSelection(settings.getBoolean(S_MULTI_PLATFORM)); - - hookListeners(); - } - - protected void hookListeners() { - fExportSourceButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fExportSourceCombo.setEnabled(fExportSourceButton.getSelection()); - } - }); - } - - protected void updateProductFields() { - fExportGroup.updateDestination(fConfigurationGroup.getProductFile()); - } - - protected void pageChanged() { - String error = fConfigurationGroup.validate(); - if (error == null) - error = fExportGroup.validate(); - setErrorMessage(error); - setPageComplete(error == null); - } - - public IWizardPage getNextPage() { - return doMultiPlatform() ? getWizard().getNextPage(this) : null; - } - - protected void hookHelpContext(Control control) { - PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IHelpContextIds.PRODUCT_EXPORT_WIZARD); - } - - protected void saveSettings(IDialogSettings settings) { - fConfigurationGroup.saveSettings(settings); - settings.put(S_SYNC_PRODUCT, fSyncButton.getSelection()); - fExportGroup.saveSettings(settings); - settings.put(S_EXPORT_SOURCE, doExportSource()); - settings.put(S_EXPORT_SOURCE_FORMAT, fExportSourceCombo.getItem(fExportSourceCombo.getSelectionIndex())); - settings.put(S_EXPORT_METADATA, doExportMetadata()); - settings.put(S_ALLOW_BINARY_CYCLES, doBinaryCycles()); - - if (fMultiPlatform != null) - settings.put(S_MULTI_PLATFORM, fMultiPlatform.getSelection()); - } - - protected boolean doSync() { - return fSyncButton.getSelection(); - } - - protected boolean doMultiPlatform() { - return fMultiPlatform != null && fMultiPlatform.getSelection(); - } - - protected boolean doExportSource() { - return fExportSourceButton.getSelection(); - } - - protected boolean doExportSourceBundles() { - return PDEUIMessages.ExportWizard_generateAssociatedSourceBundles.equals(fExportSourceCombo.getText()); - } - - protected boolean doBinaryCycles() { - return fAllowBinaryCycles.getSelection(); - } - - /** - * @return whether to generate p2 metadata on export - */ - protected boolean doExportMetadata() { - return fExportMetadata.getSelection(); - } - - protected boolean doExportToDirectory() { - return fExportGroup.doExportToDirectory(); - } - - protected String getFileName() { - return fExportGroup.getFileName(); - } - - protected String getDestination() { - return fExportGroup.getDestination(); - } - - protected String getRootDirectory() { - return fConfigurationGroup.getRootDirectory(); - } - - protected IFile getProductFile() { - return fConfigurationGroup.getProductFile(); - } - -} +/******************************************************************************* + * Copyright (c) 2005, 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.wizards.exports; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.pde.internal.ui.IHelpContextIds; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.*; +import org.eclipse.ui.PlatformUI; + +public class ProductExportWizardPage extends AbstractExportWizardPage { + + private static final String S_SYNC_PRODUCT = "syncProduct"; //$NON-NLS-1$ + private static final String S_EXPORT_SOURCE = "exportSource"; //$NON-NLS-1$ + private static final String S_EXPORT_SOURCE_FORMAT = "exportSourceFormat"; //$NON-NLS-1$ + private static final String S_ALLOW_BINARY_CYCLES = "allowBinaryCycles"; //$NON-NLS-1$ + private static final String S_MULTI_PLATFORM = "multiplatform"; //$NON-NLS-1$ + private static final String S_EXPORT_METADATA = "p2metadata"; //$NON-NLS-1$ + + private Button fSyncButton; + private IStructuredSelection fSelection; + private ProductDestinationGroup fExportGroup; + private ProductConfigurationSection fConfigurationGroup; + private Button fExportSourceButton; + private Combo fExportSourceCombo; + private Button fMultiPlatform; + private Button fExportMetadata; + private Button fAllowBinaryCycles; + + public ProductExportWizardPage(IStructuredSelection selection) { + super("productExport"); //$NON-NLS-1$ + fSelection = selection; + setTitle(PDEUIMessages.ProductExportWizardPage_title); + setDescription(PDEUIMessages.ProductExportWizardPage_desc); + } + + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.verticalSpacing = 10; + container.setLayout(layout); + + createConfigurationSection(container); + createSynchronizationSection(container); + createDestinationSection(container); + createOptionsSection(container); + + initialize(); + pageChanged(); + if (getErrorMessage() != null) { + setMessage(getErrorMessage()); + setErrorMessage(null); + } + setControl(container); + hookHelpContext(container); + Dialog.applyDialogFont(container); + + PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.PRODUCT_EXPORT_WIZARD); + } + + private void createConfigurationSection(Composite parent) { + fConfigurationGroup = new ProductConfigurationSection(this); + fConfigurationGroup.createControl(parent); + } + + private void createSynchronizationSection(Composite parent) { + Group group = new Group(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.verticalSpacing = 7; + group.setLayout(layout); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + group.setText(PDEUIMessages.ProductExportWizardPage_sync); + + Label label = new Label(group, SWT.WRAP); + label.setText(PDEUIMessages.ProductExportWizardPage_syncText); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 400; + label.setLayoutData(gd); + + fSyncButton = new Button(group, SWT.CHECK); + fSyncButton.setText(PDEUIMessages.ProductExportWizardPage_syncButton); + gd = new GridData(); + gd.horizontalIndent = 20; + fSyncButton.setLayoutData(gd); + } + + private void createDestinationSection(Composite container) { + fExportGroup = new ProductDestinationGroup(this); + fExportGroup.createControl(container); + } + + private void createOptionsSection(Composite container) { + Group group = new Group(container, SWT.NONE); + group.setText(PDEUIMessages.ProductExportWizardPage_exportOptionsGroup); + group.setLayout(new GridLayout()); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Composite composite = new Composite(group, SWT.NONE); + GridLayout layout = new GridLayout(2, false); + layout.marginHeight = layout.marginWidth = 0; + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + fExportSourceButton = new Button(composite, SWT.CHECK); + fExportSourceButton.setText(PDEUIMessages.ExportWizard_includeSource); + + fExportSourceCombo = new Combo(composite, SWT.READ_ONLY | SWT.BORDER); + fExportSourceCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + + fExportMetadata = new Button(group, SWT.CHECK); + fExportMetadata.setText(PDEUIMessages.ExportWizard_includesMetadata); + + if (getWizard().getPages().length > 1) { + fMultiPlatform = new Button(group, SWT.CHECK); + fMultiPlatform.setText(PDEUIMessages.ExportWizard_multi_platform); + fMultiPlatform.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + getContainer().updateButtons(); + } + }); + } + + fAllowBinaryCycles = new Button(group, SWT.CHECK); + fAllowBinaryCycles.setText(PDEUIMessages.ExportOptionsTab_allowBinaryCycles); + } + + protected void initialize() { + IDialogSettings settings = getDialogSettings(); + fConfigurationGroup.initialize(fSelection, settings); + + String value = settings.get(S_SYNC_PRODUCT); + fSyncButton.setSelection(value == null ? true : settings.getBoolean(S_SYNC_PRODUCT)); + + fExportGroup.initialize(settings, fConfigurationGroup.getProductFile()); + + fExportSourceButton.setSelection(settings.getBoolean(S_EXPORT_SOURCE)); + fExportSourceCombo.setItems(new String[] {PDEUIMessages.ExportWizard_generateAssociatedSourceBundles, PDEUIMessages.ExportWizard_includeSourceInBinaryBundles}); + String sourceComboValue = settings.get(S_EXPORT_SOURCE_FORMAT) != null ? settings.get(S_EXPORT_SOURCE_FORMAT) : PDEUIMessages.ExportWizard_generateAssociatedSourceBundles; + fExportSourceCombo.setText(sourceComboValue); + fExportSourceCombo.setEnabled(fExportSourceButton.getSelection()); + + fExportMetadata.setSelection(settings.getBoolean(S_EXPORT_METADATA)); + + String selected = settings.get(S_ALLOW_BINARY_CYCLES); + fAllowBinaryCycles.setSelection(selected == null ? true : "true".equals(selected)); //$NON-NLS-1$ + + if (fMultiPlatform != null) + fMultiPlatform.setSelection(settings.getBoolean(S_MULTI_PLATFORM)); + + hookListeners(); + } + + protected void hookListeners() { + fExportSourceButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + fExportSourceCombo.setEnabled(fExportSourceButton.getSelection()); + } + }); + } + + protected void updateProductFields() { + fExportGroup.updateDestination(fConfigurationGroup.getProductFile()); + } + + protected void pageChanged() { + if (getMessage() != null) + setMessage(null); + String error = fConfigurationGroup.validate(); + if (error == null) + error = fExportGroup.validate(); + setErrorMessage(error); + setPageComplete(error == null); + } + + public IWizardPage getNextPage() { + return doMultiPlatform() ? getWizard().getNextPage(this) : null; + } + + protected void hookHelpContext(Control control) { + PlatformUI.getWorkbench().getHelpSystem().setHelp(control, IHelpContextIds.PRODUCT_EXPORT_WIZARD); + } + + protected void saveSettings(IDialogSettings settings) { + fConfigurationGroup.saveSettings(settings); + settings.put(S_SYNC_PRODUCT, fSyncButton.getSelection()); + fExportGroup.saveSettings(settings); + settings.put(S_EXPORT_SOURCE, doExportSource()); + settings.put(S_EXPORT_SOURCE_FORMAT, fExportSourceCombo.getItem(fExportSourceCombo.getSelectionIndex())); + settings.put(S_EXPORT_METADATA, doExportMetadata()); + settings.put(S_ALLOW_BINARY_CYCLES, doBinaryCycles()); + + if (fMultiPlatform != null) + settings.put(S_MULTI_PLATFORM, fMultiPlatform.getSelection()); + } + + protected boolean doSync() { + return fSyncButton.getSelection(); + } + + protected boolean doMultiPlatform() { + return fMultiPlatform != null && fMultiPlatform.getSelection(); + } + + protected boolean doExportSource() { + return fExportSourceButton.getSelection(); + } + + protected boolean doExportSourceBundles() { + return PDEUIMessages.ExportWizard_generateAssociatedSourceBundles.equals(fExportSourceCombo.getText()); + } + + protected boolean doBinaryCycles() { + return fAllowBinaryCycles.getSelection(); + } + + /** + * @return whether to generate p2 metadata on export + */ + protected boolean doExportMetadata() { + return fExportMetadata.getSelection(); + } + + protected boolean doExportToDirectory() { + return fExportGroup.doExportToDirectory(); + } + + protected String getFileName() { + return fExportGroup.getFileName(); + } + + protected String getDestination() { + return fExportGroup.getDestination(); + } + + protected String getRootDirectory() { + return fConfigurationGroup.getRootDirectory(); + } + + protected IFile getProductFile() { + return fConfigurationGroup.getProductFile(); + } + +}