createWatchlistEntry(section, watchlist);
}
private void createWatchlistEntry(Entry section, final Watchlist watchlist)
{
final Entry entry = new Entry(section, watchlist.getName());
entry.setAction(new ActivateViewAction(watchlist.getName(), "SecurityList", watchlist, //$NON-NLS-1$
PortfolioPlugin.descriptor(PortfolioPlugin.IMG_WATCHLIST)));
entry.setContextMenu(new IMenuListener()
{
@Override
public void menuAboutToShow(IMenuManager manager)
{
manager.add(new Action(Messages.WatchlistRename)
{
@Override
public void run()
{
String newName = askWatchlistName(watchlist.getName());
if (newName != null)
{
watchlist.setName(newName);
editor.markDirty();
entry.setLabel(newName);
}
}
});
manager.add(new Action(Messages.WatchlistDelete)
{
@Override
public void run()
{
editor.getClient().getWatchlists().remove(watchlist);
editor.markDirty();
entry.dispose();
allSecurities.select();
}
});
}
});
entry.addDropSupport(DND.DROP_MOVE, new Transfer[] { SecurityTransfer.getTransfer() }, new DropTargetAdapter()
{
@Override
public void drop(DropTargetEvent event)
{
if (SecurityTransfer.getTransfer().isSupportedType(event.currentDataType))