diff options
3 files changed, 20 insertions, 68 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml b/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml index 2eda7897d2..09df3422d3 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml +++ b/changelog/org.eclipse.linuxtools.changelog.core/plugin.xml @@ -202,5 +202,18 @@ name="Changelog Detector"> </hyperlinkDetector> </extension> - +<extension point="org.eclipse.ui.menus"> + <menuContribution locationURI="popup:#TextEditorContext?endof=group.edit"> + <command commandId="org.eclipse.linuxtools.changelog.core.formatChangeLog"> + <visibleWhen + checkEnabled="false"> + <and> + <with variable="activeEditorId"> + <equals value="org.eclipse.linuxtools.changelog.core.editor6"/> + </with> + </and> + </visibleWhen> + </command> + </menuContribution> +</extension> </plugin> diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java index c693088542..82f197d05e 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/FormatChangeLogAction.java @@ -10,74 +10,30 @@ *******************************************************************************/ package org.eclipse.linuxtools.internal.changelog.core.actions; +import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.core.commands.IHandlerListener; -import org.eclipse.jface.action.Action; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.linuxtools.internal.changelog.core.editors.ChangeLogEditor; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; -public class FormatChangeLogAction extends Action implements IHandler { - - - ChangeLogEditor editor = null; - - public FormatChangeLogAction(ChangeLogEditor te) { - super("Format ChangeLog"); - editor = te; - } - - public FormatChangeLogAction() { - super("Format ChangeLog"); - //editor = te; - try { - editor = (ChangeLogEditor)PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().getActiveEditor(); - } catch (Exception e) { - // no editor is active now so do nothing - return; - } - } - - @Override - public void run() { +public class FormatChangeLogAction extends AbstractHandler { + public Object execute(ExecutionEvent event) throws ExecutionException { + ChangeLogEditor editor = (ChangeLogEditor) HandlerUtil.getActiveEditor(event); if (editor == null) - return; + return null; SourceViewer srcViewer = (SourceViewer)editor.getMySourceViewer(); if (srcViewer != null) { srcViewer.doOperation(ISourceViewer.FORMAT); } - - } - - public void addHandlerListener(IHandlerListener handlerListener) { - // TODO Auto-generated method stub - - } - - public void dispose() { - // TODO Auto-generated method stub - - } - - public Object execute(ExecutionEvent event) throws ExecutionException { - // TODO Auto-generated method stub - run(); return null; } - public void removeHandlerListener(IHandlerListener handlerListener) { - // TODO Auto-generated method stub - - } - } diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java index 61ce6cccb0..d848bc5bfd 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/editors/ChangeLogEditor.java @@ -19,16 +19,13 @@ import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; -import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.linuxtools.changelog.core.IEditorChangeLogContrib; import org.eclipse.linuxtools.internal.changelog.core.ChangelogPlugin; import org.eclipse.linuxtools.internal.changelog.core.Messages; -import org.eclipse.linuxtools.internal.changelog.core.actions.FormatChangeLogAction; import org.eclipse.ui.editors.text.TextEditor; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; /** @@ -38,15 +35,11 @@ import org.eclipse.ui.texteditor.ITextEditorActionConstants; */ public class ChangeLogEditor extends TextEditor { - FormatChangeLogAction fcla; - protected boolean forceNewLogEntry; public ChangeLogEditor() { super(); - fcla = new FormatChangeLogAction(this); - SourceViewerConfiguration config = getConfig(); if (config != null) { @@ -113,16 +106,6 @@ public class ChangeLogEditor extends TextEditor { return this.getSourceViewer(); } - /** - * Specifies context menu. - */ - @Override - protected void editorContextMenuAboutToShow(IMenuManager menu) { - super.editorContextMenuAboutToShow(menu); - menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fcla); - - } - public boolean isForceNewLogEntry() { return forceNewLogEntry; } |