Changeset 66

Show
Ignore:
Timestamp:
06/28/08 04:51:20 (6 months ago)
Author:
mb0
Message:
  1. fixed and cleaned up mxml wizard.
  2. add mxml wizard to navigator and perspective
  3. added new navigator to feature
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • axdt/trunk/org.axdt.feature/feature.xml

    r59 r66  
    7070         unpack="false"/> 
    7171 
     72   <plugin 
     73         id="org.axdt.navigator" 
     74         download-size="0" 
     75         install-size="0" 
     76         version="0.0.0" 
     77         unpack="false"/> 
     78 
    7279</feature> 
  • axdt/trunk/org.axdt.mxml/META-INF/MANIFEST.MF

    r58 r66  
    1010 org.eclipse.core.resources, 
    1111 org.eclipse.ui.ide, 
    12  org.eclipse.wst.sse.ui 
     12 org.eclipse.wst.sse.ui, 
     13 org.eclipse.ui.navigator, 
     14 org.axdt.as3 
    1315Eclipse-LazyStart: true 
  • axdt/trunk/org.axdt.mxml/plugin.xml

    r58 r66  
    33<plugin> 
    44        <extension point="org.eclipse.ui.newWizards"> 
    5                 <category name="AXDT" id="org.axdt.mxml"></category> 
    6                 <wizard name="MXML file" icon="icons/mxml_file.gif" 
    7                         category="org.axdt.mxml" class="org.axdt.mxml.wizards.NewMxmlWizard" 
    8                         id="org.axdt.mxml.wizards.newWizard"> 
     5                <category name="AXDT" id="org.axdt.category"></category> 
     6                <wizard name="MXML File" icon="icons/mxml_file.gif" 
     7                        category="org.axdt.category" class="org.axdt.mxml.wizards.NewMxmlWizard" 
     8                        id="org.axdt.mxml.wizards.newMxmlWizard"> 
    99                </wizard> 
    1010        </extension> 
     
    2727                </catalogContribution> 
    2828        </extension> 
     29        <extension 
     30         point="org.eclipse.ui.perspectiveExtensions"> 
     31      <perspectiveExtension 
     32            targetID="org.axdt.as3.perspective"> 
     33         <newWizardShortcut 
     34               id="org.axdt.mxml.wizards.newWizard"> 
     35         </newWizardShortcut> 
     36      </perspectiveExtension> 
     37    </extension> 
    2938</plugin> 
  • axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/wizards/NewMxmlWizard.java

    r58 r66  
    11package org.axdt.mxml.wizards; 
    22 
    3 import org.eclipse.jface.viewers.IStructuredSelection; 
    4 import org.eclipse.jface.wizard.Wizard; 
    5 import org.eclipse.ui.INewWizard; 
    6 import org.eclipse.ui.IWorkbench; 
     3import org.axdt.as3.wizards.AbstractFileWizard; 
    74import org.eclipse.core.runtime.*; 
    85import org.eclipse.jface.operation.*; 
     6 
    97import java.lang.reflect.InvocationTargetException; 
    10 import org.eclipse.jface.dialogs.MessageDialog; 
    11 import org.eclipse.jface.viewers.ISelection; 
    128import org.eclipse.core.resources.*; 
    139import org.eclipse.core.runtime.CoreException; 
     
    1612import org.eclipse.ui.ide.IDE; 
    1713 
    18 /** 
    19  * This is a sample new wizard. Its role is to create a new file  
    20  * resource in the provided container. If the container resource 
    21  * (a folder or a project) is selected in the workspace  
    22  * when the wizard is opened, it will accept it as the target 
    23  * container. The wizard creates one file with the extension 
    24  * "mxml". 
    25  */ 
    26  
    27 public class NewMxmlWizard extends Wizard implements INewWizard { 
     14public class NewMxmlWizard extends AbstractFileWizard { 
    2815        private NewMxmlWizardPage page; 
    29         private ISelection selection; 
    30  
    31         /** 
    32          * Constructor for NewMxmlWizard. 
    33          */ 
    34         public NewMxmlWizard() { 
    35                 super(); 
    36                 setNeedsProgressMonitor(true); 
    37         } 
    3816         
    39         /** 
    40          * Adding the page to the wizard. 
    41          */ 
    42  
    4317        public void addPages() { 
    4418                page = new NewMxmlWizardPage(selection); 
     
    4620        } 
    4721 
    48         /** 
    49          * This method is called when 'Finish' button is pressed in 
    50          * the wizard. We will create an operation and run it 
    51          * using wizard as execution context. 
    52          */ 
    53         public boolean performFinish() { 
     22        @Override 
     23        protected IRunnableWithProgress getRunnableFinish() { 
    5424                final String containerName = page.getContainerName(); 
    5525                final String fileName = page.getFileName(); 
    56                 IRunnableWithProgress op = new IRunnableWithProgress() { 
     26                return new IRunnableWithProgress() { 
    5727                        public void run(IProgressMonitor monitor) throws InvocationTargetException { 
    5828                                try { 
     
    6535                        } 
    6636                }; 
    67                 try { 
    68                         getContainer().run(true, false, op); 
    69                 } catch (InterruptedException e) { 
    70                         return false; 
    71                 } catch (InvocationTargetException e) { 
    72                         Throwable realException = e.getTargetException(); 
    73                         MessageDialog.openError(getShell(), "Error", realException.getMessage()); 
    74                         return false; 
    75                 } 
    76                 return true; 
    7737        } 
    7838         
    79         /** 
    80          * The worker method. It will find the container, create the 
    81          * file if missing or just replace its contents, and open 
    82          * the editor on the newly created file. 
    83          */ 
    84  
    85         private void doFinish( 
    86                 String containerName, 
    87                 String fileName, 
    88                 IProgressMonitor monitor) 
    89                 throws CoreException { 
     39        private void doFinish(String containerName,     String fileName,  
     40                        IProgressMonitor monitor) throws CoreException { 
     41                fileName = fileName +".mxml"; 
    9042                // create a sample file 
    9143                monitor.beginTask("Creating " + fileName, 2); 
    9244                IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 
     45                Path containerPath = new Path(containerName); 
    9346                IResource resource = root.findMember(new Path(containerName)); 
    94                 if (!resource.exists() || !(resource instanceof IContainer)) { 
     47                IContainer container = null; 
     48                if (resource == null || !resource.exists()) { 
     49                        if (containerPath.segmentCount()>1 
     50                                        && root.getProject(containerPath.segment(0)).exists()) { 
     51                                IProject project = root.getProject(containerPath.segment(0)); 
     52                                container = createFolder(project, containerPath, monitor); 
     53                        } 
     54                } else if (!(resource instanceof IContainer)) { 
    9555                        throwCoreException("Container \"" + containerName + "\" does not exist."); 
    9656                } 
    97                 IContainer container = (IContainer) resource; 
     57                if (container == null) 
     58                        container = (IContainer) resource; 
    9859                final IFile file = container.getFile(new Path(fileName)); 
    9960                try { 
     
    13596                return new ByteArrayInputStream(contents.getBytes()); 
    13697        } 
    137  
    138         private void throwCoreException(String message) throws CoreException { 
    139                 IStatus status = 
    140                         new Status(IStatus.ERROR, "org.axdt.mxml", IStatus.OK, message, null); 
    141                 throw new CoreException(status); 
    142         } 
    143  
    144         /** 
    145          * We will accept the selection in the workbench to see if 
    146          * we can initialize from it. 
    147          * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) 
    148          */ 
    149         public void init(IWorkbench workbench, IStructuredSelection selection) { 
    150                 this.selection = selection; 
    151         } 
    15298} 
  • axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/wizards/NewMxmlWizardPage.java

    r58 r66  
    110110                        } 
    111111                } 
    112                 fileText.setText("NewFile.mxml"); 
     112                fileText.setText(""); 
    113113        } 
    114114 
     
    143143                        return; 
    144144                } 
    145                 if (container == null 
    146                                 || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { 
    147                         updateStatus("File container must exist"); 
     145                if (container != null 
     146                                && (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { 
     147                        updateStatus("File has to be a container."); 
    148148                        return; 
    149149                } 
    150                 if (!container.isAccessible()) { 
     150                if (container != null && !container.isAccessible()) { 
    151151                        updateStatus("Project must be writable"); 
    152152                        return; 
     
    157157                } 
    158158                if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { 
    159                         updateStatus("File name must be valid"); 
     159                        updateStatus("File name must not contain slashes"); 
    160160                        return; 
    161161                } 
    162                 int dotLoc = fileName.lastIndexOf('.'); 
    163                 if (dotLoc != -1) { 
    164                         String ext = fileName.substring(dotLoc + 1); 
    165                         if (ext.equalsIgnoreCase("mxml") == false) { 
    166                                 updateStatus("File extension must be \"mxml\""); 
    167                                 return; 
    168                         } 
     162                if (fileName.indexOf('.') > 0) { 
     163                        updateStatus("File name must not contain dots"); 
     164                        return; 
    169165                } 
    170166                updateStatus(null);