Unverified Commit 79cceffb authored by Matthew Dawson's avatar Matthew Dawson
Browse files

WIP

parent c9f7b52e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10,6 +10,12 @@
% Author: Colin Eles elesc@mcmaster.ca
% Organization: McMaster Centre for Software Certification
function [] = close_fig(object,src,event)
object.Data.open = 0;
object.Data.fig = [];
delete(object.fig)
object.fig = [];
object.Data.purge;
return
if (object.validation_report_handle ~= 0)
    delete(object.validation_report_handle);
    object.validation_report_handle = 0;
+10 −10
Original line number Diff line number Diff line
@@ -15,13 +15,14 @@ elseif object.mode == 0
    name = 'Table Tool';
end
% main figure
object.fig = figure('units','pixels',...
object.fig = uifigure('units','pixels',...
    'position',[0 0 object.fig_width object.fig_height],...
    'menubar','none',...
    'name','Table Tool',...
    'numbertitle','off',...
    'resize','on',...
    'Name',name,...
    'AutoResizeChildren','off',...
    'CloseRequestFcn',@(src,event)close_fig(object,src,event),...
    'ResizeFcn',@(src,event)resize_fig(object,src,event));

@@ -98,6 +99,7 @@ object.settings_pb = uicontrol('style','push',...
% Expression Name Label
object.name_label = uicontrol('style','text',...
    'string','Expression Name',...
    'Parent',object.fig,...
    'HorizontalAlign','right',...
    'BackgroundColor',get(object.fig,'Color'));

@@ -115,18 +117,16 @@ object.function_name_control = uicontrol('style','edit',...
% input list label
object.input_label = uicontrol('style','text',...
    'string','Inputs',...
    'Parent',object.fig,...
    'HorizontalAlign','right',...
    'BackgroundColor',get(object.fig,'Color'));

% input list edit box
object.function_inputs_control = uicontrol('style','edit',...
    'units','pix',...
    'Parent',object.fig,...
object.function_inputs_control = uitextarea(object.fig,...
    'HorizontalAlign','center',...
    'FontWeight','bold',...
    'Max',2.0,...
    'FontSize',12,...
    'KeyPressFcn',@(src,event)textbox_callback(object,src,event),...
    'ValueChangingFcn',@(src,event)textbox_callback(object,src,event),...
    'BackgroundColor',[1 1 1]);


@@ -141,10 +141,10 @@ end


% Set up Menu
filemenu = uimenu('Label','File');
editmenu = uimenu('Label','Edit');
checkmenu = uimenu('Label','Typecheck');
helpmenu = uimenu('Label','Help');
filemenu = uimenu('Label','File','Parent',object.fig);
editmenu = uimenu('Label','Edit','Parent',object.fig);
checkmenu = uimenu('Label','Typecheck','Parent',object.fig);
helpmenu = uimenu('Label','Help','Parent',object.fig);
uimenu(filemenu,'Label','New','Accelerator','n','Callback',@(src,event)new_call(object,src,event));
uimenu(filemenu,'Label','Open...','Callback',@(src,event)open_call(object,src,event));
uimenu(filemenu,'Label','Save to Block','Separator','on','Accelerator','s','Callback',@(src,event)save_call(object,src,event));
+5 −26
Original line number Diff line number Diff line
@@ -11,22 +11,10 @@
function [] = textbox_callback(object,src,event)
% make sure the character pressed isn't empty

if((strcmp(event.Character,'z')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control')))
    return
end
if((strcmp(event.Character,'r')) && (strcmp(char(event.Modifier),'command') || strcmp(char(event.Modifier),'control')))
    return
end

if strcmp(event.Key,'tab')
    event.Character = '';
    return;
end


if(~isempty(unicode2native(event.Character)))
%if(~isempty(unicode2native(event.Character)))
    % make sure the character is a printable character
    if event.Character > 33 || event.Character == 8
    %if event.Character > 33 || event.Character == 8
        if object.pvs_checked == 1
            object.pvs_checked = 0;
            object.update_Statusbar;
@@ -34,7 +22,7 @@ if(~isempty(unicode2native(event.Character)))
                TableBlock.set_block_display(object.block_handle,object.pvs_checked);
            end
        end
    end
    %end
    
    % hack because api does not update the string field of
    % textbox until after it loses focus. temporarily focus on
@@ -51,25 +39,16 @@ if(~isempty(unicode2native(event.Character)))
    % the findobj function finds java objects contained within a specified 
    % Matlab GUI handle
        
    java_obj = findjobj(src);
    java_obj = java_obj.getComponent(0).getComponent(0);
    Cursor_Pos = java_obj.getCaretPosition();
    uicontrol(object.name_label);
        
    undo_data.action = 1;
    undo_data.grid = [];
    undo_data.cell = src;
    undo_data.text = get(src,'String');
    undo_data.text = event.Value;
    undo_data.subgrid = [];
    
    object.undo_man.new_state(undo_data);

    uicontrol(src);
    java_obj.setCaretPosition(Cursor_Pos);
    figure(object.fig);

    object.update_undoredo;
    
    
    
end
 No newline at end of file
%end
 No newline at end of file

FindJavaObjects/findjobj.m

deleted100644 → 0
+0 −3456

File deleted.

Preview size limit exceeded, changes collapsed.

FindJavaObjects/findjobj_fast.m

deleted100644 → 0
+0 −60
Original line number Diff line number Diff line
function jControl = findjobj_fast(hControl, jContainer)
    try jControl = hControl.getTable; return, catch, end  % fast bail-out for old uitables
    try jControl = hControl.JavaFrame.getGUIDEView; return, catch, end  % bail-out for HG2 matlab.ui.container.Panel
    oldWarn = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
    if nargin < 2 || isempty(jContainer)
        % Use a HG2 matlab.ui.container.Panel jContainer if the control's parent is a uipanel
        try
            hParent = get(hControl,'Parent');
        catch
            % Probably indicates an invalid/deleted/empty handle
            jControl = [];
            return
        end
        try jContainer = hParent.JavaFrame.getGUIDEView; catch, jContainer = []; end
    end
    if isempty(jContainer)
        hFig = ancestor(hControl,'figure');
        jf = get(hFig, 'JavaFrame');
        jContainer = jf.getFigurePanelContainer.getComponent(0);
    end
    warning(oldWarn);
    jControl = [];
    counter = 20;  % 2018-09-21 speedup (100 x 0.001 => 20 x 0.005) - Martin Lehmann suggestion on FEX 2016-06-07
    specialTooltipStr = '!@#$%^&*';
    try  % Fix for R2018b suggested by Eddie (FEX comment 2018-09-19)
        tooltipPropName = 'TooltipString';
        oldTooltip = get(hControl,tooltipPropName);
        set(hControl,tooltipPropName,specialTooltipStr);
    catch
        tooltipPropName = 'Tooltip';
        oldTooltip = get(hControl,tooltipPropName);
        set(hControl,tooltipPropName,specialTooltipStr);
    end
    while isempty(jControl) && counter>0
        counter = counter - 1;
        pause(0.005);
        jControl = findTooltipIn(jContainer, specialTooltipStr);
    end
    set(hControl,tooltipPropName,oldTooltip);
    try jControl.setToolTipText(oldTooltip); catch, end
    try jControl = jControl.getParent.getView.getParent.getParent; catch, end  % return JScrollPane if exists
end

function jControl = findTooltipIn(jContainer, specialTooltipStr)
    try
        jControl = [];  % Fix suggested by H. Koch 11/4/2017
        tooltipStr = jContainer.getToolTipText;
        %if strcmp(char(tooltipStr),specialTooltipStr)
        if ~isempty(tooltipStr) && tooltipStr.startsWith(specialTooltipStr)  % a bit faster
            jControl = jContainer;
        else
            for idx = 1 : jContainer.getComponentCount
                jControl = findTooltipIn(jContainer.getComponent(idx-1), specialTooltipStr);
                if ~isempty(jControl), return; end
            end
        end
    catch
        % ignore
    end
end