Search in sources :

Example 86 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class SchemaInfoEditorPart method createFKTable.

/**
	 * Create foreign key information table
	 * 
	 */
private void createFKTable() {
    Label fkLabel = new Label(topComposite, SWT.LEFT | SWT.WRAP);
    fkLabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    fkLabel.setText(Messages.lblFK);
    fkTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    Table fkTable = fkTableView.getTable();
    {
        createContextMenu(fkTable);
        final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true);
        fkTable.setLayoutData(gdFkTable);
        fkTable.setLinesVisible(true);
        fkTable.setHeaderVisible(true);
        CommonUITool.hackForYosemite(fkTable);
        TableColumn tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(160);
        tblCol.setText(Messages.tblColumnFK);
        tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(119);
        tblCol.setText(Messages.tblColumnColumnName);
        tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(93);
        tblCol.setText(Messages.tblColumnForeignTable);
        tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(143);
        tblCol.setText(Messages.tblColumnForeignColumnName);
        tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(84);
        tblCol.setText(Messages.tblColumnUpdateRule);
        tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(86);
        tblCol.setText(Messages.tblColumnDeleteRule);
        tblCol = new TableColumn(fkTable, SWT.NONE);
        tblCol.setWidth(100);
        tblCol.setText(Messages.tblColumnCacheColumn);
    }
    fkTableView.setContentProvider(new FKTableViewerContentProvider());
    fkTableView.setLabelProvider(new FKTableViewerLabelProvider(database));
    fkTableView.setInput(schemaInfo);
    int colNum = fkTable.getColumnCount();
    for (int i = 0; i < colNum; i++) {
        setTableEditor(fkTable, i);
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point)

Example 87 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class TableEditorPart method createGeneralTabItem.

