Search in sources :

Example 81 with TableItem

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

the class SetPKDialog method createComposite.

/**
	 * This method initializes composite
	 *
	 */
private void createComposite() {
    Composite groupComposite = new Composite(group, SWT.NONE);
    {
        GridData gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.horizontalSpan = 2;
        gridData.grabExcessHorizontalSpace = true;
        gridData.verticalAlignment = GridData.CENTER;
        groupComposite.setLayoutData(gridData);
        GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 2;
        groupComposite.setLayout(gridLayout);
    }
    upBtn = new Button(groupComposite, SWT.NONE);
    {
        upBtn.setText(Messages.btnUp);
        GridData gridData = new GridData();
        gridData.horizontalAlignment = GridData.END;
        gridData.grabExcessHorizontalSpace = true;
        gridData.verticalAlignment = GridData.CENTER;
        upBtn.setLayoutData(gridData);
    }
    upBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
            if (constraintTable.getSelectionCount() < 1) {
                return;
            }
            int selectionIndex = constraintTable.getSelectionIndex();
            if (selectionIndex == 0) {
                return;
            }
            boolean tmpCheck;
            String tmpName, tmpDomain;
            Color tmpColor;
            TableItem selectedItem = constraintTable.getSelection()[0];
            TableItem targetItem = constraintTable.getItem(selectionIndex - 1);
            tmpCheck = targetItem.getChecked();
            tmpName = targetItem.getText(1);
            tmpDomain = targetItem.getText(2);
            tmpColor = targetItem.getForeground();
            targetItem.setChecked(selectedItem.getChecked());
            targetItem.setText(1, selectedItem.getText(1));
            targetItem.setText(2, selectedItem.getText(2));
            targetItem.setForeground(selectedItem.getForeground());
            selectedItem.setChecked(tmpCheck);
            selectedItem.setText(1, tmpName);
            selectedItem.setText(2, tmpDomain);
            selectedItem.setForeground(tmpColor);
            constraintTable.setSelection(selectionIndex - 1);
            setBtnEnable();
        }
    });
    downBtn = new Button(groupComposite, SWT.NONE);
    {
        downBtn.setText(Messages.btnDown);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        downBtn.setLayoutData(gridData);
    }
    downBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(org.eclipse.swt.events.SelectionEvent event) {
            if (constraintTable.getSelectionCount() < 1) {
                return;
            }
            int selectionIndex = constraintTable.getSelectionIndex();
            if (selectionIndex == constraintTable.getItemCount() - 1) {
                return;
            }
            boolean tmpCheck;
            String tmpName, tmpDomain;
            Color tmpColor;
            TableItem selectedItem = constraintTable.getSelection()[0];
            TableItem targetItem = constraintTable.getItem(selectionIndex + 1);
            tmpCheck = targetItem.getChecked();
            tmpName = targetItem.getText(1);
            tmpDomain = targetItem.getText(2);
            tmpColor = targetItem.getForeground();
            targetItem.setChecked(selectedItem.getChecked());
            targetItem.setText(1, selectedItem.getText(1));
            targetItem.setText(2, selectedItem.getText(2));
            targetItem.setForeground(selectedItem.getForeground());
            selectedItem.setChecked(tmpCheck);
            selectedItem.setText(1, tmpName);
            selectedItem.setText(2, tmpDomain);
            selectedItem.setForeground(tmpColor);
            constraintTable.setSelection(selectionIndex + 1);
            setBtnEnable();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Color(org.eclipse.swt.graphics.Color) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 82 with TableItem

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

the class PstmtSQLDialog method createColumn.

/**
	 * Create the empty parameter table
	 *
	 * @param parent Composite
	 * @param isMulti boolean
	 */
protected void createColumn(int columnCount) {
    TableItem item = new TableItem(parameterTypeTable, SWT.NONE);
    item.setText(0, Messages.msgPstmtType);
    for (int i = 0; i < columnCount; i++) {
        TableColumn typeColumn = new TableColumn(parameterTypeTable, SWT.NONE);
        typeColumn.setWidth(90);
        typeColumn.setText(String.valueOf(i + 1));
        final TableViewerColumn paraColumn = new TableViewerColumn(parameterTable, SWT.LEFT);
        paraColumn.getColumn().setWidth(90);
        paraColumn.getColumn().setText(String.valueOf(i + 1));
        paraColumn.setEditingSupport(new ParamValueEditingSupport(parameterTable, i + 1));
    }
    parameterTable.setLabelProvider(new ParamValueLabelProvider(parameterTable.getTable()));
    //add one data to parameterTable
    ParamValueObject paramValueObject = new ParamValueObject();
    //index
    paramValueObject.getValue().add("1");
    for (int i = 0; i < columnCount; i++) {
        paramValueObject.getValue().add("");
    }
    valueList.add(paramValueObject);
    parameterTable.setInput(valueList);
    parameterTable.refresh();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) TableColumn(org.eclipse.swt.widgets.TableColumn) Point(org.eclipse.swt.graphics.Point) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 83 with TableItem

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

the class PstmtDataDialog method analyzeSql.

protected void analyzeSql() {
    if (!validSql()) {
        return;
    }
    String sql = sqlTxt.getText();
    int count = SqlParser.getStrCount(sql, "?");
    parameterTable.removeAll();
    ParameterMetaData metaData = TableUtil.getParameterMetaData(database, sqlTxt.getText());
    for (int i = 0; i < count; i++) {
        TableItem item = new TableItem(parameterTable, SWT.NONE);
        item.setText(0, String.valueOf(i + 1));
        if (metaData != null) {
            try {
                String type = metaData.getParameterTypeName(i + 1);
                if (type == null || type.trim().length() == 0) {
                    continue;
                }
                int precision = metaData.getPrecision(i + 1);
                int scale = metaData.getScale(i + 1);
                type = FieldHandlerUtils.getComleteType(type, null, precision, scale);
                item.setText(1, type);
            } catch (SQLException e) {
                continue;
            }
        }
    }
    validate();
    packTable();
}
Also used : SQLException(java.sql.SQLException) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) ParameterMetaData(java.sql.ParameterMetaData)

