⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchlistview.java

📁 EclipseTrader is a stock exchange analysis system, featuring shares pricing watch, intraday and hi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    }                    watchlist.getItems().addCollectionObserver(WatchlistView.this);                    watchlist.addObserver(WatchlistView.this);                }            }        });    }    /* (non-Javadoc)     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()     */    public void setFocus()    {        parent.setFocus();    }        /* (non-Javadoc)     * @see org.eclipse.ui.part.WorkbenchPart#dispose()     */    public void dispose()    {        if (watchlist != null)        {            watchlist.deleteObserver(this);            watchlist.getItems().removeCollectionObserver(this);            for (Iterator iter = watchlist.getItems().iterator(); iter.hasNext(); )            {                WatchlistItem watchlistItem = (WatchlistItem)iter.next();                Security security = watchlistItem.getSecurity();                if (security != null && security.getQuoteFeed() != null)                    FeedMonitor.cancelMonitor(security);            }        }        layout.dispose();        try {            preferenceStore.save();        } catch(Exception e) {            LogFactory.getLog(getClass()).warn(e);        }        super.dispose();    }        public void fillMenuBars(IMenuManager mgr)    {        mgr.add(new Separator());        mgr.add(cutAction);        mgr.add(copyAction);        mgr.add(pasteAction);        mgr.add(new Separator());        mgr.add(deleteAction);    }        public PreferenceStore getPreferenceStore()    {        return preferenceStore;    }    public void setLayout(int style)    {        if (layout != null)            layout.dispose();        switch(style)        {            case TABLE:                layout = new WatchlistTableViewer(this);                break;            case RIBBON:                layout = new WatchlistBoxViewer(this);                break;        }        tableLayout.setChecked(style == TABLE);        ribbonLayout.setChecked(style == RIBBON);        watchlist.setStyle(style);        CorePlugin.getRepository().save(watchlist);        layout.createPartControl(parent);        layout.updateView();        parent.layout();    }    public AbstractLayout getLayout()    {        return layout;    }    public Watchlist getWatchlist()    {        return watchlist;    }    /* (non-Javadoc)     * @see java.util.Observer#update(java.util.Observable, java.lang.Object)     */    public void update(Observable o, Object arg)    {        if (o == watchlist)        {            parent.getDisplay().asyncExec(new Runnable() {                public void run()                {                    if (watchlist.getDescription().length() != 0 && !watchlist.getDescription().equals(getPartName()))                        setPartName(watchlist.getDescription());                    layout.updateView();                }            });        }        if (o instanceof WatchlistItem)        {            final WatchlistItem watchlistItem = (WatchlistItem)o;            for (Iterator iter = watchlistItem.getAlerts().iterator(); iter.hasNext(); )            {                Alert alert = (Alert) iter.next();                AlertPlugin plugin = (AlertPlugin) alert.getData();                if (plugin == null)                {                    plugin = TradingPlugin.createAlertPlugin(alert.getPluginId());                    plugin.init(watchlistItem.getSecurity(), alert);                    plugin.setLastSeen(alert.getLastSeen());                    alert.setData(plugin);                }                if (plugin != null && !plugin.isSeenToday())                {                    if (plugin.apply())                    {                        plugin.setLastSeen(Calendar.getInstance().getTime());                        alert.setLastSeen(plugin.getLastSeen());                        if (alert.isHilight())                        {                            final RGB foreground = plugin.getHilightForeground();                            final RGB background = plugin.getHilightBackground();                            parent.getDisplay().asyncExec(new Runnable() {                                public void run()                                {                                    layout.tickAlert(watchlistItem, foreground, background);                                }                            });                        }                    }                }            }        }    }    /* (non-Javadoc)     * @see net.sourceforge.eclipsetrader.core.ICollectionObserver#itemAdded(java.lang.Object)     */    public void itemAdded(Object o)    {        WatchlistItem watchlistItem = (WatchlistItem)o;        layout.itemAdded(o);        Security security = watchlistItem.getSecurity();        if (security != null && security.getQuoteFeed() != null)            FeedMonitor.monitor(security);                for (Iterator iter = watchlistItem.getAlerts().iterator(); iter.hasNext(); )        {            Alert alert = (Alert) iter.next();            AlertPlugin plugin = (AlertPlugin) alert.getData();            if (plugin == null)            {                plugin = TradingPlugin.createAlertPlugin(alert.getPluginId());                plugin.init(watchlistItem.getSecurity(), alert);                plugin.setLastSeen(alert.getLastSeen());                alert.setData(plugin);            }        }                watchlistItem.addObserver(this);    }    /* (non-Javadoc)     * @see net.sourceforge.eclipsetrader.core.ICollectionObserver#itemRemoved(java.lang.Object)     */    public void itemRemoved(Object o)    {        WatchlistItem watchlistItem = (WatchlistItem)o;        watchlistItem.deleteObserver(this);        layout.itemRemoved(o);        Security security = watchlistItem.getSecurity();        if (security != null && security.getQuoteFeed() != null)            FeedMonitor.cancelMonitor(security);    }    void itemsDropped(Security[] securities, Point point)    {        int index = layout.getItemIndex(point);        if (index == -1)            index = watchlist.getItems().size();        if (watchlist != null)        {            for (int i = 0; i < securities.length; i++)            {                WatchlistItem item = new WatchlistItem();                item.setParent(watchlist);                item.setSecurity(securities[i]);                watchlist.getItems().add(index++, item);            }            CorePlugin.getRepository().save(watchlist);        }    }    void itemsDropped(WatchlistItem[] items, Point point)    {        int index = layout.getItemIndex(point);        if (index == -1)            index = watchlist.getItems().size();        if (watchlist != null)        {            for (int i = 0; i < items.length; i++)            {                items[i].setParent(watchlist);                watchlist.getItems().add(index++, items[i]);            }            CorePlugin.getRepository().save(watchlist);        }    }        public WatchlistItem[] getSelection()    {        return layout.getSelection();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -