diff --git a/core/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif b/core/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif new file mode 100644 index 00000000000..b6bc7b268f4 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif differ diff --git a/core/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif b/core/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif new file mode 100644 index 00000000000..8ab627cc5b6 Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif differ diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 00736c953db..3fcec5c37fa 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -3161,7 +3161,7 @@ processors) { settingsViewer.setInput(processors); settingsViewer.refresh(); + settingsViewer.setAllChecked(true); + updateWidgetEnablements(); } @@ -225,6 +230,11 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP projectViewer.setContentProvider(new ListContentProvider()); projectViewer.setLabelProvider(new CElementLabelProvider()); List openProjects = getAllOpenCProjects(); + Collections.sort(openProjects, new Comparator() { + public int compare(ICProject o1, ICProject o2) { + return o1.getProject().getName().compareTo(o2.getProject().getName()); + } + }); projectViewer.setInput(openProjects); final Table configTable = new Table(projectSelectionGroup, SWT.SINGLE | SWT.BORDER); @@ -233,20 +243,28 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP final TableViewer configViewer = new TableViewer(configTable); configViewer.setContentProvider(new ListContentProvider()); configViewer.setLabelProvider(new LabelProvider() { + @Override public Image getImage(Object element) { + return CPluginImages.get(CPluginImages.IMG_OBJS_CONFIG); + } @Override public String getText(Object element) { - return ((ICConfigurationDescription)element).getName(); + ICConfigurationDescription config = (ICConfigurationDescription)element; + String label = config.getName(); + if(config.isActive()) + label += " (" + Messages.ProjectSettingsWizardPage_active + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + return label; } }); + // TODO what if nothing is selected? projectTable.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TableItem[] items = projectTable.getSelection(); selectedProject = (ICProject)items[0].getData(); // its a single select so this is ok - selectedConfiguration = null; configViewer.setInput(getConfigurations(selectedProject)); configViewer.refresh(); - updateWidgetEnablements(); + configTable.select(0); + configTable.notifyListeners(SWT.Selection, new Event()); } }); @@ -259,6 +277,15 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP } }); + if(openProjects.isEmpty()) { + setErrorMessage(Messages.ProjectSettingsWizardPage_noOpenProjects); + } + + + if((initialProject == null || !initialProject.isOpen()) && !openProjects.isEmpty()) { + initialProject = openProjects.get(0).getProject(); + } + if(initialProject != null) { String initialProjectName = initialProject.getName(); for(int i = 0; i < openProjects.size(); i++) { @@ -267,7 +294,9 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP projectTable.select(i); configViewer.setInput(getConfigurations(tableProject)); configViewer.refresh(); + configTable.select(0); selectedProject = tableProject; + selectedConfiguration = (ICConfigurationDescription)configTable.getSelection()[0].getData(); break; } } @@ -330,6 +359,7 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP settingsViewer.setLabelProvider(settingsProcessorLabelProvider); settingsViewer.setInput(processors); + settingsViewer.setAllChecked(true); Composite buttonComposite = new Composite(settingsSelectionGroup, SWT.NONE); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties index 227d511a8e1..e2fe2a07593 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/settingswizards/messages.properties @@ -32,13 +32,15 @@ ProjectSettingsWizardPage_Export_title=Export ProjectSettingsWizardPage_Export_message=Export C/C++ project settings for use in another workspace ProjectSettingsWizardPage_Export_selectSettings=Select settings to export ProjectSettingsWizardPage_Export_checkBox=Export folder and file specific settings -ProjectSettingsWizardPage_Export_file=Export destination +ProjectSettingsWizardPage_Export_file=Export to file ProjectSettingsWizardPage_selectAll=Select All ProjectSettingsWizardPage_deselectAll=Deselect All ProjectSettingsWizardPage_selectProject=Select Project ProjectSettingsWizardPage_selectConfiguration=Select Configuration ProjectSettingsWizardPage_browse=Browse... +ProjectSettingsWizardPage_noOpenProjects=There are no open projects +ProjectSettingsWizardPage_active=Active ProjectSettingsWizardPage_Processor_Macros=Symbols ProjectSettingsWizardPage_Processor_Includes=Include Paths \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java new file mode 100644 index 00000000000..64619ef779d --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/ImportExportWizardButtons.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * Copyright (c) 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.cdt.ui.newui; + +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.WizardDialog; +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.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; + +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsExportWizard; +import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsImportWizard; +import org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsWizard; + +/** + * Utility class that adds buttons for "Import Settings..." and "Export Settings..." + * to the bottom of the Includes and Symbols tabs. + * + * @since 5.2 + */ +class ImportExportWizardButtons { + + private ImportExportWizardButtons() {} + + + public static void addWizardLaunchButtons(final Composite parent, final IAdaptable selection) { + Composite comp = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(2, true); + layout.marginHeight = layout.marginWidth = 0; + comp.setLayout(layout); + GridData data = new GridData(); + data.horizontalSpan = 2; + comp.setLayoutData(data); + + Button importButton = new Button(comp, SWT.NONE); + importButton.setText(UIMessages.getString("IncludeTab.import")); //$NON-NLS-1$ + importButton.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_IMPORT_SETTINGS)); + importButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { + boolean finishedPressed = launchWizard(parent.getShell(), selection, false); + // There is no way to get the contents of the property page to update + // other than to close the whole dialog and then reopen it. + if(finishedPressed) + parent.getShell().close(); + } + }); + + Button exportButton = new Button(comp, SWT.NONE); + exportButton.setText(UIMessages.getString("IncludeTab.export")); //$NON-NLS-1$ + exportButton.setImage(CPluginImages.get(CPluginImages.IMG_OBJS_EXPORT_SETTINGS)); + exportButton.addSelectionListener(new SelectionAdapter() { + @Override public void widgetSelected(SelectionEvent e) { + launchWizard(parent.getShell(), selection, true); + } + }); + + } + + + private static boolean launchWizard(Shell shell, IAdaptable selection, boolean export) { + ProjectSettingsWizard wizard; + if(export) + wizard = new ProjectSettingsExportWizard(); + else + wizard = new ProjectSettingsImportWizard(); + + wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(selection)); + WizardDialog dialog = new WizardDialog(shell, wizard); + dialog.create(); + dialog.open(); + + return wizard.isFinishedPressed(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java index 94195dfe55b..3d906c1f8e3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/IncludeTab.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.ui.newui; import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.cdt.core.settings.model.CIncludePathEntry; @@ -65,4 +66,11 @@ public void additionalTableSet() { @Override public int getKind() { return ICSettingEntry.INCLUDE_PATH; } + + + @Override + public void createControls(final Composite parent) { + super.createControls(parent); + ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement()); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties index 60c001bc1c2..93630f139a1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/PluginResources.properties @@ -545,3 +545,6 @@ CProjectWizard.0=Add C Project Nature CCProjectWizard.0=Add CC Project Nature WorkingSetConfigAction.21=Building project WorkingSetConfigAction.22=Build error +IncludeTab.export=Export Settings... +IncludeTab.import=Import Settings... + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java index adecbcb0a00..8293f5a6151 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/SymbolTab.java @@ -16,6 +16,7 @@ import java.util.Collections; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleEvent; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.cdt.core.model.util.CDTListComparator; @@ -92,4 +93,12 @@ public class SymbolTab extends AbstractLangsListTab { updateLbs(lb1, lb2); updateButtons(); } + + + @Override + public void createControls(final Composite parent) { + super.createControls(parent); + showBIButton.setSelection(true); + ImportExportWizardButtons.addWizardLaunchButtons(usercomp, page.getElement()); + } }