1 package org.opendaylight.nemo.tool.eclipse.plugin.rest.actions;
3 import java.io.IOException;
5 import org.apache.http.client.ClientProtocolException;
6 import org.apache.http.client.HttpClient;
7 import org.apache.http.client.methods.HttpPost;
8 import org.apache.http.impl.client.DefaultHttpClient;
9 import org.eclipse.jface.action.IAction;
10 import org.eclipse.jface.viewers.ISelection;
11 import org.eclipse.ui.IWorkbenchWindow;
12 import org.eclipse.ui.IWorkbenchWindowActionDelegate;
13 import org.opendaylight.nemo.tool.eclipse.plugin.rest.collectinfo.GetContent;
14 import org.eclipse.jface.dialogs.MessageDialog;
17 * Our sample action implements workbench action delegate. The action proxy will
18 * be created by the workbench and shown in the UI. When the user tries to use
19 * the action, this delegate will be created and execution will be delegated to
22 * @see IWorkbenchWindowActionDelegate
24 public class NemoAction implements IWorkbenchWindowActionDelegate {
25 private IWorkbenchWindow window;
34 * The action has been activated. The argument of the method represents the
35 * 'real' action sitting in the workbench UI.
37 * @see IWorkbenchWindowActionDelegate#run
39 public void run(IAction action) {
40 String content = GetContent.activeContent();
41 NemoParserImpl2 parserImpl = new NemoParserImpl2();
42 parserImpl.format(content);
43 boolean en = parserImpl.findRest();
45 showDialog("Please add engine info.");
47 boolean us = parserImpl.findUser();
49 showDialog("Please add user info.");
51 boolean result = parserImpl.send();
52 showDialog(parserImpl.getErrorInfo()+"\r\n"+parserImpl.getKeepResult());
58 private void showDialog(String log) {
59 MessageDialog.openInformation(window.getShell(), "Run", log);
63 * Selection in the workbench has been changed. We can change the state of
64 * the 'real' action here if we want, but this can only happen after the
65 * delegate has been created.
67 * @see IWorkbenchWindowActionDelegate#selectionChanged
69 public void selectionChanged(IAction action, ISelection selection) {
73 * We can use this method to dispose of any system resources we previously
76 * @see IWorkbenchWindowActionDelegate#dispose
78 public void dispose() {
82 * We will cache window object in order to be able to provide parent shell
83 * for the message dialog.
85 * @see IWorkbenchWindowActionDelegate#init
87 public void init(IWorkbenchWindow window) {