Search in sources :

Example 6 with YamcsConnectionProperties

use of org.yamcs.api.YamcsConnectionProperties in project yamcs-studio by yamcs.

the class ConnectHandler method doConnect.

private void doConnect(Shell shell, YamcsConfiguration conf) {
    // FIXME get the password out before doing this
    ConnectionPreferences.setLastUsedConfiguration(conf);
    YamcsConnectionProperties yprops = conf.getPrimaryConnectionProperties();
    ConnectionUIHelper.connectWithProgressDialog(shell, yprops);
}
Also used : YamcsConnectionProperties(org.yamcs.api.YamcsConnectionProperties)

Example 7 with YamcsConnectionProperties

use of org.yamcs.api.YamcsConnectionProperties in project yamcs-studio by yamcs.

the class ConnectHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    boolean singleConnectionMode = YamcsUIPlugin.getDefault().getPreferenceStore().getBoolean("singleConnectionMode");
    if (singleConnectionMode) {
        String connectionString = YamcsUIPlugin.getDefault().getPreferenceStore().getString("connectionString");
        try {
            Shell shell = HandlerUtil.getActiveShell(event);
            YamcsConnectionProperties yprops = YamcsConnectionProperties.parse(connectionString);
            ConnectionUIHelper.connectWithProgressDialog(shell, yprops);
        } catch (URISyntaxException e) {
            log.log(Level.SEVERE, "Invalid URL " + connectionString, e);
            return null;
        }
    } else {
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        ConnectionsDialog dialog = new ConnectionsDialog(window.getShell());
        if (dialog.open() == Dialog.OK) {
            YamcsConfiguration conf = dialog.getChosenConfiguration();
            doConnect(HandlerUtil.getActiveShell(event), conf);
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) Shell(org.eclipse.swt.widgets.Shell) YamcsConnectionProperties(org.yamcs.api.YamcsConnectionProperties) URISyntaxException(java.net.URISyntaxException)

Example 8 with YamcsConnectionProperties

use of org.yamcs.api.YamcsConnectionProperties in project yamcs-studio by yamcs.

the class YamcsConfiguration method getPrimaryConnectionProperties.

public YamcsConnectionProperties getPrimaryConnectionProperties() {
    YamcsConnectionProperties yprops = new YamcsConnectionProperties(primaryHost, primaryPort, instance);
    yprops.setProtocol(Protocol.http);
    if (!isAnonymous()) {
        yprops.setAuthenticationToken(new UsernamePasswordToken(user, password));
    }
    return yprops;
}
Also used : YamcsConnectionProperties(org.yamcs.api.YamcsConnectionProperties) UsernamePasswordToken(org.yamcs.security.UsernamePasswordToken)

Example 9 with YamcsConnectionProperties

use of org.yamcs.api.YamcsConnectionProperties in project yamcs-studio by yamcs.

the class ManagementCatalogue method getCurrentYamcsInstance.

// Careful we must support the case where Yamcs itself changes the instance of our client
// TODO maybe remove this and instead just store an instance field in YamcsClient ?
public static String getCurrentYamcsInstance() {
    ManagementCatalogue catalogue = getInstance();
    if (catalogue == null) {
        return null;
    }
    ClientInfo ci = catalogue.getCurrentClientInfo();
    if (ci != null) {
        return ci.getInstance();
    } else {
        // Fallback (initial connection properties
        YamcsClient yamcsClient = YamcsPlugin.getYamcsClient();
        YamcsConnectionProperties props = yamcsClient.getYamcsConnectionProperties();
        return (props != null) ? props.getInstance() : null;
    }
}
Also used : YamcsClient(org.yamcs.studio.core.client.YamcsClient) YamcsConnectionProperties(org.yamcs.api.YamcsConnectionProperties) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo)

Aggregations

YamcsConnectionProperties (org.yamcs.api.YamcsConnectionProperties)9 UsernamePasswordToken (org.yamcs.security.UsernamePasswordToken)2 YamcsClient (org.yamcs.studio.core.client.YamcsClient)2 MessageLite (com.google.protobuf.MessageLite)1 ChannelFuture (io.netty.channel.ChannelFuture)1 HttpMethod (io.netty.handler.codec.http.HttpMethod)1 URISyntaxException (java.net.URISyntaxException)1 List (java.util.List)1 Map (java.util.Map)1 CancellationException (java.util.concurrent.CancellationException)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 FutureTask (java.util.concurrent.FutureTask)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 Level (java.util.logging.Level)1