Search in sources :

Example 16 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.

the class MultiQueryThread method run.

/**
	 * Execute query
	 */
public void run() {
    // FIXME move this logic to core module
    DBConnection connection = new DBConnection(database.getDatabaseInfo());
    try {
        connection.checkAndConnect();
        connection.setAutoClosable(true);
    } catch (final SQLException event) {
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                String errorMsg = Messages.errDbConnect;
                if (event.getMessage() != null) {
                    errorMsg = Messages.bind(com.cubrid.common.ui.common.Messages.errCommonTip, event.getErrorCode(), event.getMessage());
                }
                LOGGER.error(errorMsg);
                CommonUITool.openErrorBox(Display.getDefault().getActiveShell(), errorMsg);
                CTabFolder queryResultTabFolder = queryResultComp.getQueryResultTabFolder();
                queryResultComp.disposeAllResult();
                if (event.getMessage().length() <= 0) {
                    queryResultComp.makeEmptyResult();
                } else {
                    if (event.getMessage().length() > 0) {
                        queryResultComp.makeLogResult(queries, event.getMessage());
                    }
                }
                if (queryResultTabFolder.getItemCount() > 0) {
                    queryResultTabFolder.setSelection(queryResultTabFolder.getItemCount() - 1);
                }
                queryResultComp.setCanDispose(true);
            }
        });
        return;
    }
    final Vector<String> qVector = QueryUtil.queriesToQuery(queries);
    int currentQueryIndex = 0;
    int cntResults = 0;
    String noSelectSql = "";
    StringBuilder log = new StringBuilder(256);
    @SuppressWarnings("unused") boolean hasModifyQuery = false;
    @SuppressWarnings("unused") boolean isIsolationHigher = false;
    long beginTimestamp = 0;
    double elapsedTime = 0.0;
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(3);
    result = null;
    String multiQuerySql = null;
    final Vector<QueryExecuter> curResult = new Vector<QueryExecuter>();
    if (database == null) {
        database = ((QueryUnit) queryEditor.getEditorInput()).getDatabase();
    }
    try {
        if (qVector.isEmpty()) {
            return;
        } else {
            isIsolationHigher = queryEditor.isIsolationHigherThanRepeatableRead(connection.getConnection(), queryEditor.isActive());
        }
        ServerInfo serverInfo = null;
        if (database != null) {
            serverInfo = this.database.getServer().getServerInfo();
        }
        RecentlyUsedSQLDetailPersistUtils.load(database);
        boolean enableSearchUnit = QueryOptions.getEnableSearchUnit(serverInfo);
        int unitCount = QueryOptions.getSearchUnitCount(serverInfo);
        int sqlTotalCount = qVector.size();
        for (int i = 0; i < sqlTotalCount; i++) {
            currentQueryIndex = i;
            log.delete(0, log.length());
            long endTimestamp = 0;
            SQLHistoryDetail sqlHistoryDetail = new SQLHistoryDetail();
            sqlHistoryDetail.setExecuteTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()));
            sql = qVector.get(i).toString();
            if (database.getDatabaseInfo().isShard()) {
                if (queryEditor.getDefaultShardQueryType() == DatabaseInfo.SHARD_QUERY_TYPE_ID) {
                    sql = QueryUtil.wrapShardQueryWithId(sql, queryEditor.getShardId());
                } else {
                    sql = QueryUtil.wrapShardQueryWithVal(sql, queryEditor.getShardVal());
                }
            }
            if (sql != null && sql.trim().lastIndexOf(";") == -1) {
                sql += ";";
            }
            String orignSQL = sql;
            if (enableSearchUnit && unitCount > 0) {
                multiQuerySql = SqlParser.getPaginatingSqlClause(sql);
            }
            String order = StringUtil.getOrdinalFromCardinalNumber(i + 1);
            if (multiQuerySql == null) {
                sql = SqlParser.convertComment(sql);
                beginTimestamp = System.currentTimeMillis();
                try {
                    stmt = QueryExecuter.getStatement(connection.getConnection(), sql, false, false);
                } catch (final SQLException e) {
                    throw e;
                }
                if (stmt.hasResultSet()) {
                    stmt.setQueryInfo(false);
                    stmt.setOnlyQueryPlan(false);
                    try {
                        stmt.executeQuery();
                        endTimestamp = System.currentTimeMillis();
                        rs = (CUBRIDResultSetProxy) stmt.getResultSet();
                    } catch (final SQLException e) {
                        throw e;
                    }
                    elapsedTime = (endTimestamp - beginTimestamp) * 0.001;
                    String elapsedTimeStr = nf.format(elapsedTime);
                    if (elapsedTime < 0.001) {
                        elapsedTimeStr = "0.000";
                    }
                    List<String> columnTableNameList = UIQueryUtil.loadColumnTableNameList(stmt);
                    result = createQueryExecutor(queryEditor, cntResults, sql, database, connection, orignSQL, columnTableNameList);
                    result.makeResult(rs);
                    String queryMsg = Messages.bind(Messages.querySeq, order) + "[ " + elapsedTimeStr + " " + Messages.second + " , " + Messages.totalRows + " : " + result.cntRecord + " ]" + StringUtil.NEWLINE;
                    result.setQueryMsg(queryMsg);
                    sqlHistoryDetail.setExecuteInfo(queryMsg);
                    sqlHistoryDetail.setElapseTime(elapsedTimeStr);
                    if (stmt.getStatementType() == CUBRIDCommandType.CUBRID_STMT_EVALUATE || stmt.getStatementType() == CUBRIDCommandType.CUBRID_STMT_CALL) {
                        hasModifyQuery = true;
                    }
                    curResult.addElement(result);
                    queryExecuterMap.put(sql, result);
                    cntResults++;
                } else {
                    byte execType = stmt.getStatementType();
                    /*
						 * the previous version , the variable
						 * threadExecResult is class field, but why ? is it
						 * necessary?
						 */
                    int threadExecResult = 0;
                    try {
                        threadExecResult = stmt.executeUpdate();
                        endTimestamp = System.currentTimeMillis();
                    } catch (final SQLException ee) {
                        throw ee;
                    }
                    elapsedTime = (endTimestamp - beginTimestamp) * 0.001;
                    int cntModify = threadExecResult;
                    noSelectSql += sql + StringUtil.NEWLINE;
                    hasModifyQuery = true;
                    log.append(Messages.bind(Messages.querySeq, order)).append(" ");
                    switch(execType) {
                        case CUBRIDCommandType.CUBRID_STMT_ALTER_CLASS:
                        case CUBRIDCommandType.CUBRID_STMT_ALTER_SERIAL:
                        case CUBRIDCommandType.CUBRID_STMT_RENAME_CLASS:
                        case CUBRIDCommandType.CUBRID_STMT_RENAME_TRIGGER:
                            log.append(Messages.alterOk);
                            break;
                        case CUBRIDCommandType.CUBRID_STMT_CREATE_CLASS:
                        case CUBRIDCommandType.CUBRID_STMT_CREATE_INDEX:
                        case CUBRIDCommandType.CUBRID_STMT_CREATE_TRIGGER:
                        case CUBRIDCommandType.CUBRID_STMT_CREATE_SERIAL:
                            log.append(Messages.createOk);
                            break;
                        case CUBRIDCommandType.CUBRID_STMT_DROP_DATABASE:
                        case CUBRIDCommandType.CUBRID_STMT_DROP_CLASS:
                        case CUBRIDCommandType.CUBRID_STMT_DROP_INDEX:
                        case CUBRIDCommandType.CUBRID_STMT_DROP_LABEL:
                        case CUBRIDCommandType.CUBRID_STMT_DROP_TRIGGER:
                        case CUBRIDCommandType.CUBRID_STMT_DROP_SERIAL:
                        case CUBRIDCommandType.CUBRID_STMT_REMOVE_TRIGGER:
                            log.append(Messages.dropOk);
                            break;
                        case CUBRIDCommandType.CUBRID_STMT_INSERT:
                            log.append(Messages.bind(Messages.insertOk, cntModify));
                            break;
                        case CUBRIDCommandType.CUBRID_STMT_SELECT:
                            break;
                        case CUBRIDCommandType.CUBRID_STMT_UPDATE:
                            log.append(Messages.bind(Messages.updateOk2, cntModify));
                            break;
                        case CUBRIDCommandType.CUBRID_STMT_DELETE:
                            log.append(Messages.bind(Messages.deleteOk, cntModify));
                            break;
                        /*
						 * Under two line works disable button when query's
						 * last command is commit/rollback
						 */
                        case CUBRIDCommandType.CUBRID_STMT_COMMIT_WORK:
                        case CUBRIDCommandType.CUBRID_STMT_ROLLBACK_WORK:
                            hasModifyQuery = false;
                        default:
                            log.append(Messages.queryOk);
                            break;
                    }
                    String elapsedTimeStr = nf.format(elapsedTime);
                    if (elapsedTime < 0.001) {
                        elapsedTimeStr = "0.000";
                    }
                    log.append(" [").append(elapsedTimeStr).append(" ");
                    log.append(Messages.second).append("]").append(StringUtil.NEWLINE);
                    logs.append(log);
                    logs.append(QueryEditorPart.makeSqlLogOnResult(sql));
                    sqlHistoryDetail.setExecuteInfo(log.toString());
                    sqlHistoryDetail.setElapseTime(elapsedTimeStr);
                }
            } else {
                result = createQueryExecutor(queryEditor, cntResults, "", database, connection, orignSQL, null);
                result.setMultiQuerySql(multiQuerySql);
                result.setQueryMsg(Messages.bind(Messages.querySeq, order) + StringUtil.NEWLINE);
                result.setSqlDetailHistory(sqlHistoryDetail);
                queryExecuterMap.put(sql, result);
                try {
                    result.makeTable(1, false);
                } catch (final SQLException ee) {
                    throw ee;
                }
                curResult.addElement(result);
                cntResults++;
            }
            QueryUtil.freeQuery(stmt, rs);
            stmt = null;
            rs = null;
            // SQL execution log
            sqlHistoryDetail.setSql(sql);
            RecentlyUsedSQLDetailPersistUtils.addLog(database, sqlHistoryDetail);
        }
    //				if (editor.isAutocommit()) {
    //					editor.queryAction(QUERY_ACTION.COMMIT);
    //				}
    } catch (final SQLException event) {
        LOGGER.error(event.getMessage(), event);
        //				}
        if (multiQuerySql == null || result == null) {
            final String errorSql = (String) qVector.get(currentQueryIndex);
            noSelectSql += errorSql;
            logs.append(QueryEditorPart.makeSqlErrorOnResult(currentQueryIndex, errorSql, event));
        } else {
            noSelectSql += result.getQuerySql();
            logs.append(result.getQueryMsg());
        }
        logsMap.put(sql, logs);
    } catch (final Exception event) {
        LOGGER.error(event.getMessage(), event);
        if (multiQuerySql == null || result == null) {
            final String errorSql = (String) qVector.get(currentQueryIndex);
            noSelectSql += errorSql;
            logs.append(QueryEditorPart.makeSqlErrorOnResult(currentQueryIndex, errorSql, event));
        } else {
            noSelectSql += result.getQuerySql();
            logs.append(result.getQueryMsg());
        }
        logsMap.put(sql, logs);
    } finally {
        RecentlyUsedSQLDetailPersistUtils.save(database);
        QueryUtil.freeQuery(stmt, rs);
        stmt = null;
        rs = null;
        if (connection != null && connection.isAutoClosable()) {
            connection.close();
        }
    }
}
Also used : DBConnection(com.cubrid.cubridmanager.core.common.jdbc.DBConnection) CTabFolder(org.eclipse.swt.custom.CTabFolder) SQLException(java.sql.SQLException) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Date(java.util.Date) SQLException(java.sql.SQLException) Vector(java.util.Vector) SimpleDateFormat(java.text.SimpleDateFormat) NumberFormat(java.text.NumberFormat)

