1 package com.proalpha.java.oea.plugins.querygenerator.handlers;
3 import org.eclipse.swt.widgets.Display;
4 import org.eclipse.ui.IEditorPart;
5 import org.eclipse.ui.IWorkbenchPage;
6 import org.eclipse.ui.IWorkbenchWindow;
7 import org.eclipse.ui.PlatformUI;
8 import org.eclipse.ui.texteditor.ITextEditor;
10 import com.openedge.core.runtime.IAVMInputCommandHandler;
11 import com.openedge.core.runtime.IAVMInputRequest;
12 import com.proalpha.java.oea.plugins.querygenerator.EditorTools;
16 private static int requestId = 0;
18 private String responseValue =
"";
21 public String getName() {
22 return "InsertTextToEditor";
26 public String getResponse() {
31 public boolean needResponse() {
36 public void processRequest(IAVMInputRequest inputRequest) {
38 if (inputRequest ==
null)
42 Display.getDefault().syncExec(
new InsertCommand(inputRequest.getMessage()));
46 private class InsertCommand
implements Runnable {
48 private String insertString =
"";
50 public InsertCommand(String insertString) {
52 this.insertString = insertString;
58 IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
59 IWorkbenchPage page = window.getActivePage();
60 IEditorPart editorPart = page.getActiveEditor();
61 ITextEditor editor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);
63 EditorTools.getInstance().insertText(editor, insertString);
65 window.getShell().setMinimized(
false);
69 responseValue = String.format(
"IDEWindowHandle=%d", window.getShell().handle);
75 public static int getRequestId() {
79 public static void setRequestId(
int requestId) {