Search in sources :

Example 36 with SashForm

use of org.eclipse.swt.custom.SashForm in project MonjaDB by Kanatoko.

the class MActionView method init2.

//--------------------------------------------------------------------------------
public void init2() {
    parent.setLayout(new FormLayout());
    sashForm = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL);
    FormData fd_sashForm1 = new FormData();
    fd_sashForm1.top = new FormAttachment(0, 1);
    fd_sashForm1.left = new FormAttachment(0, 1);
    fd_sashForm1.right = new FormAttachment(100, -1);
    fd_sashForm1.bottom = new FormAttachment(100, -1);
    sashForm.setLayoutData(fd_sashForm1);
    table = new Table(sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    table.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            onTableStateChange();
        }
    });
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
                e.doit = false;
                if (//Shift + Enter
                (e.stateMask & SWT.SHIFT) != 0) {
                    repeatActionsOnTable();
                } else {
                    editActions();
                }
            }
        }
    });
    FormData fd_table = new FormData();
    fd_table.top = new FormAttachment(0, 0);
    fd_table.bottom = new FormAttachment(100, 0);
    fd_table.left = new FormAttachment(0, 0);
    fd_table.right = new FormAttachment(100, 0);
    table.setLayoutData(fd_table);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn actionColumn = new TableColumn(table, SWT.NONE);
    actionColumn.setWidth(100);
    actionColumn.setText("Action");
    TableColumn dateColumn = new TableColumn(table, SWT.NONE);
    dateColumn.setWidth(100);
    dateColumn.setText("Date");
    editorComposite = new Composite(sashForm, SWT.BORDER);
    editorComposite.setLayout(new FormLayout());
    text = new Text(editorComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
    text.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            onTextStateChange();
        }
    });
    FormData fd_text = new FormData();
    fd_text.bottom = new FormAttachment(100, -40);
    fd_text.right = new FormAttachment(100);
    fd_text.top = new FormAttachment(0);
    fd_text.left = new FormAttachment(0);
    text.setLayoutData(fd_text);
    executeButton = new Button(editorComposite, SWT.NONE);
    executeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            executeActionsOnText();
        }
    });
    executeButton.setEnabled(false);
    FormData fd_executeButton = new FormData();
    fd_executeButton.top = new FormAttachment(text, 6);
    fd_executeButton.left = new FormAttachment(text, -120, SWT.RIGHT);
    fd_executeButton.right = new FormAttachment(100, -10);
    executeButton.setLayoutData(fd_executeButton);
    executeButton.setText("Execute");
    editorComposite.addControlListener(new ControlAdapter() {

        public void controlResized(ControlEvent e) {
            onSashResize();
        }
    });
    MSwtUtil.getTableColumnWidthFromProperties("actionListTable", table, prop, new int[] { 200, 100 });
    MSwtUtil.addListenerToTableColumns2(table, this);
    //table.addListener( SWT.KeyDown, this );
    table.addListener(SWT.MouseDoubleClick, this);
    menuManager = new MenuManager();
    Menu contextMenu = menuManager.createContextMenu(table);
    table.setMenu(contextMenu);
    //executeTableAction
    {
        redoAction = new Action() {

            public void run() {
                //------------
                repeatActionsOnTable();
            }
        };
        //------------
        redoAction.setToolTipText("Redo Selected Actions");
        redoAction.setText("Redo\tShift+Enter");
        initAction(redoAction, "table_go.png", menuManager);
        redoAction.setEnabled(false);
    }
    //editAction
    {
        editAction = new Action() {

            public void run() {
                //------------
                editActions();
            }
        };
        //------------
        editAction.setToolTipText("Edit Actions on The Text Editor");
        editAction.setText("Edit\tEnter");
        initAction(editAction, "pencil.png", menuManager);
        editAction.setEnabled(false);
    }
    dropDownMenu.add(new Separator());
    menuManager.add(new Separator());
    //executeAction
    {
        executeAction = new Action() {

            public void run() {
                //------------
                executeActionsOnText();
            }
        };
        //------------
        executeAction.setToolTipText("Execute Actions on the Textarea");
        executeAction.setText("Execute");
        setActionImage(executeAction, "bullet_go.png");
        addActionToToolBar(executeAction);
        executeAction.setEnabled(false);
        dropDownMenu.add(executeAction);
    }
    dropDownMenu.add(new Separator());
    menuManager.add(new Separator());
    //copyAction
    {
        copyAction = new Action() {

            public void run() {
                //------------
                copyActions();
            }
        };
        //------------
        copyAction.setToolTipText("Copy Actions to Clipboard");
        copyAction.setText("Copy");
        setActionImage(copyAction, "page_copy.png");
        addActionToToolBar(copyAction);
        copyAction.setEnabled(false);
        dropDownMenu.add(copyAction);
        menuManager.add(copyAction);
    }
    dropDownMenu.add(new Separator());
    menuManager.add(new Separator());
    //clearAction
    {
        clearAction = new Action() {

            public void run() {
                //------------
                clearActions();
            }
        };
        //------------
        clearAction.setToolTipText("Clear All");
        clearAction.setText("Clear All");
        initAction(clearAction, "table_delete.png", menuManager);
        clearAction.setEnabled(false);
    }
    //saveAction
    {
        saveAction = new Action() {

            public void run() {
                //------------
                saveActions();
            }
        };
        //------------
        saveAction.setToolTipText("Save Action");
        saveAction.setText("Save");
        initAction(saveAction, "cog_add.png", menuManager);
        saveAction.setEnabled(false);
    }
    //load actionLogList
    if (prop.containsKey(ACTION_LOG_LIST)) {
        String savedStr = prop.getProperty(ACTION_LOG_LIST);
        actionLogList = (java.util.List) JSON.parse(savedStr);
        for (int i = 0; i < actionLogList.size(); ++i) {
            Map actionLog = (Map) actionLogList.get(i);
            addActionToTable(actionLog);
        }
    } else {
        actionLogList = new LinkedList();
    }
    if (prop.containsKey(ACTIONLOG_COMPOSITE_WEIGHT)) {
        (new Thread() {

            public void run() {
                MSystemUtil.sleep(0);
                shell.getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        //----
                        sashForm.setWeights(prop.getIntArrayProperty(ACTIONLOG_COMPOSITE_WEIGHT));
                    }
                });
            //----
            }
        }).start();
    } else {
        sashForm.setWeights(new int[] { 70, 30 });
    }
    initializedTime = System.currentTimeMillis();
}
Also used : MEditAction(net.jumperz.app.MMonjaDBCore.action.mj.MEditAction) Action(org.eclipse.jface.action.Action) ModifyListener(org.eclipse.swt.events.ModifyListener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) TableColumn(org.eclipse.swt.widgets.TableColumn) SashForm(org.eclipse.swt.custom.SashForm) java.util(java.util) MenuManager(org.eclipse.jface.action.MenuManager) ControlEvent(org.eclipse.swt.events.ControlEvent) Separator(org.eclipse.jface.action.Separator)