Example 17 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.

the class MultiQueryThread method createResultQueryResultComposite.

public void createResultQueryResultComposite(SashForm parentForm, CubridDatabase database) {
    if (database == null) {
        createBlankResultComposite(parentForm);
        return;
    }
    CTabFolder folder1 = new CTabFolder(parentForm, SWT.TOP);
    folder1.setSimple(false);
    folder1.setUnselectedImageVisible(true);
    folder1.setUnselectedCloseVisible(true);
    folder1.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    folder1.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    folder1.setLayout(new GridLayout(1, true));
    folder1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    QueryResultComposite comp = new QueryResultComposite(folder1, true, this.editor);
    //		comp.setQueryResultTabItemName("[" + getData(MultiDBQueryComposite.INDEXKEY) + "]" + database.getUserName() +
    //				"@" + database.getDatabaseInfo().getDbName()
    //				+ "::" + database.getDatabaseInfo().getBrokerIP());
    comp.setQueryResultTabItemName("[" + database.getData(MultiDBQueryComposite.INDEXKEY) + "]" + database.getName() + "@" + database.getDatabaseInfo().getBrokerIP());
    comp.setCanDispose(true);
    dbResultMap.put(database, comp);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData)

Example 18 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.

the class ObjectInfoComposite method init.

public void init() {
    /*Tool bar composite*/
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    toolBarComposite.setLayout(rowLayout);
    toolBarComposite.setLayoutData(CommonUITool.createGridData(-1, -1, -1, 25));
    dataTabButton = new Button(toolBarComposite, SWT.None);
    dataTabButton.setText(Messages.tabTitleData);
    dataTabButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(0);
        }
    });
    ddlTabButton = new Button(toolBarComposite, SWT.None);
    ddlTabButton.setText(Messages.tabTitleDDL);
    ddlTabButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(1);
        }
    });
    columnTabButton = new Button(toolBarComposite, SWT.None);
    columnTabButton.setText(Messages.tabTitleColumn);
    columnTabButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(2);
        }
    });
    indexTabButton = new Button(toolBarComposite, SWT.None);
    indexTabButton.setText(Messages.tabTitleIndex);
    indexTabButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (objInfoFolder == null) {
                return;
            }
            objInfoFolder.setSelection(3);
        }
    });
    new Label(toolBarComposite, SWT.None).setText("  ");
    /*Select * button*/
    selectButton = new Button(toolBarComposite, SWT.None);
    selectButton.setText(Messages.txtSelect);
    selectButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            processSelectAction();
        }
    });
    /*Select column button*/
    selectColumnButton = new Button(toolBarComposite, SWT.None);
    selectColumnButton.setText(Messages.txtSelectColumn);
    selectColumnButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            processSelectColumnAction();
        }
    });
    /*Insert Button*/
    insertButton = new Button(toolBarComposite, SWT.None);
    insertButton.setText(Messages.txtInsert);
    insertButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            processInsertAction();
        }
    });
    /*Update button*/
    updateButton = new Button(toolBarComposite, SWT.None);
    updateButton.setText(Messages.txtUpdate);
    updateButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            processUpdateAction();
        }
    });
    /*Delete button*/
    deleteButton = new Button(toolBarComposite, SWT.None);
    deleteButton.setText(Messages.txtDelete);
    deleteButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            processDeleteAction();
        }
    });
    /*Database object information*/
    objInfoFolder = new CTabFolder(this, SWT.BOTTOM);
    objInfoFolder.setSimple(false);
    objInfoFolder.setUnselectedImageVisible(true);
    objInfoFolder.setUnselectedCloseVisible(true);
    objInfoFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    objInfoFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    objInfoFolder.setLayout(new GridLayout(1, true));
    objInfoFolder.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, -1, -1, -1, -1));
    /*Demo data tab item*/
    initDataTabItem();
    /*DDL tab item*/
    initDDLTabItem();
    /*Column tab item*/
    initColumnTabItem();
    /*If is table, create index tab item*/
    if (isTable) {
        initIndexTabItem();
    }
    /*Initial the data*/
    TaskJobExecutor taskExec = new CommonTaskJobExec() {

        public IStatus exec(IProgressMonitor monitor) {
            IStatus status = super.exec(monitor);
            if (Status.CANCEL_STATUS == status) {
                return status;
            }
            return Status.OK_STATUS;
        }

        public void done(IJobChangeEvent event) {
            getInfoDataTask = null;
        }
    };
    GetInfoDataTask getInfoDataTask = new GetInfoDataTask(Messages.getInfoJobName, this, schemaNode, isTable);
    taskExec.addTask(getInfoDataTask);
    /*Get data job*/
    TaskJob job = new TaskJob(Messages.bind(Messages.getInfoJobName, schemaNode.getName()), taskExec);
    job.setPriority(Job.LONG);
    job.setUser(false);
    job.schedule();
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) IStatus(org.eclipse.core.runtime.IStatus) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent) TaskJob(com.cubrid.common.ui.spi.progress.TaskJob) GridLayout(org.eclipse.swt.layout.GridLayout) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Button(org.eclipse.swt.widgets.Button) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 19 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.

