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();
}
});
}
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();
}
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();
}
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;
}
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);
}
}
}
}
Aggregations