Search in sources :

Example 16 with KeyAdapter

use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.

the class LogEditorPart method createPartControl.

/**
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    final Composite compositeLog = new Composite(parent, SWT.NONE);
    {
        GridLayout gridLayoutLog = new GridLayout();
        gridLayoutLog.verticalSpacing = 0;
        gridLayoutLog.marginWidth = 0;
        gridLayoutLog.marginHeight = 0;
        gridLayoutLog.horizontalSpacing = 5;
        gridLayoutLog.numColumns = 8;
        compositeLog.setLayout(gridLayoutLog);
    }
    final String type = this.cubridNode.getType();
    table = new Table(compositeLog, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
    {
        table.setHeaderVisible(true);
        GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
        gridData.horizontalSpan = 8;
        gridData.verticalSpan = 10;
        gridData.heightHint = 600;
        table.setLayoutData(gridData);
        table.setLinesVisible(true);
    }
    // fill in context menu
    if (CubridNodeType.BROKER_SQL_LOG.equals(type) || CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_SERVER_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_APPLY_DATABASE_LOG.equals(type) || CubridNodeType.LOGS_COPY_DATABASE_LOG.equals(type)) {
        //Create the context menu
        MenuManager contextMenuManager = new MenuManager();
        contextMenuManager.setRemoveAllWhenShown(true);
        contextMenuManager.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager manager) {
                buildPopupMenu(manager, type);
            }
        });
        Menu contextMenu = contextMenuManager.createContextMenu(table);
        table.setMenu(contextMenu);
        //Add listener
        table.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent event) {
                if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
                    copyDataToClipboard(type);
                }
            }
        });
    }
    table.addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            if (CubridNodeType.BROKER_SQL_LOG.equals(cubridNode.getType())) {
                TableItem[] items = table.getSelection();
                if (items != null && items.length == 1) {
                    final String content = items[0].getText(1);
                    new LogContentDetailDialog(getSite().getShell(), content).open();
                }
            } else if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(cubridNode.getType())) {
                TableItem[] items = table.getSelection();
                if (items != null && items.length == 1) {
                    final String content = items[0].getText(4);
                    new LogContentDetailDialog(getSite().getShell(), content).open();
                }
            } else if (CubridNodeType.LOGS_BROKER_ERROR_LOG.equals(cubridNode.getType())) {
                TableItem[] items = table.getSelection();
                if (items != null && items.length == 1) {
                    final String content = items[0].getText(6);
                    new LogContentDetailDialog(getSite().getShell(), content).open();
                }
            }
        }
    });
    // add bottom composite for page
    Label labelCharset = new Label(compositeLog, SWT.NONE);
    {
        labelCharset.setText(Messages.labelCharset);
        charsetCombo = new Combo(compositeLog, SWT.BORDER);
        final GridData gdCharsetText = CommonUITool.createGridData(1, 1, -1, -1);
        charsetCombo.setLayoutData(gdCharsetText);
        charsetCombo.setItems(QueryOptions.getAllCharset(null));
        charsetCombo.setText(charsetName);
    }
    Button viewLogBtn = new Button(compositeLog, SWT.NONE);
    {
        viewLogBtn.setText(Messages.viewLogJobName);
        viewLogBtn.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
        viewLogBtn.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                String charsetName = charsetCombo.getText();
                try {
                    "".getBytes(charsetName);
                } catch (UnsupportedEncodingException e) {
                    CommonUITool.openErrorBox(Messages.errCharset);
                    charsetCombo.setFocus();
                    return;
                }
                setCharsetName(charsetName);
                if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
                    connect(false);
                }
                if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
                    managerConnect();
                    updateManagerLogTable();
                }
            }
        });
    }
    // page button
    if (!CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) && !CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
        pageText = new Text(compositeLog, SWT.BORDER);
        {
            pageText.setVisible(true);
            pageText.setEditable(false);
            GridData gridData = createPageBtnGridData(150);
            gridData.grabExcessHorizontalSpace = true;
            pageText.setLayoutData(gridData);
        }
        buttonFirst = new Button(compositeLog, SWT.NONE);
        {
            buttonFirst.setVisible(true);
            buttonFirst.setText("|<");
            buttonFirst.setLayoutData(createPageBtnGridData(60));
            buttonFirst.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineStart = 1;
                    lineEnd = 100;
                    connect(false);
                }
            });
        }
        buttonPrev = new Button(compositeLog, SWT.NONE);
        {
            buttonPrev.setVisible(true);
            buttonPrev.setText("<");
            buttonPrev.setLayoutData(createPageBtnGridData(60));
            buttonPrev.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineStart -= 100;
                    if (lineStart < 1) {
                        lineStart = 1;
                    }
                    lineEnd = lineStart + 99;
                    connect(false);
                }
            });
        }
        buttonNext = new Button(compositeLog, SWT.NONE);
        {
            buttonNext.setVisible(true);
            buttonNext.setText(">");
            buttonNext.setLayoutData(createPageBtnGridData(60));
            buttonNext.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineStart += 100;
                    if (lineStart > lineTot) {
                        lineStart = lineTot;
                    }
                    lineEnd = lineStart + 99;
                    if (lineEnd > lineTot) {
                        lineEnd = lineTot;
                    }
                    connect(false);
                }
            });
        }
        buttonEnd = new Button(compositeLog, SWT.NONE);
        {
            buttonEnd.setVisible(true);
            buttonEnd.setText(">|");
            buttonEnd.setLayoutData(createPageBtnGridData(60));
            buttonEnd.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    lineEnd = lineTot;
                    lineStart = lineEnd - lineTot % 100 + 1;
                    connect(false);
                }
            });
        }
    }
    // manager log page button
    if (CubridNodeType.LOGS_MANAGER_ERROR_LOG.equals(type) || CubridNodeType.LOGS_MANAGER_ACCESS_LOG.equals(type)) {
        pageText = new Text(compositeLog, SWT.BORDER);
        {
            pageText.setVisible(true);
            pageText.setEditable(false);
            GridData gridData = createPageBtnGridData(150);
            gridData.grabExcessHorizontalSpace = true;
            pageText.setLayoutData(gridData);
        }
        buttonFirst = new Button(compositeLog, SWT.NONE);
        buttonFirst.setVisible(true);
        buttonFirst.setText("|<");
        buttonFirst.setLayoutData(createPageBtnGridData(60));
        buttonFirst.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(1);
                updateManagerLogTable();
            }
        });
        buttonPrev = new Button(compositeLog, SWT.NONE);
        buttonPrev.setVisible(true);
        buttonPrev.setText("<");
        buttonPrev.setLayoutData(createPageBtnGridData(60));
        buttonPrev.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(pageInfo.getCurrentPage() - 1);
                updateManagerLogTable();
            }
        });
        buttonNext = new Button(compositeLog, SWT.NONE);
        buttonNext.setVisible(true);
        buttonNext.setText(">");
        buttonNext.setLayoutData(createPageBtnGridData(60));
        buttonNext.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(pageInfo.getCurrentPage() + 1);
                updateManagerLogTable();
            }
        });
        buttonEnd = new Button(compositeLog, SWT.NONE);
        buttonEnd.setVisible(true);
        buttonEnd.setText(">|");
        buttonEnd.setLayoutData(createPageBtnGridData(60));
        buttonEnd.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                pageInfo.setCurrentPage(pageInfo.getPages());
                updateManagerLogTable();
            }
        });
    }
    compositeLog.pack();
}
Also used : Table(org.eclipse.swt.widgets.Table) IMenuListener(org.eclipse.jface.action.IMenuListener) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) LogContentDetailDialog(com.cubrid.cubridmanager.ui.logs.dialog.LogContentDetailDialog) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 17 with KeyAdapter

use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.

the class ColumnViewerSorter method createTablesDetailInfoTable.

/**
	 * createTablesDetailInfoTable
	 *
	 * @param parent
	 */
