function menu = getPopupSchema(this,manager)
% BUILDPOPUPMENU

% Author(s): John Glass
% Revised: 
% Copyright 1986-2004 The MathWorks, Inc.
% $$ $Date: 2004/12/10 19:40:35 $

[menu, Handles] = LocalDialogPanel(this);
h = this.Handles;
h.PopupMenuItems = Handles.PopupMenuItems;
this.Handles = h;

% -------------------------------------------------------------------------
function [Menu, Handles] = LocalDialogPanel(this)
import javax.swing.*;

Menu = JPopupMenu('Linear Analysis Result');

item1 = JMenuItem('Export');
item2 = JMenuItem('Options...');

Menu.add(item1);
set(item1, 'ActionPerformedCallback', {@LocalExportAction, this});
set(item1, 'MouseClickedCallback',    {@LocalExportAction, this});

Menu.add(item2);
set(item2, 'ActionPerformedCallback', {@LocalLinearizationSettings, this});
set(item2, 'MouseClickedCallback',    {@LocalLinearizationSettings, this});

Handles.PopupMenuItems = [item1;item2];

% -------------------------------------------------------------------------
function LocalExportAction(eventSrc, eventData, this)
data = get(eventSrc, 'ActionPerformedCallbackData');

%% Export the lti object to the workspace
defaultnames = {sprintf('opspec_%s',this.Model)};
exporteddata = {this.OpSpecData};
export2wsdlg({'Operating Point Specification'},defaultnames,exporteddata)

% -------------------------------------------------------------------------
function LocalLinearizationSettings(es,ed,this)

%% Call the constructor that displays the options
dlg = jDialogs.LinOptionsDialog(this);
awtinvoke(dlg.JavaPanel.getTabbedPane,'setSelectedIndex',1);
vis = dlg.JavaPanel.isVisible;

%% Put the dialog on top of the explorer
dlg.JavaPanel.pack
if vis
    awtinvoke(dlg.JavaPanel,'setLocationRelativeTo',slctrlexplorer);
else
    dlg.JavaPanel.setLocationRelativeTo(slctrlexplorer);
    awtinvoke(dlg.JavaPanel,'setVisible',true);
end