1 package com.proalpha.java.oea.plugins.querygenerator.handlers;
3 import org.eclipse.core.commands.AbstractHandler;
4 import org.eclipse.core.commands.ExecutionEvent;
5 import org.eclipse.core.commands.ExecutionException;
6 import org.eclipse.ui.IEditorInput;
7 import org.eclipse.ui.IEditorPart;
8 import org.eclipse.ui.IWorkbenchPage;
9 import org.eclipse.ui.IWorkbenchWindow;
10 import org.eclipse.ui.PlatformUI;
11 import org.eclipse.ui.texteditor.ITextEditor;
13 import com.proalpha.java.oea.plugins.querygenerator.EditorTools;
18 public Object execute(ExecutionEvent event)
throws ExecutionException {
23 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
24 IWorkbenchPage page = window.getActivePage();
25 IEditorPart editorPart = page.getActiveEditor();
26 ITextEditor editor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);
30 IEditorInput editorInput = editor.getEditorInput();
32 String insertString =
"";
34 if (editorInput.getName().endsWith(
".cls"))
35 insertString =
"publish 'qgEvt_Snapshot':U from source-procedure%n"
37 +
" ${<Snapshot-Name>},%n"
38 +
" ${<Where-Option>}).";
41 insertString =
"publish 'qgEvt_Snapshot':U%n"
43 +
" ${<Snapshot-Name>},%n"
44 +
" ${<Where-Option>}).";
47 EditorTools.getInstance().insertText(editor, String.format(insertString));
49 window.getShell().setMinimized(
false);
58 public boolean isEnabled() {
63 public boolean isHandled() {