Example 84 with TableItem

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

the class InsertTableDataDialog method validate.

private boolean validate() {
    setErrorMessage(null);
    for (int i = 0; i < attrTable.getItemCount(); i++) {
        TableItem item = attrTable.getItem(i);
        String value = item.getText(EDIT_COLUMN);
        if (!validate(value, item)) {
            return false;
        }
    }
    return true;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem)

Example 85 with TableItem

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

the class PstmtDataDialog method handle.

protected void handle(final Event event) {
    if (isChanging) {
        return;
    }
    Point pt = new Point(event.x, event.y);
    int topIndex = parameterTable.getTopIndex();
    int curIndex = newIndex;
    newIndex = parameterTable.getSelectionIndex();
    if (curIndex < 0 || newIndex < 0 || topIndex > newIndex || curIndex != newIndex) {
        return;
    }
    final TableItem item = parameterTable.getItem(newIndex);
    if (item == null) {
        return;
    }
    for (int i = 1; i < parameterTable.getColumnCount(); i++) {
        Rectangle rect = item.getBounds(i);
        if (rect.contains(pt)) {
            if (i == 1) {
                handleType(item);
            } else if (i == 2) {
                handleValue(item);
            }
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)475 Point (org.eclipse.swt.graphics.Point)136 Table (org.eclipse.swt.widgets.Table)125 TableColumn (org.eclipse.swt.widgets.TableColumn)79 SelectionEvent (org.eclipse.swt.events.SelectionEvent)73 GridData (org.eclipse.swt.layout.GridData)70 GridLayout (org.eclipse.swt.layout.GridLayout)61 Composite (org.eclipse.swt.widgets.Composite)56 ArrayList (java.util.ArrayList)55 Image (org.eclipse.swt.graphics.Image)55 Button (org.eclipse.swt.widgets.Button)53 Rectangle (org.eclipse.swt.graphics.Rectangle)52 Label (org.eclipse.swt.widgets.Label)51 Shell (org.eclipse.swt.widgets.Shell)49 Color (org.eclipse.swt.graphics.Color)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Text (org.eclipse.swt.widgets.Text)42 FillLayout (org.eclipse.swt.layout.FillLayout)40 Test (org.junit.Test)39 SelectionListener (org.eclipse.swt.events.SelectionListener)36