Search in sources :

Example 31 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project eclipse.platform.swt by eclipse.

the class Shape method addListeners.

void addListeners() {
    addPaintListener(e -> {
        GC gc = e.gc;
        Display display = getDisplay();
        Color c = display.getSystemColor(color);
        gc.setBackground(c);
        Rectangle rect = getClientArea();
        int length = Math.min(rect.width, rect.height);
        if (shape == CIRCLE) {
            gc.fillOval(0, 0, length, length);
        } else {
            gc.fillRectangle(0, 0, length, length);
        }
        if (isFocusControl())
            gc.drawFocus(rect.x, rect.y, rect.width, rect.height);
    });
    addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            redraw();
        }

        @Override
        public void focusLost(FocusEvent e) {
            redraw();
        }
    });
    addMouseListener(MouseListener.mouseDownAdapter(e -> {
        if (getClientArea().contains(e.x, e.y)) {
            setFocus();
        }
    }));
    addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
        // key listener enables traversal out
        }
    });
    addTraverseListener(e -> {
        switch(e.detail) {
            case SWT.TRAVERSE_TAB_NEXT:
            case SWT.TRAVERSE_TAB_PREVIOUS:
                e.doit = true;
                break;
        }
    });
    getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            MessageFormat formatter = new MessageFormat("");
            // $NON_NLS$
            formatter.applyPattern(bundle.getString("name"));
            // $NON_NLS$
            String colorName = bundle.getString("color" + color);
            // $NON_NLS$
            String shapeName = bundle.getString("shape" + shape);
            // $NON_NLS$
            e.result = formatter.format(new String[] { colorName, shapeName });
        }
    });
    getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        @Override
        public void getRole(AccessibleControlEvent e) {
            e.detail = ACC.ROLE_GRAPHIC;
        }

        @Override
        public void getState(AccessibleControlEvent e) {
            e.detail = ACC.STATE_FOCUSABLE;
            if (isFocusControl())
                e.detail |= ACC.STATE_FOCUSED;
        }
    });
}
Also used : AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) ACC(org.eclipse.swt.accessibility.ACC) Rectangle(org.eclipse.swt.graphics.Rectangle) FocusEvent(org.eclipse.swt.events.FocusEvent) Display(org.eclipse.swt.widgets.Display) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) GC(org.eclipse.swt.graphics.GC) MessageFormat(java.text.MessageFormat) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) MouseListener(org.eclipse.swt.events.MouseListener) ResourceBundle(java.util.ResourceBundle) Color(org.eclipse.swt.graphics.Color) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) KeyEvent(org.eclipse.swt.events.KeyEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Canvas(org.eclipse.swt.widgets.Canvas) FocusAdapter(org.eclipse.swt.events.FocusAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) FocusAdapter(org.eclipse.swt.events.FocusAdapter) MessageFormat(java.text.MessageFormat) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) Color(org.eclipse.swt.graphics.Color) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) GC(org.eclipse.swt.graphics.GC) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Display(org.eclipse.swt.widgets.Display)

Example 32 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project eclipse.platform.swt by eclipse.

the class BarChart method addListeners.

