Home > api-openbis-matlab > user_url_pw_input_dialog.m

user_url_pw_input_dialog

PURPOSE ^

user_url_pw_input

SYNOPSIS ^

function [url, user, pass] = user_url_pw_input_dialog

DESCRIPTION ^

user_url_pw_input
   Return the URL, user name and password for the openBIS server

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [url, user, pass] = user_url_pw_input_dialog
0002 %user_url_pw_input
0003 %   Return the URL, user name and password for the openBIS server
0004 
0005 url = 'https://XYZ.ethz.ch/openbis:8443';
0006 user = '';
0007 pass = '';
0008 
0009 
0010 ScreenSize = get(0,'ScreenSize');
0011 fig = uifigure('Name', 'Enter openBIS credentials', 'Position',[(ScreenSize(3:4)-[300 75])/2 400 150]);
0012 fig.CloseRequestFcn = @(fig,event)my_closereq(fig);
0013 
0014 % URL label and text field
0015 lbl_url = uilabel(fig, 'Text', 'URL:', ...
0016     'Position',[10 120 80 20]);
0017 
0018 txt_url = uieditfield(fig,...
0019     'Position',[70 120 280 20], ...
0020     'Value', url, ...
0021     'Tag', 'url_textfield');
0022 
0023 % User label and text field
0024 lbl_user = uilabel(fig, 'Text', 'User:', ...
0025     'Position',[10 90 80 20]);
0026 
0027 txt_user = uieditfield(fig,...
0028     'Position',[70 90 280 20], ...
0029     'Value', user, ...
0030     'Tag', 'user_textfield');
0031 
0032 % Password label and text field
0033 lbl_pass = uilabel(fig, 'Text', 'Password:', ...
0034     'Position',[10 60 80 20]);
0035 
0036 txt_pass = uieditfield(fig,...
0037     'Position',[70 60 280 20], ...
0038     'Tag', 'pass_textfield', ...
0039     'ValueChangingFcn', @textChanging, ...
0040     'UserData', '');
0041 
0042 % Push button to accept entries
0043 btn = uibutton(fig,'push', ...
0044                'Position',[150 10 100 40], ...
0045                'Text', 'Connect', ...
0046                'FontWeight', 'bold', ...
0047                'ButtonPushedFcn', @(btn,event) buttonPushed(btn, fig));
0048 
0049 uiwait(fig)
0050     
0051     % run this when figure closes
0052     function my_closereq(fig,selection)
0053         
0054         url = get(txt_url, 'Value');
0055         user = get(txt_user, 'Value');
0056         pass = get(txt_pass,'UserData');
0057         
0058         delete(fig)
0059         
0060     end
0061 
0062 end
0063 
0064 % Callback functions
0065 function textChanging(txt, event)
0066 % replace typed text with stars
0067 % Todo: handle delete / backspace
0068 
0069 % disp(event.Value);
0070 
0071 if isempty(txt.UserData)
0072     txt.UserData = event.Value;
0073 else
0074     txt.UserData = append(txt.UserData, event.Value(end));
0075 end
0076 
0077 val = event.Value;
0078 if ~isempty(val)
0079     val(1:length(val)) = '*';
0080 else
0081    val = '*'; 
0082 end
0083 txt.Value = val;
0084 
0085 end
0086 
0087 function buttonPushed(btn, fig)
0088 % close the figure, call CloseRequestFcn before
0089         
0090         close(fig)
0091 end
0092 
0093

Generated on Tue 06-Jul-2021 16:01:18 by m2html © 2005