use of org.eclipse.core.commands.ExecutionException in project linuxtools by eclipse.
the class RunScriptHandler method prepareNonLocalScript.
/**
* Attempts to set up a channel for a script that runs on a non-local host or user.
* @return <code>true</code> on success, <code>false</code> on failure.
* @throws ExecutionException If failure occurs during a (non-simple) launch,
* this will throw an exception instead of returning <code>false</code>.
*/
private void prepareNonLocalScript() throws ExecutionException {
try {
ScpClient scpclient = new ScpClient(remoteOptions);
// $NON-NLS-1$
tmpfileName = new Path("/tmp").append(getFileName(fileName)).toOSString();
scpclient.transfer(fileName, tmpfileName);
} catch (final JSchException | IOException e) {
String message = e instanceof JSchException ? // $NON-NLS-1$
Localization.getString("RunScriptHandler.checkCredentials") : // $NON-NLS-1$
Localization.getString("RunScriptHandler.ioError");
throw new ExecutionException(message, e);
}
}
use of org.eclipse.core.commands.ExecutionException in project yamcs-studio by yamcs.
the class ExportEventsHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
EventLogView eventLogView = (EventLogView) part;
// Ask for file to export
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.csv" });
String targetFile = dialog.open();
if (targetFile == null) {
// cancelled
return null;
}
// Write CSV
try {
List<Event> events = eventLogView.getEventLog().getEvents();
writeEvents(new File(targetFile), events);
MessageDialog.openInformation(shell, "Export Events", "Events exported successfully.");
} catch (Exception e) {
MessageDialog.openError(shell, "Export Events", "Unable to perform events export.\nDetails:" + e.getMessage());
}
return null;
}
use of org.eclipse.core.commands.ExecutionException in project yamcs-studio by yamcs.
the class ExportCommandsHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Shell shell = HandlerUtil.getActiveShell(event);
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
CommandHistoryView view = (CommandHistoryView) part;
// Ask for file to export
FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.csv" });
String targetFile = dialog.open();
if (targetFile == null) {
// cancelled
return null;
}
// Write CSV
try {
writeEvents(new File(targetFile), view.getTableViewer().getTable());
MessageDialog.openInformation(shell, "Export Command History", "Command History exported successfully.");
} catch (Exception e) {
MessageDialog.openError(shell, "Export Command History", "Unable to perform command history export.\nDetails:" + e.getMessage());
}
return null;
}
use of org.eclipse.core.commands.ExecutionException in project yamcs-studio by yamcs.
the class ArmCommandHandler method armCommand.
private void armCommand(Shell activeShell, CommandStackView view, StackedCommand command) throws ExecutionException {
IssueCommandRequest req = command.toIssueCommandRequest().setDryRun(true).build();
CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
String qname;
try {
qname = command.getSelectedAliasEncoded();
} catch (UnsupportedEncodingException e1) {
throw new ExecutionException(e1.getMessage());
}
catalogue.sendCommand("realtime", qname, req).whenComplete((data, exc) -> {
if (exc == null) {
Display.getDefault().asyncExec(() -> {
boolean doArm = false;
SignificanceInfo significance = command.getMetaCommand().getSignificance();
switch(significance.getConsequenceLevel()) {
case WATCH:
case WARNING:
case DISTRESS:
case CRITICAL:
case SEVERE:
String level = Character.toUpperCase(significance.getConsequenceLevel().toString().charAt(0)) + significance.getConsequenceLevel().toString().substring(1);
if (MessageDialog.openConfirm(activeShell, "Confirm", level + ": Are you sure you want to arm this command?\n" + " " + command.toStyledString(view).getString() + "\n\n" + significance.getReasonForWarning())) {
doArm = true;
}
break;
case NONE:
doArm = true;
break;
default:
throw new IllegalStateException("Unexpected significance level " + significance.getConsequenceLevel());
}
if (doArm) {
log.info(String.format("Command armed %s", command));
command.setStackedState(StackedState.ARMED);
view.refreshState();
}
});
} else {
Display.getDefault().asyncExec(() -> {
command.setStackedState(StackedState.REJECTED);
view.clearArm();
view.refreshState();
});
}
});
}
use of org.eclipse.core.commands.ExecutionException in project yamcs-studio by yamcs.
the class OPIShell method sendUpdateCommand.
/**
* Alert whoever is listening that a new OPIShell has been created.
*/
private static void sendUpdateCommand() {
IServiceLocator serviceLocator = PlatformUI.getWorkbench();
ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
try {
Command command = commandService.getCommand(OPI_SHELLS_CHANGED_ID);
command.executeWithChecks(new ExecutionEvent());
} catch (ExecutionException | NotHandledException | NotEnabledException | NotDefinedException e) {
log.log(Level.WARNING, "Failed to send OPI shells changed command", e);
}
}
Aggregations