Search in sources :

Example 6 with CellValue

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);
}
Also used : Calendar(java.util.Calendar) CellValue(com.cubrid.common.ui.spi.table.CellValue) Date(java.util.Date)

Example 7 with CellValue

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);
//			}
}
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)

Example 8 with CellValue

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;
}
Also used : HashMap(java.util.HashMap) TableItem(org.eclipse.swt.widgets.TableItem) CellValue(com.cubrid.common.ui.spi.table.CellValue)

Example 9 with CellValue

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());
        }
    }
}
Also used : CellValue(com.cubrid.common.ui.spi.table.CellValue) Point(org.eclipse.swt.graphics.Point)

Example 10 with CellValue

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());
//			}
//		}
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) CellValue(com.cubrid.common.ui.spi.table.CellValue)

Aggregations

CellValue (com.cubrid.common.ui.spi.table.CellValue)24 Point (org.eclipse.swt.graphics.Point)11 HashMap (java.util.HashMap)9 Map (java.util.Map)8 ArrayList (java.util.ArrayList)7 SQLException (java.sql.SQLException)6 TableItem (org.eclipse.swt.widgets.TableItem)6 ParamSetException (com.cubrid.common.ui.spi.util.paramSetter.ParamSetException)5 FormatDataResult (com.cubrid.cubridmanager.core.cubrid.table.model.FormatDataResult)4 PstmtParameter (com.cubrid.common.ui.cubrid.table.dialog.PstmtParameter)3 ParamSetter (com.cubrid.common.ui.spi.util.paramSetter.ParamSetter)3 DBConnection (com.cubrid.cubridmanager.core.common.jdbc.DBConnection)3 File (java.io.File)3 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 Calendar (java.util.Calendar)3 Date (java.util.Date)3 ColumnInfo (com.cubrid.common.ui.query.control.ColumnInfo)2 IOException (java.io.IOException)2 DateTimeComponent (com.cubrid.common.ui.query.control.DateTimeComponent)1