/**
	 * Create general tab item
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createGeneralTabItem(final TabFolder tabFolder) {
    final TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE);
    generalTabItem.setText(Messages.infoGeneralTab);
    final Composite compositeGenaral = new Composite(tabFolder, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    compositeGenaral.setLayout(gridLayout);
    generalTabItem.setControl(compositeGenaral);
    final Group group = new Group(compositeGenaral, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    gridLayout = new GridLayout();
    gridLayout.numColumns = 2;
    group.setLayout(gridLayout);
    group.setText(Messages.lblTableInfo);
    final Label tableNameLabel = new Label(group, SWT.NONE);
    tableNameLabel.setData(Messages.dataNewKey, null);
    tableNameLabel.setText(Messages.lblTableName);
    tableNameComp = new Composite(group, SWT.NONE);
    {
        GridLayout gl = new GridLayout();
        gl.numColumns = 5;
        gl.marginWidth = 0;
        tableNameComp.setLayout(gl);
        tableNameComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        tableNameText = new Text(tableNameComp, SWT.BORDER);
        tableNameText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
        {
            GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
            gd.widthHint = 200;
            tableNameText.setLayoutData(gd);
        }
        tableNameText.addModifyListener(new ModifyListener() {

            public void modifyText(ModifyEvent event) {
                if (tableNameText.getText().length() == 0) {
                    CommonUITool.hideErrorBaloon(errorBaloon);
                } else if (verifyTableName()) {
                    String tableName = tableNameText.getText();
                    newSchemaInfo.setClassname(tableName);
                }
            }
        });
        tableNameText.addFocusListener(new FocusAdapter() {

            public void focusLost(FocusEvent e) {
                CommonUITool.hideErrorBaloon(errorBaloon);
            }
        });
        final Label ownerLabel = new Label(tableNameComp, SWT.NONE);
        ownerLabel.setText(Messages.lblOwner);
        ownerCombo = new Combo(tableNameComp, SWT.READ_ONLY);
        {
            GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
            gd.widthHint = 100;
            ownerCombo.setLayoutData(gd);
        }
        ownerCombo.setVisibleItemCount(10);
        fillOwnerCombo();
        if (supportCharset) {
            final Label collationLabel = new Label(tableNameComp, SWT.NONE);
            collationLabel.setText(Messages.lblCollation);
            collationCombo = new Combo(tableNameComp, SWT.READ_ONLY);
            {
                GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
                gd.widthHint = 100;
                collationCombo.setLayoutData(gd);
            }
            collationCombo.setVisibleItemCount(10);
            fillCollationCombo();
            String collation = collationCombo.getText();
            newSchemaInfo.setCollation(collation);
            collationCombo.addSelectionListener(new SelectionListener() {

                public void widgetSelected(SelectionEvent e) {
                    String collation = collationCombo.getText();
                    newSchemaInfo.setCollation(collation);
                }

                public void widgetDefaultSelected(SelectionEvent e) {
                }
            });
            if (!isNewTableFlag && newSchemaInfo.getCollation() != null) {
                collationCombo.setText(newSchemaInfo.getCollation());
            }
        } else {
            new Label(tableNameComp, SWT.NONE);
            new Label(tableNameComp, SWT.NONE);
        }
    }
    final Label tableDescLabel = new Label(group, SWT.NONE);
    tableDescLabel.setText(Messages.lblTableDesc);
    tableDescText = new Text(group, SWT.BORDER);
    tableDescText.setTextLimit(512);
    tableDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    if (newSchemaInfo != null && newSchemaInfo.getDescription() != null) {
        tableDescText.setText(newSchemaInfo.getDescription());
    }
    tableDescText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent e) {
            if (!isSupportTableComment) {
                CommonUITool.showErrorBaloon(group, tableDescText, errorBaloon, "", Messages.errNotSupportTableCommentNotice);
                tableDescText.setFocus();
            }
        }

        public void focusLost(FocusEvent e) {
            CommonUITool.hideErrorBaloon(errorBaloon);
        }
    });
    tableDescText.setEditable(isSupportTableComment);
    if (database == null) {
        return;
    }
    if (CompatibleUtil.isSupportReuseOID(database.getDatabaseInfo())) {
        reuseOIDBtn = new Button(group, SWT.CHECK);
        reuseOIDBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
        reuseOIDBtn.setText(Messages.btnReuseOid);
        if (!isNewTableFlag) {
            reuseOIDBtn.setEnabled(false);
        }
    }
    final Label columnsLabel = new Label(compositeGenaral, SWT.NONE);
    columnsLabel.setText(Messages.lblColumn);
    // create attribute table
    columnTableView = new TableViewer(compositeGenaral, SWT.FULL_SELECTION | SWT.BORDER);
    columnTableView.setUseHashlookup(true);
    columnTableView.setColumnProperties(columnProperites);
    columnsTable = columnTableView.getTable();
    //columnsTable.pack();
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.heightHint = 189;
    columnsTable.setLayoutData(gdColumnsTable);
    columnsTable.setLinesVisible(true);
    columnsTable.setHeaderVisible(true);
    // The empty column
    final TableColumn emptyColumn = new TableColumn(columnsTable, SWT.NONE);
    emptyColumn.setWidth(0);
    // The flag column
    final TableColumn flagColumn = new TableColumn(columnsTable, SWT.RIGHT_TO_LEFT);
    flagColumn.setWidth(28);
    // NAME
    final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
    nameColumn.setWidth(140);
    nameColumn.setText(Messages.tblColumnName);
    // DATATYPE
    final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
    dataTypeColumn.setWidth(120);
    dataTypeColumn.setText(Messages.tblColumnDataType);
    // DEFAULT
    final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
    defaultColumn.setWidth(98);
    defaultColumn.setText(Messages.tblColumnDefault);
    defaultColumn.setToolTipText(Messages.tblColumnDefaultHint);
    // AUTO INCREMENT
    final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
    autoIncrTableColumn.setAlignment(SWT.LEFT);
    autoIncrTableColumn.setWidth(100);
    autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
    autoIncrTableColumn.setToolTipText(Messages.tblColumnAutoIncrHint);
    // NOT NULL
    final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
    notNullColumn.setWidth(65);
    notNullColumn.setText(Messages.tblColumnNotNull);
    notNullColumn.setAlignment(SWT.LEFT);
    notNullColumn.setToolTipText(Messages.tblColumnNotNullHint);
    // PK
    final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
    pkColumn.setAlignment(SWT.CENTER);
    pkColumn.setWidth(90);
    pkColumn.setText(Messages.tblColumnPK);
    // UK
    final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
    uniqueColumn.setWidth(55);
    uniqueColumn.setText(Messages.tblColumnUnique);
    uniqueColumn.setAlignment(SWT.LEFT);
    uniqueColumn.setToolTipText(Messages.tblColumnUniqueHint);
    // SHARED
    sharedColumn = new TableColumn(columnsTable, SWT.NONE);
    sharedColumn.setWidth(65);
    sharedColumn.setText(Messages.tblColumnShared);
    sharedColumn.setAlignment(SWT.LEFT);
    sharedColumn.setToolTipText(Messages.tblColumnSharedHint);
    if (supportCharset) {
        final TableColumn collationColumn = new TableColumn(columnsTable, SWT.NONE);
        collationColumn.setWidth(120);
        collationColumn.setText(Messages.tblColumnColumnCollation);
        collationColumn.setAlignment(SWT.LEFT);
    }
    final TableColumn descColumn = new TableColumn(columnsTable, SWT.NONE);
    descColumn.setWidth(180);
    descColumn.setText(Messages.tblColumnColumnDesc);
    descColumn.setAlignment(SWT.LEFT);
    boolean canEdit = true;
    if (!editor.isNewTableFlag() && !editor.isSupportChange()) {
        canEdit = false;
    }
    attrContentProvider = new AttributeContentProvider();
    attrLabelProvider = new AttributeLabelProvider(database.getDatabaseInfo(), newSchemaInfo, canEdit, editorAdaptor);
    columnTableView.setContentProvider(attrContentProvider);
    columnTableView.setLabelProvider(attrLabelProvider);
    CellEditor[] cellEditor = new CellEditor[columnProperites.length];
    {
        int index = 0;
        // Empty
        cellEditor[index++] = null;
        // Flag
        cellEditor[index++] = null;
        // NAME
        cellEditor[index++] = new TextCellEditor(columnsTable);
        // DATATYPE
        cellEditor[index++] = new DataTypeCellEditor((Composite) columnsTable, listDataTypes(), editorAdaptor);
        // DEFAULT
        cellEditor[index++] = new TextCellEditor(columnsTable);
        // AUTO INCREMENT
        cellEditor[index++] = new AutoIncrementCellEditor(columnsTable, editorAdaptor);
        // NOT NULL
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // PK
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // UK
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // SHARD
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // COLLATION
        if (supportCharset) {
            cellEditor[index++] = new ComboBoxCellEditor(columnsTable, getCollationArray(), SWT.READ_ONLY);
        }
        // MEMO
        cellEditor[index++] = new TextCellEditor(columnsTable);
    }
    columnTableView.setCellEditors(cellEditor);
    columnTableView.setCellModifier(new AttributeCellModifier(editorAdaptor));
    loadColumnData();
    CommonUITool.hackForYosemite(columnsTable);
    // Create button
    final Composite btnRowComposite = new Composite(compositeGenaral, SWT.NONE);
    btnRowComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginWidth = 5;
        btnRowComposite.setLayout(layout);
    }
    final Composite optComposite = new Composite(btnRowComposite, SWT.NONE);
    optComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginWidth = 0;
        optComposite.setLayout(layout);
    }
    final Composite btnComposite = new Composite(btnRowComposite, SWT.NONE);
    btnComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    {
        GridLayout layout = new GridLayout();
        layout.marginRight = 0;
        layout.numColumns = 6;
        layout.marginWidth = 0;
        btnComposite.setLayout(layout);
    }
    final Button setPkButton = new Button(btnComposite, SWT.NONE);
    setPkButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    setPkButton.setText(Messages.btnPK);
    setPkButton.addSelectionListener(new PkBtnListenerOnGeneTab(isNewTableFlag));
    final GridData gdUpDown = new GridData(60, SWT.DEFAULT);
    upColumnBtn = new Button(btnComposite, SWT.NONE);
    upColumnBtn.setLayoutData(gdUpDown);
    upColumnBtn.setEnabled(false);
    upColumnBtn.setText(Messages.btnUp);
    upColumnBtn.addSelectionListener(new UpBtnListenerOnGeneTab());
    downColumnBtn = new Button(btnComposite, SWT.DOWN);
    downColumnBtn.setLayoutData(gdUpDown);
    downColumnBtn.setEnabled(false);
    downColumnBtn.setText(Messages.btnDown);
    downColumnBtn.addSelectionListener(new DownBtnListenerOnGeneTab());
    final Button addButton = new Button(btnComposite, SWT.NONE);
    final GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gdAddButton.horizontalIndent = 10;
    addButton.setLayoutData(gdAddButton);
    addButton.setText(Messages.btnAddColumn);
    addButton.addSelectionListener(new AddBtnListenerOnGeneTab());
    deleteColumnBtn = new Button(btnComposite, SWT.NONE);
    final GridData gdDeleteButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gdDeleteButton.horizontalIndent = 10;
    deleteColumnBtn.setLayoutData(gdDeleteButton);
    deleteColumnBtn.setEnabled(false);
    deleteColumnBtn.setText(Messages.btnDelColumn);
    deleteColumnBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            deleteColumn();
        }
    });
    columnsTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            handleSelectionChangeInColumnTable();
        }
    });
    buildColumnTableMenu();
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) ModifyListener(org.eclipse.swt.events.ModifyListener) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) TabItem(org.eclipse.swt.widgets.TabItem) GridData(org.eclipse.swt.layout.GridData) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 88 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class QueryPlanCompositeWithHistory method initialize.

/**
	 * Initializing a Plan Tab
	 */
