KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > wizards > newresource > BasicNewFolderResourceWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.wizards.newresource;
12
13 import org.eclipse.core.resources.IFolder;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.ui.IWorkbench;
17 import org.eclipse.ui.dialogs.WizardNewFolderMainPage;
18 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
19 import org.eclipse.ui.internal.wizards.newresource.ResourceMessages;
20
21 /**
22  * Standard workbench wizard that create a new folder resource in the workspace.
23  * <p>
24  * This class may be instantiated and used without further configuration;
25  * this class is not intended to be subclassed.
26  * </p>
27  * <p>
28  * Example:
29  * <pre>
30  * IWorkbenchWizard wizard = new BasicNewFolderResourceWizard();
31  * wizard.init(workbench, selection);
32  * WizardDialog dialog = new WizardDialog(shell, wizard);
33  * dialog.open();
34  * </pre>
35  * During the call to <code>open</code>, the wizard dialog is presented to the
36  * user. When the user hits Finish, a folder resource at the user-specified
37  * workspace path is created, the dialog closes, and the call to
38  * <code>open</code> returns.
39  * </p>
40  */

41 public class BasicNewFolderResourceWizard extends 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(ResourceMessages.NewFolder_text, getSelection());
57         addPage(mainPage);
58     }
59
60     /* (non-Javadoc)
61      * Method declared on IWorkbenchWizard.
62      */

63     public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
64         super.init(workbench, currentSelection);
65         setWindowTitle(ResourceMessages.NewFolder_title);
66         setNeedsProgressMonitor(true);
67     }
68
69     /* (non-Javadoc)
70      * Method declared on BasicNewResourceWizard.
71      */

72     protected void initializeDefaultPageImageDescriptor() {
73       ImageDescriptor desc = IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/newfolder_wiz.png");//$NON-NLS-1$
74
setDefaultPageImageDescriptor(desc);
75        
76     }
77
78     /* (non-Javadoc)
79      * Method declared on IWizard.
80      */

81     public boolean performFinish() {
82         IFolder folder = mainPage.createNewFolder();
83         if (folder == null) {
84             return false;
85         }
86
87         selectAndReveal(folder);
88
89         return true;
90     }
91 }
92
Popular Tags