Example 37 with SashForm

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

the class ColumnViewerSorter method createPartControl.

public void createPartControl(Composite parent) {
    parent.setLayout(new GridLayout(1, false));
    ToolBar toolBar = new ToolBar(parent, SWT.LEFT_TO_RIGHT | SWT.FLAT);
    toolBar.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ToolItem refreshItem = new ToolItem(toolBar, SWT.PUSH);
    refreshItem.setText(Messages.tablesDetailInfoPartRefreshBtn);
    refreshItem.setToolTipText(Messages.tablesDetailInfoPartBtnRefreshTip);
    refreshItem.setImage(CommonUIPlugin.getImage("icons/action/refresh.png"));
    refreshItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            refresh();
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem countItem = new ToolItem(toolBar, SWT.PUSH);
    countItem.setText(Messages.tablesDetailInfoPartBtnEsitmateRecord);
    countItem.setToolTipText(Messages.tablesDetailInfoPartBtnEsitmateRecordTip);
    countItem.setImage(CommonUIPlugin.getImage("icons/action/count.gif"));
    countItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            List<TableDetailInfo> list = new ArrayList<TableDetailInfo>();
            TableItem[] items = tableListView.getTable().getSelection();
            for (TableItem item : items) {
                list.add((TableDetailInfo) item.getData());
            }
            // Check selected size and confirm
            if (list.size() == 0) {
                CommonUITool.openWarningBox(Messages.tablesDetailInfoPartAlertNotSelected);
                return;
            }
            if (CommonUITool.openConfirmBox(Messages.tablesDetailInfoPartBtnEsitmateRecordAlert)) {
                LoadTableRecordCountsProgress progress = new LoadTableRecordCountsProgress(database, list);
                progress.getTableCounts();
                tableListView.refresh();
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem viewDataItem = new ToolItem(toolBar, SWT.PUSH);
    viewDataItem.setText(Messages.tablesDetailInfoPartBtnViewData);
    viewDataItem.setToolTipText(Messages.tablesDetailInfoPartBtnViewDataTip);
    viewDataItem.setImage(CommonUIPlugin.getImage("icons/action/table_select_all.png"));
    viewDataItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TableItem[] items = tableListView.getTable().getSelection();
            if (items.length == 1) {
                TableDetailInfo tableDetailInfo = (TableDetailInfo) items[0].getData();
                String query = SQLGenerateUtils.getSelectSQLWithLimit(tableDetailInfo.getTableName(), 1, 100);
                QueryEditorUtil.openQueryEditorAndRunQuery(database, query, true, true);
            } else {
                CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnViewDataSelectOne);
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem copyTableNamesItem = new ToolItem(toolBar, SWT.PUSH);
    copyTableNamesItem.setText(Messages.tablesDetailInfoPartBtnCopyTableNames);
    copyTableNamesItem.setToolTipText(Messages.tablesDetailInfoPartBtnCopyTableNamesTip);
    copyTableNamesItem.setImage(CommonUIPlugin.getImage("icons/action/copy_table_name.gif"));
    copyTableNamesItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            List<String> nameList = new ArrayList<String>();
            for (TableDetailInfo tablesDetailInfoPOJO : tableList) {
                nameList.add(tablesDetailInfoPOJO.getTableName());
            }
            if (nameList.size() == 0) {
                CommonUITool.openWarningBox(Messages.tablesDetailInfoPartBtnCopySuccessFailed);
                return;
            }
            copyNamesToClipboard(nameList);
            CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnCopySuccessTitle, Messages.tablesDetailInfoPartBtnCopySuccessMsg);
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem copyColumnNamesItem = new ToolItem(toolBar, SWT.PUSH);
    copyColumnNamesItem.setText(Messages.tablesDetailInfoPartBtnCopyColumnNames);
    copyColumnNamesItem.setToolTipText(Messages.tablesDetailInfoPartBtnCopyColumnNamesTip);
    copyColumnNamesItem.setImage(CommonUIPlugin.getImage("icons/action/copy_column_name.gif"));
    copyColumnNamesItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            TablesDetailInfoCTabItem tabItem = (TablesDetailInfoCTabItem) tabFolder.getSelection();
            schemaInfo = tabItem.getTableInfoComposite().getData();
            if (schemaInfo == null) {
                CommonUITool.openWarningBox(Messages.tablesDetailInfoPartBtnCopySuccessFailed);
                return;
            }
            List<String> nameList = new ArrayList<String>();
            for (DBAttribute att : schemaInfo.getAttributes()) {
                nameList.add(att.getName());
            }
            copyNamesToClipboard(nameList);
            CommonUITool.openInformationBox(Messages.tablesDetailInfoPartBtnCopySuccessTitle, Messages.tablesDetailInfoPartBtnCopySuccessMsg);
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    final NewTableAction newTableAction = (NewTableAction) ActionManager.getInstance().getAction(NewTableAction.ID);
    ToolItem newTableItem = new ToolItem(toolBar, SWT.PUSH);
    newTableItem.setText(newTableAction.getText());
    newTableItem.setImage(CommonUITool.getImage(newTableAction.getImageDescriptor()));
    newTableItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            newTableAction.run(database);
        }
    });
    ScrolledComposite scrolledComp = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComp.setLayout(new FillLayout());
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    topSash = new SashForm(scrolledComp, SWT.VERTICAL);
    topSash.setBackground(ResourceManager.getColor(136, 161, 227));
    GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.horizontalSpacing = 0;
    topSash.setLayout(gridLayout);
    topSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    topSash.SASH_WIDTH = 1;
    scrolledComp.setContent(topSash);
    createTablesDetailInfoTable(topSash);
    createTabFolder(topSash);
    topSash.setWeights(new int[] { 70, 30 });
    this.setInputs();
}
Also used : TablesDetailInfoCTabItem(com.cubrid.common.ui.cubrid.table.dashboard.control.TableDashboardComposite.TablesDetailInfoCTabItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) FillLayout(org.eclipse.swt.layout.FillLayout) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) DBAttribute(com.cubrid.common.core.common.model.DBAttribute) NewTableAction(com.cubrid.common.ui.cubrid.table.action.NewTableAction) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ArrayList(java.util.ArrayList) List(java.util.List) LoadTableRecordCountsProgress(com.cubrid.common.ui.spi.progress.LoadTableRecordCountsProgress) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 38 with SashForm

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

