use of com.cubrid.common.ui.query.control.DateTimeComponent 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);
// }
}
Aggregations