Search in sources :

Example 26 with KeyEvent

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

the class FilterResultContrItem method createControl.

/**
	 * Create the content
	 *
	 * @param parent Composite
	 * @return Control
	 */
protected Control createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
    comp.setLayoutData(gridData);
    final GridLayout gdLayout = new GridLayout(5, false);
    gdLayout.marginHeight = 0;
    gdLayout.marginWidth = 0;
    gdLayout.horizontalSpacing = 0;
    gdLayout.verticalSpacing = 0;
    gdLayout.marginRight = 10;
    comp.setLayout(gdLayout);
    Label lbl = new Label(comp, SWT.NONE);
    lbl.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    lbl.setText(" " + Messages.lblFilterSearch + " ");
    text = new Text(comp, SWT.NONE | SWT.BORDER | SWT.LEFT);
    text.setLayoutData(CommonUITool.createGridData(1, 1, 100, -1));
    text.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                doFilter();
            }
        }
    });
    dropDownButton = new Button(comp, SWT.FLAT | SWT.DOWN);
    dropDownButton.setText(Messages.lblFilterSearchOption);
    dropDownButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            handleSelectionEvent();
        }
    });
    Label lblLimit = new Label(comp, SWT.NONE);
    lblLimit.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    lblLimit.setText(" " + Messages.lblSearchLimit + " ");
    pageLimitCombo = new Combo(comp, SWT.READ_ONLY);
    pageLimitCombo.setItems(new String[] { "1000", "5000", "10000" });
    pageLimitCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    pageLimitCombo.setText("" + pageLimit);
    pageLimitCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            int limit = StringUtil.intValue(pageLimitCombo.getText());
            ServerInfo serverInfo = qe.getDatabase().getServer().getServerInfo();
            QueryOptions.setSearchUnitCount(serverInfo, limit);
        }
    });
    loadMenuItems();
    return comp;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 27 with KeyEvent

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

the class SqlmapNavigatorView method createCondView.

/**
	 * Create the main view.
	 *
	 * @param parent {@link Composite} the parent composite
	 */
private void createCondView(Composite parent) {
    String[] columnNames = { Messages.lblSqlmapUse, Messages.lblSqlmapCondition };
    Label lblCondTitle = new Label(parent, SWT.NONE);
    lblCondTitle.setText(Messages.lblSqlmapConditions);
    condView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 80));
    condView.setColumnProperties(columnNames);
    condView.setContentProvider(new TableContentProvider());
    condView.setLabelProvider(new SqlmapLabelProvider(this));
    condView.setCellModifier(new SqlmapCellModifier(this));
    CellEditor[] cellEditor = new CellEditor[columnNames.length];
    cellEditor[0] = new CheckboxCellEditor(condView.getTable());
    condView.setCellEditors(cellEditor);
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnPixelData(30));
    tableLayout.addColumnData(new ColumnPixelData(160));
    condView.getTable().setLayout(tableLayout);
    condView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent e) {
            if (e.character == ' ') {
                toggleUsedBySelectedCondition();
            }
            super.keyPressed(e);
        }
    });
}
Also used : CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) KeyEvent(org.eclipse.swt.events.KeyEvent) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 28 with KeyEvent

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

the class CopyDatabaseDialog method createDestinationDatabaseGroup.

/**
	 * Create Destination Database Group
	 * 
	 * @param composite the parent composite
	 */
