From ef4e5c166a699f92ca2662430582a05c90e3f090 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Sun, 21 Aug 2005 02:48:27 +0000 Subject: [PATCH] 2005-08-20 Alain Magloire Fix PR 86802 106911 87497 : Assembly editor fixes. * src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java * src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java * src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java * plugin.xml --- core/org.eclipse.cdt.ui/ChangeLog | 7 + core/org.eclipse.cdt.ui/plugin.xml | 2 + .../asm/ASMEditorActionContributor.java | 9 ++ .../asm/AsmSourceViewerConfiguration.java | 3 +- .../internal/ui/editor/asm/AsmTextEditor.java | 124 +----------------- 5 files changed, 24 insertions(+), 121 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index f152c731105..3f141d5c5bb 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,10 @@ +2005-08-20 Alain Magloire + Fix PR 86802 106911 87497 : Assembly editor fixes. + * src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java + * src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java + * src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java + * plugin.xml + 2005-08-09 Chris Wiebe Fix bug# 106564: platform keybindings plugin.xml diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index b8c57e65756..06cddcaa07d 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -537,6 +537,8 @@ name="%AsmEditor.name" icon="icons/obj16/s_file_obj.gif" class="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor" + contributorClass="org.eclipse.cdt.internal.ui.editor.asm.ASMEditorActionContributor" + symbolicFontName="org.eclipse.cdt.ui.editors.textfont" id="org.eclipse.cdt.ui.editor.asm.AsmEditor"> diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java new file mode 100644 index 00000000000..aaa498eae4e --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/ASMEditorActionContributor.java @@ -0,0 +1,9 @@ +package org.eclipse.cdt.internal.ui.editor.asm; + +import org.eclipse.ui.editors.text.TextEditorActionContributor; + +public class ASMEditorActionContributor extends + TextEditorActionContributor { + + // nothing for now +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java index 858640473c8..00cfee03f31 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmSourceViewerConfiguration.java @@ -18,9 +18,10 @@ import org.eclipse.jface.text.rules.DefaultDamagerRepairer; import org.eclipse.jface.text.rules.RuleBasedScanner; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; +import org.eclipse.ui.editors.text.TextSourceViewerConfiguration; -public class AsmSourceViewerConfiguration extends SourceViewerConfiguration { +public class AsmSourceViewerConfiguration extends TextSourceViewerConfiguration { private AsmTextEditor fEditor; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java index 2bd5165947a..7d838dc0e9d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/asm/AsmTextEditor.java @@ -11,48 +11,21 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.editor.asm; -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import org.eclipse.cdt.internal.ui.editor.CEditorMessages; + import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.editors.text.TextEditor; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.texteditor.DefaultRangeIndicator; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; - - - /** * Assembly text editor */ -public class AsmTextEditor extends TextEditor { -//public class AsmTextEditor extends StatusTextEditor { -// FIXME: Should this editor have a different preference store ? -// For now we are sharing with the CEditor and any changes will in the -// setting of the CEditor will be reflected in this editor. - +public class AsmTextEditor extends TextEditor { /** * Creates a new text editor. */ public AsmTextEditor() { super(); - initializeEditor(); } /** * Initializes this editor. @@ -61,82 +34,13 @@ public class AsmTextEditor extends TextEditor { AsmTextTools textTools= CUIPlugin.getDefault().getAsmTextTools(); setSourceViewerConfiguration(new AsmSourceViewerConfiguration(textTools, this)); setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider()); - setRangeIndicator(new DefaultRangeIndicator()); // FIXME: Should this editor have a different preference store ? // For now we are sharing with the CEditor and any changes will in the // setting of the CEditor will be reflected in this editor. - setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore()); + setPreferenceStore(CUIPlugin.getDefault().getCombinedPreferenceStore()); setEditorContextMenuId("#ASMEditorContext"); //$NON-NLS-1$ setRulerContextMenuId("#ASMEditorRulerContext"); //$NON-NLS-1$ - //setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$ - } - - /** - * The TextEditor implementation of this - * IEditorPart method returns true. - */ - public boolean isSaveAsAllowed() { - return true; - } - /** - * The TextEditor implementation of this - * AbstractTextEditor method asks the user for the workspace path - * of a file resource and saves the document there. - */ - protected void performSaveAs(IProgressMonitor progressMonitor) { - /* - * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors. - * Changed Behavior to make sure that if called inside a regular save (because - * of deletion of input element) there is a way to report back to the caller. - */ - - Shell shell= getSite().getShell(); - - SaveAsDialog dialog= new SaveAsDialog(shell); - dialog.open(); - IPath path= dialog.getResult(); - - if (path == null) { - if (progressMonitor != null) - progressMonitor.setCanceled(true); - return; - } - - IWorkspace workspace= ResourcesPlugin.getWorkspace(); - IFile file= workspace.getRoot().getFile(path); - final IEditorInput newInput= new FileEditorInput(file); - - WorkspaceModifyOperation op= new WorkspaceModifyOperation() { - public void execute(final IProgressMonitor monitor) throws CoreException { - /* - * 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there - * Changed false to true. - */ - getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true); - } - }; - - boolean success= false; - try { - - getDocumentProvider().aboutToChange(newInput); - new ProgressMonitorDialog(shell).run(false, true, op); - success= true; - - } catch (InterruptedException x) { - } catch (InvocationTargetException x) { - // Shared with C editor - String title= CEditorMessages.getString("CEditor.error.saving.title"); //$NON-NLS-1$ - String msg= MessageFormat.format(CEditorMessages.getString("CEditor.error.saving.message"), new Object[] { x.getTargetException().getMessage() }); //$NON-NLS-1$ - MessageDialog.openError(shell, title, msg); - } finally { - getDocumentProvider().changed(newInput); - if (success) - setInput(newInput); - } - - if (progressMonitor != null) - progressMonitor.setCanceled(!success); + //setOutlinerContextMenuId("#ASMEditorOutlinerContext"); //$NON-NLS-1$ } /* @@ -152,25 +56,5 @@ public class AsmTextEditor extends TextEditor { return affects ? affects : super.affectsTextPresentation(event); } - - /* - * @see AbstractTextEditor#createActions() - * @since 2.0 - */ - protected void createActions() { - super.createActions(); - } - - - - /* - * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager) - * @since 2.0 - */ - protected void editorContextMenuAboutToShow(IMenuManager menu) { - super.editorContextMenuAboutToShow(menu); - addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_RIGHT); - addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_LEFT); - } }