the class TableDashboardComposite method initialize.

/**
	 * Create the SQL history composite
	 */
public void initialize() {
    SashForm bottomSash = new SashForm(tabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = 2;
    bottomSash.setBackground(BACK_COLOR);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = 2;
    tailSash.setBackground(BACK_COLOR);
    Composite tableComp = new Composite(tailSash, SWT.NONE);
    tableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    tableComp.setLayout(new GridLayout());
    createColumnsTable(tableComp);
    tabItem = new TablesDetailInfoCTabItem(tabFolder, SWT.NONE, this);
    tabItem.setControl(bottomSash);
    tabItem.setShowClose(true);
    tabFolder.setSelection(tabItem);
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData)

Example 39 with SashForm

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

the class QueryPlanCompositeWithHistory method initialize.

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

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

        public void mouseDown(MouseEvent event) {
        }

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

Example 40 with SashForm

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

the class RecentlyUsedSQLComposite method initialize.

/**
	 * Create the SQL history composite
	 */
public void initialize() {
    Composite toolBarComposite = new Composite(this, SWT.NONE);
    GridLayout gridLayout = new GridLayout(1, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 10;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    gridLayout.numColumns = 2;
    toolBarComposite.setLayout(gridLayout);
    toolBarComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    ToolBar delHistoryToolBar = new ToolBar(toolBarComposite, SWT.FLAT | SWT.RIGHT);
    delHistoryToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
    ToolItem delHistory = new ToolItem(delHistoryToolBar, SWT.PUSH);
    delHistory.setImage(CommonUIPlugin.getImage("icons/action/table_record_delete.png"));
    delHistory.setDisabledImage(CommonUIPlugin.getImage("icons/action/table_record_delete_disabled.png"));
    delHistory.setToolTipText(Messages.tooltip_qedit_sql_history_delete);
    delHistory.setText(Messages.btn_qedit_sql_history_delete);
    delHistory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (sqlHistoryTable.getTable().getSelectionIndices().length == 0) {
                MessageDialog.openError(PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages.error, Messages.sql_history_delete_error);
                return;
            }
            MessageBox messageBox = new MessageBox(getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
            messageBox.setText(Messages.tooltip_qedit_sql_history_delete);
            messageBox.setMessage(Messages.sql_history_delete_message);
            // remove data ,both view and model
            int buttonID = messageBox.open();
            if (buttonID == SWT.YES) {
                deleteHistory();
            }
        }
    });
    // help messages
    Label helpMsg = new Label(toolBarComposite, SWT.None);
    helpMsg.setText(Messages.recentlyUsedSQLHelp);
    helpMsg.setLayoutData(new GridData(SWT.TRAIL, SWT.CENTER, true, false));
    // create the query result tab folder
    recentlyUsedSQLTabFolder = new CTabFolder(this, SWT.BOTTOM);
    recentlyUsedSQLTabFolder.setSimple(false);
    recentlyUsedSQLTabFolder.setUnselectedImageVisible(true);
    recentlyUsedSQLTabFolder.setUnselectedCloseVisible(true);
    recentlyUsedSQLTabFolder.setSelectionBackground(CombinedQueryEditorComposite.BACK_COLOR);
    recentlyUsedSQLTabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    recentlyUsedSQLTabFolder.setLayout(new GridLayout(1, true));
    recentlyUsedSQLTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    //TabContextMenuManager tabContextMenuManager = new TabContextMenuManager(recentlyUsedSQLTabFolder);
    //tabContextMenuManager.createContextMenu();
    recentlyUsedSQLTabItem = new CTabItem(resultTabFolder, SWT.NONE);
    recentlyUsedSQLTabItem.setText(Messages.qedit_sql_history_folder);
    recentlyUsedSQLTabItem.setControl(this);
    recentlyUsedSQLTabItem.setShowClose(false);
    final SashForm bottomSash = new SashForm(recentlyUsedSQLTabFolder, SWT.VERTICAL);
    bottomSash.SASH_WIDTH = SASH_WIDTH;
    bottomSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    createHistoryTable(bottomSash);
    SashForm tailSash = new SashForm(bottomSash, SWT.HORIZONTAL);
    tailSash.SASH_WIDTH = SASH_WIDTH;
    tailSash.setBackground(CombinedQueryEditorComposite.BACK_COLOR);
    logMessageArea = new StyledText(tailSash, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
    CommonUITool.registerCopyPasteContextMenu(logMessageArea, false);
    bottomSash.setWeights(new int[] { 80, 20 });
    logMessageArea.setToolTipText(Messages.tooltipHowToExpandLogPane);
    logMessageArea.addFocusListener(new FocusListener() {

        public void focusLost(FocusEvent e) {
            bottomSash.setWeights(new int[] { 80, 20 });
        }

        public void focusGained(FocusEvent e) {
            bottomSash.setWeights(new int[] { 20, 80 });
        }
    });
    CTabItem tabItem = new CTabItem(recentlyUsedSQLTabFolder, SWT.NONE);
    tabItem.setText(Messages.qedit_sql_history);
    tabItem.setControl(bottomSash);
    tabItem.setShowClose(false);
    recentlyUsedSQLTabFolder.setSelection(tabItem);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FocusEvent(org.eclipse.swt.events.FocusEvent) MessageBox(org.eclipse.swt.widgets.MessageBox) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FocusListener(org.eclipse.swt.events.FocusListener) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

SashForm (org.eclipse.swt.custom.SashForm)96 GridData (org.eclipse.swt.layout.GridData)65 GridLayout (org.eclipse.swt.layout.GridLayout)57 Composite (org.eclipse.swt.widgets.Composite)56 SelectionEvent (org.eclipse.swt.events.SelectionEvent)31 FillLayout (org.eclipse.swt.layout.FillLayout)30 Label (org.eclipse.swt.widgets.Label)26 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)25 CTabItem (org.eclipse.swt.custom.CTabItem)14 Button (org.eclipse.swt.widgets.Button)13 StyledText (org.eclipse.swt.custom.StyledText)12 ToolBar (org.eclipse.swt.widgets.ToolBar)12 ArrayList (java.util.ArrayList)11 Point (org.eclipse.swt.graphics.Point)11 Table (org.eclipse.swt.widgets.Table)11 ToolItem (org.eclipse.swt.widgets.ToolItem)11 TableViewer (org.eclipse.jface.viewers.TableViewer)10 Event (org.eclipse.swt.widgets.Event)10 Listener (org.eclipse.swt.widgets.Listener)9 Tree (org.eclipse.swt.widgets.Tree)9