use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.
the class PstmtDataDialog method createParameterTable.
protected void createParameterTable(Composite parent, boolean isMulti) {
Composite composite = new Composite(parent, SWT.NONE);
{
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
composite.setLayout(gridLayout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
composite.setLayoutData(gridData);
}
parameterTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.heightHint = 100;
parameterTable.setLayoutData(gridData);
parameterTable.setHeaderVisible(true);
parameterTable.setLinesVisible(true);
TableColumn[] tblColumns = new TableColumn[3];
tblColumns[0] = new TableColumn(parameterTable, SWT.NONE);
tblColumns[0].setText(Messages.colParaName);
tblColumns[0].setWidth(130);
tblColumns[1] = new TableColumn(parameterTable, SWT.NONE);
tblColumns[1].setText(Messages.colParaType);
tblColumns[1].setWidth(110);
tblColumns[2] = new TableColumn(parameterTable, SWT.NONE);
tblColumns[2].setWidth(130);
if (isMulti) {
tblColumns[2].setText(Messages.colFileColumn);
} else {
tblColumns[2].setText(Messages.colParaValue);
}
tableEditor = new TableEditor(parameterTable);
tableEditor.horizontalAlignment = SWT.LEFT;
tableEditor.grabHorizontal = true;
parameterTable.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (event.button != 1) {
return;
}
handle(event);
}
});
}
Button clearButton = new Button(composite, SWT.NONE);
{
GridData gridData = new GridData();
gridData.verticalAlignment = SWT.TOP;
clearButton.setLayoutData(gridData);
if (isMulti) {
clearButton.setText(Messages.btnClearColumn);
} else {
clearButton.setText(Messages.btnClearValue);
}
clearButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
for (int i = 0; i < parameterTable.getItemCount(); i++) {
parameterTable.getItem(i).setText(2, "");
}
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
});
}
}
use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method createTableGroup.
private void createTableGroup(Composite composite) {
final String[] columnNames = new String[] { "", com.cubrid.common.ui.query.Messages.msgBatchRunSqlFile, com.cubrid.common.ui.query.Messages.msgBatchRunMemo, com.cubrid.common.ui.query.Messages.msgBatchRunRegdate };
tv = CommonUITool.createCommonTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
tv.setInput(FavoriteQueryPersistUtil.getInstance().getListData());
{
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnPixelData(0));
tableLayout.addColumnData(new ColumnPixelData(209));
tableLayout.addColumnData(new ColumnPixelData(80));
tableLayout.addColumnData(new ColumnPixelData(118));
tv.getTable().setLayout(tableLayout);
}
editor = new TableEditor(tv.getTable());
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
tv.getTable().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateButtonStatus();
}
});
tv.getTable().addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (event.button != 1) {
return;
}
updateButtonStatus();
Point pt = new Point(event.x, event.y);
int newIndex = tv.getTable().getSelectionIndex();
if (tv.getTable().getItemCount() <= newIndex || newIndex < 0) {
return;
}
final TableItem item = tv.getTable().getItem(newIndex);
if (item == null) {
return;
}
Rectangle rect = item.getBounds(2);
if (rect.contains(pt)) {
focusCell(item, newIndex, 2);
}
}
});
tv.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
ISelection selection = event.getSelection();
openSelectedFile(selection);
}
});
createContextMenu();
}
use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.
the class SchemaInfoEditorPart method setTableEditor.
/**
*
* Set table editor
*
* @param table Table
* @param columnIndex index
*/
private void setTableEditor(final Table table, final int columnIndex) {
final TableEditor editor = new TableEditor(table);
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
table.addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (event.button != 1) {
return;
}
Point pt = new Point(event.x, event.y);
int topIndex = table.getTopIndex();
int selectedIndex = table.getSelectionIndex();
if (selectedIndex < 0 || topIndex > selectedIndex) {
return;
}
final TableItem item = table.getItem(selectedIndex);
if (item == null) {
return;
}
Rectangle rect = item.getBounds(columnIndex);
if (rect.contains(pt)) {
Control oldEditor = editor.getEditor();
if (oldEditor != null) {
oldEditor.dispose();
}
final StyledText newEditor = new StyledText(table, SWT.READ_ONLY);
newEditor.addListener(SWT.FocusOut, new Listener() {
public void handleEvent(final Event event) {
if (event.type == SWT.FocusOut) {
newEditor.dispose();
}
}
});
com.cubrid.common.ui.spi.util.CommonUITool.registerContextMenu(newEditor, false);
newEditor.setText(item.getText(columnIndex));
newEditor.selectAll();
newEditor.setFocus();
editor.setEditor(newEditor, item, columnIndex);
}
}
});
}
use of org.eclipse.swt.custom.TableEditor in project cubrid-manager by CUBRID.
the class JdbcOptionComposite method createJdbcTableGroup.
/**
*
* Create JDBC table group
*
* @param composite the composite
*/
private void createJdbcTableGroup(Composite composite) {
final String[] columnNameArr = new String[] { Messages.tblColJdbcAttrName, Messages.tblColJdbcAttrValue };
jdbcInfoTv = CommonUITool.createCommonTableViewer(composite, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 150));
jdbcInfoTv.setInput(jdbcListData);
TableLayout tableLayout = new TableLayout();
jdbcInfoTv.getTable().setLayout(tableLayout);
tableLayout.addColumnData(new ColumnWeightData(35, true));
tableLayout.addColumnData(new ColumnWeightData(65, true));
editor = new TableEditor(jdbcInfoTv.getTable());
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
jdbcInfoTv.getTable().addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (event.button != 1) {
return;
}
Point pt = new Point(event.x, event.y);
int newIndex = jdbcInfoTv.getTable().getSelectionIndex();
if (jdbcInfoTv.getTable().getItemCount() <= newIndex || newIndex < 0) {
return;
}
final TableItem item = jdbcInfoTv.getTable().getItem(newIndex);
if (item == null) {
return;
}
for (int i = 0; i < 2; i++) {
Rectangle rect = item.getBounds(i);
if (rect.contains(pt)) {
focusCell(item, newIndex, i);
break;
}
}
}
});
}
use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.
the class PromptDefaultValueDialog method createTextEditor.
private void createTextEditor(TableItem item, int column, String displayText) {
TableEditor editor = new TableEditor(table);
final Text text = new Text(table, SWT.NONE);
text.setText(displayText);
editor.setEditor(text, item, column);
editor.grabHorizontal = true;
editor.layout();
editors.add(editor);
}
Aggregations