Search in sources :

Example 41 with CTabFolder

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

the class TableSchemaCompareInfoPart method createTabFolder.

public void createTabFolder(Composite parent) {
    tabFolder = new CTabFolder(parent, SWT.TOP);
    tabFolder.setLayout(new FillLayout());
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tabFolder.setSimple(true);
    tabFolder.setUnselectedImageVisible(true);
    tabFolder.setUnselectedCloseVisible(true);
    tabFolder.setSelectionBackground(ResourceManager.getColor(136, 161, 227));
    tabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    Menu contextMenu = new Menu(tabFolder);
    tabFolder.setMenu(contextMenu);
    MenuItem closeItem = new MenuItem(contextMenu, SWT.POP_UP);
    closeItem.setText(Messages.closeAllTabs);
    closeItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            CTabItem[] items = tabFolder.getItems();
            for (CTabItem item : items) {
                item.dispose();
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
        }
    });
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) Menu(org.eclipse.swt.widgets.Menu) CTabItem(org.eclipse.swt.custom.CTabItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 42 with CTabFolder

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

the class QueryEditorPart method fillInToolbar.

public void fillInToolbar() {
    qeToolBar.addDatabaseChangedListener(new Listener() {

        public void handleEvent(Event event) {
            Object data = event.data;
            if (data instanceof CubridDatabase) {
                CubridDatabase database = (CubridDatabase) data;
                if (database == DatabaseNavigatorMenu.NULL_DATABASE) {
                    resetJDBCConnection();
                } else {
                    initConnection(database);
                }
                ServerInfo serverInfo = database.getServer() == null ? null : database.getServer().getServerInfo();
                boolean autoCommit = QueryOptions.getAutoCommit(serverInfo);
                setAutocommit(autoCommit);
            }
        }
    });
    final ToolBar toolBar = qeToolBar;
    // [TOOLS-2425]Support shard broker
    changeShardIdValItem = new ToolItem(toolBar, SWT.PUSH);
    changeShardIdValItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/change_shard_id.png"));
    changeShardIdValItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/change_shard_id_disabled.png"));
    changeShardIdValItem.setToolTipText(Messages.changeShardId);
    changeShardIdValItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            CubridDatabase cubridDatabase = getSelectedDatabase();
            if (cubridDatabase != null) {
                DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
                if (dbInfo != null && dbInfo.isShard()) {
                    ShardIdSelectionDialog dialog = new ShardIdSelectionDialog(Display.getDefault().getActiveShell());
                    dialog.setDatabaseInfo(dbInfo);
                    dialog.setShardId(shardId);
                    dialog.setShardVal(shardVal);
                    dialog.setShardQueryType(shardQueryType);
                    if (dialog.open() == IDialogConstants.OK_ID) {
                        shardId = dialog.getShardId();
                        shardVal = dialog.getShardVal();
                        shardQueryType = dialog.getShardQueryType();
                        changeQueryEditorPartNameWithShard();
                    }
                }
            }
        }
    });
    CubridDatabase cubridDatabase = getSelectedDatabase();
    if (cubridDatabase == null || CubridDatabase.hasValidDatabaseInfo(cubridDatabase) && cubridDatabase.getDatabaseInfo().isShard()) {
        changeShardIdValItem.setEnabled(false);
    }
    new ToolItem(toolBar, SWT.SEPARATOR);
    runItem = new ToolItem(toolBar, SWT.PUSH);
    runItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_run.png"));
    runItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_run_disabled.png"));
    runItem.setToolTipText(Messages.run + "(F5)");
    runItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            runQuery(false);
        }
    });
    multiRunItem = new ToolItem(toolBar, SWT.PUSH);
    multiRunItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_multi_run.png"));
    multiRunItem.setToolTipText(Messages.runMultiQuery + "(F8)");
    multiRunItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            changeMultiQueryMode();
        }
    });
    queryPlanItem = new ToolItem(toolBar, SWT.PUSH);
    queryPlanItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_execution_plan.png"));
    queryPlanItem.setToolTipText(Messages.queryPlanTip + "(F6)");
    queryPlanItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            runQuery(true);
        }
    });
    ToolItem historyItem = new ToolItem(toolBar, SWT.PUSH);
    historyItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_history.png"));
    historyItem.setToolTipText(Messages.queryHistory + "(F7)");
    historyItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            getCombinedQueryComposite().select(2, -1);
        }
    });
    setPstmtParaItem = new ToolItem(toolBar, SWT.PUSH);
    setPstmtParaItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_set_param.png"));
    setPstmtParaItem.setToolTipText(Messages.tipSetPstmt);
    setPstmtParaItem.setEnabled(false);
    setPstmtParaItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
                return;
            }
            PstmtSQLDialog dialog = new PstmtSQLDialog(getSite().getShell(), getSelectedDatabase());
            dialog.create();
            dialog.setEditorInput((QueryUnit) getEditorInput());
            String queries = getSelectedText();
            dialog.setSql(queries);
            dialog.open();
        }
    });
    tuneModeItem = new ToolItem(toolBar, SWT.CHECK);
    tuneModeItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/tune_mode.png"));
    tuneModeItem.setToolTipText(Messages.tipExecStat + "(F9)");
    tuneModeItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            boolean isTuneMode = tuneModeItem.getSelection();
            changeCollectExecStats(isTuneMode);
            if (isTuneMode) {
                showToolTip(qeToolBar, tuneModeItem, Messages.ttQeToolbarTuneModeTitle, Messages.ttQeToolbarTuneModeMSg);
            } else {
                hideToolTip();
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    final ToolItem addEditorItem = new ToolItem(toolBar, SWT.PUSH);
    addEditorItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/tab_item_add.png"));
    addEditorItem.setToolTipText(Messages.queryEditorAddTabItemTooltip + "(Ctrl+Shift+T)");
    addEditorItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            addEditorTab();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    runBatchItem = new ToolItem(toolBar, SWT.PUSH);
    runBatchItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/run_batch_sql.png"));
    runBatchItem.setToolTipText(Messages.batchRun);
    runBatchItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            try {
                // FIXME extract utility
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IViewPart view = page.findView(FavoriteQueryNavigatorView.ID);
                if (view != null) {
                    page.hideView(view);
                } else {
                    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(FavoriteQueryNavigatorView.ID, null, IWorkbenchPage.VIEW_ACTIVATE);
                }
            } catch (PartInitException e) {
                LOGGER.error(e.getMessage(), e);
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem itemFormatterr = new ToolItem(toolBar, SWT.PUSH);
    itemFormatterr.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_format.png"));
    itemFormatterr.setToolTipText(Messages.formatTip + "(Ctrl+Shift+F)");
    itemFormatterr.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            combinedQueryComposite.getSqlEditorComp().format();
        }
    });
    ToolItem itemIndent = new ToolItem(toolBar, SWT.PUSH);
    itemIndent.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_indent_add.png"));
    itemIndent.setToolTipText(Messages.indentTip + "(Tab)");
    itemIndent.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
                return;
            }
            combinedQueryComposite.getSqlEditorComp().indent();
        }
    });
    ToolItem itemUnindent = new ToolItem(toolBar, SWT.PUSH);
    itemUnindent.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_indent_delete.png"));
    itemUnindent.setToolTipText(Messages.unIndentTip + "(Shift+Tab)");
    itemUnindent.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
                return;
            }
            combinedQueryComposite.getSqlEditorComp().unindent();
        }
    });
    ToolItem clearItem = new ToolItem(toolBar, SWT.PUSH);
    clearItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/clear_sql.png"));
    clearItem.setToolTipText(Messages.clear);
    clearItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
                return;
            }
            if (!CommonUITool.openConfirmBox(Messages.msgClear)) {
                return;
            }
            combinedQueryComposite.getSqlEditorComp().setQueries("");
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem itemComment = new ToolItem(toolBar, SWT.PUSH);
    itemComment.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_comment_add.png"));
    itemComment.setToolTipText(Messages.commentTip + "(Ctrl+/)");
    itemComment.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
                return;
            }
            combinedQueryComposite.getSqlEditorComp().comment();
        }
    });
    ToolItem itemUncomment = new ToolItem(toolBar, SWT.PUSH);
    itemUncomment.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_comment_delete.png"));
    itemUncomment.setToolTipText(Messages.unCommentTip + "(Ctrl+/)");
    itemUncomment.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (combinedQueryComposite.getSqlEditorComp().isDisposed()) {
                return;
            }
            combinedQueryComposite.getSqlEditorComp().uncomment();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    commitItem = new ToolItem(toolBar, SWT.PUSH);
    commitItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit.png"));
    commitItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_commit_disabled.png"));
    commitItem.setToolTipText(Messages.commit);
    commitItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            commit();
        }
    });
    commitItem.setEnabled(false);
    rollbackItem = new ToolItem(toolBar, SWT.PUSH);
    rollbackItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback.png"));
    rollbackItem.setDisabledImage(CommonUIPlugin.getImage("icons/queryeditor/query_rollback_disabled.png"));
    rollbackItem.setToolTipText(Messages.rollback);
    rollbackItem.setEnabled(false);
    rollbackItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            rollback();
        }
    });
    autoCommitItem = new ToolItem(toolBar, SWT.CHECK);
    autoCommitItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/query_auto_false.png"));
    autoCommitItem.setToolTipText(Messages.autoCommit);
    autoCommitItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            if (checkActive()) {
                return;
            }
            setAutocommit(autoCommitItem.getSelection());
            if (connection != null) {
                try {
                    connection.setAutoCommit(isAutocommit());
                } catch (SQLException e) {
                }
            }
        }
    });
    setAutocommit(true);
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem openItem = new ToolItem(toolBar, SWT.PUSH);
    openItem.setImage(CommonUIPlugin.getImage("/icons/queryeditor/file_open.png"));
    openItem.setToolTipText(Messages.open);
    openItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            doOpen();
        }
    });
    ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
    saveItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveItem.setToolTipText(Messages.save);
    saveItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            doSave(new NullProgressMonitor());
        }
    });
    ToolItem saveAsItem = new ToolItem(toolBar, SWT.PUSH);
    saveAsItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
    saveAsItem.setToolTipText(Messages.saveAs);
    saveAsItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            doSaveAs();
        }
    });
    //Fill in the show or hide result pane tool item
    new ToolItem(toolBar, SWT.SEPARATOR);
    showResultItem = new ToolItem(toolBar, SWT.PUSH);
    showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
    showResultItem.setToolTipText(Messages.tooltip_qedit_result_show_hide);
    showResultItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            hideToolTip();
            CTabFolder resultTabFolder = combinedQueryComposite.getResultTabFolder();
            SashForm topSash = combinedQueryComposite.getTopSash();
            if (resultTabFolder.getMinimized()) {
                resultTabFolder.setMinimized(false);
                resultTabFolder.setMaximized(false);
                topSash.setMaximizedControl(null);
                showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_down.png"));
                topSash.layout(true);
            } else if (!resultTabFolder.getMaximized() && !resultTabFolder.getMinimized()) {
                resultTabFolder.setMinimized(true);
                topSash.setMaximizedControl(combinedQueryComposite.getSqlEditorComp().getParent());
                showResultItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/qe_panel_up.png"));
                topSash.layout(true);
            }
        }
    });
    topComposite.pack();
    packToolBar();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IViewPart(org.eclipse.ui.IViewPart) ITextListener(org.eclipse.jface.text.ITextListener) Listener(org.eclipse.swt.widgets.Listener) IPartListener(org.eclipse.ui.IPartListener) DisposeListener(org.eclipse.swt.events.DisposeListener) CTabFolder(org.eclipse.swt.custom.CTabFolder) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SQLException(java.sql.SQLException) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) PstmtSQLDialog(com.cubrid.common.ui.cubrid.table.dialog.PstmtSQLDialog) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ShardIdSelectionDialog(com.cubrid.common.ui.common.dialog.ShardIdSelectionDialog) SashForm(org.eclipse.swt.custom.SashForm) EditorToolBar(com.cubrid.common.ui.query.control.EditorToolBar) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Event(org.eclipse.swt.widgets.Event) TextEvent(org.eclipse.jface.text.TextEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 43 with CTabFolder

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

the class QueryRecordListComparator method createDialogArea.

/**
	 * Create dialog area content
	 *
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite container = new Composite(parent, SWT.None);
    container.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    container.setLayout(new FormLayout());
    topComposite = new Composite(container, SWT.None);
    FormData topData = new FormData();
    topData.top = new FormAttachment(0, 0);
    topData.bottom = new FormAttachment(0, 30);
    topData.left = new FormAttachment(0, 0);
    topData.right = new FormAttachment(100, 0);
    topComposite.setLayoutData(topData);
    topComposite.setLayout(new GridLayout(6, false));
    Label historyLable = new Label(topComposite, SWT.None);
    historyLable.setText(Messages.lblProject);
    historyLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    historyCombo = new Combo(topComposite, SWT.READ_ONLY);
    historyCombo.setLayoutData(CommonUITool.createGridData(1, 1, 200, -1));
    historyCombo.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            String name = historyCombo.getText();
            switchQueryRecordProject(name);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    ToolBar toolBar = new ToolBar(topComposite, SWT.None);
    toolBar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    addItem = new ToolItem(toolBar, SWT.PUSH);
    addItem.setImage(CommonUIPlugin.getImage("icons/queryplan/add_query.gif"));
    addItem.setToolTipText(Messages.itemTooltipAdd);
    addItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            addQueryRecordProject();
        }
    });
    deleteItem = new ToolItem(toolBar, SWT.PUSH);
    deleteItem.setImage(CommonUIPlugin.getImage("icons/queryplan/delete_query.gif"));
    deleteItem.setToolTipText(Messages.itemTooltipRemove);
    deleteItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
            if (queryRecordLeftCombo.getItemCount() == 0) {
                CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
                tabFolder.setSelection(0);
            }
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            if (CommonUITool.openConfirmBox(Messages.confirmDeleteTuningProject)) {
                ApplicationPersistUtil.getInstance().removeQueryRecordProject(database.getDatabaseInfo(), historyCombo.getText());
                ApplicationPersistUtil.getInstance().save();
                switchQueryRecordProject("");
            }
        }
    });
    renameItem = new ToolItem(toolBar, SWT.PUSH);
    renameItem.setImage(CommonUIPlugin.getImage("icons/queryplan/rename_query.gif"));
    renameItem.setToolTipText(Messages.itemTooltipRename);
    renameItem.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            renameQueryRecordProject();
        }
    });
    Label placeHolderLabel = new Label(topComposite, SWT.None);
    placeHolderLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    buttomComposite = new Composite(container, SWT.None);
    buttomComposite.setLayout(new FillLayout());
    FormData buttomData = new FormData();
    buttomData.top = new FormAttachment(0, 30);
    buttomData.bottom = new FormAttachment(100, 0);
    buttomData.left = new FormAttachment(0, 0);
    buttomData.right = new FormAttachment(100, 0);
    buttomComposite.setLayoutData(buttomData);
    buttomComposite.setLayout(new FillLayout());
    tabFolder = new CTabFolder(buttomComposite, SWT.BORDER);
    tabFolder.setTabHeight(20);
    tabFolder.marginHeight = 5;
    tabFolder.marginWidth = 5;
    tabFolder.setMaximizeVisible(false);
    tabFolder.setMinimizeVisible(false);
    tabFolder.setSimple(false);
    tabFolder.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            if (tabFolder.getSelectionIndex() == 1) {
                List<QueryRecordProject> projectList = loadProjectList();
                if (projectList.size() == 0) {
                    CommonUITool.openErrorBox(Messages.msgQueryTunerNotSavedProject);
                    tabFolder.setSelection(0);
                } else {
                    QueryRecordProject usingProject = null;
                    String projectName = historyCombo.getText();
                    for (int i = 0; i < projectList.size(); i++) {
                        QueryRecordProject temp = projectList.get(i);
                        if (StringUtil.isEqual(projectName, temp.getName())) {
                            usingProject = temp;
                            break;
                        }
                    }
                    if (usingProject != null) {
                        if (usingProject.getQueryRecordList().size() == 0) {
                            CommonUITool.openErrorBox(Messages.errNoQueryInProject);
                            return;
                        }
                        switchQueryRecordProject(historyCombo.getText());
                    }
                }
            }
        }
    });
    createQueryTunerTab(tabFolder);
    createQueryCompareTab(tabFolder);
    init();
    return parent;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) QueryPlanComposite(com.cubrid.common.ui.query.control.queryplan.QueryPlanComposite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) QueryRecordProject(com.cubrid.common.ui.query.tuner.QueryRecordProject) GridLayout(org.eclipse.swt.layout.GridLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) ArrayList(java.util.ArrayList) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 44 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.

the class SMAPSView method createRootTabFolder.

/**
	 * 初始化根CTablFolder
	 * @param parent
	 */
private void createRootTabFolder(Composite parent) {
    rootTabFolder = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
    rootTabFolder.setTabHeight(20);
    rootTabFolder.setLayout(new FillLayout());
    rootTabFolder.marginHeight = 10;
    rootTabFolder.marginWidth = 10;
    rootTabFolder.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    rootTabFolder.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    rootTabFolder.setUnselectedCloseVisible(true);
    rootTabFolder.pack();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 45 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project dbeaver by serge-rider.

the class DatabaseEditorUtils method setPartBackground.

public static void setPartBackground(IEditorPart editor, Composite composite) {
    CTabFolder tabFolder = null;
    Composite rootComposite = null;
    for (Composite c = composite; c != null; c = c.getParent()) {
        if (c.getParent() instanceof CTabFolder) {
            tabFolder = (CTabFolder) c.getParent();
            rootComposite = c;
            break;
        }
    }
    if (tabFolder == null) {
        return;
    }
    tabFolder.setBorderVisible(false);
    Color bgColor = null;
    if (editor instanceof IDataSourceContainerProvider) {
        DBPDataSourceContainer container = ((IDataSourceContainerProvider) editor).getDataSourceContainer();
        if (container != null) {
            bgColor = UIUtils.getConnectionColor(container.getConnectionConfiguration());
        }
    } else if (editor instanceof DBPContextProvider) {
        DBCExecutionContext context = ((DBPContextProvider) editor).getExecutionContext();
        if (context != null) {
            bgColor = UIUtils.getConnectionColor(context.getDataSource().getContainer().getConnectionConfiguration());
        }
    }
    if (bgColor == null) {
        rootComposite.setBackground(null);
    } else {
        rootComposite.setBackground(bgColor);
    }
}
Also used : IDataSourceContainerProvider(org.jkiss.dbeaver.model.IDataSourceContainerProvider) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) DBPContextProvider(org.jkiss.dbeaver.model.DBPContextProvider) Color(org.eclipse.swt.graphics.Color) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

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