private void createDestinationDatabaseGroup(Composite composite) {
    final Group destinationDBGroup = new Group(composite, SWT.NONE);
    destinationDBGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
    destinationDBGroup.setText(Messages.grpDbDestName);
    final GridLayout gridLayout = new GridLayout();
    destinationDBGroup.setLayout(gridLayout);
    final Composite destinationDBComposit = new Composite(destinationDBGroup, SWT.LEFT);
    final GridData gdDestinationDBComposit = new GridData(SWT.FILL, SWT.BOTTOM, true, false);
    destinationDBComposit.setLayoutData(gdDestinationDBComposit);
    final GridLayout glDestinationDBComposite = new GridLayout();
    glDestinationDBComposite.numColumns = 3;
    destinationDBComposit.setLayout(glDestinationDBComposite);
    final Label destinationDBNameLabel = new Label(destinationDBComposit, SWT.LEFT);
    destinationDBNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    destinationDBNameLabel.setText(Messages.lblDescDbName);
    destinationDBNameText = new Text(destinationDBComposit, SWT.BORDER);
    final GridData gdDestinationDBNameText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    destinationDBNameText.setLayoutData(gdDestinationDBNameText);
    destinationDBNameText.addKeyListener(new EditListener());
    new Label(destinationDBComposit, SWT.LEFT);
    final Label destinationDBDirPathLabel = new Label(destinationDBComposit, SWT.LEFT);
    destinationDBDirPathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    destinationDBDirPathLabel.setText(Messages.lblDescDbPathName);
    destinationDBDirPathText = new Text(destinationDBComposit, SWT.BORDER);
    destinationDBDirPathText.setRedraw(true);
    destinationDBDirPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 1 : 2, 1, -1, -1));
    destinationDBDirPathText.addKeyListener(new EditListener() {

        @Override
        public void keyReleased(KeyEvent event) {
            isDefaultChanged = true;
            super.keyReleased(event);
        }
    });
    if (isLocalServer) {
        dbDirPathButton = new Button(destinationDBComposit, SWT.PUSH);
        dbDirPathButton.setText(Messages.btnBrowseName);
        dbDirPathButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
        dbDirPathButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                DirectoryDialog dialog = new DirectoryDialog(getShell());
                String text = destinationDBDirPathText.getText();
                if (text == null || text.trim().length() == 0) {
                    text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_DATABASE_PATH + database.getId());
                }
                if (text != null) {
                    dialog.setFilterPath(text);
                }
                dialog.setText(Messages.msgSelectDir);
                dialog.setMessage(Messages.msgSelectDir);
                String newPath = dialog.open();
                if (newPath != null) {
                    destinationDBDirPathText.setText(newPath);
                    isDefaultChanged = true;
                    CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_DATABASE_PATH + database.getId(), newPath);
                }
            }
        });
    }
    final Label volumnPath = new Label(destinationDBComposit, SWT.LEFT);
    volumnPath.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    volumnPath.setText(Messages.lblVolumePathName);
    volumePathText = new Text(destinationDBComposit, SWT.BORDER);
    volumePathText.setRedraw(true);
    volumePathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 1 : 2, 1, -1, -1));
    volumePathText.addKeyListener(new EditListener() {

        @Override
        public void keyReleased(KeyEvent event) {
            isDefaultChanged = true;
            super.keyReleased(event);
        }
    });
    if (isLocalServer) {
        dbExtPathButton = new Button(destinationDBComposit, SWT.PUSH);
        dbExtPathButton.setText(Messages.btnBrowseName);
        dbExtPathButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
        dbExtPathButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                DirectoryDialog dialog = new DirectoryDialog(getShell());
                String text = volumePathText.getText();
                if (text == null || text.trim().length() == 0) {
                    text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_EXTENDED_VOLUME_PATH + database.getId());
                }
                if (text == null || text.trim().length() == 0) {
                    text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_DATABASE_PATH + database.getId());
                }
                if (text != null) {
                    dialog.setFilterPath(text);
                }
                dialog.setText(Messages.msgSelectDir);
                dialog.setMessage(Messages.msgSelectDir);
                String newPath = dialog.open();
                if (newPath != null) {
                    volumePathText.setText(newPath);
                    isDefaultChanged = true;
                    CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_EXTENDED_VOLUME_PATH + database.getId(), newPath);
                }
            }
        });
    }
    final Label destinationDBLogPathLabel = new Label(destinationDBComposit, SWT.LEFT);
    destinationDBLogPathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    destinationDBLogPathLabel.setText(Messages.lblDescLogPathName);
    destinationDBLogPathText = new Text(destinationDBComposit, SWT.BORDER);
    destinationDBLogPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 1 : 2, 1, -1, -1));
    destinationDBLogPathText.addKeyListener(new EditListener() {

        @Override
        public void keyReleased(KeyEvent event) {
            isDefaultChanged = true;
            super.keyReleased(event);
        }
    });
    if (isLocalServer) {
        Button folders = new Button(destinationDBComposit, SWT.PUSH);
        folders.setText(Messages.btnBrowseName);
        folders.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
        folders.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent event) {
                DirectoryDialog dialog = new DirectoryDialog(getShell());
                String text = destinationDBLogPathText.getText();
                if (text == null || text.trim().length() == 0) {
                    text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_LOG_FILE_PATH + database.getId());
                }
                if (text == null || text.trim().length() == 0) {
                    text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_DATABASE_PATH + database.getId());
                }
                if (text != null) {
                    dialog.setFilterPath(text);
                }
                dialog.setFilterPath(text);
                dialog.setText(Messages.msgSelectDir);
                dialog.setMessage(Messages.msgSelectDir);
                String newPath = dialog.open();
                if (newPath != null) {
                    destinationDBLogPathText.setText(newPath);
                    isDefaultChanged = true;
                    CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_LOG_FILE_PATH + database.getId(), newPath);
                }
            }
        });
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CLabel(org.eclipse.swt.custom.CLabel) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 29 with KeyEvent

use of org.eclipse.swt.events.KeyEvent 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 30 with KeyEvent

use of org.eclipse.swt.events.KeyEvent 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)

Aggregations

KeyEvent (org.eclipse.swt.events.KeyEvent)98 KeyAdapter (org.eclipse.swt.events.KeyAdapter)63 GridData (org.eclipse.swt.layout.GridData)54 GridLayout (org.eclipse.swt.layout.GridLayout)42 Composite (org.eclipse.swt.widgets.Composite)42 SelectionEvent (org.eclipse.swt.events.SelectionEvent)41 Text (org.eclipse.swt.widgets.Text)34 KeyListener (org.eclipse.swt.events.KeyListener)32 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)32 Label (org.eclipse.swt.widgets.Label)29 ModifyEvent (org.eclipse.swt.events.ModifyEvent)22 ModifyListener (org.eclipse.swt.events.ModifyListener)22 Point (org.eclipse.swt.graphics.Point)21 Button (org.eclipse.swt.widgets.Button)21 MouseEvent (org.eclipse.swt.events.MouseEvent)20 TableViewer (org.eclipse.jface.viewers.TableViewer)19 StyledText (org.eclipse.swt.custom.StyledText)13 FocusEvent (org.eclipse.swt.events.FocusEvent)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)12 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)12