Changeset 66
- Timestamp:
- 06/28/08 04:51:20 (6 months ago)
- Files:
-
- axdt/trunk/org.axdt.feature/feature.xml (modified) (1 diff)
- axdt/trunk/org.axdt.mxml/META-INF/MANIFEST.MF (modified) (1 diff)
- axdt/trunk/org.axdt.mxml/plugin.xml (modified) (2 diffs)
- axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/actions (added)
- axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/actions/NewMxmlAction.java (added)
- axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/wizards/NewMxmlWizard.java (modified) (5 diffs)
- axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/wizards/NewMxmlWizardPage.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
axdt/trunk/org.axdt.feature/feature.xml
r59 r66 70 70 unpack="false"/> 71 71 72 <plugin 73 id="org.axdt.navigator" 74 download-size="0" 75 install-size="0" 76 version="0.0.0" 77 unpack="false"/> 78 72 79 </feature> axdt/trunk/org.axdt.mxml/META-INF/MANIFEST.MF
r58 r66 10 10 org.eclipse.core.resources, 11 11 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 13 15 Eclipse-LazyStart: true axdt/trunk/org.axdt.mxml/plugin.xml
r58 r66 3 3 <plugin> 4 4 <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.new Wizard">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"> 9 9 </wizard> 10 10 </extension> … … 27 27 </catalogContribution> 28 28 </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> 29 38 </plugin> axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/wizards/NewMxmlWizard.java
r58 r66 1 1 package org.axdt.mxml.wizards; 2 2 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; 3 import org.axdt.as3.wizards.AbstractFileWizard; 7 4 import org.eclipse.core.runtime.*; 8 5 import org.eclipse.jface.operation.*; 6 9 7 import java.lang.reflect.InvocationTargetException; 10 import org.eclipse.jface.dialogs.MessageDialog;11 import org.eclipse.jface.viewers.ISelection;12 8 import org.eclipse.core.resources.*; 13 9 import org.eclipse.core.runtime.CoreException; … … 16 12 import org.eclipse.ui.ide.IDE; 17 13 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 { 14 public class NewMxmlWizard extends AbstractFileWizard { 28 15 private NewMxmlWizardPage page; 29 private ISelection selection;30 31 /**32 * Constructor for NewMxmlWizard.33 */34 public NewMxmlWizard() {35 super();36 setNeedsProgressMonitor(true);37 }38 16 39 /**40 * Adding the page to the wizard.41 */42 43 17 public void addPages() { 44 18 page = new NewMxmlWizardPage(selection); … … 46 20 } 47 21 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() { 54 24 final String containerName = page.getContainerName(); 55 25 final String fileName = page.getFileName(); 56 IRunnableWithProgress op =new IRunnableWithProgress() {26 return new IRunnableWithProgress() { 57 27 public void run(IProgressMonitor monitor) throws InvocationTargetException { 58 28 try { … … 65 35 } 66 36 }; 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;77 37 } 78 38 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"; 90 42 // create a sample file 91 43 monitor.beginTask("Creating " + fileName, 2); 92 44 IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); 45 Path containerPath = new Path(containerName); 93 46 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)) { 95 55 throwCoreException("Container \"" + containerName + "\" does not exist."); 96 56 } 97 IContainer container = (IContainer) resource; 57 if (container == null) 58 container = (IContainer) resource; 98 59 final IFile file = container.getFile(new Path(fileName)); 99 60 try { … … 135 96 return new ByteArrayInputStream(contents.getBytes()); 136 97 } 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 if146 * 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 }152 98 } axdt/trunk/org.axdt.mxml/src/org/axdt/mxml/wizards/NewMxmlWizardPage.java
r58 r66 110 110 } 111 111 } 112 fileText.setText(" NewFile.mxml");112 fileText.setText(""); 113 113 } 114 114 … … 143 143 return; 144 144 } 145 if (container == null146 ||(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."); 148 148 return; 149 149 } 150 if ( !container.isAccessible()) {150 if (container != null && !container.isAccessible()) { 151 151 updateStatus("Project must be writable"); 152 152 return; … … 157 157 } 158 158 if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { 159 updateStatus("File name must be valid");159 updateStatus("File name must not contain slashes"); 160 160 return; 161 161 } 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; 169 165 } 170 166 updateStatus(null);
