use of org.yamcs.studio.core.model.CommandingCatalogue in project yamcs-studio by yamcs.
the class CommandQueuesTableViewer method updateQueueState.
// rebuild doesn't seem to do anything and therefore is not currently included in rest api
// keeping it around for future reference mostly
private void updateQueueState(CommandQueueInfo queue, QueueState queueState, boolean rebuild) {
EditCommandQueueRequest req = EditCommandQueueRequest.newBuilder().setState(queueState.toString()).build();
CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
catalogue.editQueue(queue, req);
}
use of org.yamcs.studio.core.model.CommandingCatalogue 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.yamcs.studio.core.model.CommandingCatalogue in project yamcs-studio by yamcs.
the class AddCommentHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
Shell shell = HandlerUtil.getActiveShell(event);
if (sel != null && sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
if (selection.isEmpty()) {
return null;
}
// Populate with text of first record. But only if single selection
String initialValue = "";
if (selection.size() == 1) {
CommandHistoryRecord rec = (CommandHistoryRecord) selection.getFirstElement();
String existingComment = rec.getTextForColumn("Comment", false);
if (existingComment != null) {
initialValue = existingComment;
}
}
String dialogMessage;
if (selection.size() == 1) {
dialogMessage = "Add a comment for this command";
} else {
dialogMessage = "Add a comment for the " + selection.size() + " selected commands";
}
IInputValidator validator = newText -> null;
InputDialog commentDialog = new InputDialog(shell, "Add Comment", dialogMessage, initialValue, validator) {
@Override
protected int getInputTextStyle() {
return SWT.MULTI | SWT.BORDER | SWT.V_SCROLL;
}
@Override
protected Control createDialogArea(Composite parent) {
Control res = super.createDialogArea(parent);
((GridData) this.getText().getLayoutData()).heightHint = 4 * this.getText().getLineHeight();
return res;
}
};
int commentResult = commentDialog.open();
if (commentResult == Window.OK) {
String newComment = commentDialog.getValue();
CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
// TODO improve me. Bundle into only one error message
// Or even better: one api call.
Iterator<?> it = selection.iterator();
while (it.hasNext()) {
CommandHistoryRecord rec = (CommandHistoryRecord) it.next();
catalogue.updateCommandComment("realtime", rec.getCommandId(), newComment).exceptionally(t -> {
Display.getDefault().asyncExec(() -> {
MessageBox dialog = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
dialog.setText("Comment Update");
dialog.setMessage("Comment has not been updated. Details: " + t.getMessage());
// open dialog and await user selection
dialog.open();
});
return null;
});
}
}
}
return null;
}
use of org.yamcs.studio.core.model.CommandingCatalogue in project yamcs-studio by yamcs.
the class CommandQueuedTableViewer method updateQueueEntryState.
// rebuild doesn't seem to do anything and therefore is not currently included in rest api
// keeping it around for future reference mostly
private void updateQueueEntryState(CommandQueueEntry entry, String state, boolean rebuild) {
EditCommandQueueEntryRequest req = EditCommandQueueEntryRequest.newBuilder().setState(state).build();
CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
catalogue.editQueuedCommand(entry, req);
}
use of org.yamcs.studio.core.model.CommandingCatalogue in project yamcs-studio by yamcs.
the class IssueCommandHandler method issueCommand.
private void issueCommand(Shell activeShell, CommandStackView view, StackedCommand command) throws ExecutionException {
IssueCommandRequest req = command.toIssueCommandRequest().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(() -> {
log.info(String.format("Command issued. %s", req));
command.setStackedState(StackedState.ISSUED);
view.selectActiveCommand();
view.refreshState();
});
} else {
Display.getDefault().asyncExec(() -> {
command.setStackedState(StackedState.REJECTED);
view.refreshState();
});
}
});
}
Aggregations