function menu = getDefuaultPopupSchema(this,manager,varargin)
% GETPOPUPSCHEMA Constructs the default popup menu

% Author(s): James G. Owen
% Revised: 
% Copyright 1986-2002 The MathWorks, Inc.
% $Revision: 1.1.6.1 $ $Date: 2004/12/26 21:44:33 $

%% Create menus
menu  = com.mathworks.mwswing.MJPopupMenu('Default Menu');
menuDelete = com.mathworks.mwswing.MJMenuItem('Delete');
menuCopy = com.mathworks.mwswing.MJMenuItem('Copy');
menuPaste = com.mathworks.mwswing.MJMenuItem('Paste');
menuRename = com.mathworks.mwswing.MJMenuItem('Rename');

%% Add them
menu.add(menuCopy);
menu.add(menuPaste);
menu.addSeparator;
menu.add(menuDelete);
menu.add(menuRename);

%% Assign menu callbacks
set(handle(menuDelete,'callbackproperties'),'ActionPerformedCallback',...
    @(es,ed) remove(this,manager));
set(handle(menuCopy,'callbackproperties'),'ActionPerformedCallback',...
    @(es,ed) copynode(this,manager))
set(handle(menuPaste,'callbackproperties'),'ActionPerformedCallback',...
    @(es,ed) pastenode(this,manager))
set(handle(menuRename,'callbackproperties'),'ActionPerformedCallback',...
    {@LocalRename,this,manager});

%% Add listener to update the enabled state of the paste menu depending on
%% the contents of the viewer clipboard
this.addListeners(handle.listener(manager.Root.Tsviewer,...
    manager.Root.Tsviewer.findprop('Clipboard'),'PropertyPostSet',...
    {@localSetPasteMenu manager.Root.Tsviewer menuPaste}));
localSetPasteMenu([],[],manager.Root.Tsviewer,menuPaste) % Exercise it

% --------------------------------------------------------------------------- %
function LocalRename(eventSrc,eventData,this,manager)

newname = inputdlg('New view name','Time Series Tools');
if length(newname)>0
   this.Label = newname{1};
end

function localSetPasteMenu(eventSrc,eventData,viewer,MenuPaste)

%% Callback to tsviewer clipboard listener which sets the enabled state of
%% the paste menu
MenuPaste.setEnabled(isa(viewer.ClipBoard,'tsguis.viewnode'));
