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

📄 patternsearchview.java

📁 EclipseTrader is a stock exchange analysis system, featuring shares pricing watch, intraday and hi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                }            }        };        historyMenu.setImageDescriptor(TradingPlugin.getImageDescriptor("icons/elcl16/search_history.gif"));        historyMenu.setDisabledImageDescriptor(TradingPlugin.getImageDescriptor("icons/dlcl16/search_history.gif"));        historyMenu.setToolTipText("Search History");        historyMenu.setMenuCreator(menuCreator);        toolBarManager.appendToGroup("end", historyMenu);                site.getActionBars().updateActionBars();                super.init(site);    }    /* (non-Javadoc)     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)     */    public void createPartControl(Composite parent)    {        Composite content = new Composite(parent, SWT.NONE);        GridLayout gridLayout = new GridLayout();        gridLayout.marginWidth = gridLayout.marginHeight = 0;        content.setLayout(gridLayout);                table = new Table(content, SWT.SINGLE|SWT.FULL_SELECTION);        table.setHeaderVisible(true);        table.setLinesVisible(false);        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));        TableColumn column = new TableColumn(table, SWT.NONE);        column.setWidth(0);        column.setResizable(false);        column = new TableColumn(table, SWT.LEFT);        column.setText("Code");        column.addSelectionListener(new SelectionAdapter() {            public void widgetSelected(SelectionEvent e)            {                List list = currentPage.getResults();                Collections.sort(list, new Comparator() {                    public int compare(Object arg0, Object arg1)                    {                        return ((PatternSearchItem) arg0).getCode().compareTo(((PatternSearchItem) arg1).getCode());                    }                });                updateView();            }        });        column = new TableColumn(table, SWT.LEFT);        column.setText("Name");        column.addSelectionListener(new SelectionAdapter() {            public void widgetSelected(SelectionEvent e)            {                List list = currentPage.getResults();                Collections.sort(list, new Comparator() {                    public int compare(Object arg0, Object arg1)                    {                        return ((PatternSearchItem) arg0).getDescription().compareTo(((PatternSearchItem) arg1).getDescription());                    }                });                updateView();            }        });        column = new TableColumn(table, SWT.RIGHT);        column.setText("Date");        column.addSelectionListener(new SelectionAdapter() {            public void widgetSelected(SelectionEvent e)            {                List list = currentPage.getResults();                Collections.sort(list, new Comparator() {                    public int compare(Object arg0, Object arg1)                    {                        return ((PatternSearchItem) arg0).getDate().compareTo(((PatternSearchItem) arg1).getDate());                    }                });                updateView();            }        });        column = new TableColumn(table, SWT.RIGHT);        column.setText("Price");        column = new TableColumn(table, SWT.LEFT);        column.setText("Pattern");        column.addSelectionListener(new SelectionAdapter() {            public void widgetSelected(SelectionEvent e)            {                List list = currentPage.getResults();                Collections.sort(list, new Comparator() {                    public int compare(Object arg0, Object arg1)                    {                        return ((PatternSearchItem) arg0).getPattern().compareTo(((PatternSearchItem) arg1).getPattern());                    }                });                updateView();            }        });        column = new TableColumn(table, SWT.LEFT);        column.setText("Bullish / Bearish");        column.addSelectionListener(new SelectionAdapter() {            public void widgetSelected(SelectionEvent e)            {                List list = currentPage.getResults();                Collections.sort(list, new Comparator() {                    public int compare(Object arg0, Object arg1)                    {                        return ((PatternSearchItem) arg0).getOpportunity().compareTo(((PatternSearchItem) arg1).getOpportunity());                    }                });                updateView();            }        });                for (int i = 1; i < table.getColumnCount(); i++)            table.getColumn(i).pack();        setContentDescription(" ");    }    /* (non-Javadoc)     * @see org.eclipse.ui.part.WorkbenchPart#setFocus()     */    public void setFocus()    {    }        public void addPage(final IPatternSearchPage page)    {        Job job = new Job("Search pattern") {            protected IStatus run(IProgressMonitor monitor)            {                page.run(monitor);                pages.add(page);                currentPage = page;                table.getDisplay().asyncExec(new Runnable() {                    public void run()                    {                        updateView();                    }                });                return Status.OK_STATUS;            }        };        job.setUser(true);        job.schedule();    }        private void updateView()    {        table.setRedraw(false);        table.removeAll();        if (currentPage != null)        {            setContentDescription(currentPage.getDescription());            int index = 0;            for (Iterator iter = currentPage.getResults().iterator(); iter.hasNext(); index++)            {                PatternSearchItem item = (PatternSearchItem) iter.next();                TableItem tableItem = new TableItem(table, SWT.NONE);                tableItem.setBackground((index & 1) == 0 ? evenBackground : oddBackground);                tableItem.setForeground((index & 1) == 0 ? evenForeground : oddForeground);                tableItem.setText(1, item.getCode());                tableItem.setText(2, item.getDescription());                tableItem.setText(3, item.getDate() != null ? dateFormat.format(item.getDate()) : "");                tableItem.setText(4, item.getPrice() != null ? priceFormat.format(item.getPrice()) : "");                tableItem.setText(5, item.getPattern());                tableItem.setText(6, item.getOpportunity());                tableItem.setForeground(6, item.getOpportunity().equals("Bullish") ? positiveForeground : negativeForeground);            }        }        else            setContentDescription(" ");        table.setRedraw(true);        for (int i = 1; i < table.getColumnCount(); i++)            table.getColumn(i).pack();        removeCurrentAction.setEnabled(currentPage != null);        removeAllAction.setEnabled(currentPage != null);        refreshAction.setEnabled(currentPage != null);    }    /* (non-Javadoc)     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)     */    public void widgetDefaultSelected(SelectionEvent e)    {    }    /* (non-Javadoc)     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)     */    public void widgetSelected(SelectionEvent e)    {        currentPage = (IPatternSearchPage) e.widget.getData();;        updateView();    }}

⌨️ 快捷键说明

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