the class CombinedQueryEditorComposite method createResultFolder.

/**
	 * Create the result folder including query result and query plan result
	 *
	 * @param topSash SashForm
	 * @param sqlEditorParentComp Composite
	 */
private void createResultFolder(final SashForm topSash, final Composite sqlEditorParentComp) {
    final Composite resultComp = new Composite(topSash, SWT.NONE);
    {
        GridLayout gridLayout = new GridLayout();
        gridLayout.horizontalSpacing = 0;
        gridLayout.verticalSpacing = 0;
        gridLayout.marginWidth = 0;
        gridLayout.marginHeight = 0;
        resultComp.setLayout(gridLayout);
        resultComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    }
    // result folder
    final CTabFolder resultTabFolder = new CTabFolder(resultComp, SWT.TOP);
    resultTabFolder.setLayout(new FillLayout());
    resultTabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    resultTabFolder.setSimple(false);
    resultTabFolder.setUnselectedImageVisible(true);
    resultTabFolder.setUnselectedCloseVisible(true);
    resultTabFolder.setSelectionBackground(BACK_COLOR);
    resultTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    resultTabFolder.setMinimizeVisible(true);
    resultTabFolder.setMaximizeVisible(true);
    this.resultTabFolder = resultTabFolder;
    resultTabFolder.addCTabFolder2Listener(new CTabFolder2Listener() {

        public void close(CTabFolderEvent event) {
        }

        public void maximize(CTabFolderEvent event) {
            resultTabFolder.setMaximized(true);
            topSash.setMaximizedControl(resultComp);
            editor.getShowResultItem().setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
            topSash.layout(true);
        }

        public void minimize(CTabFolderEvent event) {
            resultTabFolder.setMinimized(true);
            topSash.setMaximizedControl(sqlEditorParentComp);
            editor.getShowResultItem().setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
            topSash.layout(true);
        }

        public void restore(CTabFolderEvent event) {
            resultTabFolder.setMinimized(false);
            resultTabFolder.setMaximized(false);
            topSash.setMaximizedControl(null);
            editor.getShowResultItem().setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
            topSash.layout(true);
        }

        public void showList(CTabFolderEvent event) {
        }
    });
    // query result tab area
    queryResultComp = new QueryResultComposite(resultTabFolder, SWT.NONE, editor);
    // query plan result tab area
    queryPlanResultComp = new QueryPlanCompositeWithHistory(resultTabFolder, SWT.NONE, editor);
    // recently Used SQL tab area
    recentlyUsedSQLComposite = new RecentlyUsedSQLComposite(resultTabFolder, SWT.NONE, editor);
    recentlyUsedSQLComposite.initialize();
    // create multiple query
    multiDBQueryComp = new MultiDBQueryComposite(resultTabFolder, SWT.NONE, editor);
    multiDBQueryComp.initialize();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) CTabFolder2Listener(org.eclipse.swt.custom.CTabFolder2Listener) GridData(org.eclipse.swt.layout.GridData) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 20 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.

