mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 282854 - Add an import/export from file button to the Paths and Symbols page
This commit is contained in:
parent
4eb4fa693c
commit
c595624439
12 changed files with 163 additions and 7 deletions
BIN
core/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/obj16/export_settings_wiz.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 572 B |
BIN
core/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/obj16/import_settings_wiz.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 371 B |
|
@ -3161,7 +3161,7 @@
|
|||
<wizard
|
||||
category="org.eclipse.cdt.ui.exportWizardCategory"
|
||||
class="org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsExportWizard"
|
||||
icon="icons/obj16/hfolder_obj.gif"
|
||||
icon="icons/obj16/export_settings_wiz.gif"
|
||||
id="org.eclipse.cdt.ui.projectSettingsExportWizard"
|
||||
name="%projectSettingsIndexExportWizard.name">
|
||||
<selection
|
||||
|
@ -3289,7 +3289,7 @@
|
|||
<wizard
|
||||
category="org.eclipse.cdt.ui.importWizardCategory"
|
||||
class="org.eclipse.cdt.internal.ui.wizards.settingswizards.ProjectSettingsImportWizard"
|
||||
icon="icons/obj16/hfolder_obj.gif"
|
||||
icon="icons/obj16/import_settings_wiz.gif"
|
||||
id="org.eclipse.cdt.ui.projectSettingsImportWizard"
|
||||
name="%projectSettingsIndexExportWizard.name">
|
||||
<selection
|
||||
|
|
|
@ -121,6 +121,8 @@ public class CPluginImages {
|
|||
public static final String IMG_OBJS_EXCLUDSION_FILTER_ATTRIB= NAME_PREFIX + "exclusion_filter_attrib.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_SOURCE_ATTACH_ATTRIB = NAME_PREFIX + "source_attach_attrib.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_ARCHIVE_WSRC= NAME_PREFIX + "ar_src_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_IMPORT_SETTINGS = NAME_PREFIX + "import_settings_wiz.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_EXPORT_SETTINGS = NAME_PREFIX + "export_settings_wiz.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_OBJS_PROJECT=NAME_PREFIX + "prj_obj.gif"; //$NON-NLS-1$
|
||||
|
||||
|
@ -205,6 +207,8 @@ public class CPluginImages {
|
|||
public static final ImageDescriptor DESC_OBJS_ORDER= createManaged(T_OBJ, IMG_OBJS_ORDER);
|
||||
public static final ImageDescriptor DESC_OBJS_EXCLUSION_FILTER_ATTRIB = createManaged(T_OBJ, IMG_OBJS_EXCLUDSION_FILTER_ATTRIB);
|
||||
public static final ImageDescriptor DESC_OBJS_SOURCE_ATTACH_ATTRIB= createManaged(T_OBJ, IMG_OBJS_SOURCE_ATTACH_ATTRIB);
|
||||
public static final ImageDescriptor DESC_OBJS_IMPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_IMPORT_SETTINGS);
|
||||
public static final ImageDescriptor DESC_OBJS_EXPORT_SETTINGS = createManaged(T_OBJ, IMG_OBJS_EXPORT_SETTINGS);
|
||||
public static final ImageDescriptor DESC_OVR_PATH_INHERIT= create(T_OVR, "path_inherit_co.gif"); //$NON-NLS-1$
|
||||
public static final ImageDescriptor DESC_OVR_FOCUS= create(T_OVR, "focus_ovr.gif"); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -49,7 +49,9 @@ class Messages extends NLS {
|
|||
ProjectSettingsWizardPage_deselectAll,
|
||||
ProjectSettingsWizardPage_selectProject,
|
||||
ProjectSettingsWizardPage_browse,
|
||||
ProjectSettingsWizardPage_selectConfiguration;
|
||||
ProjectSettingsWizardPage_noOpenProjects,
|
||||
ProjectSettingsWizardPage_selectConfiguration,
|
||||
ProjectSettingsWizardPage_active;
|
||||
|
||||
// messages for settings processors
|
||||
public static String
|
||||
|
|
|
@ -25,6 +25,9 @@ public abstract class ProjectSettingsWizard extends Wizard {
|
|||
|
||||
public abstract ProjectSettingsWizardPage getPage();
|
||||
|
||||
private boolean finishedPressed;
|
||||
|
||||
|
||||
@Override
|
||||
public void addPages() {
|
||||
super.addPages();
|
||||
|
@ -41,9 +44,14 @@ public abstract class ProjectSettingsWizard extends Wizard {
|
|||
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
finishedPressed = true;
|
||||
return mainPage.finish();
|
||||
}
|
||||
|
||||
public boolean isFinishedPressed() {
|
||||
return finishedPressed;
|
||||
}
|
||||
|
||||
|
||||
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
||||
this.selection = selection;
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.wizards.settingswizards;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -36,6 +37,7 @@ import org.eclipse.swt.layout.GridLayout;
|
|||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
@ -52,6 +54,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
|||
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider;
|
||||
import org.eclipse.cdt.internal.ui.wizards.settingswizards.IProjectSettingsWizardPageStrategy.MessageType;
|
||||
|
||||
|
@ -163,6 +166,8 @@ abstract public class ProjectSettingsWizardPage extends WizardPage implements IP
|
|||
public void setDisplayedSettingsProcessors(List<ISettingsProcessor> 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<ICProject> openProjects = getAllOpenCProjects();
|
||||
Collections.sort(openProjects, new Comparator<ICProject>() {
|
||||
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);
|
||||
|
|
|
@ -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
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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...
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue