Search in sources :

Example 1 with ClientInfo

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));
    }
}
Also used : ProcessorInfo(org.yamcs.protobuf.YamcsManagement.ProcessorInfo) YamcsInstance(org.yamcs.protobuf.YamcsManagement.YamcsInstance) ConnectionInfo(org.yamcs.protobuf.Web.ConnectionInfo) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo) Statistics(org.yamcs.protobuf.YamcsManagement.Statistics)

Example 2 with ClientInfo

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);
                }
            }
        });
    }
}
Also used : ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ControlListener(org.eclipse.swt.events.ControlListener) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo) ControlEvent(org.eclipse.swt.events.ControlEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 3 with ClientInfo

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;
}
Also used : ManagementCatalogue(org.yamcs.studio.core.model.ManagementCatalogue) Shell(org.eclipse.swt.widgets.Shell) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo)

Example 4 with ClientInfo

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");
    }
}
Also used : ProcessorInfo(org.yamcs.protobuf.YamcsManagement.ProcessorInfo) ManagementListener(org.yamcs.studio.core.model.ManagementListener) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo) ConnectionInfo(org.yamcs.protobuf.Web.ConnectionInfo) Statistics(org.yamcs.protobuf.YamcsManagement.Statistics)

Example 5 with ClientInfo

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);
        }
    });
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo)

Aggregations

ClientInfo (org.yamcs.protobuf.YamcsManagement.ClientInfo)9 ManagementCatalogue (org.yamcs.studio.core.model.ManagementCatalogue)4 ProcessorInfo (org.yamcs.protobuf.YamcsManagement.ProcessorInfo)3 EditClientRequest (org.yamcs.protobuf.Rest.EditClientRequest)2 ConnectionInfo (org.yamcs.protobuf.Web.ConnectionInfo)2 Statistics (org.yamcs.protobuf.YamcsManagement.Statistics)2 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 ControlListener (org.eclipse.swt.events.ControlListener)1 Shell (org.eclipse.swt.widgets.Shell)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 IWorkbench (org.eclipse.ui.IWorkbench)1 YamcsConnectionProperties (org.yamcs.api.YamcsConnectionProperties)1 CreateProcessorRequest (org.yamcs.protobuf.Rest.CreateProcessorRequest)1 YamcsInstance (org.yamcs.protobuf.YamcsManagement.YamcsInstance)1 YamcsClient (org.yamcs.studio.core.client.YamcsClient)1 ManagementListener (org.yamcs.studio.core.model.ManagementListener)1