Search in sources :

Example 76 with ToolBar

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

the class CubridNavigatorView method createPartControl.

/**
	 * Create the part control
	 *
	 * @param parent Composite
	 */
public void createPartControl(Composite parent) {
    ViewForm viewForm = new ViewForm(parent, SWT.NONE);
    viewForm.setLayout(new GridLayout());
    tv = new TreeViewer(viewForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    tv.setFilters(NodeFilterManager.getInstance().getViewerFilter());
    //create the navigator
    createNavigator();
    //get the isShowGroup configuration
    isShowGroup = savedIsShowGroup();
    //set the tree view's input.
    setTreeInput();
    toolTip = new ToolTip(tv.getTree().getShell(), SWT.BALLOON);
    toolTip.setAutoHide(true);
    //Create the context menu
    MenuManager contextMenuManager = new MenuManager("#PopupMenu", "navigatorContextMenu");
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            buildPopupMenu(manager);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(tv.getControl());
    tv.getControl().setMenu(contextMenu);
    // register the context menu for providing extension by extension point
    IWorkbenchPartSite site = getSite();
    site.registerContextMenu(contextMenuManager, tv);
    site.setSelectionProvider(tv);
    //add the select the object text composite to top left of toolbar
    ToolBar toolBar = new ToolBar(viewForm, SWT.FLAT);
    ToolBarManager toolBarManager = new ToolBarManager(toolBar);
    SelectTreeObjContrItem textContrItem = new SelectTreeObjContrItem(tv);
    toolBarManager.add(textContrItem);
    toolBarManager.update(true);
    viewForm.setContent(tv.getControl());
    viewForm.setTopLeft(toolBar);
    //add the other actions to the top right of toolbar
    toolBar = new ToolBar(viewForm, SWT.FLAT | SWT.CENTER);
    toolBarManager = new ToolBarManager(toolBar);
    buildToolBar(toolBarManager);
    toolBarManager.update(true);
    viewForm.setTopRight(toolBar);
    //Add the actions to view menu bar, you can add them by extension point or code define
    IActionBars actionBar = getViewSite().getActionBars();
    final IMenuManager menuManager = actionBar.getMenuManager();
    menuManager.addMenuListener(new IMenuListener2() {

        //reserve these actions by code define,these codes rebuild every time.
        //hence when hide, remove them not including these actions by extension point
        private IMenuManager lastMenuManager = new MenuManager();

        public void menuAboutToShow(IMenuManager manager) {
            lastMenuManager.removeAll();
            //build the code defined actions
            buildViewMenu(lastMenuManager);
            for (IContributionItem item : lastMenuManager.getItems()) {
                manager.add(item);
            }
        }

        public void menuAboutToHide(IMenuManager manager) {
            for (IContributionItem item : lastMenuManager.getItems()) {
                manager.remove(item);
            }
        }
    });
    menuManager.add(new Separator());
    activeContext();
    addListener();
    setFocus();
}
Also used : ToolTip(org.eclipse.swt.widgets.ToolTip) TreeViewer(org.eclipse.jface.viewers.TreeViewer) IContributionItem(org.eclipse.jface.action.IContributionItem) IMenuListener(org.eclipse.jface.action.IMenuListener) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ViewForm(org.eclipse.swt.custom.ViewForm) GridLayout(org.eclipse.swt.layout.GridLayout) IMenuListener2(org.eclipse.jface.action.IMenuListener2) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ToolBar(org.eclipse.swt.widgets.ToolBar) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) IActionBars(org.eclipse.ui.IActionBars) Separator(org.eclipse.jface.action.Separator)

Example 77 with ToolBar

use of org.eclipse.swt.widgets.ToolBar 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 78 with ToolBar

use of org.eclipse.swt.widgets.ToolBar 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 79 with ToolBar

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

the class AddTableFileDialog method createFromComposite.

/**
	 * Create the from composite
	 */
