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

📄 workplatformview.java

📁 用Eclipse开发的桥吊无线管理系统.希望对大家有帮助:)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    SWT.COLOR_DARK_RED));

            buttonStart.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    TableItem item = table.getItem(number);
                    Color color = Display.getCurrent().getSystemColor(
                            SWT.COLOR_BLUE);
                    item.setForeground(1, color);
                    table.setSelection(2);
                    table.redraw();

                    StaticData.id = item.getText(0);
                    String name = "BriCraProcessing";
                    BriCraProcessingTaskStr bcp = new BriCraProcessingTaskStr(
                            name, StaticData.id);
                    BriCraActionStr bpa = new BriCraActionStr(StaticData.id);
                    bpa.getActionStructure();
                    bcp.getTaskStructure();// 返回给下一层的数据结构
                }
            });

            buttonStop.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {

                    table.setSelection(number);
                    Color color = Display.getCurrent().getSystemColor(
                            SWT.COLOR_RED);
                    TableItem item = table.getItem(number);
                    item.setForeground(1, color);
                    table.setSelection(2);

                    String name = "BriCraFinished";
                    String id = StaticData.id;
                    BriCraFinishedTaskStr bfd = new BriCraFinishedTaskStr(name,
                            id);
                    BriCraActionStr bpa = new BriCraActionStr(StaticData.id);
                    bpa.getActionStructure();
                    bfd.getTaskStructure();
                }
            });

            buttonApply.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {

                    table.setSelection(number);
                    System.out.println(number);
                    TableItem item = table.getItem(1);//为什么会出现index out of bounds 这个问题呢??
                    String id = item.getText(0);
                    String name = "BriCraException";
                    BriCraExceptionTaskStr bed = new BriCraExceptionTaskStr(
                            name, id);
                    BriCraActionStr bas = new BriCraActionStr(StaticData.id);
                    bas.getActionStructure();
                    bed.getTaskStructure();
                }
            });

            buttonLogout.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    StaticData.name = "BriCraLogout";
                    BriCraLogoutTaskStr blod = new BriCraLogoutTaskStr(
                            StaticData.name, StaticData.dockcode,
                            StaticData.usercode);
                    blod.getTaskStructure();// 需要以参数的形式传给下一层
                    try {

                        // tip 从一个view调用另一个view,并且返回另一个view的句柄
                        
                        IViewPart viewPart = getSite().getPage().showView(
                                LogoutView.ID, null,
                                IWorkbenchPage.VIEW_VISIBLE);
                        System.out.println("注销页面该出来了");
                        
                        IWorkbenchWindow window = getSite()
                                .getWorkbenchWindow();
                        window.getActivePage().hideView(
                                window.getActivePage().findView(
                                        login_QD.view.WorkPlatformView.ID));

                        

                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                }
            });
        }
    }

    public class TableComp extends Composite {
        // public Table table;

        public TableComp(Composite c) {
            super(c, SWT.BORDER);
            GridLayout gl = new GridLayout();
            gl.numColumns = 3;
            this.setLayout(gl);

            final Table table = new Table(this, SWT.MULTI | SWT.FULL_SELECTION);
            table.setHeaderVisible(true);
            table.setLinesVisible(true);
            GridData gd = new GridData(GridData.FILL_BOTH | GridData.CENTER);
            table.setLayoutData(gd);
            table.setRedraw(false);

            // table.select(1000000);
            /*
             * 为Table增加两列并设置列宽都是80
             */
            TableColumn col1 = new TableColumn(table, SWT.NONE);
            col1.setText("ID");
            col1.setWidth(100);
            TableColumn col2 = new TableColumn(table, SWT.NONE);
            col2.setText("集装箱号");
            col2.setWidth(280);
            TableColumn col3 = new TableColumn(table, SWT.NONE);
            col3.setText("起始位置");
            col3.setWidth(280);
            TableColumn col4 = new TableColumn(table, SWT.NONE);
            col4.setText("终止位置");
            col4.setWidth(280);

            /**
             * 监听Table的鼠标双击事件
             */
            table.addMouseListener(new MouseListener() {
                public void mouseDoubleClick(MouseEvent e) {
                    int selIndex = table.getSelectionIndex();
                    TableItem item = table.getItem(selIndex);
                    String str = "列1 = " + item.getText(0) + "\n列2 = "
                            + item.getText(1);
                    MessageDialog.openInformation(null, null, str);
                }

                public void mouseDown(MouseEvent e) {
                }

                public void mouseUp(MouseEvent e) {
                }
            });

        }
    }

    public class TableViewerControl {

        private TableViewer tv; // 定义一个表格对象

        public TableViewer open(Composite parent) {

            // 调用自定义方法创建表格
            createTableViewer(parent);
            // 第四步:设定内容器
            tv.setContentProvider(new TableViewerContentProvider());
            // 第五步:设定标签器
            tv.setLabelProvider(new TableViewerLabelProvider());
            // 第六步:用setInput输入数据
            tv.setInput(WorkFactory.getWorks());
            addListener();
            return tv;
        }

        private void createTableViewer(Composite parent) {
            /*
             * 第一步:定义一个TableViewer对象。式样:MULTI可多选、H_SCROLL有水平
             * 滚动条、V_SCROLL有垂直滚动条、BORDER有边框、FULL_SELECTION整行选择
             */

            tv = new TableViewer(parent, SWT.MULTI | SWT.BORDER
                    | SWT.FULL_SELECTION);
            /*
             * 第二步:通过TableViewer中的Table对其布局
             */
            table = tv.getTable();
            table.setHeaderVisible(true); // 显示表头
            table.setLinesVisible(true); // 显示表格线
            TableLayout tLayout = new TableLayout(); // 专用于表格的布局
            table.setLayout(tLayout);

            /*
             * 第三步:建立TableViewer中的列
             */
            tLayout.addColumnData(new ColumnWeightData(50));
            new TableColumn(table, SWT.NONE).setText("ID号");
            tLayout.addColumnData(new ColumnWeightData(150));
            new TableColumn(table, SWT.NONE).setText("集装箱号");
            tLayout.addColumnData(new ColumnWeightData(150));
            new TableColumn(table, SWT.NONE).setText("起始位置");
            tLayout.addColumnData(new ColumnWeightData(150));
            new TableColumn(table, SWT.NONE).setText("终止位置");

        }

        /**
         * 添加监听器
         */
        private void addListener() {
            /*
             * tv的鼠标双击事件监听
             */
            tv.addDoubleClickListener(new IDoubleClickListener() {
                public void doubleClick(DoubleClickEvent event) {
                    IStructuredSelection selection = (IStructuredSelection) event
                            .getSelection();
                    // 得到记录的实体对象(要类型转换)
                    WorkEntity o = (WorkEntity) selection.getFirstElement();
                    // 一个弹出提示框
                    MessageDialog.openInformation(null, "提示", o.getName());
                }
            });
            /*
             * tv的选择事件(单击)监听
             */
            tv.addSelectionChangedListener(new ISelectionChangedListener() {
                public void selectionChanged(SelectionChangedEvent event) {
                    number = table.getSelectionIndex();
                    System.out.println(number);
                }
            });

        }

    }

    public void setFocus() {
        // TODO Auto-generated method stub

    }
}

⌨️ 快捷键说明

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