the class QueryEditorPart method createCombinedQueryEditorCTabFolder.

/**
	 * create editor CTabFolder all sql editor tab will add to this
	 */
public void createCombinedQueryEditorCTabFolder() {
    combinedQueryEditortabFolder = new CTabFolder(topComposite, SWT.TOP);
    combinedQueryEditortabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    combinedQueryEditortabFolder.setUnselectedImageVisible(true);
    combinedQueryEditortabFolder.setUnselectedCloseVisible(false);
    combinedQueryEditortabFolder.setBorderVisible(true);
    combinedQueryEditortabFolder.setSimple(false);
    combinedQueryEditortabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    combinedQueryEditortabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    combinedQueryEditortabFolder.setMinimizeVisible(false);
    combinedQueryEditortabFolder.setMaximizeVisible(false);
    combinedQueryEditortabFolder.setTabHeight(22);
    combinedQueryEditortabFolder.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            CTabItem item = combinedQueryEditortabFolder.getSelection();
            if (item instanceof SubQueryEditorTabItem) {
                SubQueryEditorTabItem queryResultTabItem = (SubQueryEditorTabItem) item;
                combinedQueryComposite = queryResultTabItem.getControl();
                combinedQueryComposite.refreshEditorComposite();
                InfoWindowManager.getInstance().updateContent(QueryEditorPart.this);
            }
        }
    });
    TabContextMenuManager ctxmenu = new TabContextMenuManager(combinedQueryEditortabFolder);
    ctxmenu.createContextMenu();
    //add a default SQL Tab item
    addEditorTab();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CTabItem(org.eclipse.swt.custom.CTabItem) TabContextMenuManager(com.cubrid.common.ui.spi.util.TabContextMenuManager)

Aggregations

CTabFolder (org.eclipse.swt.custom.CTabFolder)66 CTabItem (org.eclipse.swt.custom.CTabItem)36 GridData (org.eclipse.swt.layout.GridData)35 GridLayout (org.eclipse.swt.layout.GridLayout)27 Composite (org.eclipse.swt.widgets.Composite)26 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 FillLayout (org.eclipse.swt.layout.FillLayout)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)13 Label (org.eclipse.swt.widgets.Label)13 Point (org.eclipse.swt.graphics.Point)9 Shell (org.eclipse.swt.widgets.Shell)8 StyledText (org.eclipse.swt.custom.StyledText)7 SelectionListener (org.eclipse.swt.events.SelectionListener)7 Button (org.eclipse.swt.widgets.Button)7 SashForm (org.eclipse.swt.custom.SashForm)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6 FormData (org.eclipse.swt.layout.FormData)6 Text (org.eclipse.swt.widgets.Text)6 ToolBar (org.eclipse.swt.widgets.ToolBar)6 ToolItem (org.eclipse.swt.widgets.ToolItem)6