private void initialize() {
    createPlanToolbar();
    //create the plan tab folder and history sash
    plansHistorySash = new SashForm(this, SWT.HORIZONTAL);
    plansHistorySash.setLayout(new GridLayout(2, true));
    plansHistorySash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    //create left plan tab folder
    plansTabFolder = new CTabFolder(plansHistorySash, SWT.BOTTOM | SWT.CLOSE);
    plansTabFolder.setSimple(false);
    plansTabFolder.setUnselectedImageVisible(true);
    plansTabFolder.setUnselectedCloseVisible(true);
    plansTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    plansTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    plansTabFolder.setLayout(new GridLayout(1, true));
    plansTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(plansTabFolder);
    tabContextMenuManager.createContextMenu();
    //create the right plan history table
    planHistoryTable = new Table(plansHistorySash, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    planHistoryTable.setLayout(new GridLayout(1, true));
    planHistoryTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    planHistoryTable.setHeaderVisible(true);
    planHistoryTable.setLinesVisible(true);
    planHistoryTable.addMouseListener(new MouseListener() {

        public void mouseDoubleClick(MouseEvent event) {
            int selectionIndex = planHistoryTable.getSelectionIndex();
            if (selectionIndex < 0) {
                return;
            }
            TableItem tableItem = planHistoryTable.getItem(planHistoryTable.getSelectionIndex());
            if (tableItem == null) {
                return;
            }
            int uid = Integer.valueOf(tableItem.getText(0));
            StructQueryPlan sq = planHistoryList.get(uid - 1);
            PlanTabItem tabItem = findPlanTab(uid);
            if (tabItem == null) {
                tabItem = newPlanTab(uid);
            }
            plansTabFolder.setSelection(tabItem);
            printPlan(tabItem, sq);
        }

        public void mouseDown(MouseEvent event) {
        }

        public void mouseUp(MouseEvent event) {
        }
    });
    int i = 0;
    planHistoryTblCols[i] = new TableColumn(planHistoryTable, SWT.RIGHT);
    // No
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col1);
    planHistoryTblCols[i].setMoveable(true);
    planHistoryTblCols[i].setWidth(20);
    addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "NUMBER");
    planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
    // Date
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col2);
    planHistoryTblCols[i].setMoveable(true);
    planHistoryTblCols[i].setWidth(100);
    addStringSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "STRING");
    planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.RIGHT);
    // Cost
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col4);
    planHistoryTblCols[i].setMoveable(true);
    planHistoryTblCols[i].setWidth(90);
    addNumberSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "NUMBER");
    planHistoryTblCols[++i] = new TableColumn(planHistoryTable, SWT.LEFT);
    // Cost
    planHistoryTblCols[i].setText(Messages.qedit_plan_history_col3);
    planHistoryTblCols[i].setMoveable(false);
    planHistoryTblCols[i].setWidth(90);
    addStringSorter(planHistoryTable, planHistoryTblCols[i]);
    sortType.put(planHistoryTblCols[i], "STRING");
    sashPlanWeight = new int[] { 80, 20 };
    plansHistorySash.setWeights(sashPlanWeight);
    newPlanTab(1);
    plansTabFolder.setSelection(0);
    hideHistoryPane();
    refreshToolbarStatus(QueryOptions.getQueryPlanDisplayType());
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) TableItem(org.eclipse.swt.widgets.TableItem) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) MouseListener(org.eclipse.swt.events.MouseListener) GridData(org.eclipse.swt.layout.GridData) StructQueryPlan(com.cubrid.common.core.queryplan.StructQueryPlan) TabContextMenuManager(com.cubrid.common.ui.spi.util.TabContextMenuManager)

