From 29eec1d60a161fef74d8a5d078a7c9e6af98e9b2 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 19 Mar 2007 15:17:58 +0000 Subject: [PATCH] Completed 167551, wizard to export index for use in other workspaces. --- .../core/pdom/TeamPDOMExportOperation.java | 9 +- .../core/pdom/indexer/IndexerPreferences.java | 22 +- .../icons/dtool16/exportzip_wiz.gif | Bin 0 -> 331 bytes .../icons/etool16/exportzip_wiz.gif | Bin 0 -> 571 bytes .../icons/wizban/exportzip_wiz.png | Bin 0 -> 7271 bytes core/org.eclipse.cdt.ui/plugin.properties | 5 +- core/org.eclipse.cdt.ui/plugin.xml | 20 ++ .../cdt/internal/ui/CPluginImages.java | 1 + .../ui/wizards/indexwizards/Messages.java | 33 ++ .../TeamProjectIndexExportWizard.java | 55 +++ .../TeamProjectIndexExportWizardPage.java | 320 ++++++++++++++++++ .../wizards/indexwizards/messages.properties | 18 + 12 files changed, 472 insertions(+), 11 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/wizban/exportzip_wiz.png create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java index b750afd0375..ae9210ccf24 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/TeamPDOMExportOperation.java @@ -84,25 +84,26 @@ public class TeamPDOMExportOperation implements IWorkspaceRunnable { PDOMManager pdomManager= CCoreInternals.getPDOMManager(); // wait for indexer - monitor.beginTask(Messages.TeamPDOMExportOperation_taskExportIndex, 100); - pdomManager.joinIndexer(Integer.MAX_VALUE, subMonitor(monitor, 80)); + monitor.beginTask("", 100); //$NON-NLS-1$ + pdomManager.joinIndexer(Integer.MAX_VALUE, subMonitor(monitor, 1)); checkMonitor(monitor); // create index IIndexLocationConverter converter= new ResourceContainerRelativeLocationConverter(ResourcesPlugin.getWorkspace().getRoot()); - monitor.subTask(Messages.TeamPDOMExportOperation_subtaskCreateDatabase); pdomManager.exportProjectPDOM(fProject, tmpPDOM, converter); checkMonitor(monitor); monitor.worked(5); // create checksums PDOM pdom= new PDOM(tmpPDOM, converter); - createChecksums(fProject, pdom, tmpChecksums, subMonitor(monitor, 10)); + monitor.setTaskName(Messages.Checksums_taskComputeChecksums); + createChecksums(fProject, pdom, tmpChecksums, subMonitor(monitor, 94)); // create archive createArchive(tmpPDOM, tmpChecksums); // store preferences + monitor.setTaskName(Messages.TeamPDOMExportOperation_taskExportIndex); IndexerPreferences.setIndexImportLocation(fProject.getProject(), fTargetLocation.toString()); } finally { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/IndexerPreferences.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/IndexerPreferences.java index df61e784f26..19588a283f4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/IndexerPreferences.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/IndexerPreferences.java @@ -302,12 +302,22 @@ public class IndexerPreferences { } public static String getIndexImportLocation(IProject project) { - Preferences[] prefs= new Preferences[] { - getProjectPreferences(project), - getInstancePreferences(), - getConfigurationPreferences(), - getDefaultPreferences() - }; + Preferences[] prefs; + if (project != null) { + prefs= new Preferences[] { + getProjectPreferences(project), + getInstancePreferences(), + getConfigurationPreferences(), + getDefaultPreferences() + }; + } + else { + prefs= new Preferences[] { + getInstancePreferences(), + getConfigurationPreferences(), + getDefaultPreferences() + }; + } return Platform.getPreferencesService().get(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION, prefs); } diff --git a/core/org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif b/core/org.eclipse.cdt.ui/icons/dtool16/exportzip_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..b285d84395c6d45d409eed19fd4ae2c92b0abfe1 GIT binary patch literal 331 zcmZ?wbhEHb6krfwxXQrr^XIQ0KYo7w`t9@QF9!}DdHm%0gNIMnZQOqK`t6&y?_axd z=flU(uU@}>{^He=73=3MTDfZ7md)GuZrZkI+|z@WmQ12P!o zCkD0*he-tqH6=rKulcF9_{WbO{`T9IT42^P-;&L|~80sdq!4?zwtuDL?-O5(}F!rlps N@)HVXxjHgf0|0ePgj@gs literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif b/core/org.eclipse.cdt.ui/icons/etool16/exportzip_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..b7a493ca2f1f8a6080b7bb849f7f8e9b456117b6 GIT binary patch literal 571 zcmZ?wbhEHb6krfwc*ek>=1{q8>(!56e(QKN8T++%PF?f!*B_h6KG(!4KIzkg^A-f> zF9^z=ACx;UIB$M%?!54##bE^tBTJUVRxD4dT@zQfc<-r)Pv86u$ekOQJ2yCgerVys z@Zv>L<;x;Vmqe8AvI>*KB2 z+ooa7sHmvM!_M3;Vy4vOvD~9w#Xxx(8=Ke4R#j7lCO0-wPcQdYVPp9w7jq^nCf8P3 zBcUcIOHomA=T002S=1^@s6A3-Z300009a7bBm000XU z000XU0RW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S5wYW}~tKS8a50^9|dud;3~6 zf^JwAp;9VidNL1EA?vg@ogvU>K~K{cRO{~3cYk>E!1sQ92z|K}0?qAhrrf}(;R0Sd zK8BZ$k7MA>G%ED~ficj`?G{?7*rP3aPare{gXey827zWcHtT=>{4GB{Gp-Ice9_C5 z!kxFtde;YbJfIXkTrL6Wn1!zF3S527Zp7koPflm(>}SP(|H&}=-0sN+1i8!EuTL;II#BgaQ?H`1zvsv(J8NU-n!7^U|FMo;kXH_trI7(Vc>2DJab5jh!_q)sgQ->uXS{ zH&LlJL*{A5M4^J0&rIN++qR9qW6S!V9XnO7q%B^_2&=IIz%Vh37;Tg;1x{(%z#<|e z^10mATmRvT_12kF4_@t_am2McTb_qo3myQ7cgg^X1_K*MVp%?t|Df{Dgx{Us9{W$vK z5md`1uwfX@bm4N1G)|7t*g65@<9U4K5UBg0VBFOB2Mh$|10ZDu{p$RMUuRG>lWKX;n2BY1ZTg z!6ITGAWRj5*e7ni_Ot)-$n#XqPu`78FScI28^3z$DHvu1dg<>ncs9T4=f9f%^hBY) z8vwe~379BM9X(a*5@S!^xO3Gh01)PQOIqc}0!*;aB4L*!61u)-X+(XG6rjoi@>mBF_D6{u^#SaF;@Ih?s+UEg{MYpMYN6RqB= z0jLvTMF7@MIoPt>d5m#ElRB z%YQzFK%3j=h|}w!<;)m3RSmm2yJQ3a7;olSppU8zlZ^fo2x3N# zMQol8+2I#&P55BI$n1KT)^XwXIv9$%s$(4uM{8sjuA7neI-AaY=XqhNi0A#S#m}9+ zrjImg3p}Xu--IQs9R)7M!lNh*vfm2J%+dRn4d^z0azCUC?b$;k%ud2 zsE#P)0f<461LzIc=C3qXwZZZORs_mk3`Sk4teRyOp<93+(8cNY*cQbIR~D-PKxxBq z0IM$+Pypaql)x1@6o5^15j)e4BA1BNl?c}V4* + + + + + + %teamProjectIndexExportWizard.description + + + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java index b9aa0716154..0a6fceca5e6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java @@ -263,6 +263,7 @@ public class CPluginImages { public static final ImageDescriptor DESC_WIZBAN_NEW_HEADERFILE= create(T_WIZBAN, "newhfile_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_WIZBAN_NEW_SOURCEFILE= create(T_WIZBAN, "newcfile_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_WIZBAN_NEWSRCFOLDR= create(T_WIZBAN, "newsrcfldr_wiz.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_WIZBAN_EXPORTINDEX= create(T_WIZBAN, "exportzip_wiz.png"); //$NON-NLS-1$ public static final ImageDescriptor DESC_TOOL_NEWCLASS= create(T_TOOL, "newclass_wiz.gif"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java new file mode 100644 index 00000000000..ae0f6aee21f --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/Messages.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. 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: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.wizards.indexwizards; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Messages { + private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.wizards.indexwizards.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + private Messages() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java new file mode 100644 index 00000000000..71cb5a45653 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizard.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. 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: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.wizards.indexwizards; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IExportWizard; +import org.eclipse.ui.IWorkbench; + +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.CPluginImages; + +public class TeamProjectIndexExportWizard extends Wizard implements IExportWizard { + private static final String DIALOG_SETTINGS_SECTION = "TeamProjectIndexExportWizard"; //$NON-NLS-1$ + private TeamProjectIndexExportWizardPage fMainPage; + private IStructuredSelection fSelection; + + public TeamProjectIndexExportWizard() { + IDialogSettings workbenchSettings = CUIPlugin.getDefault().getDialogSettings(); + IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS_SECTION); + if (section == null) { + section = workbenchSettings.addNewSection(DIALOG_SETTINGS_SECTION); + } + setDialogSettings(section); + } + + public void addPages() { + super.addPages(); + fMainPage = new TeamProjectIndexExportWizardPage(fSelection); + addPage(fMainPage); + } + + public boolean performFinish() { + return fMainPage.finish(); + } + + public void init(IWorkbench workbench, IStructuredSelection selection) { + fSelection= selection; + setWindowTitle(Messages.getString("TeamProjectIndexExportWizard.title")); //$NON-NLS-1$ + setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_EXPORTINDEX); + setNeedsProgressMonitor(true); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java new file mode 100644 index 00000000000..c157d7d5869 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/TeamProjectIndexExportWizardPage.java @@ -0,0 +1,320 @@ +/******************************************************************************* + * Copyright (c) 2007 Wind River Systems, Inc. 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: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.internal.ui.wizards.indexwizards; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.WizardDataTransferPage; + +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.ui.CElementLabelProvider; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.core.pdom.TeamPDOMExportOperation; +import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; + +import org.eclipse.cdt.internal.ui.viewsupport.ListContentProvider; + +public class TeamProjectIndexExportWizardPage extends WizardDataTransferPage implements Listener { + + private IStructuredSelection fInitialSelection; + private CheckboxTableViewer fProjectViewer; + private Text fDestinationField; + + /** + * Create an instance of this class + */ + protected TeamProjectIndexExportWizardPage(String name, IStructuredSelection selection) { + super(name); + fInitialSelection= selection; + } + + /** + * Create an instance of this class. + * + * @param selection the selection + */ + public TeamProjectIndexExportWizardPage(IStructuredSelection selection) { + this("indexExportPage", selection); //$NON-NLS-1$ + setTitle(Messages.getString("TeamProjectIndexExportWizardPage.title")); //$NON-NLS-1$ + setDescription(Messages.getString("TeamProjectIndexExportWizardPage.description")); //$NON-NLS-1$ + } + + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + Composite composite = new Composite(parent, SWT.NULL); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL + | GridData.HORIZONTAL_ALIGN_FILL)); + composite.setFont(parent.getFont()); + + createResourcesGroup(composite); +// createButtonsGroup(composite); + createDestinationGroup(composite); +// createOptionsGroup(composite); + + restoreWidgetValues(); + if (fInitialSelection != null) { + setupBasedOnInitialSelections(); + } + setupDestination(); + + updateWidgetEnablements(); + setPageComplete(determinePageCompletion()); + setErrorMessage(null); // should not initially have error message + + setControl(composite); + giveFocusToDestination(); + } + + /** + * Creates the checkbox tree and list for selecting resources. + * + * @param parent the parent control + */ + protected final void createResourcesGroup(Composite parent) { + Composite resourcesGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + resourcesGroup.setLayout(layout); + resourcesGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); + resourcesGroup.setFont(parent.getFont()); + + Table table= new Table(resourcesGroup, SWT.CHECK | SWT.BORDER); + table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fProjectViewer= new CheckboxTableViewer(table); + fProjectViewer.setContentProvider(new ListContentProvider()); + fProjectViewer.setLabelProvider(new CElementLabelProvider()); + ICheckStateListener listener = new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + updateWidgetEnablements(); + } + }; + fProjectViewer.addCheckStateListener(listener); + + initProjects(); + } + + private void initProjects() { + ArrayList input = new ArrayList(); + ICProject[] projects; + try { + projects = CoreModel.getDefault().getCModel().getCProjects(); + for (int i = 0; i < projects.length; i++) { + if (projects[i].getProject().isOpen()) { + input.add(projects[i]); + } + } + } catch (CModelException e) { + CUIPlugin.getDefault().log(e); + } + fProjectViewer.setInput(input); + } + + private void setupBasedOnInitialSelections() { + HashSet names= new HashSet(); + Iterator it = fInitialSelection.iterator(); + while (it.hasNext()) { + IProject project = (IProject) it.next(); + names.add(project.getName()); + } + + Collection prjs= (Collection) fProjectViewer.getInput(); + for (Iterator iterator = prjs.iterator(); iterator.hasNext();) { + ICProject prj = (ICProject) iterator.next(); + if (names.contains(prj.getElementName())) { + fProjectViewer.setChecked(prj, true); + } + } + } + + private void setupDestination() { + String dest; + ICProject[] prjs= getCheckedElements(); + if (prjs.length > 0) { + dest= IndexerPreferences.getIndexImportLocation(prjs[0].getProject()); + } + else { + dest= IndexerPreferences.getIndexImportLocation(null); + } + fDestinationField.setText(dest); + } + + + private void createDestinationGroup(Composite parent) { + Font font = parent.getFont(); + // destination specification group + Composite destinationSelectionGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + destinationSelectionGroup.setLayout(layout); + destinationSelectionGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL)); + destinationSelectionGroup.setFont(font); + + Label destinationLabel = new Label(destinationSelectionGroup, SWT.NONE); + destinationLabel.setText(Messages.getString("TeamProjectIndexExportWizardPage.destinationLabel")); //$NON-NLS-1$ + destinationLabel.setFont(font); + + // destination name entry field + fDestinationField = new Text(destinationSelectionGroup, SWT.BORDER); + fDestinationField.addListener(SWT.Modify, this); + fDestinationField.addListener(SWT.Selection, this); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + fDestinationField.setLayoutData(data); + fDestinationField.setFont(font); + + new Label(parent, SWT.NONE); // vertical spacer + } + + + public boolean finish() { + ICProject[] projectsToExport= getCheckedElements(); + + // about to invoke the operation so save our state + saveWidgetValues(); + + return executeExportOperation(projectsToExport); + } + + private ICProject[] getCheckedElements() { + Object[] obj= fProjectViewer.getCheckedElements(); + ICProject[] prjs= new ICProject[obj.length]; + System.arraycopy(obj, 0, prjs, 0, obj.length); + return prjs; + } + + private boolean executeExportOperation(final ICProject[] projects) { + final String dest= getDestinationValue(); + final MultiStatus status= new MultiStatus(CUIPlugin.PLUGIN_ID, + 0, Messages.getString("TeamProjectIndexExportWizardPage.errorWhileExporting"), null); //$NON-NLS-1$ + + IRunnableWithProgress op= new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { + monitor.beginTask("", projects.length); //$NON-NLS-1$ + for (int i = 0; i < projects.length; i++) { + ICProject project = projects[i]; + TeamPDOMExportOperation op= new TeamPDOMExportOperation(project); + op.setTargetLocation(dest); + try { + op.run(new SubProgressMonitor(monitor, 1)); + } catch (CoreException e) { + status.merge(e.getStatus()); + } + } + } + }; + try { + getContainer().run(true, true, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + displayErrorDialog(e.getTargetException()); + return false; + } + + if (!status.isOK()) { + ErrorDialog.openError(getContainer().getShell(), + getErrorDialogTitle(), + null, // no special message + status); + return false; + } + + return true; + } + + private String getDestinationValue() { + return fDestinationField.getText().trim(); + } + + private void giveFocusToDestination() { + fDestinationField.setFocus(); + } + + /** + * Answer a boolean indicating whether the receivers destination specification + * widgets currently all contain valid values. + */ + protected boolean validateDestinationGroup() { + String destinationValue = getDestinationValue(); + if (destinationValue.length() == 0) { + setMessage(Messages.getString("TeamProjectIndexExportWizardPage.noDestination")); //$NON-NLS-1$ + return false; + } + + setErrorMessage(null); + return true; + } + + protected boolean validateSourceGroup() { + // there must be some resources selected for Export + boolean isValid = true; + Object[] projectsToExport = getCheckedElements(); + if (projectsToExport.length == 0){ + setErrorMessage(Messages.getString("TeamProjectIndexExportWizardPage.noSelection")); //$NON-NLS-1$ + isValid = false; + } else { + setErrorMessage(null); + } + return super.validateSourceGroup() && isValid; + } + + protected void updateWidgetEnablements() { + boolean pageComplete = determinePageCompletion(); + setPageComplete(pageComplete); + if (pageComplete) { + setMessage(null); + } + super.updateWidgetEnablements(); + } + + + public void handleEvent(Event event) { + updateWidgetEnablements(); + } + + protected String getErrorDialogTitle() { + return Messages.getString("TeamProjectIndexExportWizardPage.errorDlgTitle"); //$NON-NLS-1$ + } + + protected boolean allowNewContainerName() { + return false; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties new file mode 100644 index 00000000000..a292e221840 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/indexwizards/messages.properties @@ -0,0 +1,18 @@ +############################################################################### +# Copyright (c) 2007 Wind River Systems, Inc. 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: +# Markus Schorn (Wind River Systems) +############################################################################### +TeamProjectIndexExportWizard.title=Export +TeamProjectIndexExportWizardPage.title=C/C++ index +TeamProjectIndexExportWizardPage.description=Export C/C++ index for use in other workspaces. +TeamProjectIndexExportWizardPage.destinationLabel=Export destination: +TeamProjectIndexExportWizardPage.errorWhileExporting=Errors occurred while exporting index +TeamProjectIndexExportWizardPage.noDestination=Enter a destination archive file. +TeamProjectIndexExportWizardPage.noSelection=At least one project must be selected. +TeamProjectIndexExportWizardPage.errorDlgTitle=Export C/C++ Index