void addListeners() {
    addPaintListener(e -> {
        GC gc = e.gc;
        Rectangle rect = getClientArea();
        Display display = getDisplay();
        int count = data.size();
        Point valueSize = gc.stringExtent(Integer.valueOf(valueMax).toString());
        int leftX = rect.x + 2 * GAP + valueSize.x;
        int bottomY = rect.y + rect.height - 2 * GAP - valueSize.y;
        int unitWidth = (rect.width - 4 * GAP - valueSize.x - AXIS_WIDTH) / count - GAP;
        int unitHeight = (rect.height - 3 * GAP - AXIS_WIDTH - 2 * valueSize.y) / ((valueMax - valueMin) / valueIncrement);
        // draw the title
        int titleWidth = gc.stringExtent(title).x;
        int center = (Math.max(titleWidth, count * (unitWidth + GAP) + GAP) - titleWidth) / 2;
        gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
        gc.drawString(title, leftX + AXIS_WIDTH + center, rect.y + GAP);
        // draw the y axis and value labels
        gc.setLineWidth(AXIS_WIDTH);
        gc.drawLine(leftX, rect.y + GAP + valueSize.y, leftX, bottomY);
        for (int i1 = valueMin; i1 <= valueMax; i1 += valueIncrement) {
            int y = bottomY - i1 * unitHeight;
            gc.drawLine(leftX, y, leftX - GAP, y);
            gc.drawString(Integer.valueOf(i1).toString(), rect.x + GAP, y - valueSize.y);
        }
        // draw the x axis and item labels
        gc.drawLine(leftX, bottomY, rect.x + rect.width - GAP, bottomY);
        for (int i2 = 0; i2 < count; i2++) {
            Object[] dataItem1 = data.get(i2);
            String itemLabel = (String) dataItem1[0];
            int x1 = leftX + AXIS_WIDTH + GAP + i2 * (unitWidth + GAP);
            gc.drawString(itemLabel, x1, bottomY + GAP);
        }
        // draw the bars
        gc.setBackground(display.getSystemColor(color));
        for (int i3 = 0; i3 < count; i3++) {
            Object[] dataItem2 = data.get(i3);
            int itemValue1 = ((Integer) dataItem2[1]).intValue();
            int x2 = leftX + AXIS_WIDTH + GAP + i3 * (unitWidth + GAP);
            gc.fillRectangle(x2, bottomY - AXIS_WIDTH - itemValue1 * unitHeight, unitWidth, itemValue1 * unitHeight);
        }
        if (isFocusControl()) {
            if (selectedItem == -1) {
                // draw the focus rectangle around the whole bar chart
                gc.drawFocus(rect.x, rect.y, rect.width, rect.height);
            } else {
                // draw the focus rectangle around the selected item
                Object[] dataItem3 = data.get(selectedItem);
                int itemValue2 = ((Integer) dataItem3[1]).intValue();
                int x3 = leftX + AXIS_WIDTH + GAP + selectedItem * (unitWidth + GAP);
                gc.drawFocus(x3, bottomY - itemValue2 * unitHeight - AXIS_WIDTH, unitWidth, itemValue2 * unitHeight + AXIS_WIDTH + GAP + valueSize.y);
            }
        }
    });
    addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            redraw();
        }

        @Override
        public void focusLost(FocusEvent e) {
            redraw();
        }
    });
    addMouseListener(MouseListener.mouseDownAdapter(e -> {
        if (getClientArea().contains(e.x, e.y)) {
            setFocus();
            int item = -1;
            int count = data.size();
            for (int i = 0; i < count; i++) {
                if (itemBounds(i).contains(e.x, e.y)) {
                    item = i;
                    break;
                }
            }
            if (item != selectedItem) {
                selectedItem = item;
                redraw();
                getAccessible().setFocus(item);
                getAccessible().selectionChanged();
            }
        }
    }));
    addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            boolean change = false;
            switch(e.keyCode) {
                case SWT.ARROW_DOWN:
                case SWT.ARROW_RIGHT:
                    selectedItem++;
                    if (selectedItem >= data.size())
                        selectedItem = 0;
                    change = true;
                    break;
                case SWT.ARROW_UP:
                case SWT.ARROW_LEFT:
                    selectedItem--;
                    if (selectedItem <= -1)
                        selectedItem = data.size() - 1;
                    change = true;
                    break;
                case SWT.HOME:
                    selectedItem = 0;
                    change = true;
                    break;
                case SWT.END:
                    selectedItem = data.size() - 1;
                    change = true;
                    break;
            }
            if (change) {
                redraw();
                getAccessible().setFocus(selectedItem);
                getAccessible().selectionChanged();
            }
        }
    });
    addTraverseListener(e -> {
        switch(e.detail) {
            case SWT.TRAVERSE_TAB_NEXT:
            case SWT.TRAVERSE_TAB_PREVIOUS:
                e.doit = true;
                break;
        }
    });
    getAccessible().addAccessibleListener(new AccessibleAdapter() {

        @Override
        public void getName(AccessibleEvent e) {
            // $NON_NLS$
            MessageFormat formatter = new MessageFormat("");
            // $NON_NLS$
            formatter.applyPattern(bundle.getString("name"));
            int childID = e.childID;
            if (childID == ACC.CHILDID_SELF) {
                e.result = title;
            } else {
                Object[] item = data.get(childID);
                e.result = formatter.format(item);
            }
        }

        @Override
        public void getDescription(AccessibleEvent e) {
            int childID = e.childID;
            if (childID != ACC.CHILDID_SELF) {
                Object[] item = data.get(childID);
                String value = item[1].toString();
                // $NON_NLS$
                String colorName = bundle.getString("color" + color);
                // $NON_NLS$
                MessageFormat formatter = new MessageFormat("");
                // $NON_NLS$
                formatter.applyPattern(bundle.getString("color_value"));
                e.result = formatter.format(new String[] { colorName, value });
            }
        }
    });
    getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {

        @Override
        public void getRole(AccessibleControlEvent e) {
            if (e.childID == ACC.CHILDID_SELF) {
                e.detail = ACC.ROLE_LIST;
            } else {
                e.detail = ACC.ROLE_LISTITEM;
            }
        }

        @Override
        public void getChildCount(AccessibleControlEvent e) {
            e.detail = data.size();
        }

        @Override
        public void getChildren(AccessibleControlEvent e) {
            int count = data.size();
            Object[] children = new Object[count];
            for (int i = 0; i < count; i++) {
                children[i] = Integer.valueOf(i);
            }
            e.children = children;
        }

        @Override
        public void getChildAtPoint(AccessibleControlEvent e) {
            Point testPoint = toControl(e.x, e.y);
            int childID = ACC.CHILDID_NONE;
            if (getClientArea().contains(testPoint)) {
                childID = ACC.CHILDID_SELF;
                int count = data.size();
                for (int i = 0; i < count; i++) {
                    if (itemBounds(i).contains(testPoint)) {
                        childID = i;
                        break;
                    }
                }
            }
            e.childID = childID;
        }

        @Override
        public void getLocation(AccessibleControlEvent e) {
            Rectangle location = null;
            Point pt = null;
            int childID = e.childID;
            if (childID == ACC.CHILDID_SELF) {
                location = getClientArea();
                pt = getParent().toDisplay(location.x, location.y);
            } else {
                location = itemBounds(childID);
                pt = toDisplay(location.x, location.y);
            }
            e.x = pt.x;
            e.y = pt.y;
            e.width = location.width;
            e.height = location.height;
        }

        @Override
        public void getFocus(AccessibleControlEvent e) {
            int childID = ACC.CHILDID_NONE;
            if (isFocusControl()) {
                if (selectedItem == -1) {
                    childID = ACC.CHILDID_SELF;
                } else {
                    childID = selectedItem;
                }
            }
            e.childID = childID;
        }

        @Override
        public void getSelection(AccessibleControlEvent e) {
            e.childID = (selectedItem == -1) ? ACC.CHILDID_NONE : selectedItem;
        }

        @Override
        public void getValue(AccessibleControlEvent e) {
            int childID = e.childID;
            if (childID != ACC.CHILDID_SELF) {
                Object[] dataItem = data.get(childID);
                e.result = ((Integer) dataItem[1]).toString();
            }
        }

        @Override
        public void getState(AccessibleControlEvent e) {
            int childID = e.childID;
            e.detail = ACC.STATE_FOCUSABLE;
            if (isFocusControl())
                e.detail |= ACC.STATE_FOCUSED;
            if (childID != ACC.CHILDID_SELF) {
                e.detail |= ACC.STATE_SELECTABLE;
                if (childID == selectedItem)
                    e.detail |= ACC.STATE_SELECTED;
            }
        }
    });
}
Also used : AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) ACC(org.eclipse.swt.accessibility.ACC) Rectangle(org.eclipse.swt.graphics.Rectangle) FocusEvent(org.eclipse.swt.events.FocusEvent) Display(org.eclipse.swt.widgets.Display) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) GC(org.eclipse.swt.graphics.GC) Point(org.eclipse.swt.graphics.Point) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) ResourceBundle(java.util.ResourceBundle) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) KeyEvent(org.eclipse.swt.events.KeyEvent) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Canvas(org.eclipse.swt.widgets.Canvas) FocusAdapter(org.eclipse.swt.events.FocusAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) FocusAdapter(org.eclipse.swt.events.FocusAdapter) MessageFormat(java.text.MessageFormat) AccessibleControlEvent(org.eclipse.swt.accessibility.AccessibleControlEvent) AccessibleControlAdapter(org.eclipse.swt.accessibility.AccessibleControlAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) AccessibleAdapter(org.eclipse.swt.accessibility.AccessibleAdapter) Point(org.eclipse.swt.graphics.Point) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) KeyEvent(org.eclipse.swt.events.KeyEvent) GC(org.eclipse.swt.graphics.GC) AccessibleEvent(org.eclipse.swt.accessibility.AccessibleEvent) Display(org.eclipse.swt.widgets.Display)