Example 89 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class QueryResultComposite method makeEmptyResult.

/**
	 * Make empty result contents.
	 * 
	 */
public void makeEmptyResult() {
    resultTabFolder.setSelection(queryResultTabItem);
    SashForm bottomSash = new SashForm(queryResultTabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = SASH_WIDTH;
    bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    Table table = new Table(bottomSash, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
    setDropTraget(table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn tableColumn = new TableColumn(table, SWT.NONE);
    tableColumn.setWidth(60);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = SASH_WIDTH;
    tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    bottomSash.setWeights(new int[] { 70, 30 });
    CTabItem tabItem = new CTabItem(queryResultTabFolder, SWT.NONE);
    tabItem.setText(Messages.qedit_result);
    tabItem.setControl(bottomSash);
    queryResultTabFolder.setSelection(tabItem);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Table(org.eclipse.swt.widgets.Table) StyledText(org.eclipse.swt.custom.StyledText) TableColumn(org.eclipse.swt.widgets.TableColumn) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 90 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class QueryRecordListComparator method displayQueryPlan.

/**
	 * Display query record for tuner tab
	 *
	 * @param queryRecord
	 */
private void displayQueryPlan(final QueryRecord queryRecord) {
    if (queryPlanComposite != null && !queryPlanComposite.isDisposed()) {
        queryPlanComposite.dispose();
    }
    queryPlanComposite = new Composite(queryPlanContainer, SWT.BORDER);
    queryPlanComposite.setLayout(new GridLayout());
    ToolBar queryPlanToolBar = new ToolBar(queryPlanComposite, SWT.None);
    queryPlanToolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hideItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    hideItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
    hideItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    dispModeTextItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    dispModeTextItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_raw.png"));
    dispModeTextItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    dispModeTreeItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    dispModeTreeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_tree.png"));
    dispModeTreeItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    dispModeGraphItem = new ToolItem(queryPlanToolBar, SWT.CHECK);
    dispModeGraphItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_explain_mode_graph.png"));
    dispModeGraphItem.setToolTipText(Messages.tooltip_qedit_explain_display_mode);
    TableViewer statisticsViewer = new TableViewer(queryPlanComposite, SWT.FULL_SELECTION);
    statisticsViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 50));
    statisticsViewer.getTable().setHeaderVisible(true);
    statisticsViewer.getTable().setLinesVisible(false);
    TableColumn itemColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    itemColumn.setText(Messages.columnItem);
    itemColumn.setWidth(60);
    TableColumn fetchColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    fetchColumn.setText(Messages.columnFetches);
    fetchColumn.setWidth(60);
    TableColumn dirtyColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    dirtyColumn.setText(Messages.columnDirties);
    dirtyColumn.setWidth(60);
    TableColumn ioReadColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    ioReadColumn.setText(Messages.columnIORead);
    ioReadColumn.setWidth(80);
    TableColumn ioWriteColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    ioWriteColumn.setText(Messages.columnIOWrite);
    ioWriteColumn.setWidth(80);
    TableColumn costColumn = new TableColumn(statisticsViewer.getTable(), SWT.None);
    costColumn.setText(Messages.columnCost);
    costColumn.setWidth(60);
    statisticsViewer.setContentProvider(new QueryPlanContentProvider());
    statisticsViewer.setLabelProvider(new QueryPlanLabelPrivoder(statisticsViewer, true));
    List<QueryRecord> recordList = new ArrayList<QueryRecord>();
    if (queryRecord != null) {
        recordList.add(queryRecord);
    }
    if (lastRecord != null) {
        recordList.add(lastRecord);
    }
    statisticsViewer.setInput(recordList);
    final SashForm queryPlanSashForm = new SashForm(queryPlanComposite, SWT.VERTICAL);
    queryPlanSashForm.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    queryPlanSashForm.setBackground(SASH_COLOR);
    queryPlanSashForm.setLayout(new GridLayout());
    queryPlanSashForm.SASH_WIDTH = 2;
    DatabaseInfo databaseInfo = database == null ? null : database.getDatabaseInfo();
    final QueryPlanComposite nowPlanComposite = new QueryPlanComposite(queryPlanSashForm, SWT.None, queryRecord == null ? null : queryRecord.getQueryPlan(), databaseInfo);
    final QueryPlanComposite beforePlanComposite = new QueryPlanComposite(queryPlanSashForm, SWT.None, lastRecord == null ? null : lastRecord.getQueryPlan(), databaseInfo);
    queryPlanSashForm.setWeights(new int[] { 500, 500 });
    hideItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            isHiden = !isHiden;
            performHideOperation(queryPlanSashForm, isHiden);
        }
    });
    dispModeTextItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, DISPLAY_TEXT);
        }
    });
    dispModeTreeItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, DISPLAY_TREE);
        }
    });
    dispModeGraphItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, DISPLAY_GRAPH);
        }
    });
    performHideOperation(queryPlanSashForm, isHiden);
    updateTunerPlanDisplayModel(nowPlanComposite, beforePlanComposite, tunerDisplayModel);
    queryPlanContainer.layout();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) QueryRecord(com.cubrid.common.ui.query.tuner.QueryRecord) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

TableColumn (org.eclipse.swt.widgets.TableColumn)305 Table (org.eclipse.swt.widgets.Table)151 GridData (org.eclipse.swt.layout.GridData)105 TableViewer (org.eclipse.jface.viewers.TableViewer)94 Composite (org.eclipse.swt.widgets.Composite)92 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)76 TableItem (org.eclipse.swt.widgets.TableItem)76 Point (org.eclipse.swt.graphics.Point)57 Label (org.eclipse.swt.widgets.Label)55 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)52 Button (org.eclipse.swt.widgets.Button)48 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)41 FillLayout (org.eclipse.swt.layout.FillLayout)37 Listener (org.eclipse.swt.widgets.Listener)37 Event (org.eclipse.swt.widgets.Event)35 Shell (org.eclipse.swt.widgets.Shell)35 Test (org.junit.Test)33 SelectionListener (org.eclipse.swt.events.SelectionListener)32 Text (org.eclipse.swt.widgets.Text)30