public void createTablesDetailInfoTable(Composite parent) {
    final Composite tableComposite = new Composite(parent, SWT.NONE);
    tableComposite.setLayout(new FillLayout());
    tableComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tableListView = new TableViewer(tableComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    tableListView.getTable().setHeaderVisible(true);
    tableListView.getTable().setLinesVisible(true);
    final TableViewerColumn columnTableName = new TableViewerColumn(tableListView, SWT.LEFT);
    columnTableName.getColumn().setWidth(150);
    columnTableName.getColumn().setText(Messages.tablesDetailInfoPartColTableName);
    columnTableName.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_NAME));
            tableListView.getTable().setSortColumn(columnTableName.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnTableDesc = new TableViewerColumn(tableListView, SWT.LEFT);
    columnTableDesc.getColumn().setWidth(200);
    columnTableDesc.getColumn().setText(Messages.tablesDetailInfoPartColTableMemo);
    columnTableDesc.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_MEMO));
            tableListView.getTable().setSortColumn(columnTableDesc.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnRecordsCount = new TableViewerColumn(tableListView, SWT.LEFT);
    columnRecordsCount.getColumn().setWidth(60);
    columnRecordsCount.getColumn().setText(Messages.tablesDetailInfoPartColRecordsCount);
    columnRecordsCount.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_RECORD));
            tableListView.getTable().setSortColumn(columnRecordsCount.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnColumnsCount = new TableViewerColumn(tableListView, SWT.LEFT);
    columnColumnsCount.getColumn().setWidth(80);
    columnColumnsCount.getColumn().setText(Messages.tablesDetailInfoPartColColumnsCount);
    columnColumnsCount.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_COLUMN));
            tableListView.getTable().setSortColumn(columnColumnsCount.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnPK = new TableViewerColumn(tableListView, SWT.LEFT);
    columnPK.getColumn().setWidth(50);
    columnPK.getColumn().setText(Messages.tablesDetailInfoPartColPK);
    columnPK.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_PK));
            tableListView.getTable().setSortColumn(columnPK.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnTableUK = new TableViewerColumn(tableListView, SWT.LEFT);
    columnTableUK.getColumn().setWidth(50);
    columnTableUK.getColumn().setText(Messages.tablesDetailInfoPartColUK);
    columnTableUK.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_UK));
            tableListView.getTable().setSortColumn(columnTableUK.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnFK = new TableViewerColumn(tableListView, SWT.LEFT);
    columnFK.getColumn().setWidth(50);
    columnFK.getColumn().setText(Messages.tablesDetailInfoPartColFK);
    columnFK.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_FK));
            tableListView.getTable().setSortColumn(columnFK.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnIndex = new TableViewerColumn(tableListView, SWT.LEFT);
    columnIndex.getColumn().setWidth(50);
    columnIndex.getColumn().setText(Messages.tablesDetailInfoPartColIndex);
    columnIndex.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_INDEX));
            tableListView.getTable().setSortColumn(columnIndex.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    final TableViewerColumn columnRecordsSize = new TableViewerColumn(tableListView, SWT.LEFT);
    columnRecordsSize.getColumn().setWidth(100);
    columnRecordsSize.getColumn().setText(Messages.tablesDetailInfoPartColTableRecordsSize);
    columnRecordsSize.getColumn().addSelectionListener(new SelectionAdapter() {

        boolean isAsc = false;

        public void widgetSelected(SelectionEvent e) {
            tableListView.setSorter(new ColumnViewerSorter(isAsc, ColumnViewerSorter.PROPERTY_SIZE));
            tableListView.getTable().setSortColumn(columnRecordsSize.getColumn());
            tableListView.getTable().setSortDirection(isAsc ? SWT.UP : SWT.DOWN);
            isAsc = !isAsc;
        }
    });
    tableListView.setContentProvider(new TableDashboardContentProvider());
    tableListView.setLabelProvider(new TableDashboardLabelProvider());
    tableListView.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TableDetailInfo oneTableDetail = (TableDetailInfo) selection.getFirstElement();
            openTableDetail(oneTableDetail);
        }
    });
    tableListView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
                copySelectedTableNamesToClipboard();
            } else if (event.keyCode == SWT.CR) {
                showEditDialog(tableListView.getTable(), tableListView.getTable().getSelectionIndex());
            }
        }
    });
    registerContextMenu();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 18 with KeyAdapter

