new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / com / xaraya / wizard / NewXarayaResourceWizard.java
1 package com.xaraya.wizard;
2
3 import org.eclipse.core.resources.IFile;
4 import org.eclipse.core.resources.IFolder;
5 import org.eclipse.jface.viewers.IStructuredSelection;
6 import org.eclipse.ui.IWorkbench;
7 import org.eclipse.ui.IWorkbenchPage;
8 import org.eclipse.ui.IWorkbenchWindow;
9 import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
10
11 public class NewXarayaResourceWizard extends BasicNewResourceWizard {
12         
13     private XarayaModuleContainerPage mainPage;  //get where to place resource and module name
14     private XarayaModuleFilePage  page1;  //get first load of details author/email/which files
15
16         private XarayaVersionModel xvm = new XarayaVersionModel();  //holder for details
17                 
18 public NewXarayaResourceWizard() {
19         super();
20         //initialize static classes that are required..
21         new XarayaModuleText();  
22         new XarayaModuleMessages();
23 }
24
25 public void addPages() {
26         super.addPages();
27         mainPage = new XarayaModuleContainerPage(XarayaModuleMessages.getString("Xaraya.label.container"), getSelection());
28         addPage(mainPage);
29         page1 = new XarayaModuleFilePage(XarayaModuleMessages.getString("Xaraya.label.container"));
30         addPage(page1);
31 }
32
33 public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
34         super.init(workbench, currentSelection);
35         setWindowTitle(XarayaModuleMessages.getString("Xaraya.label.container"));
36         setNeedsProgressMonitor(true);
37 }
38
39 public boolean performFinish() {
40         page1.saveDataToModel();
41         IFolder folder = mainPage.createNewModuleFolder(); //create the folder for the module
42         if (folder == null)
43                 return false;
44
45         Object[] files = mainPage.createNewModuleFiles();  //create the files
46         
47         selectAndReveal(folder);        
48
49         // Open editor on new xaraya init file.
50         IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
51         try {
52                 IWorkbenchPage page = dw.getActivePage();
53                 if (page != null)
54                 page.openEditor((IFile)files[0]);
55         } catch (Exception e) {
56         }
57         
58         return true;
59 }
60
61 }