use of org.yamcs.protobuf.YamcsManagement.ClientInfo in project yamcs-studio by yamcs.
the class ManagementCatalogue method onMessage.
@Override
public void onMessage(WebSocketSubscriptionData msg) {
if (msg.hasConnectionInfo()) {
ConnectionInfo connectionInfo = msg.getConnectionInfo();
YamcsInstance instance = connectionInfo.getInstance();
log.fine("Instance " + instance.getName() + ": " + instance.getState());
managementListeners.forEach(l -> l.instanceUpdated(connectionInfo));
}
if (msg.hasClientInfo()) {
ClientInfo clientInfo = msg.getClientInfo();
if (clientInfo.getState() == ClientState.DISCONNECTED) {
ClientInfo previousClientInfo = clientInfoById.remove(clientInfo.getId());
checkOwnClientState(previousClientInfo, clientInfo);
managementListeners.forEach(l -> l.clientDisconnected(clientInfo));
} else {
ClientInfo previousClientInfo = clientInfoById.put(clientInfo.getId(), clientInfo);
checkOwnClientState(previousClientInfo, clientInfo);
managementListeners.forEach(l -> l.clientUpdated(clientInfo));
}
}
if (msg.hasProcessorInfo()) {
ProcessorInfo processorInfo = msg.getProcessorInfo();
String instance = processorInfo.getInstance();
Map<String, ProcessorInfo> instanceProcessors = processorInfoByInstance.get(instance);
if (instanceProcessors == null) {
instanceProcessors = new ConcurrentHashMap<>();
processorInfoByInstance.put(instance, instanceProcessors);
}
if (processorInfo.getState() == ServiceState.TERMINATED) {
instanceProcessors.remove(processorInfo.getName());
} else {
instanceProcessors.put(processorInfo.getName(), processorInfo);
}
managementListeners.forEach(l -> l.processorUpdated(processorInfo));
}
if (msg.hasStatistics()) {
Statistics statistics = msg.getStatistics();
managementListeners.forEach(l -> l.statisticsUpdated(statistics));
}
}
use of org.yamcs.protobuf.YamcsManagement.ClientInfo in project yamcs-studio by yamcs.
the class ClientsTableViewer method addFixedColumns.
private void addFixedColumns() {
TableViewerColumn idColumn = new TableViewerColumn(this, SWT.CENTER);
idColumn.getColumn().setText(COL_ID);
idColumn.getColumn().setWidth(30);
idColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ClientInfo client = (ClientInfo) element;
return String.valueOf(client.getId());
}
});
TableViewerColumn userColumn = new TableViewerColumn(this, SWT.LEFT);
userColumn.getColumn().setText(COL_USER);
userColumn.getColumn().setWidth(100);
userColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ClientInfo client = (ClientInfo) element;
return String.valueOf(client.getUsername());
}
});
TableViewerColumn applicationColumn = new TableViewerColumn(this, SWT.LEFT);
applicationColumn.getColumn().setText(COL_APPLICATION);
applicationColumn.getColumn().setWidth(100);
applicationColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ClientInfo client = (ClientInfo) element;
return client.getApplicationName();
}
});
TableViewerColumn instanceColumn = new TableViewerColumn(this, SWT.LEFT);
instanceColumn.getColumn().setText(COL_INSTANCE);
instanceColumn.getColumn().setWidth(100);
instanceColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ClientInfo client = (ClientInfo) element;
return client.getInstance();
}
});
TableViewerColumn processorColumn = new TableViewerColumn(this, SWT.LEFT);
processorColumn.getColumn().setText(COL_PROCESSOR);
processorColumn.getColumn().setWidth(100);
processorColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ClientInfo client = (ClientInfo) element;
return client.getProcessorName();
}
});
// prevent resize to 0
for (TableColumn column : getTable().getColumns()) {
column.addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (column.getWidth() < 5) {
column.setWidth(5);
}
}
});
}
}
use of org.yamcs.protobuf.YamcsManagement.ClientInfo in project yamcs-studio by yamcs.
the class RestartInstanceHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ManagementCatalogue catalogue = ManagementCatalogue.getInstance();
ClientInfo clientInfo = catalogue.getCurrentClientInfo();
Shell shell = HandlerUtil.getActiveShell(event);
String instance = clientInfo.getInstance();
catalogue.restartInstance(clientInfo.getInstance()).whenComplete((ret, ex) -> {
log.log(Level.SEVERE, "Failed to restart instance '" + instance + "'", ex);
Display.getDefault().asyncExec(() -> {
MessageDialog.openError(shell, "Failed to restart instance '" + instance + "'", ex.getMessage());
});
});
return null;
}
use of org.yamcs.protobuf.YamcsManagement.ClientInfo in project yamcs-studio by yamcs.
the class YamcsUIPlugin method postWorkbenchStartup.
/**
* Hook called by application layer to bootstrap connection state
*/
public void postWorkbenchStartup(IWorkbench workbench) {
// Listen to processing-info updates
// Trigger initial state
doUpdateGlobalProcessingState(workbench, null);
ManagementCatalogue.getInstance().addManagementListener(new ManagementListener() {
@Override
public void processorUpdated(ProcessorInfo processorInfo) {
updateGlobalProcessingState(processorInfo);
}
@Override
public void processorClosed(ProcessorInfo processorInfo) {
updateGlobalProcessingState(processorInfo);
}
@Override
public void statisticsUpdated(Statistics stats) {
}
@Override
public void clientUpdated(ClientInfo clientInfo) {
updateGlobalProcessingState(clientInfo);
}
@Override
public void clientDisconnected(ClientInfo clientInfo) {
updateGlobalProcessingState(clientInfo);
}
@Override
public void instanceUpdated(ConnectionInfo connectionInfo) {
}
@Override
public void clearAllManagementData() {
}
});
// Request connection to Yamcs server
boolean singleConnectionMode = getPreferenceStore().getBoolean("singleConnectionMode");
if (!singleConnectionMode && ConnectionPreferences.isAutoConnect()) {
RCPUtils.runCommand("org.yamcs.studio.core.ui.autoconnect");
}
}
use of org.yamcs.protobuf.YamcsManagement.ClientInfo in project yamcs-studio by yamcs.
the class YamcsUIPlugin method updateGlobalProcessingState.
private void updateGlobalProcessingState(ProcessorInfo processorInfo) {
// First update state of various buttons (at the level of the workbench)
// (TODO sometimes clientInfo has not been updated yet, that's whey we have the next method too)
IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(() -> {
ClientInfo clientInfo = ManagementCatalogue.getInstance().getCurrentClientInfo();
if (clientInfo != null && clientInfo.getProcessorName().equals(processorInfo.getName())) {
doUpdateGlobalProcessingState(workbench, processorInfo);
}
});
}
Aggregations