Example 33 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project yamcs-studio by yamcs.

the class MultipleSelectionCombo method createPopup.

/**
 * Create shell that simulates drop-down
 */
private void createPopup() {
    popup = new Shell(getShell(), SWT.NO_TRIM | SWT.ON_TOP);
    popup.setLayout(new FillLayout());
    list = new org.eclipse.swt.widgets.List(popup, SWT.MULTI | SWT.V_SCROLL);
    list.setToolTipText(tool_tip);
    // Position popup under the text box
    Rectangle bounds = text.getBounds();
    bounds.y += bounds.height;
    // As high as necessary for items
    bounds.height = 5 + 2 * list.getBorderWidth() + list.getItemHeight() * items.size();
    // ..with limitation
    bounds.height = Math.min(bounds.height, display.getBounds().height / 2);
    // Map to screen coordinates
    bounds = display.map(text, null, bounds);
    popup.setBounds(bounds);
    popup.open();
    // Update text from changed list selection
    list.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            updateSelectionFromList();
            updateText();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            updateSelectionFromList();
            updateText();
            hidePopup();
        }
    });
    String[] stringItems = new String[items.size()];
    for (int i = 0; i < items.size(); i++) {
        stringItems[i] = stringRepresention(items.get(i));
    }
    list.setItems(stringItems);
    int[] intSelectionIndex = new int[selectionIndex.size()];
    for (int i = 0; i < intSelectionIndex.length; i++) {
        intSelectionIndex[i] = selectionIndex.get(i);
    }
    list.setSelection(intSelectionIndex);
    list.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.keyCode == SWT.CR) {
                hidePopup();
            }
        }
    });
    // Hide popup when loosing focus
    list.addFocusListener(new FocusAdapter() {

        @Override
        public void focusLost(final FocusEvent e) {
            // This field is an unsigned integer and should be AND'ed with
            // 0xFFFFFFFFL so that it can be treated as a signed long.
            lost_focus = e.time & 0xFFFFFFFFL;
            hidePopup();
        }
    });
    list.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) FillLayout(org.eclipse.swt.layout.FillLayout) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) Shell(org.eclipse.swt.widgets.Shell) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 34 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project cubrid-manager by CUBRID.

