diff options
author | Alexander Kurtakov | 2012-04-04 22:00:37 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2012-04-04 22:00:37 +0000 |
commit | fb3d92a51931192325a24902f19af64e03e6d410 (patch) | |
tree | c9dd990ceb84bec3f28c552843b523df3478aaa7 /changelog | |
parent | 1dbb4e97adef8cac14a4b1ef7f5efeb118fa1070 (diff) | |
download | org.eclipse.linuxtools-fb3d92a51931192325a24902f19af64e03e6d410.tar.gz org.eclipse.linuxtools-fb3d92a51931192325a24902f19af64e03e6d410.tar.xz org.eclipse.linuxtools-fb3d92a51931192325a24902f19af64e03e6d410.zip |
Make handlers use HandlerUtil to simplify.
Diffstat (limited to 'changelog')
2 files changed, 13 insertions, 24 deletions
diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java index b6ff4eb4bb..149a1fbbb5 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/InsertChangeLogKeyHandler.java @@ -24,7 +24,7 @@ import org.eclipse.linuxtools.internal.changelog.core.ChangeLogWriter; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; -import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; /** @@ -101,8 +101,7 @@ public class InsertChangeLogKeyHandler extends ChangeLogAction implements public Object execute(ExecutionEvent event) throws ExecutionException { try { - currentEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getActivePage().getActiveEditor(); + currentEditor = HandlerUtil.getActiveEditor(event); } catch (Exception e) { // no editor is active now so do nothing return null; diff --git a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java index d2874ee65f..939b76e794 100644 --- a/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java +++ b/changelog/org.eclipse.linuxtools.changelog.core/src/org/eclipse/linuxtools/internal/changelog/core/actions/PrepareChangelogKeyHandler.java @@ -17,8 +17,6 @@ import org.eclipse.core.commands.IHandler; import org.eclipse.core.commands.IHandlerListener; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.MessageDialog; @@ -26,7 +24,6 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.linuxtools.internal.changelog.core.ChangelogPlugin; import org.eclipse.linuxtools.internal.changelog.core.Messages; import org.eclipse.swt.widgets.Shell; import org.eclipse.team.ui.synchronize.ISynchronizeModelElement; @@ -39,6 +36,7 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.handlers.HandlerUtil; /** * @@ -59,8 +57,8 @@ public class PrepareChangelogKeyHandler extends ChangeLogAction implements IHand // try getting currently selected project try { - IWorkbenchPage ref = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IWorkbenchPart part = ref.getActivePart(); + IWorkbenchPage ref = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); + IWorkbenchPart part = HandlerUtil.getActivePart(event); if (part instanceof IEditorPart) { // If we are in an editor, check if the file being edited is an IResource // that belongs to a project in the workspace @@ -130,23 +128,15 @@ public class PrepareChangelogKeyHandler extends ChangeLogAction implements IHand } final IStructuredSelection result = tempResult; - try { - Action exampleAction; - exampleAction = new PrepareChangeLogAction() { - @Override - public void run() { - setSelection(result); - doRun(); - } - }; - - exampleAction.run(); + Action exampleAction = new PrepareChangeLogAction() { + @Override + public void run() { + setSelection(result); + doRun(); + } + }; - } catch (Exception e) { - ChangelogPlugin.getDefault().getLog().log( - new Status(IStatus.ERROR, ChangelogPlugin.PLUGIN_ID, IStatus.ERROR, - e.getMessage(), e)); - } + exampleAction.run(); return null; } |