});
}
private void fillContextMenu(IMenuManager manager)
{
final Security security = (Security) ((IStructuredSelection) securities.getSelection()).getFirstElement();
if (security == null)
return;
manager.add(new AbstractDialogAction(Messages.SecurityMenuBuy)
{
@Override
Dialog createDialog(Security security)
{
return new BuySellSecurityDialog(getShell(), getClient(), security, PortfolioTransaction.Type.BUY);
}
});
manager.add(new AbstractDialogAction(Messages.SecurityMenuSell)
{
@Override
Dialog createDialog(Security security)
{
return new BuySellSecurityDialog(getShell(), getClient(), security, PortfolioTransaction.Type.SELL);
}
});
manager.add(new AbstractDialogAction(Messages.SecurityMenuDividends)
{
@Override
Dialog createDialog(Security security)
{
return new DividendsDialog(getShell(), getClient(), null, security);
}
});
manager.add(new AbstractDialogAction(Messages.SecurityMenuStockSplit)
{
@Override
Dialog createDialog(Security security)
{
StockSplitWizard wizard = new StockSplitWizard(getClient(), security);
return new WizardDialog(getShell(), wizard);
}
});
manager.add(new Separator());
manager.add(new AbstractDialogAction(Messages.SecurityMenuEditSecurity)
{
@Override
Dialog createDialog(Security security)
{
return new EditSecurityDialog(getShell(), getClient(), security);
}
@Override
protected void performFinish(Security security)
{
super.performFinish(security);
updateQuotes(security);
}
});
manager.add(new Separator());
manager.add(new Action(Messages.SecurityMenuUpdateQuotes)
{
@Override
public void run()
{
updateQuotes(security);
}
});
manager.add(new AbstractDialogAction(Messages.SecurityMenuImportQuotes)
{
@Override
Dialog createDialog(Security security)
{
return new WizardDialog(getShell(), new ImportQuotesWizard(security));
}
});
manager.add(new Separator());
manager.add(new WebLocationMenu(security));
manager.add(new Separator());
if (watchlist == null)
{
manager.add(new Action(Messages.SecurityMenuDeleteSecurity)
{
@Override
public void run()
{
if (!security.getTransactions(getClient()).isEmpty())
{
MessageDialog.openError(getShell(), Messages.MsgDeletionNotPossible,
MessageFormat.format(Messages.MsgDeletionNotPossibleDetail, security.getName()));
}
else
{
getClient().removeSecurity(security);