the class BrokerConfigEditComposite method registerContextMenu.

/**
	 * Register context menu
	 */
private void registerContextMenu() {
    final Table confTable = confTableViewer.getTable();
    confTable.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent event) {
            ActionManager.getInstance().changeFocusProvider(confTable);
        }
    });
    final MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    final Menu contextMenu = menuManager.createContextMenu(confTable);
    confTable.setMenu(contextMenu);
    final Menu menu = new Menu(editorPart.getSite().getShell(), SWT.POP_UP);
    final MenuItem itemEditAnnotation = new MenuItem(menu, SWT.PUSH);
    itemEditAnnotation.setText(Messages.cubridBrokerConfEditorTableMenuEditAnnotation);
    itemEditAnnotation.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("all")
        public void widgetSelected(SelectionEvent event) {
            // It seems like MenuEvent can't get the mouse click Point
            // so use the point which table MouseDown event marked
            final Point pt = clickPoint;
            int selectIndex = confTable.getSelectionIndex();
            if (selectIndex < 0) {
                return;
            }
            final TableItem item = confTable.getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 0, len = confTable.getColumnCount(); i < len; i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    if (i == 0) {
                        openErrorBox(editorPart.getSite().getShell(), Messages.cubridBrokerConfEditAnnotationDialogOpenErrorMsg);
                        return;
                    }
                    IStructuredSelection selection = (IStructuredSelection) confTableViewer.getSelection();
                    HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
                    String brokerName = confListData.get(0).get(String.valueOf(i));
                    String parentPropertyKey = valueMap.get("0");
                    String parentKey = " ";
                    if (selectIndex == 0) {
                        parentKey += brokerName;
                    } else {
                        parentKey += brokerName + "->" + parentPropertyKey;
                    }
                    String annotationKey = i + ANNOTATION;
                    CubridBrokerConfEditAnnotationDialog dialog = new CubridBrokerConfEditAnnotationDialog(editorPart.getSite().getShell(), parentKey, annotationKey, valueMap);
                    if (dialog.open() == OK_ID) {
                        editorPart.setDirty(true);
                    }
                }
            }
        }
    });
    final MenuItem itemAddBrokerConf = new MenuItem(menu, SWT.PUSH);
    itemAddBrokerConf.setText(Messages.cubridBrokerConfEditorAddBrokerConfItemLabel);
    itemAddBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_insert.png"));
    itemAddBrokerConf.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            addBrokerConfColumn();
            editorPart.setDirty(true);
        }
    });
    final MenuItem itemDeleteBrokerConf = new MenuItem(menu, SWT.PUSH);
    itemDeleteBrokerConf.setText(Messages.cubridBrokerConfEditorDeleteBrokerConfItemLabel);
    itemDeleteBrokerConf.setImage(CommonUIPlugin.getImage("icons/action/column_delete.png"));
    itemDeleteBrokerConf.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            // It seems like MenuEvent can't get the mouse click Point
            // so use the point which table MouseDown event marked
            final Point pt = clickPoint;
            final TableItem item = findSelectItem(confTable);
            if (item == null) {
                return;
            }
            int columnCount = confTable.getColumnCount();
            for (int i = 0; i < columnCount; i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    Map<String, String> valueMap = confListData.get(0);
                    String confName = valueMap.get(String.valueOf(i));
                    String msg = Messages.bind(Messages.cubridBrokerConfEditorDeleteBrokerConfConfirm, confName);
                    if (!CommonUITool.openConfirmBox(msg)) {
                        return;
                    }
                    confTable.getColumn(i).dispose();
                    for (int j = 1; j < columnCount; j++) {
                        confTable.getColumn(j).setText(Messages.cubridBrokerConfEditorBrokerTitle + (j - 1));
                    }
                    // delete data from cubridBrokerConfig, so regenerate cubridBrokerConfListData from cubridBrokerConfig
                    editorPart.getBrokerConfPersistUtil().deleteBrokerPropertyByBrokerName(brokerConfig, confName);
                    confListData.clear();
                    confListData.addAll(editorPart.parseBrokerConfigToCommonTableValue(brokerConfig));
                    confTableViewer.refresh();
                    editorPart.setDirty(true);
                    return;
                }
            }
        }
    });
    menu.addMenuListener(new MenuAdapter() {

        public void menuShown(MenuEvent event) {
            // It seems like MenuEvent can't get the mouse click Point
            // so use the point which table MouseDown event marked
            final Point pt = clickPoint;
            // It will allow that the click timing is more than 300 msec.
            if (System.currentTimeMillis() - clickPointTiming > 300) {
                itemEditAnnotation.setEnabled(false);
                itemDeleteBrokerConf.setEnabled(false);
                itemAddBrokerConf.setEnabled(false);
                return;
            }
            int selectIndex = confTable.getSelectionIndex();
            if (selectIndex < 0) {
                itemEditAnnotation.setEnabled(false);
                itemDeleteBrokerConf.setEnabled(false);
                itemAddBrokerConf.setEnabled(true);
                return;
            }
            final TableItem item = confTable.getItem(selectIndex);
            if (item == null) {
                return;
            }
            for (int i = 0, len = confTable.getColumnCount(); i < len; i++) {
                Rectangle rect = item.getBounds(i);
                if (rect.contains(pt)) {
                    boolean enableToAccess = i > 0;
                    itemEditAnnotation.setEnabled(enableToAccess);
                    itemDeleteBrokerConf.setEnabled(enableToAccess);
                }
            }
            itemAddBrokerConf.setEnabled(true);
        }
    });
    confTable.setMenu(menu);
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Table(org.eclipse.swt.widgets.Table) HashMap(java.util.HashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) Rectangle(org.eclipse.swt.graphics.Rectangle) CubridBrokerConfEditAnnotationDialog(com.cubrid.common.ui.common.dialog.CubridBrokerConfEditAnnotationDialog) MenuAdapter(org.eclipse.swt.events.MenuAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StringUtils.defaultString(org.apache.commons.lang.StringUtils.defaultString) FocusEvent(org.eclipse.swt.events.FocusEvent) MenuManager(org.eclipse.jface.action.MenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Map(java.util.Map) HashMap(java.util.HashMap) MenuEvent(org.eclipse.swt.events.MenuEvent)

Example 35 with FocusAdapter

use of org.eclipse.swt.events.FocusAdapter in project cubrid-manager by CUBRID.

the class ConnectionComposite method createDbInfoGroup.

private void createDbInfoGroup(Composite composite) {
    Group dbInfoGroup = new Group(composite, SWT.NONE);
    dbInfoGroup.setText(Messages.grpDbInfo);
    dbInfoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    dbInfoGroup.setLayout(createGridLayout(3));
    Label databaseLabel = new Label(dbInfoGroup, SWT.LEFT);
    databaseLabel.setText(Messages.lblLoginDatabaseName);
    databaseLabel.setLayoutData(createGridData(1, 1, -1, -1));
    if (isMultiBroker) {
        databaseCombo = new Combo(dbInfoGroup, SWT.LEFT | SWT.BORDER);
        databaseCombo.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    } else {
        databaseText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
        databaseText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    }
    Label userNameLabel = new Label(dbInfoGroup, SWT.LEFT);
    userNameLabel.setText(Messages.lblDbUserName);
    userNameLabel.setLayoutData(createGridData(1, 1, -1, -1));
    userNameText = new Text(dbInfoGroup, SWT.LEFT | SWT.BORDER);
    userNameText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    Label passwordLabel = new Label(dbInfoGroup, SWT.LEFT);
    passwordLabel.setText(Messages.lblDbPassword);
    passwordLabel.setLayoutData(createGridData(1, 1, -1, -1));
    passwordText = new Text(dbInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_PASSWORD_LENGTH);
    passwordText.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 2, 1, 100, -1));
    passwordText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            passwordText.selectAll();
            passwordText.setFocus();
        }
    });
    new Label(dbInfoGroup, SWT.NONE).setLayoutData(createGridData(1, 1, 0, 0));
    int span = 2;
    if (isIncludingSavePwd) {
        btnSavePassword = new Button(dbInfoGroup, SWT.CHECK);
        btnSavePassword.setLayoutData(createGridData(GridData.BEGINNING, 1, 1, -1, -1));
        btnSavePassword.setText(Messages.btnSavePassword);
        span = 1;
    }
    btnAutoCommit = new Button(dbInfoGroup, SWT.CHECK);
    btnAutoCommit.setLayoutData(createGridData(GridData.BEGINNING, span, 1, -1, -1));
    btnAutoCommit.setText(autoCommitLabel);
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) Button(org.eclipse.swt.widgets.Button) CommonUITool.createGridData(com.cubrid.common.ui.spi.util.CommonUITool.createGridData) GridData(org.eclipse.swt.layout.GridData) Messages.shardValLabel(com.cubrid.common.ui.query.Messages.shardValLabel) Messages.autoCommitLabel(com.cubrid.common.ui.query.Messages.autoCommitLabel) Label(org.eclipse.swt.widgets.Label) Messages.shardIdLabel(com.cubrid.common.ui.query.Messages.shardIdLabel) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Aggregations

FocusAdapter (org.eclipse.swt.events.FocusAdapter)68 FocusEvent (org.eclipse.swt.events.FocusEvent)64 SelectionEvent (org.eclipse.swt.events.SelectionEvent)42 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)36 Composite (org.eclipse.swt.widgets.Composite)29 GridData (org.eclipse.swt.layout.GridData)28 Text (org.eclipse.swt.widgets.Text)26 GridLayout (org.eclipse.swt.layout.GridLayout)25 Label (org.eclipse.swt.widgets.Label)20 Button (org.eclipse.swt.widgets.Button)17 Menu (org.eclipse.swt.widgets.Menu)17 Point (org.eclipse.swt.graphics.Point)16 MenuManager (org.eclipse.jface.action.MenuManager)15 MenuItem (org.eclipse.swt.widgets.MenuItem)15 ModifyEvent (org.eclipse.swt.events.ModifyEvent)14 ModifyListener (org.eclipse.swt.events.ModifyListener)14 KeyEvent (org.eclipse.swt.events.KeyEvent)12 Combo (org.eclipse.swt.widgets.Combo)12 KeyAdapter (org.eclipse.swt.events.KeyAdapter)11 Group (org.eclipse.swt.widgets.Group)11