| /******************************************************************************* |
| * Copyright (c) 2000, 2003 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.ui.wizards.newresource; |
| |
| import java.net.MalformedURLException; |
| import java.net.URL; |
| |
| import org.eclipse.core.resources.IFolder; |
| import org.eclipse.core.runtime.Platform; |
| import org.eclipse.jface.resource.ImageDescriptor; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.ui.IWorkbench; |
| import org.eclipse.ui.PlatformUI; |
| import org.eclipse.ui.dialogs.WizardNewFolderMainPage; |
| |
| /** |
| * Standard workbench wizard that create a new folder resource in the workspace. |
| * <p> |
| * This class may be instantiated and used without further configuration; |
| * this class is not intended to be subclassed. |
| * </p> |
| * <p> |
| * Example: |
| * <pre> |
| * IWorkbenchWizard wizard = new BasicNewFolderResourceWizard(); |
| * wizard.init(workbench, selection); |
| * WizardDialog dialog = new WizardDialog(shell, wizard); |
| * dialog.open(); |
| * </pre> |
| * During the call to <code>open</code>, the wizard dialog is presented to the |
| * user. When the user hits Finish, a folder resource at the user-specified |
| * workspace path is created, the dialog closes, and the call to |
| * <code>open</code> returns. |
| * </p> |
| */ |
| public class BasicNewFolderResourceWizard extends BasicNewResourceWizard { |
| private WizardNewFolderMainPage mainPage; |
| /** |
| * Creates a wizard for creating a new folder resource in the workspace. |
| */ |
| public BasicNewFolderResourceWizard() { |
| super(); |
| } |
| /* (non-Javadoc) |
| * Method declared on IWizard. |
| */ |
| public void addPages() { |
| super.addPages(); |
| mainPage = new WizardNewFolderMainPage(ResourceMessages.getString("NewFolder.text"), getSelection()); //$NON-NLS-1$ |
| addPage(mainPage); |
| } |
| /* (non-Javadoc) |
| * Method declared on IWorkbenchWizard. |
| */ |
| public void init(IWorkbench workbench, IStructuredSelection currentSelection) { |
| super.init(workbench, currentSelection); |
| setWindowTitle(ResourceMessages.getString("NewFolder.title")); //$NON-NLS-1$ |
| setNeedsProgressMonitor(true); |
| } |
| /* (non-Javadoc) |
| * Method declared on BasicNewResourceWizard. |
| */ |
| protected void initializeDefaultPageImageDescriptor() { |
| String iconPath = "icons/full/";//$NON-NLS-1$ |
| try { |
| URL installURL = Platform.getPlugin(PlatformUI.PLUGIN_ID).getDescriptor().getInstallURL(); |
| URL url = new URL(installURL, iconPath + "wizban/newfolder_wiz.gif");//$NON-NLS-1$ |
| ImageDescriptor desc = ImageDescriptor.createFromURL(url); |
| setDefaultPageImageDescriptor(desc); |
| } |
| catch (MalformedURLException e) { |
| // Should not happen. Ignore. |
| } |
| } |
| /* (non-Javadoc) |
| * Method declared on IWizard. |
| */ |
| public boolean performFinish() { |
| IFolder folder = mainPage.createNewFolder(); |
| if (folder == null) |
| return false; |
| |
| selectAndReveal(folder); |
| |
| return true; |
| } |
| } |