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

% Author(s): John Glass, Bora Eryilmaz
% Revised: 
% Copyright 1986-2004 The MathWorks, Inc.
% $Revision: 1.1.6.3 $ $Date: 2004/11/18 23:44:15 $

menu  = com.mathworks.mwswing.MJPopupMenu('Default Menu');
item1 = com.mathworks.mwswing.MJMenu('New');
item2 = com.mathworks.mwswing.MJMenuItem('Task...');
item3 = com.mathworks.mwswing.MJMenuItem('Save...');
item4 = com.mathworks.mwswing.MJMenuItem('Delete');
item5 = com.mathworks.mwswing.MJMenuItem('Rename');

menu.add( item1 ); item1.add( item2 );
menu.addSeparator;
menu.add( item3 );
menu.addSeparator;
menu.add( item4 );
menu.add( item5 );

h = handle( item2, 'callbackproperties' );
fun = @(x,y) LocalNewTask(this, manager);
h.ActionPerformedCallback = fun;
h.MouseClickedCallback    = fun;

h = handle( item3, 'callbackproperties' );
fun = @(x,y) LocalSave(this, manager);
h.ActionPerformedCallback = fun;
h.MouseClickedCallback    = fun;

h = handle( item4, 'callbackproperties' );
fun = @(x,y) LocalDelete(this, manager);
h.ActionPerformedCallback = fun;
h.MouseClickedCallback    = fun;

h = handle( item5, 'callbackproperties' );
fun = @(x,y) LocalRename(this, manager);
h.ActionPerformedCallback = fun;
h.MouseClickedCallback    = fun;

% --------------------------------------------------------------------------- %
function LocalNewTask(this, manager)
% Create the new task dialog and let it handle the rest
newdlg = explorer.NewTaskDialog(this);
awtinvoke(newdlg.Dialog, 'setVisible', true)

% --------------------------------------------------------------------------- %
function LocalSave(this, manager)
manager.saveas(this)

% --------------------------------------------------------------------------- %
function LocalDelete(this, manager)
parent = this.up;
parent.removeNode(this);
manager.Explorer.setSelected(parent.getTreeNodeInterface);

% --------------------------------------------------------------------------- %
function LocalRename(this, manager)
Tree = manager.ExplorerPanel.getSelector.getTree;
Tree.startEditingAtPath(Tree.getSelectionPath);