use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.

the class TableDashboardComposite method createColumnsTable.

/**
	 * Create the column information table
	 *
	 */
private void createColumnsTable(Composite topComposite) {
    columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    Table columnsTable = columnTableView.getTable();
    columnsTable.setLinesVisible(true);
    columnsTable.setHeaderVisible(true);
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.heightHint = 189;
    columnsTable.setLayoutData(gdColumnsTable);
    // 0 PK
    TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setAlignment(SWT.CENTER);
    tblCol.setWidth(WIDTH_PKCOLUMN);
    tblCol.setText(Messages.tblColumnPK);
    // 1 NAME
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NAMECOLUMN);
    tblCol.setText(Messages.tblColumnName);
    // 2 MEMO
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NAMECOLUMN);
    tblCol.setText(Messages.tblColumnMemo);
    // 3 DATATYPE
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_DATATYPECOLUMN);
    tblCol.setText(Messages.tblColumnDataType);
    // 4 DEFAULT
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(98);
    tblCol.setText(Messages.tblColumnDefault);
    // 5 AUTO INCREMENT
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setAlignment(SWT.CENTER);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnAutoIncr);
    // 6 NOT NULL
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
    tblCol.setText(Messages.tblColumnNotNull);
    tblCol.setAlignment(SWT.CENTER);
    // 7 UK
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_UNIQUECOLUMN);
    tblCol.setText(Messages.tblColumnUnique);
    tblCol.setAlignment(SWT.CENTER);
    // 8 SHARED
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_SHAREDCOLUMN);
    tblCol.setResizable(true);
    tblCol.setText(Messages.tblColumnShared);
    tblCol.setAlignment(SWT.CENTER);
    labelProvider = new TableDashboardDetailLabelProvider(null, null);
    columnTableView.setContentProvider(new TableDashboardDetailContentProvider());
    columnTableView.setLabelProvider(labelProvider);
    columnTableView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
                copyTablesDetailToClipboard();
            } else if (event.keyCode == SWT.CR) {
                showEditDialog(columnTableView.getTable(), columnTableView.getTable().getSelectionIndex());
            }
        }
    });
    registerContextMenu();
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Table(org.eclipse.swt.widgets.Table) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 19 with KeyAdapter