private void createFromComposite() {
    Composite fromComposite = new Composite(sashForm, SWT.NONE);
    {
        GridLayout gridLayout = new GridLayout();
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginWidth = 0;
        gridLayout.verticalSpacing = 5;
        gridLayout.marginHeight = 0;
        fromComposite.setLayout(gridLayout);
    }
    Label lblFrom = new Label(fromComposite, SWT.NONE);
    lblFrom.setText(Messages.colFileColumn);
    fromList = new org.eclipse.swt.widgets.List(fromComposite, SWT.BORDER | SWT.V_SCROLL);
    {
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.grabExcessVerticalSpace = true;
        gridData.horizontalAlignment = GridData.FILL;
        gridData.heightHint = 200;
        fromList.setLayoutData(gridData);
    }
    ToolBar fromToolbar = new ToolBar(fromComposite, SWT.FLAT);
    fromToolbar.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
    ToolItem itemDel = new ToolItem(fromToolbar, SWT.PUSH);
    itemDel.setText(Messages.importDeleteExcelColumnBTN);
    itemDel.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (fromList.getItemCount() > 0 && fromList.getSelectionCount() > 0) {
                int index = fromList.getSelectionIndex();
                if (index == fromList.getItemCount() - 1) {
                    fromList.setSelection(index - 1);
                    fromList.remove(index);
                } else {
                    fromList.remove(index);
                    fromList.setSelection(index);
                }
                validate();
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 80 with ToolBar

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

the class SettingCubridHAConfPage method createControl.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    setControl(container);
    setDescription(Messages.descSettingCubridHAPage);
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout(4, false));
    FormData leftData = new FormData();
    leftData.top = new FormAttachment(0, 5);
    leftData.bottom = new FormAttachment(100, 0);
    leftData.left = new FormAttachment(0, 5);
    leftData.right = new FormAttachment(50, -5);
    leftComposite.setLayoutData(leftData);
    Label separator = new Label(container, SWT.SEPARATOR);
    FormData separatorData = new FormData();
    separatorData.top = new FormAttachment(0, 5);
    separatorData.bottom = new FormAttachment(100, -5);
    separatorData.left = new FormAttachment(50, -5);
    separatorData.right = new FormAttachment(50, 5);
    separator.setLayoutData(separatorData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    rightComposite.setLayout(new GridLayout(4, false));
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(50, 5);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    /*Create left widget*/
    Label hostALabel = new Label(leftComposite, SWT.None);
    hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hostALabel.setText(Messages.lblMaster);
    masterHostLabel = new Label(leftComposite, SWT.None);
    masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
    masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
    masterViewer.getTable().setLinesVisible(true);
    masterViewer.getTable().setHeaderVisible(true);
    masterViewer.setContentProvider(new TableContentProvider());
    masterViewer.setLabelProvider(new CubridConfTableProvider());
    masterViewer.setColumnProperties(PROPS);
    CellEditor[] editors = new CellEditor[2];
    editors[0] = null;
    editors[1] = new TextCellEditor(masterViewer.getTable());
    masterViewer.setCellEditors(editors);
    masterViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(PROPS[1])) {
                return true;
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            DataModel model = (DataModel) element;
            if (property.equals(PROPS[0])) {
                return model.getKey() == null ? "" : model.getKey();
            } else if (property.equals(PROPS[1])) {
                return model.getValue() == null ? "" : model.getValue();
            }
            return "";
        }

        public void modify(Object element, String property, Object value) {
            TableItem item = (TableItem) element;
            DataModel model = (DataModel) item.getData();
            model.setValue(value.toString());
            masterViewer.refresh(model);
            updateHAModel(masterViewer, model, false);
        }
    });
    TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
    keyAColumn.setText(Messages.lblKey);
    keyAColumn.setWidth(160);
    TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
    valueAColumn.setText(Messages.lblValue);
    valueAColumn.setWidth(200);
    Label masterUserLabel = new Label(leftComposite, SWT.None);
    masterUserLabel.setText(Messages.lblUser);
    masterUserLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterUserCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
    masterUserCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    masterUserCombo.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            initMasterTableData();
        }
    });
    ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
    toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, -1, -1));
    ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
    addItemA.setToolTipText(Messages.itemAddParameter);
    addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
    addItemA.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            addParameter(masterViewer);
        }
    });
    ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
    editItemA.setToolTipText(Messages.itemEditParameter);
    editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
    editItemA.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            editParameter(masterViewer);
        }
    });
    ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
    dropItemA.setToolTipText(Messages.itemDeleteParameter);
    dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
    dropItemA.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            dropParameter(masterViewer);
        }
    });
    /*Create right widget*/
    Label hostBLabel = new Label(rightComposite, SWT.None);
    hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    hostBLabel.setText(Messages.lblSlave);
    slaveHostLabel = new Label(rightComposite, SWT.None);
    slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
    slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
    slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
    slaveViewer.getTable().setLinesVisible(true);
    slaveViewer.getTable().setHeaderVisible(true);
    slaveViewer.setContentProvider(new TableContentProvider());
    slaveViewer.setLabelProvider(new CubridConfTableProvider());
    slaveViewer.setColumnProperties(PROPS);
    CellEditor[] editorsB = new CellEditor[2];
    editorsB[0] = null;
    editorsB[1] = new TextCellEditor(slaveViewer.getTable());
    slaveViewer.setCellEditors(editorsB);
    slaveViewer.setCellModifier(new ICellModifier() {

        public boolean canModify(Object element, String property) {
            if (property.equals(PROPS[1])) {
                return true;
            }
            return false;
        }

        public Object getValue(Object element, String property) {
            DataModel model = (DataModel) element;
            if (property.equals(PROPS[0])) {
                return model.getKey() == null ? "" : model.getKey();
            } else if (property.equals(PROPS[1])) {
                return model.getValue() == null ? "" : model.getValue();
            }
            return "";
        }

        public void modify(Object element, String property, Object value) {
            TableItem item = (TableItem) element;
            DataModel model = (DataModel) item.getData();
            model.setValue(value.toString());
            slaveViewer.refresh(model);
            updateHAModel(slaveViewer, model, false);
        }
    });
    TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
    keyBColumn.setText(Messages.lblKey);
    keyBColumn.setWidth(160);
    TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
    valueBColumn.setText(Messages.lblValue);
    valueBColumn.setWidth(200);
    Label slaveUserLabel = new Label(rightComposite, SWT.None);
    slaveUserLabel.setText(Messages.lblUser);
    slaveUserLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    slaveUserCombo = new Combo(rightComposite, SWT.BORDER | SWT.READ_ONLY);
    slaveUserCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    slaveUserCombo.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            initSlaveTableData();
        }
    });
    ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
    toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 2, 1, -1, -1));
    ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
    addItemB.setToolTipText(Messages.itemAddParameter);
    addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
    addItemB.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            addParameter(slaveViewer);
        }
    });
    ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
    editItemB.setToolTipText(Messages.itemEditParameter);
    editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
    editItemB.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            editParameter(slaveViewer);
        }
    });
    ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
    dropItemB.setToolTipText(Messages.itemDeleteParameter);
    dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
    dropItemB.addSelectionListener(new SelectionListener() {

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

        public void widgetDefaultSelected(SelectionEvent e) {
            dropParameter(slaveViewer);
        }
    });
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) ICellModifier(org.eclipse.jface.viewers.ICellModifier) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) FormAttachment(org.eclipse.swt.layout.FormAttachment) ToolItem(org.eclipse.swt.widgets.ToolItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

ToolBar (org.eclipse.swt.widgets.ToolBar)127 ToolItem (org.eclipse.swt.widgets.ToolItem)110 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 GridData (org.eclipse.swt.layout.GridData)81 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)74 GridLayout (org.eclipse.swt.layout.GridLayout)68 Composite (org.eclipse.swt.widgets.Composite)67 Image (org.eclipse.swt.graphics.Image)35 Label (org.eclipse.swt.widgets.Label)34 DisposeEvent (org.eclipse.swt.events.DisposeEvent)27 DisposeListener (org.eclipse.swt.events.DisposeListener)26 Point (org.eclipse.swt.graphics.Point)24 Cursor (org.eclipse.swt.graphics.Cursor)22 TableViewer (org.eclipse.jface.viewers.TableViewer)18 FillLayout (org.eclipse.swt.layout.FillLayout)18 Button (org.eclipse.swt.widgets.Button)17 Text (org.eclipse.swt.widgets.Text)17 ArrayList (java.util.ArrayList)14 SashForm (org.eclipse.swt.custom.SashForm)14 Combo (org.eclipse.swt.widgets.Combo)14