Skip to content
Snippets Groups Projects
user_url_pw_input.m 1.67 KiB
Newer Older
  • Learn to ignore specific revisions
  • function [url, user, pass] = user_url_pw_input
    %user_url_pw_input
    %   Return the URL, user name and password for the openBIS server
    
    url = 'https://XYZ.ethz.ch/openbis:8443';
    user = '';
    pass = '';
    
    ScreenSize = get(0,'ScreenSize');
    hfig = figure('Menubar','figure', ...
        'Units','Pixels', ...
        'Resize','on', ...
        'NumberTitle','off', ...
        'Name',['Enter openBIS credentials'], ...
        'Position',[ (ScreenSize(3:4)-[200 75])/2 300 200], ...
        'Color',[0.8 0.8 0.8], ...
        'WindowStyle','modal');
    
    % hedit = uicontrol('Parent',hfig, ...
    %     'Style','Edit', ...
    %     'Enable','inactive', ...
    %     'Units','Pixels','Position',[49 28 202 22], ...
    %     'FontSize',15, ...
    %     'String',[], ...
    %     'BackGroundColor',[0.7 0.7 0.7]);
    
    huser = uicontrol('Parent',hfig, ...
        'Style','Text', ...
        'Tag','user', ...
        'Units','Pixels','Position',[1 30 198 18], ...
        'FontSize',15, ...
        'BackGroundColor',[1 1 1]);
    
    hpass = uicontrol('Parent',hfig, ...
        'Style','Text', ...
        'Tag','password', ...
        'Units','Pixels','Position',[51 30 198 18], ...
        'FontSize',15, ...
        'BackGroundColor',[1 1 1]);
    
    
    set(hfig,'KeyPressFcn',{@keypress_Callback, huser, hpass}, ...
        'CloseRequestFcn','uiresume')
    
    uiwait
    pass = get(hpass,'userdata');
    delete(hfig)
    
    
    function keypress_Callback(~,data, huser, hpass)
    
    pass = get(hpass,'userdata');
    
    switch data.Key
        case 'backspace'
            pass = pass(1:end-1);
        case 'return'
            uiresume
            return
        otherwise
            try
                pass = [pass data.Character];
            catch
                disp('Some error occured during password entry!')
            end
    end
    
    set(hpass,'userdata',pass)
    set(hpass,'String',char('*'*sign(pass)))