use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.
the class ViewDashboardEditorPart method dropView.
public void dropView() {
TableItem[] items = viewsDetailInfoTable.getTable().getSelection();
if (items.length > 0) {
List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
for (TableItem item : items) {
ViewDetailInfo viewInfo = (ViewDetailInfo) item.getData();
Set<String> typeSet = new HashSet<String>();
typeSet.add(NodeType.USER_VIEW);
ICubridNode viewNode = CommonUITool.findNode(database, typeSet, viewInfo.getViewName());
selectNodeList.add((ISchemaNode) viewNode);
}
if (selectNodeList.size() > 0) {
DropViewAction action = (DropViewAction) ActionManager.getInstance().getAction(DropViewAction.ID);
ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
action.run(selectNodeList.toArray(nodeArr));
if (!action.isCanceledTask()) {
refresh();
}
}
} else {
CommonUITool.openWarningBox(Messages.viewDetailInfoPartTableNoSelectionMsg);
}
}
use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.
the class QueryExecuter method handleButtonEvent.
/**
* Open detail dialog
*
* @param event MouseEvent
*/
@SuppressWarnings("unchecked")
public void handleButtonEvent(int rowIndex, int columnIndex) {
// Get columnInfo
ColumnInfo columnInfo = (ColumnInfo) tblResult.getColumn(columnIndex).getData();
// Get data
final TableItem item = selectableSupport.getTableCursor().getRow();
Map<String, CellValue> dataMap = (Map<String, CellValue>) item.getData();
Map<String, CellValue> newValueMap = (Map<String, CellValue>) item.getData(LASTEST_DATA_FLAG);
if (newValueMap == null) {
newValueMap = new HashMap<String, CellValue>();
newValueMap.putAll(dataMap);
item.setData(LASTEST_DATA_FLAG, newValueMap);
}
String dataIndex = String.valueOf(columnIndex);
CellValue cellValue = newValueMap.get(dataIndex);
if (cellValue == null) {
cellValue = new CellValue();
newValueMap.put(dataIndex, cellValue);
}
String charset = getDatabaseInfo() != null ? getDatabaseInfo().getCharSet() : null;
String dataType = DataType.makeType(columnInfo.getType(), columnInfo.getChildElementType(), columnInfo.getPrecision(), columnInfo.getScale());
cellValue.setFileCharset(charset);
CellViewer cellViewer = new CellViewer(columnInfo, editMode, charset);
if (IDialogConstants.OK_ID == cellViewer.openCellViewer(tblResult.getShell(), cellValue)) {
CellValue newValue = cellViewer.getValue();
if (!CellViewer.isCellValueEqual(cellValue, newValue)) {
String showValue = null;
if (newValue.getValue() == null) {
showValue = DataType.NULL_EXPORT_FORMAT;
item.setText(columnIndex, showValue);
newValueMap.put(dataIndex, newValue);
updateValue(item, dataMap, newValueMap);
} else if (newValue.getValue() instanceof String) {
String strValue = newValue.getValue().toString();
FormatDataResult result = DBAttrTypeFormatter.format(dataType, strValue, null, false, charset, false);
if (result.isSuccess()) {
// Update the data
showValue = newValue.getShowValue();
item.setText(columnIndex, showValue);
newValueMap.put(dataIndex, newValue);
updateValue(item, dataMap, newValueMap);
} else {
CommonUITool.openErrorBox(Messages.bind(Messages.errTextTypeNotMatch, dataType));
return;
}
} else if (newValue.getValue() instanceof byte[]) {
if (DataType.DATATYPE_BIT.equalsIgnoreCase(columnInfo.getType()) || DataType.DATATYPE_BIT_VARYING.equalsIgnoreCase(columnInfo.getType())) {
byte[] bValues = (byte[]) newValue.getValue();
if (bValues.length * 8 > columnInfo.getPrecision() + 7) {
String msg = Messages.bind(Messages.errTextTypeNotMatch, dataType);
CommonUITool.openErrorBox(msg);
return;
}
}
showValue = newValue.getShowValue();
item.setText(columnIndex, showValue);
newValueMap.put(dataIndex, newValue);
updateValue(item, dataMap, newValueMap);
} else {
showValue = newValue.getShowValue();
item.setText(columnIndex, showValue);
newValueMap.put(dataIndex, newValue);
updateValue(item, dataMap, newValueMap);
}
selectableSupport.getTableCursor().redraw();
}
}
}
use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.
the class GetInfoDataTask method displayDemoDataTableItem.
/**
* Display table item by the data in allDataList
*/
private void displayDemoDataTableItem() {
for (int i = 0; i < allDataList.size(); i++) {
TableItem item = new TableItem(demoDataTable, SWT.MULTI);
Map<String, Object> map = allDataList.get(i);
makeItemValue(item, map);
if (i % 2 == 0) {
item.setBackground(ResourceManager.getColor(230, 230, 230));
}
if (doesGetOidInfo) {
item.setBackground(1, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
}
}
// Auto set column size, maximum is 300px,minimum is 50px
CommonUITool.packTable(demoDataTable, 50, 300);
}
use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.
the class BatchRunComposite 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 = (CheckboxTableViewer) CommonUITool.createCheckBoxTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
tv.setInput(listData);
TableLayout tableLayout = new TableLayout();
tv.getTable().setLayout(tableLayout);
tableLayout.addColumnData(new ColumnPixelData(30));
tableLayout.addColumnData(new ColumnPixelData(209));
tableLayout.addColumnData(new ColumnPixelData(272));
tableLayout.addColumnData(new ColumnPixelData(118));
editor = new TableEditor(tv.getTable());
editor.horizontalAlignment = SWT.LEFT;
editor.grabHorizontal = true;
tv.getTable().addListener(SWT.MouseUp, new Listener() {
public void handleEvent(Event event) {
if (event.button != 1) {
return;
}
validateCheck();
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);
}
}
});
}
use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.
the class FilterChooserDialog method createComposite.
/**
*
* Create the composite
*
* @param parent Composite
*/
private void createComposite(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
composite.setLayout(layout);
Label infoLabel = new Label(composite, SWT.NONE);
infoLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
infoLabel.setText(Messages.lblFilterChooser);
String[] columnNames = new String[] { Messages.colColumn };
tv = (CheckboxTableViewer) CommonUITool.createCheckBoxTableViewer(composite, null, columnNames, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, 300, 200));
tv.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
if (!event.getChecked() && selectAllBtn.getSelection()) {
selectAllBtn.setSelection(false);
}
if (colInfoList != null && colInfoList.size() == tv.getCheckedElements().length) {
selectAllBtn.setSelection(true);
}
}
});
final List<Map<String, Object>> colNameList = new ArrayList<Map<String, Object>>();
for (int i = 0; i < colInfoList.size(); i++) {
ColumnInfo colInfo = colInfoList.get(i);
Map<String, Object> map = new HashMap<String, Object>();
map.put("0", colInfo.getName());
map.put("1", colInfo);
colNameList.add(map);
}
tv.setInput(colNameList);
tv.getTable().setFocus();
selectAllBtn = new Button(composite, SWT.CHECK);
{
selectAllBtn.setText(Messages.btnSelectAll);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 0;
gridData.horizontalSpan = 3;
selectAllBtn.setLayoutData(gridData);
}
selectAllBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
boolean selection = selectAllBtn.getSelection();
tv.setAllChecked(selection);
}
});
for (TableItem item : tv.getTable().getItems()) {
@SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) item.getData();
if (map != null && selectedColInfoList.contains(map.get("1"))) {
item.setChecked(true);
}
}
TableColumn[] tblCols = tv.getTable().getColumns();
for (TableColumn tblCol : tblCols) {
tblCol.setWidth(280);
}
if (colInfoList != null && selectedColInfoList != null && colInfoList.size() == selectedColInfoList.size()) {
selectAllBtn.setSelection(true);
}
}
Aggregations