function tsCustomizeUitable(t,varargin)

%% Function to customize uitables in the tstool by disabling all context
%% menus, removing row headers and optionally customizing the editbility
%% of columns

import com.mathworks.toolbox.timeseries.*;

%% Turn off the default uitable context menus
mouseListeners = t.getTable.getMouseListeners;
for k=1:length(mouseListeners)
    if isa(mouseListeners(k), 'com.mathworks.widgets.spreadsheet.SpreadsheetTable$TableMouseEventListener')
        t.getTable.removeMouseListener(mouseListeners(k));
    end
end

%% Turn off the default header menus
mouseListeners = t.getTable.getTableHeader.getMouseListeners;
for k=1:length(mouseListeners)
    if isa(mouseListeners(k), 'com.mathworks.widgets.spreadsheet.SpreadsheetTable$TableHeaderMouseEventListener')
        t.getTable.getTableHeader.removeMouseListener(mouseListeners(k));
    end
end

%% Remove row headers
set(t.getTableScrollPane.getRowHeader,'Visible','off');

%% Customize column editability
if nargin>=2
    noeditcols = varargin{1};
    for k=1:length(noeditcols)
        t.setEditable(noeditcols(k),false);
    end
end