Search in sources :

Example 96 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class SqlmapCellModifier method modify.

@SuppressWarnings("unchecked")
@Override
public void modify(Object element, String property, Object value) {
    if (!(element instanceof TableItem)) {
        return;
    }
    TableItem tableItem = (TableItem) element;
    Map<String, String> data = (Map<String, String>) tableItem.getData();
    parentView.changeUseCondition(data.get("1"), (Boolean) value);
    parentView.refreshView();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Map(java.util.Map)

Example 97 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class SelectedLoactionComparator method getSelectedLocation.

/**
	 * Get selected table item's point
	 * 
	 * @param table
	 * @param x
	 * @param y
	 * @return
	 */
private Point getSelectedLocation(Table table, int x, int y) {
    Point pt = new Point(x, y);
    TableItem item = table.getItem(pt);
    /*While the Table style is not full selection, the performance is low*/
    if (item == null) {
        int columnCount = table.getColumnCount();
        for (TableItem temp : table.getItems()) {
            for (int i = 0; i < columnCount; i++) {
                if (temp.getBounds(i).contains(pt)) {
                    item = temp;
                    break;
                }
            }
        }
    }
    if (item == null) {
        return null;
    }
    int columnCount = table.getColumnCount();
    for (int col = 0; col < columnCount; col++) {
        Rectangle rect = item.getBounds(col);
        if (rect.contains(pt)) {
            int row = table.indexOf(item);
            return new Point(col, row);
        }
    }
    return null;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 98 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class SelectedLoactionComparator method drawSelectedItem.

/**
	 * Draw selected item by location
	 * 
	 * @param location
	 */
private void drawSelectedItem(Point location, boolean isNotify) {
    int colLen = table.getColumnCount();
    TableItem item = table.getItem(location.y);
    for (int x = 0; x < colLen; x++) {
        if (x == location.x || location.x == 0) {
            item.setBackground(x, selectedCellBG);
        } else if (!selectedList.contains(new Point(x, location.y))) {
            item.setBackground(x, unSelectedCellBG);
        }
    }
    table.deselectAll();
    if (isNotify) {
        fireSelectionChanged();
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 99 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class SelectedLoactionComparator method setSelection.

public void setSelection(TableItem item, int column) {
    selectedList.clear();
    int rowIndex = -1;
    if (item != null && table.getColumnCount() > column) {
        TableItem[] items = table.getItems();
        for (int i = 0; i < items.length; i++) {
            TableItem tempItem = items[i];
            if (tempItem.equals(item)) {
                rowIndex = i;
                break;
            }
        }
        if (rowIndex >= 0) {
            tableCursor.setSelection(rowIndex, column);
            addSelectPoint(new Point(column, rowIndex), true);
            drawSelectedItems(true);
        }
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 100 with TableItem

use of org.eclipse.swt.widgets.TableItem in project cubrid-manager by CUBRID.

the class BrokerParameterDialog method performOk.

/**
	 * Executes tasks
	 */
private void performOk() {
    TableItem[] items = paraTable.getItems();
    for (TableItem item : items) {
        String key = item.getText(0).trim();
        if (key.length() != 0) {
            if (key.equals(ConfConstants.LONG_QUERY_TIME) || key.equals(ConfConstants.LONG_TRANSACTION_TIME)) {
                String newVal = item.getText(2).trim();
                if (isQueryOrTransTimeUseMs) {
                    double dVal = Double.parseDouble(newVal) / 1000;
                    newVal = Double.toString(dVal);
                }
                brokerMap.put(key, newVal);
            } else {
                brokerMap.put(key, item.getText(2).trim());
            }
        }
    }
    brokerMap.put("0", nameTxt.getText().trim());
    brokerMap.put("1", brokerMap.get(ConfConstants.BROKER_PORT));
    String brokerName = nameTxt.getText().trim();
    boolean state = refreshBtn.getSelection();
    String interval = intervalTxt.getText().trim();
    if (null == brokerIntervalSetting) {
        brokerIntervalSetting = new BrokerIntervalSetting();
        brokerIntervalSetting.setBrokerName(brokerName);
    }
    brokerIntervalSetting.setInterval(interval);
    brokerIntervalSetting.setOn(state);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)475 Point (org.eclipse.swt.graphics.Point)136 Table (org.eclipse.swt.widgets.Table)125 TableColumn (org.eclipse.swt.widgets.TableColumn)79 SelectionEvent (org.eclipse.swt.events.SelectionEvent)73 GridData (org.eclipse.swt.layout.GridData)70 GridLayout (org.eclipse.swt.layout.GridLayout)61 Composite (org.eclipse.swt.widgets.Composite)56 ArrayList (java.util.ArrayList)55 Image (org.eclipse.swt.graphics.Image)55 Button (org.eclipse.swt.widgets.Button)53 Rectangle (org.eclipse.swt.graphics.Rectangle)52 Label (org.eclipse.swt.widgets.Label)51 Shell (org.eclipse.swt.widgets.Shell)49 Color (org.eclipse.swt.graphics.Color)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Text (org.eclipse.swt.widgets.Text)42 FillLayout (org.eclipse.swt.layout.FillLayout)40 Test (org.junit.Test)39 SelectionListener (org.eclipse.swt.events.SelectionListener)36