01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.wizards.newresource;
11:
12: import org.eclipse.core.resources.IFolder;
13: import org.eclipse.jface.resource.ImageDescriptor;
14: import org.eclipse.jface.viewers.IStructuredSelection;
15: import org.eclipse.ui.IWorkbench;
16: import org.eclipse.ui.dialogs.WizardNewFolderMainPage;
17: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
18: import org.eclipse.ui.internal.wizards.newresource.ResourceMessages;
19:
20: /**
21: * Standard workbench wizard that create a new folder resource in the workspace.
22: * <p>
23: * This class may be instantiated and used without further configuration;
24: * this class is not intended to be subclassed.
25: * </p>
26: * <p>
27: * Example:
28: * <pre>
29: * IWorkbenchWizard wizard = new BasicNewFolderResourceWizard();
30: * wizard.init(workbench, selection);
31: * WizardDialog dialog = new WizardDialog(shell, wizard);
32: * dialog.open();
33: * </pre>
34: * During the call to <code>open</code>, the wizard dialog is presented to the
35: * user. When the user hits Finish, a folder resource at the user-specified
36: * workspace path is created, the dialog closes, and the call to
37: * <code>open</code> returns.
38: * </p>
39: */
40: public class BasicNewFolderResourceWizard extends
41: BasicNewResourceWizard {
42: private WizardNewFolderMainPage mainPage;
43:
44: /**
45: * Creates a wizard for creating a new folder resource in the workspace.
46: */
47: public BasicNewFolderResourceWizard() {
48: super ();
49: }
50:
51: /* (non-Javadoc)
52: * Method declared on IWizard.
53: */
54: public void addPages() {
55: super .addPages();
56: mainPage = new WizardNewFolderMainPage(
57: ResourceMessages.NewFolder_text, getSelection());
58: addPage(mainPage);
59: }
60:
61: /* (non-Javadoc)
62: * Method declared on IWorkbenchWizard.
63: */
64: public void init(IWorkbench workbench,
65: IStructuredSelection currentSelection) {
66: super .init(workbench, currentSelection);
67: setWindowTitle(ResourceMessages.NewFolder_title);
68: setNeedsProgressMonitor(true);
69: }
70:
71: /* (non-Javadoc)
72: * Method declared on BasicNewResourceWizard.
73: */
74: protected void initializeDefaultPageImageDescriptor() {
75: ImageDescriptor desc = IDEWorkbenchPlugin
76: .getIDEImageDescriptor("wizban/newfolder_wiz.png");//$NON-NLS-1$
77: setDefaultPageImageDescriptor(desc);
78:
79: }
80:
81: /* (non-Javadoc)
82: * Method declared on IWizard.
83: */
84: public boolean performFinish() {
85: IFolder folder = mainPage.createNewFolder();
86: if (folder == null) {
87: return false;
88: }
89:
90: selectAndReveal(folder);
91:
92: return true;
93: }
94: }
|