use of com.cubrid.common.ui.spi.table.CellValue in project cubrid-manager by CUBRID.
the class DateCellPopupDialog method buttonPressed.
/**
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
* @param buttonId the id of the button that was pressed (see
* <code>IDialogConstants.*_ID</code> constants)
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
String stringValue = NULL_VALUE;
Date dateValue = null;
Calendar calendar = null;
if (!setNullBtn.getSelection()) {
if (dateComposite != null) {
int year = dateComposite.getYear();
int month = dateComposite.getMonth();
int day = dateComposite.getDay();
calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
dateValue = new Date(calendar.getTimeInMillis());
stringValue = DateUtil.getDatetimeString(dateValue, DateUtil.DATE_FORMAT);
}
}
newValue = new CellValue(dateValue);
newValue.setShowValue(stringValue);
}
super.buttonPressed(buttonId);
}
use of com.cubrid.common.ui.spi.table.CellValue in project cubrid-manager by CUBRID.
the class InputMethodAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
int dateTimeComponentWidth = 300;
int dateTimeComponentHeight = 230;
Shell shell = new Shell(Display.getDefault().getActiveShell(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
shell.setText("");
shell.setLayout(new GridLayout());
shell.setLayoutData(new GridData(GridData.FILL_BOTH));
DateTimeComponent dateTimeComponent = new DateTimeComponent(shell, SWT.BORDER);
dateTimeComponent.setLayout(new GridLayout());
dateTimeComponent.setLayoutData(new GridData(GridData.FILL_BOTH));
Point dateTimeComponentSize = dateTimeComponent.componentSize();
dateTimeComponentWidth = dateTimeComponentSize.x;
dateTimeComponentHeight = dateTimeComponentSize.y;
shell.setSize(dateTimeComponentWidth, dateTimeComponentHeight);
Point p = Display.getDefault().getCursorLocation();
Rectangle screenSize = Display.getDefault().getClientArea();
if (p.x + dateTimeComponentWidth > screenSize.width) {
p.x = screenSize.width - dateTimeComponentWidth - 50;
}
if (p.y + dateTimeComponentHeight > screenSize.height) {
p.y = screenSize.height - dateTimeComponentHeight - 50;
}
shell.setLocation(p);
shell.open();
while (!shell.isDisposed()) {
if (!Display.getDefault().readAndDispatch())
Display.getDefault().sleep();
}
if (item != null && type != null && dateTimeComponent.getReturnDateValue() != null) {
Map<String, CellValue> oldValueMap = new HashMap<String, CellValue>();
for (int i = 1; i < queryExecuter.getTblResult().getColumnCount(); i++) {
oldValueMap.put(String.valueOf(i), new CellValue(item.getText(i), item.getText(i)));
}
if (type.equalsIgnoreCase("DATE")) {
item.setText(column, dateTimeComponent.getReturnDateValue());
} else if (type.equalsIgnoreCase("TIMESTAMP")) {
item.setText(column, dateTimeComponent.getReturnTimestampValue());
} else if (type.equalsIgnoreCase("TIME")) {
item.setText(column, dateTimeComponent.getReturnTimeValue());
} else {
item.setText(column, dateTimeComponent.getReturnDateTimeValue());
}
Map<String, CellValue> newValueMap = new HashMap<String, CellValue>();
for (int i = 1; i < queryExecuter.getTblResult().getColumnCount(); i++) {
newValueMap.put(String.valueOf(i), new CellValue(item.getText(i), item.getText(i)));
}
queryExecuter.updateValue(item, oldValueMap, newValueMap);
}
// String data = stext.getSelectionText();
// if (data != null && !data.equals("")) {
// IAction pasteAction = ActionManager.getInstance().getAction(
// PasteAction.ID);
// FocusAction.changeActionStatus(pasteAction, stext);
// }
}
use of com.cubrid.common.ui.spi.table.CellValue in project cubrid-manager by CUBRID.
the class QueryExecuter method addNewItem.
/**
* add a new item into table result
* @return a new added TableItem
*/
public TableItem addNewItem() {
TableItem itemNew = new TableItem(tblResult, SWT.MULTI);
changeInsertedItemStyle(itemNew);
selectableSupport.setSelection(itemNew, 0);
String key = "" + itemNew.hashCode();
// The data is necessary
Map<String, CellValue> dataMap = new HashMap<String, CellValue>();
itemNew.setData(dataMap);
itemNew.setData(LASTEST_DATA_FLAG, dataMap);
itemNew.setData(NEW_RECORD_FLAG, key);
insValues.put(key, dataMap);
return itemNew;
}
use of com.cubrid.common.ui.spi.table.CellValue in project cubrid-manager by CUBRID.
the class QueryExecuter method makeItemValue.
/**
* make a table item by its data.
*
* @param item a TableItem instance
* @param mapItemData a item data instance with type of Map<String, Object>
*/
private void makeItemValue(TableItem item, Map<String, CellValue> mapItemData) {
for (int j = 0; allColumnList != null && j < allColumnList.size(); j++) {
String columnIndex = allColumnList.get(j).getIndex();
String type = allColumnList.get(j).getType();
CellValue colValue = mapItemData.get(columnIndex);
if (colValue == null || colValue.getShowValue() == null) {
item.setText(j + 1, DataType.NULL_EXPORT_FORMAT);
item.setBackground(j + 1, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
item.setData((j + 1) + "", DataType.VALUE_NULL);
} else if (DataType.DATATYPE_BLOB.equalsIgnoreCase(type)) {
item.setText(j + 1, DataType.BLOB_EXPORT_FORMAT);
item.setBackground(j + 1, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
} else if (DataType.DATATYPE_CLOB.equalsIgnoreCase(type)) {
item.setText(j + 1, DataType.CLOB_EXPORT_FORMAT);
item.setBackground(j + 1, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
} else if ((DataType.DATATYPE_BIT_VARYING.equalsIgnoreCase(type) || DataType.DATATYPE_BIT.equalsIgnoreCase(type)) && DataType.BIT_EXPORT_FORMAT.equals(colValue.getShowValue())) {
String data = colValue.getShowValue();
item.setText(j + 1, data);
item.setBackground(j + 1, Display.getCurrent().getSystemColor(SWT.COLOR_GRAY));
} else {
item.setText(j + 1, colValue.getShowValue());
}
}
}
use of com.cubrid.common.ui.spi.table.CellValue in project cubrid-manager by CUBRID.
the class QueryExecuter method deleteRecord.
/**
* delete the record
*
* @param selection TableItem[]
*/
@SuppressWarnings("unchecked")
protected void deleteRecord(Table table, TableItem[] selection) {
if (selection == null) {
selection = selectableSupport.getSelectedTableItems();
if (selection.length == 0) {
return;
}
} else {
if (selection.length == 0) {
return;
}
}
ArrayList<TableItem> itemsWithOIDList = new ArrayList<TableItem>();
ArrayList<TableItem> itemsInsertedList = new ArrayList<TableItem>();
// dispatch the selected items into corresponding list
for (TableItem item : selection) {
if (isNewInsertedRecordItem(item)) {
itemsInsertedList.add(item);
insValues.remove("" + item.hashCode());
} else {
itemsWithOIDList.add(item);
delValues.put("" + item.hashCode(), (Map<String, CellValue>) item.getData());
insertSaveItem.setEnabled(getEditable());
rollbackModifiedItem.setEnabled(getEditable());
}
}
TableItem[] itemsInserted = new TableItem[itemsInsertedList.size()];
itemsInserted = itemsInsertedList.toArray(itemsInserted);
TableItem[] itemsWithOID = new TableItem[itemsWithOIDList.size()];
itemsWithOID = itemsWithOIDList.toArray(itemsWithOID);
selection = itemsWithOID;
for (TableItem item : itemsWithOIDList) {
item.dispose();
}
for (TableItem item : itemsInsertedList) {
item.dispose();
}
// int iDeletedItemCount = oid.length + itemsInserted.length;
// CommonTool.openInformationBox(Messages.delete,
// Messages.bind(Messages.deleteOk, iDeletedItemCount));
// makeItem();
// updateActions();
// } catch (SQLException event) {
// CommonTool.openErrorBox(event.getErrorCode() + CommonTool.NEWLINE + Messages.errorHead
// + event.getMessage());
// }
// }
}
Aggregations