use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.

the class ImportResultDialog method createDialogArea.

/**
	 * Create the dialog area
	 *
	 * @param parent Composite
	 * @return Control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    {
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(layout);
    }
    TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table = tableViewer.getTable();
    {
        GridData gdData = new GridData(GridData.FILL_BOTH);
        gdData.heightHint = 400;
        gdData.widthHint = 500;
        table.setLayoutData(gdData);
    }
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
    tableColumn.setText(Messages.importColumnNO);
    tableColumn = new TableColumn(table, SWT.LEFT);
    tableColumn.setText(Messages.importColumnMessage);
    tableViewer.setLabelProvider(new TableLabelProvider(tableViewer, null));
    tableViewer.setContentProvider(new TableContentProvider());
    tableViewer.setInput(errorList);
    //Create the context menu
    MenuManager contextMenuManager = new MenuManager();
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            //copy action
            Action copyAction = new Action(Messages.bind(Messages.contextCopy, "Ctrl+C")) {

                public void run() {
                    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

                        public void run() {
                            copyDataToClipboard();
                        }
                    });
                }
            };
            manager.add(copyAction);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(table);
    table.setMenu(contextMenu);
    //Add listener
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
                copyDataToClipboard();
            }
        }
    });
    for (int i = 0; i < table.getColumnCount(); i++) {
        TableColumn tblColumn = table.getColumn(i);
        tblColumn.pack();
        if (tblColumn.getWidth() > 400) {
            tblColumn.setWidth(400);
        }
    }
    Label label = new Label(composite, SWT.LEFT);
    label.setForeground(ResourceManager.getColor(255, 0, 0));
    label.setText(message);
    return composite;
}
Also used : Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 20 with KeyAdapter

use of org.eclipse.swt.events.KeyAdapter in project cubrid-manager by CUBRID.

the class ERSchemaToolBar method createSearchComp.

/**
	 * create searching table text composite
	 *
	 * @return comp composite
	 */
private Composite createSearchComp() {
    Composite comp = new Composite(this, SWT.NONE);
    final GridLayout gdLayout = new GridLayout(1, true);
    gdLayout.marginHeight = 1;
    gdLayout.marginWidth = 1;
    gdLayout.horizontalSpacing = 1;
    gdLayout.verticalSpacing = 1;
    comp.setLayout(gdLayout);
    // comp.setLayoutData(new GridData(GridData.RIGHT, SWT.CENTER, false,
    // false));
    comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END, GridData.VERTICAL_ALIGN_CENTER, false, false));
    final Text text = new Text(comp, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
    text.setToolTipText(Messages.tipSearchTableName);
    text.setLayoutData(CommonUITool.createGridData(1, 1, 140, 14));
    text.addKeyListener(new KeyAdapter() {

        public void keyReleased(KeyEvent e) {
            String keyWord = text.getText().trim();
            erSchemaEditor.doSearchTables(keyWord);
        }
    });
    return comp;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text)

Aggregations

KeyAdapter (org.eclipse.swt.events.KeyAdapter)80 KeyEvent (org.eclipse.swt.events.KeyEvent)80 GridData (org.eclipse.swt.layout.GridData)50 GridLayout (org.eclipse.swt.layout.GridLayout)40 Composite (org.eclipse.swt.widgets.Composite)39 SelectionEvent (org.eclipse.swt.events.SelectionEvent)33 Text (org.eclipse.swt.widgets.Text)30 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)28 Label (org.eclipse.swt.widgets.Label)24 Button (org.eclipse.swt.widgets.Button)20 TableViewer (org.eclipse.jface.viewers.TableViewer)18 ModifyEvent (org.eclipse.swt.events.ModifyEvent)17 ModifyListener (org.eclipse.swt.events.ModifyListener)16 FocusEvent (org.eclipse.swt.events.FocusEvent)15 Point (org.eclipse.swt.graphics.Point)15 Table (org.eclipse.swt.widgets.Table)14 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12 FocusAdapter (org.eclipse.swt.events.FocusAdapter)11