manager.add(new Action(Messages.SecurityMenuAddPrice)
{
@Override
public void run()
{
Security security = (Security) prices.getData(Security.class.toString());
if (security == null)
return;
SecurityPrice price = new SecurityPrice();
price.setTime(Dates.today());
security.addPrice(price);
markDirty();
prices.setInput(security.getPrices());
latest.setInput(security);
transactions.setInput(security.getTransactions(getClient()));
events.setInput(security.getEvents());
updateChart(security);
prices.setSelection(new StructuredSelection(price), true);
prices.editElement(price, 0);
}
});
manager.add(new Separator());
}
if (((IStructuredSelection) prices.getSelection()).getFirstElement() != null)
{
manager.add(new Action(Messages.SecurityMenuDeletePrice)
{
@Override
public void run()
{
Security security = (Security) prices.getData(Security.class.toString());
if (security == null)
return;
Iterator<?> iter = ((IStructuredSelection) prices.getSelection()).iterator();
while (iter.hasNext())
{
SecurityPrice price = (SecurityPrice) iter.next();
if (price == null)
continue;
security.removePrice(price);
}
markDirty();
prices.setInput(security.getPrices());
latest.setInput(security);
transactions.setInput(security.getTransactions(getClient()));
events.setInput(security.getEvents());
updateChart(security);
}
});
}
if (prices.getTable().getItemCount() > 0)
{
manager.add(new Action(Messages.SecurityMenuDeleteAllPrices)
{
@Override
public void run()
{
Security security = (Security) prices.getData(Security.class.toString());
if (security == null)
return;
security.removeAllPrices();
markDirty();
prices.setInput(security.getPrices());
latest.setInput(security);
transactions.setInput(security.getTransactions(getClient()));
events.setInput(security.getEvents());
updateChart(security);
}
});
}
if (isSecuritySelected)
{
manager.add(new Separator());
manager.add(new Action(Messages.SecurityMenuUpdateQuotes)
{
@Override
public void run()
{
Security security = (Security) prices.getData(Security.class.toString());
if (security != null)
securities.updateQuotes(security);
}
});
manager.add(new Action(Messages.SecurityMenuImportQuotes)
{
@Override
public void run()
{
Security security = (Security) prices.getData(Security.class.toString());
if (security == null)
return;
Dialog dialog = new WizardDialog(getActiveShell(), new ImportQuotesWizard(security));
if (dialog.open() != Dialog.OK)