diff --git a/textValue.m b/textValue.m deleted file mode 100644 index 36ed8d5df90b6e75d611b74250c518d41e88ee36..0000000000000000000000000000000000000000 --- a/textValue.m +++ /dev/null @@ -1,51 +0,0 @@ -function pass = textValue -% Create figure and components. - -ScreenSize = get(0,'ScreenSize'); -fig = uifigure('Position',[(ScreenSize(3:4)-[300 75])/2 300 75]); -fig.CloseRequestFcn = @(fig,event)my_closereq(fig); - -lbl = uilabel(fig, ... - 'Position',[10 10 150 20]); - -txt = uieditfield(fig,... - 'Position',[10 40 150 20], ... - 'Tag', 'my_textfield', ... - 'ValueChangedFcn', @textChanged, ... - 'ValueChangingFcn', @textChanging, ... - 'UserData', ''); - - -uiwait(fig) - - function my_closereq(fig,selection) - pass = get(txt,'UserData'); - delete(fig) - - end - -disp(pass) - -end - -% Callback functions -function textChanged(txt) -% disp(txt.UserData) -end - -function textChanging(txt, event) -disp(event.Value); - -if isempty(txt.UserData) - txt.UserData = event.Value; -else - txt.UserData = append(txt.UserData, event.Value(end)); -end - -val = event.Value; -val(1:length(val)) = '*'; -txt.Value = val; - -end - - diff --git a/user_url_pw_input.m b/user_url_pw_input.m deleted file mode 100644 index 3dfd54607b32bbe028793ea6abe6ccea3a703dca..0000000000000000000000000000000000000000 --- a/user_url_pw_input.m +++ /dev/null @@ -1,69 +0,0 @@ -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))) \ No newline at end of file diff --git a/user_url_pw_input_dialog.m b/user_url_pw_input_dialog.m new file mode 100644 index 0000000000000000000000000000000000000000..970f750aa528640de0380f6b8cdba72f7258df02 --- /dev/null +++ b/user_url_pw_input_dialog.m @@ -0,0 +1,93 @@ +function [url, user, pass] = user_url_pw_input_dialog +%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'); +fig = uifigure('Name', 'Enter openBIS credentials', 'Position',[(ScreenSize(3:4)-[300 75])/2 400 150]); +fig.CloseRequestFcn = @(fig,event)my_closereq(fig); + +% URL label and text field +lbl_url = uilabel(fig, 'Text', 'URL:', ... + 'Position',[10 120 80 20]); + +txt_url = uieditfield(fig,... + 'Position',[70 120 280 20], ... + 'Value', url, ... + 'Tag', 'url_textfield'); + +% User label and text field +lbl_user = uilabel(fig, 'Text', 'User:', ... + 'Position',[10 90 80 20]); + +txt_user = uieditfield(fig,... + 'Position',[70 90 280 20], ... + 'Value', user, ... + 'Tag', 'user_textfield'); + +% Password label and text field +lbl_pass = uilabel(fig, 'Text', 'Password:', ... + 'Position',[10 60 80 20]); + +txt_pass = uieditfield(fig,... + 'Position',[70 60 280 20], ... + 'Tag', 'pass_textfield', ... + 'ValueChangingFcn', @textChanging, ... + 'UserData', ''); + +% Push button to accept entries +btn = uibutton(fig,'push', ... + 'Position',[150 10 100 40], ... + 'Text', 'Connect', ... + 'FontWeight', 'bold', ... + 'ButtonPushedFcn', @(btn,event) buttonPushed(btn, fig)); + +uiwait(fig) + + % run this when figure closes + function my_closereq(fig,selection) + + url = get(txt_url, 'Value'); + user = get(txt_user, 'Value'); + pass = get(txt_pass,'UserData'); + + delete(fig) + + end + +end + +% Callback functions +function textChanging(txt, event) +% replace typed text with stars +% Todo: handle delete / backspace + +% disp(event.Value); + +if isempty(txt.UserData) + txt.UserData = event.Value; +else + txt.UserData = append(txt.UserData, event.Value(end)); +end + +val = event.Value; +if ~isempty(val) + val(1:length(val)) = '*'; +else + val = '*'; +end +txt.Value = val; + +end + +function buttonPushed(btn, fig) +% close the figure, call CloseRequestFcn before + + close(fig) +end + +