private void makeActions() {
scheduleAction = new Action() {
public void run() {
IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
final Job j = (Job) sel.getFirstElement();
org.eclipse.core.runtime.jobs.Job sj = new org.eclipse.core.runtime.jobs.Job("Scheduling Hudson build") {
protected IStatus run(IProgressMonitor monitor) {
try {
new HudsonClient().scheduleJob(j.getName());
} catch (IOException e1) {
return new Status(Status.ERROR, Activator.PLUGIN_ID, 0, "Unable to schedule job", e1);
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
viewer.refresh();
}
});
return Status.OK_STATUS;
}
};
sj.setPriority(org.eclipse.core.runtime.jobs.Job.INTERACTIVE);
sj.schedule();
}
};
scheduleAction.setText("Schedule new build");
scheduleAction.setToolTipText("Schedule new build for project");
scheduleAction.setImageDescriptor(Activator.getImageDescriptor("icons/schedule.png"));
scheduleAction.setEnabled(false);
openBrowserAction = new Action() {
public void run() {
IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
openBrowser(sel);
}
};
openBrowserAction.setText("Open in browser");
openBrowserAction.setToolTipText("Open job status in browser");
openBrowserAction.setEnabled(false);
viewConsoleAction = new Action() {
public void run() {
IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
Job j = (Job) sel.getFirstElement();
String url = baseUrl + "/job/" + j.getName() + "/lastBuild/consoleText";
openBrowser(url, "Console output");
}
};
viewConsoleAction.setText("View console output");
viewConsoleAction.setToolTipText("Open the console output for the latest build");
viewConsoleAction.setEnabled(false);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
scheduleAction.setEnabled(sel.size() == 1);
openBrowserAction.setEnabled(sel.size() == 1);
Job j = (Job) sel.getFirstElement();
viewConsoleAction.setEnabled(sel.size() == 1 && j.getLastBuild() != null);
}
});
refreshAction = new Action() {
public void run() {