Fixed bug 76816: [misc] Text and location of Open Untitled Text File
diff --git a/org.eclipse.ui.editors/icons/full/dtool16/new_untitled_text_file.gif b/org.eclipse.ui.editors/icons/full/dtool16/new_untitled_text_file.gif new file mode 100644 index 0000000..b226e41 --- /dev/null +++ b/org.eclipse.ui.editors/icons/full/dtool16/new_untitled_text_file.gif Binary files differ
diff --git a/org.eclipse.ui.editors/icons/full/etool16/new_untitled_text_file.gif b/org.eclipse.ui.editors/icons/full/etool16/new_untitled_text_file.gif new file mode 100644 index 0000000..b226e41 --- /dev/null +++ b/org.eclipse.ui.editors/icons/full/etool16/new_untitled_text_file.gif Binary files differ
diff --git a/org.eclipse.ui.editors/plugin.properties b/org.eclipse.ui.editors/plugin.properties index c12d09e..a0bf2c6 100644 --- a/org.eclipse.ui.editors/plugin.properties +++ b/org.eclipse.ui.editors/plugin.properties
@@ -36,9 +36,8 @@ openExternalFile.label= Open File&... openExternalFile.description= Opens a File -newTextEditor.name= Open Untitled Text File -newTextEditor.label= Open &Untitled Text File -newTextEditor.description= Creates and opens an empty untitled text file +NewUntitledTextFile.label= Untitled Text File +NewUntitledTextFile.description= Creates an empty untitled text file ActionDefinition.quickDiff.name= Quick Diff Toggle ActionDefinition.quickDiff.description= Toggles quick diff information display on the line number ruler @@ -69,8 +68,7 @@ Dummy.label= -openExternalFileActionSet.label= Open External Files -newTextEditorActionSet.label= Open Untitled Text Files +openFilesActionSet.label= Open Files textEditorAnnotationNavigationActionSet.label= Annotation Navigation goToPreviousAnnotation.label= Previous Annotation
diff --git a/org.eclipse.ui.editors/plugin.xml b/org.eclipse.ui.editors/plugin.xml index ba95a58..fb697d0 100644 --- a/org.eclipse.ui.editors/plugin.xml +++ b/org.eclipse.ui.editors/plugin.xml
@@ -57,13 +57,6 @@ id="org.eclipse.ui.edit.text.openExternalFile"> </command> <command - name="%newTextEditor.name" - categoryId="org.eclipse.ui.category.file" - description="%newTextEditor.description" - id="org.eclipse.ui.edit.text.newTextEditor"> - </command> - - <command name="%ActionDefinition.quickDiff.name" categoryId="org.eclipse.ui.category.edit" description="%ActionDefinition.quickDiff.description" @@ -312,10 +305,36 @@ </action> </editorContribution> </extension> + + <extension + point="org.eclipse.ui.newWizards"> + <wizard + name="%NewUntitledTextFile.label" + icon="icons/full/etool16/new_untitled_text_file.gif" + category="org.eclipse.ui.Basic" + class="org.eclipse.ui.internal.editors.text.UntitledTextFileWizard" + canFinishEarly="true" + hasPages="false" + id="org.eclipse.ui.editors.wizards.UntitledTextFileWizard"> + <description> + %NewUntitledTextFile.description + </description> + </wizard> + </extension> + <extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="org.eclipse.ui.resourcePerspective"> + <newWizardShortcut + id="org.eclipse.ui.editors.wizards.UntitledTextFileWizard"> + </newWizardShortcut> + </perspectiveExtension> + </extension> + <extension point="org.eclipse.ui.actionSets"> <actionSet - label="%openExternalFileActionSet.label" + label="%openFilesActionSet.label" visible="true" id="org.eclipse.ui.edit.text.actionSet.openExternalFile"> <action @@ -329,20 +348,6 @@ </action> </actionSet> <actionSet - label="%newTextEditorActionSet.label" - visible="true" - id="org.eclipse.ui.edit.text.actionSet.newTextEditor"> - <action - definitionId="org.eclipse.ui.edit.text.newTextEditor" - label="%newTextEditor.label" - helpContextId="new_text_editor_action_context" - class="org.eclipse.ui.internal.editors.text.NewTextEditorAction" - tooltip="%newTextEditor.description" - menubarPath="file/new.ext" - id="org.eclipse.ui.edit.text.newTextEditor"> - </action> - </actionSet> - <actionSet label="%textEditorAnnotationNavigationActionSet.label" visible="false" id="org.eclipse.ui.edit.text.actionSet.annotationNavigation">
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NewTextEditorAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UntitledTextFileWizard.java similarity index 69% rename from org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NewTextEditorAction.java rename to org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UntitledTextFileWizard.java index 3e62ade..2020099 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NewTextEditorAction.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UntitledTextFileWizard.java
@@ -11,29 +11,34 @@ package org.eclipse.ui.internal.editors.text; import java.io.File; + import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; + +import org.eclipse.ui.editors.text.EditorsUI; + import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorRegistry; +import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PartInitException; -import org.eclipse.ui.editors.text.EditorsUI; /** + * Wizard with no page that creates the untitled text file + * and opens the text editor. + * * @since 3.1 */ -public class NewTextEditorAction extends Action implements IWorkbenchWindowActionDelegate { +public class UntitledTextFileWizard extends Wizard implements INewWizard { private IWorkbenchWindow fWindow; - public NewTextEditorAction() { - setEnabled(true); + public UntitledTextFileWizard() { } /* @@ -43,42 +48,6 @@ fWindow= null; } - /* - * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow) - */ - public void init(IWorkbenchWindow window) { - fWindow= window; - } - - /* - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - run(); - } - - /* - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) { - // ignore - } - - /* - * @see org.eclipse.jface.action.Action#run() - */ - public void run() { - File file= queryFile(); - IEditorInput input= createEditorInput(file); - String editorId= getEditorId(file); - IWorkbenchPage page= fWindow.getActivePage(); - try { - page.openEditor(input, editorId); - } catch (PartInitException e) { - e.printStackTrace(); - } - } - private File queryFile() { IPath stateLocation= EditorsPlugin.getDefault().getStateLocation(); IPath path= stateLocation.append("/_" + new Object().hashCode()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -97,4 +66,28 @@ private IEditorInput createEditorInput(File file) { return new NonExistingFileEditorInput(file, TextEditorMessages.NewTextEditorAction_namePrefix); } + + /* + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + public boolean performFinish() { + File file= queryFile(); + IEditorInput input= createEditorInput(file); + String editorId= getEditorId(file); + IWorkbenchPage page= fWindow.getActivePage(); + try { + page.openEditor(input, editorId); + } catch (PartInitException e) { + EditorsPlugin.log(e); + return false; + } + return true; + } + + /* + * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + fWindow= workbench.getActiveWorkbenchWindow(); + } }