Search in sources :

Example 1 with DateTimeComponent

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);
//			}
}
Also used : Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) DateTimeComponent(com.cubrid.common.ui.query.control.DateTimeComponent) HashMap(java.util.HashMap) GridData(org.eclipse.swt.layout.GridData) Rectangle(org.eclipse.swt.graphics.Rectangle) CellValue(com.cubrid.common.ui.spi.table.CellValue) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Aggregations

DateTimeComponent (com.cubrid.common.ui.query.control.DateTimeComponent)1 CellValue (com.cubrid.common.ui.spi.table.CellValue)1 HashMap (java.util.HashMap)1 Point (org.eclipse.swt.graphics.Point)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Shell (org.eclipse.swt.widgets.Shell)1