From f11db48d9bbba51a369c40ca644eefed910e2d68 Mon Sep 17 00:00:00 2001 From: Chris Wiebe Date: Fri, 24 Sep 2004 16:28:02 +0000 Subject: [PATCH] 2004-09-24 Chris Wiebe new folder wizards * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java * icons/full/ctool16/newsrcfldr_wiz.gif * icons/full/dtool16/newsrcfldr_wiz.gif * icons/full/etool16/newsrcfldr_wiz.gif * icons/full/wizban/newsrcfldr_wiz.gif * src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java * src/org/eclipse/cdt/internal/ui/CPluginImages.java * src/org/eclipse/cdt/internal/ui/ICHelpContextIDs.java * src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java * src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java * src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java * src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties * src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java * src/org/eclipse/cdt/ui/CUIPlugin.java * src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java * src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java * plugin.properties * plugin.xml --- core/org.eclipse.cdt.ui/ChangeLog | 22 + .../CBrowsingPerspectiveFactory.java | 31 +- .../icons/full/ctool16/newsrcfldr_wiz.gif | Bin 0 -> 352 bytes .../icons/full/dtool16/newsrcfldr_wiz.gif | Bin 0 -> 345 bytes .../icons/full/etool16/newsrcfldr_wiz.gif | Bin 0 -> 352 bytes .../icons/full/wizban/newsrcfldr_wiz.gif | Bin 0 -> 2904 bytes core/org.eclipse.cdt.ui/plugin.properties | 7 +- core/org.eclipse.cdt.ui/plugin.xml | 64 ++- .../cdt/internal/ui/CPerspectiveFactory.java | 17 +- .../cdt/internal/ui/CPluginImages.java | 1 + .../internal/ui/CPluginResources.properties | 21 - .../cdt/internal/ui/ICHelpContextIds.java | 1 + .../internal/ui/wizards/CWizardRegistry.java | 64 ++- .../ui/wizards/NewFolderDropDownAction.java | 23 + .../ui/wizards/OpenNewFolderWizardAction.java | 4 + .../folderwizard/NewFolderWizardMessages.java | 60 +++ .../NewFolderWizardMessages.properties | 51 ++ .../NewSourceFolderWizardPage.java | 488 ++++++++++++++++++ .../src/org/eclipse/cdt/ui/CUIPlugin.java | 1 - .../ui/wizards/NewFolderCreationWizard.java | 16 + .../NewSourceFolderCreationWizard.java | 60 +++ 21 files changed, 878 insertions(+), 53 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/icons/full/ctool16/newsrcfldr_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/dtool16/newsrcfldr_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/etool16/newsrcfldr_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/icons/full/wizban/newsrcfldr_wiz.gif create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index c4650791e4c..e8d9bf5068d 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,25 @@ +2004-09-24 Chris Wiebe + + new folder wizards + * browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java + * icons/full/ctool16/newsrcfldr_wiz.gif + * icons/full/dtool16/newsrcfldr_wiz.gif + * icons/full/etool16/newsrcfldr_wiz.gif + * icons/full/wizban/newsrcfldr_wiz.gif + * src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java + * src/org/eclipse/cdt/internal/ui/CPluginImages.java + * src/org/eclipse/cdt/internal/ui/ICHelpContextIDs.java + * src/org/eclipse/cdt/internal/ui/wizards/CWizardRegistry.java + * src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java + * src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java + * src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties + * src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java + * src/org/eclipse/cdt/ui/CUIPlugin.java + * src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java + * src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java + * plugin.properties + * plugin.xml + 2004-09-22 Chris Wiebe updated wizard banner icons to new look diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java index fd5e9c8c249..43981ac2d17 100644 --- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java +++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java @@ -75,22 +75,7 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory { layout.addShowInPart(CUIPlugin.CVIEW_ID); layout.addShowInPart(IPageLayout.ID_RES_NAV); - // new actions - C project creation wizard - String[] wizIDs = CWizardRegistry.getProjectWizardIDs(); - for (int i = 0; i < wizIDs.length; ++i) { - layout.addNewWizardShortcut(wizIDs[i]); - } - layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID); - // new actions - C type creation wizard - wizIDs = CWizardRegistry.getTypeWizardIDs(); - for (int i = 0; i < wizIDs.length; ++i) { - layout.addNewWizardShortcut(wizIDs[i]); - } - // new actions - C file creation wizard - wizIDs = CWizardRegistry.getFileWizardIDs(); - for (int i = 0; i < wizIDs.length; ++i) { - layout.addNewWizardShortcut(wizIDs[i]); - } + addCWizardShortcuts(layout); } public void createInitialLayout(IPageLayout layout) { @@ -127,14 +112,17 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory { layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); layout.addShowViewShortcut(IPageLayout.ID_RES_NAV); + addCWizardShortcuts(layout); + } + + private void addCWizardShortcuts(IPageLayout layout) { // new actions - C project creation wizard String[] wizIDs = CWizardRegistry.getProjectWizardIDs(); for (int i = 0; i < wizIDs.length; ++i) { layout.addNewWizardShortcut(wizIDs[i]); } - layout.addNewWizardShortcut(CUIPlugin.FOLDER_WIZARD_ID); - // new actions - C type creation wizard - wizIDs = CWizardRegistry.getTypeWizardIDs(); + // new actions - C folder creation wizard + wizIDs = CWizardRegistry.getFolderWizardIDs(); for (int i = 0; i < wizIDs.length; ++i) { layout.addNewWizardShortcut(wizIDs[i]); } @@ -143,6 +131,11 @@ public class CBrowsingPerspectiveFactory implements IPerspectiveFactory { for (int i = 0; i < wizIDs.length; ++i) { layout.addNewWizardShortcut(wizIDs[i]); } + // new actions - C type creation wizard + wizIDs = CWizardRegistry.getTypeWizardIDs(); + for (int i = 0; i < wizIDs.length; ++i) { + layout.addNewWizardShortcut(wizIDs[i]); + } } private void createVerticalLayout(IPageLayout layout) { diff --git a/core/org.eclipse.cdt.ui/icons/full/ctool16/newsrcfldr_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/ctool16/newsrcfldr_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..7caaa0fdae80dd36136eb7e0dfebcec30a743989 GIT binary patch literal 352 zcmZ?wbhEHb6krfwxXQq=<z-#f&HMNF{jZnv{(n95_sjYJzhD3Te17Xh<*k#H zcTHFOc7NKR=ZpV;JT$LTY+0k!vL>meO;YQ+1_w>tjc>imCy>i_%G{$DEjf3fuO!P?7{bS})a`S9S_kq*N*caChUP(RwL zv$jBWL$TV%Y`Onnz(68U{K>+|z@X2d1JVcb69ZfAf$0SvI#T`Ji?dcr>9Khxopvpq z7{__kVWGq-4i>kxlvxry94(1TA)@y_G`n2taA<3)xp#2CjRwDl6BA==E0buan1q;W zGb2L?1C!KLDQPM7e!Vs(h57U4HD}M2TP7zfqtic8Z?e(`B}GN;{x(J??OnTFsw&+N L96aRi$Y2csdB2rM literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/dtool16/newsrcfldr_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/dtool16/newsrcfldr_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..0e30f55d3882121c6736989a69a7475cf584d84e GIT binary patch literal 345 zcmZ?wbhEHb6krfwxXQrr|NsAg|Ni~_`Sbht@87)z#J3)>c$hl$4YJZDF7dQ2fcl$iSe)paU`<}Kc{SScVVDACy literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/etool16/newsrcfldr_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/etool16/newsrcfldr_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..7caaa0fdae80dd36136eb7e0dfebcec30a743989 GIT binary patch literal 352 zcmZ?wbhEHb6krfwxXQq=<z-#f&HMNF{jZnv{(n95_sjYJzhD3Te17Xh<*k#H zcTHFOc7NKR=ZpV;JT$LTY+0k!vL>meO;YQ+1_w>tjc>imCy>i_%G{$DEjf3fuO!P?7{bS})a`S9S_kq*N*caChUP(RwL zv$jBWL$TV%Y`Onnz(68U{K>+|z@X2d1JVcb69ZfAf$0SvI#T`Ji?dcr>9Khxopvpq z7{__kVWGq-4i>kxlvxry94(1TA)@y_G`n2taA<3)xp#2CjRwDl6BA==E0buan1q;W zGb2L?1C!KLDQPM7e!Vs(h57U4HD}M2TP7zfqtic8Z?e(`B}GN;{x(J??OnTFsw&+N L96aRi$Y2csdB2rM literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/icons/full/wizban/newsrcfldr_wiz.gif b/core/org.eclipse.cdt.ui/icons/full/wizban/newsrcfldr_wiz.gif new file mode 100644 index 0000000000000000000000000000000000000000..6b7f8e74c0df01dad87e2ddf448790bcacdc8942 GIT binary patch literal 2904 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 literal 0 HcmV?d00001 diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index b2b77b36963..41f3a0efd28 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -40,13 +40,16 @@ CElementCreationActionSet.description= C/C++ Element Creation Action Set NewProjectDropDownAction.label=&Project... NewProjectDropDownAction.tooltip=New C/C++ Project -OpenNewFolderWizardAction.label=&Folder -OpenNewFolderWizardAction.tooltip=New Folder +NewFolderDropDownAction.label=&Source Folder... +NewFolderDropDownAction.tooltip=New C/C++ Source Folder +NewWizards.sourceFolder = Source Folder +NewWizards.sourceFolder.description = Create a new source folder NewWizards.folder = Folder NewWizards.folder.description = Create a new folder resource NewFileDropDownAction.label=&Source File... NewFileDropDownAction.tooltip=New C/C++ Source File + NewWizards.sourceFile = Source File NewWizards.sourceFile.description = Create a new source file NewWizards.headerFile = Header File diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index c393713255f..ea992c2528a 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -348,6 +348,32 @@ %NewWizards.file.description + + + + + + %NewWizards.sourceFolder.description + + + + + + + + %NewWizards.folder.description + + + + + + + + %NewWizards.sourceFolder.description + + + + + + + + %NewWizards.folder.description + + + class="org.eclipse.cdt.internal.ui.wizards.NewFolderDropDownAction" + disabledIcon="icons/full/dtool16/newsrcfldr_wiz.gif" + icon="icons/full/etool16/newsrcfldr_wiz.gif" + label="%NewFolderDropDownAction.label" + pulldown="true" + tooltip="%NewFolderDropDownAction.tooltip"> + * + * + * + * + * My C Folder Wizard + * + * + * + * @return an array of IConfigurationElement + */ + public static IConfigurationElement[] getFolderWizardElements() { + List elemList = new ArrayList(); + IConfigurationElement[] elements = getAllWizardElements(); + for (int i = 0; i < elements.length; ++i) { + IConfigurationElement element = elements[i]; + if (isFolderWizard(element)) { + elemList.add(element); + } + } + return (IConfigurationElement[]) elemList.toArray(new IConfigurationElement[elemList.size()]); + } + + private static boolean isFolderWizard(IConfigurationElement element) { + IConfigurationElement[] classElements = element.getChildren(IWorkbenchConstants.TAG_CLASS); + if (classElements.length > 0) { + for (int i = 0; i < classElements.length; i++) { + IConfigurationElement[] paramElements = classElements[i].getChildren(TAG_PARAMETER); + for (int k = 0; k < paramElements.length; k++) { + IConfigurationElement curr = paramElements[k]; + String name = curr.getAttribute(TAG_NAME); + if (name != null && name.equals(ATT_CFOLDER)) { + String value = curr.getAttribute(TAG_VALUE); + if (value != null) + return Boolean.valueOf(value).booleanValue(); + } + } + } + } + return false; + } + public static IAction[] getFileWizardActions() { return createActions(getFileWizardElements()); } - + private static String[] getWizardIDs(IConfigurationElement[] elements) { List idList = new ArrayList(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java new file mode 100644 index 00000000000..4a641ba37b4 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/NewFolderDropDownAction.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. All rights reserved. This + * program and the accompanying materials are made available under the terms of + * the Common Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: QNX Software Systems - initial API and implementation + ******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards; + +import org.eclipse.jface.action.IAction; + +public class NewFolderDropDownAction extends AbstractWizardDropDownAction { + + public NewFolderDropDownAction() { + super(); +// WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_FOLDER_WIZARD_ACTION); + } + + protected IAction[] getWizardActions() { + return CWizardRegistry.getFolderWizardActions(); + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java index be3c13f4d64..d1e2e60a724 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/OpenNewFolderWizardAction.java @@ -17,6 +17,10 @@ import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard; import org.eclipse.cdt.ui.CUIPlugin; +/** + * @deprecated use NewFolderCreationWizard instead + */ + public class OpenNewFolderWizardAction extends Action implements IWorkbenchWindowActionDelegate { public void run() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java new file mode 100644 index 00000000000..3102cf7c282 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.folderwizard; + + +import java.text.MessageFormat; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + + +public class NewFolderWizardMessages { + + private static final String RESOURCE_BUNDLE= NewFolderWizardMessages.class.getName(); + private static ResourceBundle fgResourceBundle; + static { + try { + fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE); + } catch (MissingResourceException x) { + fgResourceBundle = null; + } + } + + private NewFolderWizardMessages() { + } + + public static String getString(String key) { + try { + return fgResourceBundle.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } catch (NullPointerException e) { + return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + /** + * Gets a string from the resource bundle and formats it with the argument + * + * @param key the string used to get the bundle value, must not be null + */ + public static String getFormattedString(String key, Object arg) { + return MessageFormat.format(getString(key), new Object[] { arg }); + } + + /** + * Gets a string from the resource bundle and formats it with arguments + */ + public static String getFormattedString(String key, Object[] args) { + return MessageFormat.format(getString(key), args); + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties new file mode 100644 index 00000000000..50d6e55f6fe --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewFolderWizardMessages.properties @@ -0,0 +1,51 @@ +############################################################################### +# Copyright (c) 2004 QNX Software Systems and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Common Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/cpl-v10.html +# +# Contributors: +# QNX Software Systems - Initial API and implementation +############################################################################### + +# ------- NewSourceFolderCreationWizard ------- +NewSourceFolderCreationWizard.title= New Source Folder + +# ------- NewSourceFolderWizardPage------- + +NewSourceFolderCreationWizard.title=New Source Folder + +NewSourceFolderWizardPage.title=Source folder +NewSourceFolderWizardPage.description=Add a new source folder + +NewSourceFolderWizardPage.root.label=Fol&der name: +NewSourceFolderWizardPage.root.button=Br&owse... + +NewSourceFolderWizardPage.project.label=Project &name: +NewSourceFolderWizardPage.project.button=Bro&wse... + +NewSourceFolderWizardPage.operation=Creating new source folder... + +NewSourceFolderWizardPage.exclude.label=&Update exclusion filters in other source folders to solve nesting. + +NewSourceFolderWizardPage.ChooseExistingRootDialog.title=Existing Folder Selection +NewSourceFolderWizardPage.ChooseExistingRootDialog.description=&Choose folder as source folder: + +NewSourceFolderWizardPage.ChooseProjectDialog.title=Project Selection +NewSourceFolderWizardPage.ChooseProjectDialog.description=&Choose project for the new source folder: + +NewSourceFolderWizardPage.error.EnterRootName=Root name must be entered. +NewSourceFolderWizardPage.error.InvalidRootName=Invalid folder name. {0} +NewSourceFolderWizardPage.error.NotAFolder=Not a folder. +NewSourceFolderWizardPage.error.AlreadyExisting=The folder is already a source folder. + +NewSourceFolderWizardPage.error.EnterProjectName=Project name must be entered. +NewSourceFolderWizardPage.error.InvalidProjectPath=Invalid project path. +NewSourceFolderWizardPage.error.NotACProject=Project is not a C project. +NewSourceFolderWizardPage.error.ProjectNotExists=Project does not exist. + +NewSourceFolderWizardPage.warning.ReplaceSFandOL=To avoid overlapping, the existing project source folder entry will be replaced and the output folder set to ''{0}''. +NewSourceFolderWizardPage.warning.ReplaceOL=An exclusion pattern will be added to the project source folder entry and the output folder will be set to ''{0}''. +NewSourceFolderWizardPage.warning.ReplaceSF=To avoid overlapping, the existing project source folder entry will be replaced. +NewSourceFolderWizardPage.warning.AddedExclusions=Exclusion patterns of {0} source folder(s) updated to solve nesting. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java new file mode 100644 index 00000000000..7e06d6653fd --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/folderwizard/NewSourceFolderWizardPage.java @@ -0,0 +1,488 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.wizards.folderwizard; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.cdt.core.CCProjectNature; +import org.eclipse.cdt.core.CProjectNature; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.CoreModelUtil; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICModelStatus; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.IPathEntry; +import org.eclipse.cdt.core.model.ISourceEntry; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.internal.core.model.PathEntryManager; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.dialogs.TypedElementSelectionValidator; +import org.eclipse.cdt.internal.ui.dialogs.TypedViewerFilter; +import org.eclipse.cdt.internal.ui.util.CoreUtility; +import org.eclipse.cdt.internal.ui.util.EditorUtility; +import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.IStringButtonAdapter; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField; +import org.eclipse.cdt.internal.ui.wizards.dialogfields.StringButtonDialogField; +import org.eclipse.cdt.ui.CElementLabelProvider; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; +import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; +import org.eclipse.ui.dialogs.ISelectionStatusValidator; +import org.eclipse.ui.help.WorkbenchHelp; +import org.eclipse.ui.model.WorkbenchContentProvider; +import org.eclipse.ui.model.WorkbenchLabelProvider; +import org.eclipse.ui.views.navigator.ResourceSorter; + +public class NewSourceFolderWizardPage extends NewElementWizardPage { + + private static final String PAGE_NAME= "NewSourceFolderWizardPage"; //$NON-NLS-1$ + + private StringButtonDialogField fProjectField; + private StatusInfo fProjectStatus; + + private StringButtonDialogField fRootDialogField; + private StatusInfo fRootStatus; + + private SelectionButtonDialogField fExcludeInOthersFields; + + private IWorkspaceRoot fWorkspaceRoot; + + private ICProject fCurrCProject; + private IPathEntry[] fEntries; + + private IPathEntry[] fNewEntries; + + private boolean fIsProjectAsSourceFolder; + + private ISourceRoot fCreatedRoot; + + public NewSourceFolderWizardPage() { + super(PAGE_NAME); + + setTitle(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.title")); //$NON-NLS-1$ + setDescription(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.description")); //$NON-NLS-1$ + + fWorkspaceRoot= ResourcesPlugin.getWorkspace().getRoot(); + + RootFieldAdapter adapter= new RootFieldAdapter(); + + fProjectField= new StringButtonDialogField(adapter); + fProjectField.setDialogFieldListener(adapter); + fProjectField.setLabelText(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.project.label")); //$NON-NLS-1$ + fProjectField.setButtonLabel(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.project.button")); //$NON-NLS-1$ + + fRootDialogField= new StringButtonDialogField(adapter); + fRootDialogField.setDialogFieldListener(adapter); + fRootDialogField.setLabelText(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.root.label")); //$NON-NLS-1$ + fRootDialogField.setButtonLabel(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.root.button")); //$NON-NLS-1$ + + fExcludeInOthersFields= new SelectionButtonDialogField(SWT.CHECK); + fExcludeInOthersFields.setDialogFieldListener(adapter); + fExcludeInOthersFields.setLabelText(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.exclude.label")); //$NON-NLS-1$ + +//TODO fExcludeInOthersFields.setEnabled(CoreModel.ENABLED.equals(CoreModel.getOption(CoreModel.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS))); + + fRootStatus= new StatusInfo(); + fProjectStatus= new StatusInfo(); + } + + // -------- Initialization --------- + + public void init(IStructuredSelection selection) { + if (selection == null || selection.isEmpty()) { + setDefaultAttributes(); + return; + } + + Object selectedElement= selection.getFirstElement(); + if (selectedElement == null) { + selectedElement= EditorUtility.getActiveEditorCInput(); + } + + String projPath= null; + + if (selectedElement instanceof IResource) { + IProject proj= ((IResource)selectedElement).getProject(); + if (proj != null) { + projPath= proj.getFullPath().makeRelative().toString(); + } + } else if (selectedElement instanceof ICElement) { + ICProject jproject= ((ICElement)selectedElement).getCProject(); + if (jproject != null) { + projPath= jproject.getProject().getFullPath().makeRelative().toString(); + } + } + + if (projPath != null) { + fProjectField.setText(projPath); + fRootDialogField.setText(""); //$NON-NLS-1$ + } else { + setDefaultAttributes(); + } + } + + private void setDefaultAttributes() { + String projPath= ""; //$NON-NLS-1$ + + try { + // find the first C project + IProject[] projects= fWorkspaceRoot.getProjects(); + for (int i= 0; i < projects.length; i++) { + IProject proj= projects[i]; + if (proj.hasNature(CProjectNature.C_NATURE_ID) || proj.hasNature(CCProjectNature.CC_NATURE_ID)) { + projPath= proj.getFullPath().makeRelative().toString(); + break; + } + } + } catch (CoreException e) { + // ignore here + } + fProjectField.setText(projPath); + fRootDialogField.setText(""); //$NON-NLS-1$ + } + + + // -------- UI Creation --------- + + /* + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + public void createControl(Composite parent) { + initializeDialogUnits(parent); + + Composite composite= new Composite(parent, SWT.NONE); + + GridLayout layout= new GridLayout(); + layout.marginWidth= 0; + layout.marginHeight= 0; + layout.numColumns= 3; + composite.setLayout(layout); + + fProjectField.doFillIntoGrid(composite, 3); + fRootDialogField.doFillIntoGrid(composite, 3); + fExcludeInOthersFields.doFillIntoGrid(composite, 3); + + int maxFieldWidth= convertWidthInCharsToPixels(40); + LayoutUtil.setWidthHint(fProjectField.getTextControl(null), maxFieldWidth); + LayoutUtil.setHorizontalGrabbing(fProjectField.getTextControl(null)); + LayoutUtil.setWidthHint(fRootDialogField.getTextControl(null), maxFieldWidth); + + setControl(composite); + Dialog.applyDialogFont(composite); + WorkbenchHelp.setHelp(composite, ICHelpContextIds.NEW_SRCFLDER_WIZARD_PAGE); + } + + /* + * @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean) + */ + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + fRootDialogField.setFocus(); + } + } + + // -------- ContainerFieldAdapter -------- + + private class RootFieldAdapter implements IStringButtonAdapter, IDialogFieldListener { + + // -------- IStringButtonAdapter + public void changeControlPressed(DialogField field) { + packRootChangeControlPressed(field); + } + + // -------- IDialogFieldListener + public void dialogFieldChanged(DialogField field) { + packRootDialogFieldChanged(field); + } + } + protected void packRootChangeControlPressed(DialogField field) { + if (field == fRootDialogField) { + IPath initialPath= new Path(fRootDialogField.getText()); + String title= NewFolderWizardMessages.getString("NewSourceFolderWizardPage.ChooseExistingRootDialog.title"); //$NON-NLS-1$ + String message= NewFolderWizardMessages.getString("NewSourceFolderWizardPage.ChooseExistingRootDialog.description"); //$NON-NLS-1$ + IFolder folder= chooseFolder(title, message, initialPath); + if (folder != null) { + IPath path= folder.getFullPath().removeFirstSegments(1); + fRootDialogField.setText(path.toString()); + } + } else if (field == fProjectField) { + ICProject jproject= chooseProject(); + if (jproject != null) { + IPath path= jproject.getProject().getFullPath().makeRelative(); + fProjectField.setText(path.toString()); + } + } + } + + protected void packRootDialogFieldChanged(DialogField field) { + if (field == fRootDialogField) { + updateRootStatus(); + } else if (field == fProjectField) { + updateProjectStatus(); + updateRootStatus(); + } else if (field == fExcludeInOthersFields) { + updateRootStatus(); + } + updateStatus(new IStatus[] { fProjectStatus, fRootStatus }); + } + + + private void updateProjectStatus() { + fCurrCProject= null; + fIsProjectAsSourceFolder= false; + + String str= fProjectField.getText(); + if (str.length() == 0) { + fProjectStatus.setError(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.error.EnterProjectName")); //$NON-NLS-1$ + return; + } + IPath path= new Path(str); + if (path.segmentCount() != 1) { + fProjectStatus.setError(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.error.InvalidProjectPath")); //$NON-NLS-1$ + return; + } + IProject project= fWorkspaceRoot.getProject(path.toString()); + if (!project.exists()) { + fProjectStatus.setError(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.error.ProjectNotExists")); //$NON-NLS-1$ + return; + } + try { + if (project.hasNature(CProjectNature.C_NATURE_ID) || project.hasNature(CCProjectNature.CC_NATURE_ID)) { + fCurrCProject= CoreModel.getDefault().create(project); + fEntries= fCurrCProject.getRawPathEntries(); + fProjectStatus.setOK(); + return; + } + } catch (CoreException e) { + CUIPlugin.getDefault().log(e); + fCurrCProject= null; + } + fProjectStatus.setError(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.error.NotACProject")); //$NON-NLS-1$ + } + + private void updateRootStatus() { + fRootDialogField.enableButton(fCurrCProject != null); + fIsProjectAsSourceFolder= false; + if (fCurrCProject == null) { + return; + } + fRootStatus.setOK(); + + IPath projPath= fCurrCProject.getProject().getFullPath(); + String str= fRootDialogField.getText(); + if (str.length() == 0) { + fRootStatus.setError(NewFolderWizardMessages.getFormattedString("NewSourceFolderWizardPage.error.EnterRootName", fCurrCProject.getProject().getFullPath().toString())); //$NON-NLS-1$ + } else { + IPath path= projPath.append(str); + IStatus validate= fWorkspaceRoot.getWorkspace().validatePath(path.toString(), IResource.FOLDER); + if (validate.matches(IStatus.ERROR)) { + fRootStatus.setError(NewFolderWizardMessages.getFormattedString("NewSourceFolderWizardPage.error.InvalidRootName", validate.getMessage())); //$NON-NLS-1$ + } else { + IResource res= fWorkspaceRoot.findMember(path); + if (res != null) { + if (res.getType() != IResource.FOLDER) { + fRootStatus.setError(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.error.NotAFolder")); //$NON-NLS-1$ + return; + } + } + ArrayList newEntries= new ArrayList(fEntries.length + 1); + int projectEntryIndex= -1; + + for (int i= 0; i < fEntries.length; i++) { + IPathEntry curr= fEntries[i]; + if (curr.getEntryKind() == IPathEntry.CDT_SOURCE) { + if (path.equals(curr.getPath())) { + fRootStatus.setError(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.error.AlreadyExisting")); //$NON-NLS-1$ + return; + } + if (projPath.equals(curr.getPath())) { + projectEntryIndex= i; + } + } + newEntries.add(curr); + } + + IPathEntry newEntry= CoreModel.newSourceEntry(path); + + Set modified= new HashSet(); + if (fExcludeInOthersFields.isSelected()) { + addExclusionPatterns(newEntry, newEntries, modified); + newEntries.add(CoreModel.newSourceEntry(path)); + } else { + if (projectEntryIndex != -1) { + fIsProjectAsSourceFolder= true; + newEntries.set(projectEntryIndex, newEntry); + } else { + newEntries.add(CoreModel.newSourceEntry(path)); + } + } + + fNewEntries= (IPathEntry[]) newEntries.toArray(new IPathEntry[newEntries.size()]); + + ICModelStatus status= PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries); + if (!status.isOK()) { + IStatus status2= PathEntryManager.getDefault().validatePathEntry(fCurrCProject, fNewEntries); + if (status2.isOK()) { + return; + } + fRootStatus.setError(status.getMessage()); + return; + } else if (fIsProjectAsSourceFolder) { + fRootStatus.setInfo(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.warning.ReplaceSF")); //$NON-NLS-1$ + return; + } + if (!modified.isEmpty()) { + fRootStatus.setInfo(NewFolderWizardMessages.getFormattedString("NewSourceFolderWizardPage.warning.AddedExclusions", String.valueOf(modified.size()))); //$NON-NLS-1$ + return; + } + } + } + } + + private void addExclusionPatterns(IPathEntry newEntry, List existing, Set modifiedEntries) { + IPath entryPath= newEntry.getPath(); + for (int i= 0; i < existing.size(); i++) { + IPathEntry curr= (IPathEntry) existing.get(i); + IPath currPath= curr.getPath(); + if (curr.getEntryKind() == IPathEntry.CDT_SOURCE && currPath.isPrefixOf(entryPath)) { + IPath[] exclusionFilters= ((ISourceEntry)curr).getExclusionPatterns(); + if (!CoreModelUtil.isExcludedPath(entryPath, exclusionFilters)) { + IPath pathToExclude= entryPath.removeFirstSegments(currPath.segmentCount()).addTrailingSeparator(); + IPath[] newExclusionFilters= new IPath[exclusionFilters.length + 1]; + System.arraycopy(exclusionFilters, 0, newExclusionFilters, 0, exclusionFilters.length); + newExclusionFilters[exclusionFilters.length]= pathToExclude; + + IPathEntry updated= CoreModel.newSourceEntry(currPath, newExclusionFilters); + existing.set(i, updated); + modifiedEntries.add(updated); + } + } + } + } + + // ---- creation ---------------- + + public ISourceRoot getNewSourceRoot() { + return fCreatedRoot; + } + + public IResource getCorrespondingResource() { + return fCurrCProject.getProject().getFolder(fRootDialogField.getText()); + } + + public void createSourceRoot(IProgressMonitor monitor) throws CoreException, InterruptedException { + if (monitor == null) { + monitor= new NullProgressMonitor(); + } + monitor.beginTask(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.operation"), 3); //$NON-NLS-1$ + try { + IPath projPath= fCurrCProject.getProject().getFullPath(); + String relPath= fRootDialogField.getText(); + + IFolder folder= fCurrCProject.getProject().getFolder(relPath); + if (!folder.exists()) { + CoreUtility.createFolder(folder, true, true, new SubProgressMonitor(monitor, 1)); + } + if (monitor.isCanceled()) { + throw new InterruptedException(); + } + + fCurrCProject.setRawPathEntries(fNewEntries, new SubProgressMonitor(monitor, 2)); + + fCreatedRoot= fCurrCProject.findSourceRoot(folder); + } finally { + monitor.done(); + } + } + + // ------------- choose dialogs + + private IFolder chooseFolder(String title, String message, IPath initialPath) { + Class[] acceptedClasses= new Class[] { IFolder.class }; + ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); + ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null); + + ILabelProvider lp= new WorkbenchLabelProvider(); + ITreeContentProvider cp= new WorkbenchContentProvider(); + + IProject currProject= fCurrCProject.getProject(); + + ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp); + dialog.setValidator(validator); + dialog.setTitle(title); + dialog.setMessage(message); + dialog.addFilter(filter); + dialog.setInput(currProject); + dialog.setSorter(new ResourceSorter(ResourceSorter.NAME)); + IResource res= currProject.findMember(initialPath); + if (res != null) { + dialog.setInitialSelection(res); + } + + if (dialog.open() == Window.OK) { + return (IFolder) dialog.getFirstResult(); + } + return null; + } + + private ICProject chooseProject() { + ICProject[] projects; + try { + projects= CoreModel.create(fWorkspaceRoot).getCProjects(); + } catch (CModelException e) { + CUIPlugin.getDefault().log(e); + projects= new ICProject[0]; + } + + ILabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_DEFAULT); + ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), labelProvider); + dialog.setTitle(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.ChooseProjectDialog.title")); //$NON-NLS-1$ + dialog.setMessage(NewFolderWizardMessages.getString("NewSourceFolderWizardPage.ChooseProjectDialog.description")); //$NON-NLS-1$ + dialog.setElements(projects); + dialog.setInitialSelections(new Object[] { fCurrCProject }); + if (dialog.open() == Window.OK) { + return (ICProject) dialog.getFirstResult(); + } + return null; + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 8d53a94bac9..c896c38d830 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -91,7 +91,6 @@ public class CUIPlugin extends AbstractUIPlugin { public final static String CWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCWizards"; //$NON-NLS-1$ public final static String CCWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCCWizards"; //$NON-NLS-1$ - public static final String FOLDER_WIZARD_ID = "org.eclipse.cdt.ui.wizards.NewFolderCreationWizard"; //$NON-NLS-1$ public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$ public static final String BUILDER_ID = PLUGIN_CORE_ID + ".cbuilder"; //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java new file mode 100644 index 00000000000..5faa8c5cbee --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewFolderCreationWizard.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.wizards; + +import org.eclipse.ui.wizards.newresource.BasicNewFolderResourceWizard; + +public class NewFolderCreationWizard extends BasicNewFolderResourceWizard { +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java new file mode 100644 index 00000000000..377b4e0dac0 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/wizards/NewSourceFolderCreationWizard.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2000, 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.wizards; + +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.wizards.NewElementWizard; +import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewFolderWizardMessages; +import org.eclipse.cdt.internal.ui.wizards.folderwizard.NewSourceFolderWizardPage; +import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +public class NewSourceFolderCreationWizard extends NewElementWizard { + + private NewSourceFolderWizardPage fPage; + + public NewSourceFolderCreationWizard() { + super(); + setDefaultPageImageDescriptor(CPluginImages.DESC_WIZBAN_NEWSRCFOLDR); + setDialogSettings(CUIPlugin.getDefault().getDialogSettings()); + setWindowTitle(NewFolderWizardMessages.getString("NewSourceFolderCreationWizard.title")); //$NON-NLS-1$ + } + + /* + * @see Wizard#addPages + */ + public void addPages() { + super.addPages(); + fPage= new NewSourceFolderWizardPage(); + addPage(fPage); + fPage.init(getSelection()); + } + + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor) + */ + protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException { + fPage.createSourceRoot(monitor); // use the full progress monitor + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.IWizard#performFinish() + */ + public boolean performFinish() { + boolean res= super.performFinish(); + if (res) { + selectAndReveal(fPage.getCorrespondingResource()); + } + return res; + } + +}