Search in sources :

Example 11 with TraverseListener

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

the class PstmtSQLDialog method handleType.

/**
	 * Handle type
	 *
	 * @param item TableItem
	 */
protected void handleType(final TableItem item, final int editColumn) {
    String[][] typeMapping = DataType.getTypeMapping(database.getDatabaseInfo(), true, true);
    LinkedList<String> typeList = new LinkedList<String>();
    for (int i = 0; i < typeMapping.length; i++) {
        String type = typeMapping[i][0];
        if (!type.startsWith(DataType.DATATYPE_OBJECT)) {
            typeList.add(type);
        }
    }
    // add default precision
    typeList.addFirst("NUMERIC(38,12)");
    sortTypeList(typeList);
    addColumnToList(typeList);
    String[] items = typeList.toArray(new String[] {});
    final Combo typeCombo = new Combo(parameterTypeTable, SWT.BORDER | SWT.FULL_SELECTION);
    typeCombo.setItems(items);
    typeCombo.setVisibleItemCount(20);
    final String paraName = item.getText(0);
    typeCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validateType(paraName, typeCombo.getText(), editColumn);
        }
    });
    typeCombo.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            if (isChanging) {
                return;
            }
            isChanging = true;
            //				if (validateType(paraName, typeCombo.getText(), editColumn)) {
            item.setText(editColumn, typeCombo.getText());
            //				}
            typeCombo.dispose();
            isChanging = false;
            validate();
        }
    });
    //add listener for key pressed
    typeCombo.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                //					if (validateType(paraName, typeCombo.getText(), editColumn)) {
                item.setText(editColumn, typeCombo.getText());
                //					}
                typeCombo.dispose();
                isChanging = false;
                validate();
                event.doit = true;
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                typeCombo.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(typeCombo, item, editColumn);
    typeCombo.setText(item.getText(editColumn));
    typeCombo.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) LinkedList(java.util.LinkedList) Point(org.eclipse.swt.graphics.Point) ModifyEvent(org.eclipse.swt.events.ModifyEvent)

Example 12 with TraverseListener

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

the class PstmtDataDialog method handleType.

protected void handleType(final TableItem item) {
    String[][] typeMapping = DataType.getTypeMapping(database.getDatabaseInfo(), true, true);
    List<String> typeList = new ArrayList<String>();
    for (int i = 0; i < typeMapping.length; i++) {
        String type = typeMapping[i][0];
        if (!type.startsWith(DataType.DATATYPE_OBJECT)) {
            typeList.add(type);
        }
    }
    String[] items = typeList.toArray(new String[] {});
    final int editColumn = 1;
    final Combo typeCombo = new Combo(parameterTable, SWT.BORDER | SWT.FULL_SELECTION);
    typeCombo.setItems(items);
    typeCombo.setVisibleItemCount(20);
    final String paraName = item.getText(0);
    typeCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validateType(paraName, typeCombo.getText());
        }
    });
    typeCombo.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            if (isChanging) {
                return;
            }
            isChanging = true;
            if (validateType(paraName, typeCombo.getText())) {
                item.setText(editColumn, typeCombo.getText());
            }
            typeCombo.dispose();
            isChanging = false;
            validate();
        }
    });
    //add listener for key pressed
    typeCombo.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                if (validateType(paraName, typeCombo.getText())) {
                    item.setText(editColumn, typeCombo.getText());
                }
                typeCombo.dispose();
                isChanging = false;
                validate();
                event.doit = true;
                handleValue(item);
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                typeCombo.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(typeCombo, item, editColumn);
    typeCombo.setText(item.getText(editColumn));
    typeCombo.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) ArrayList(java.util.ArrayList) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) Point(org.eclipse.swt.graphics.Point) ModifyEvent(org.eclipse.swt.events.ModifyEvent)

Example 13 with TraverseListener

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

the class InsertTableDataDialog method handleValue.

private void handleValue(final TableItem item) {
    // Clean up any previous editor control
    Control oldEditor = tableEditor.getEditor();
    if (oldEditor != null) {
        oldEditor.dispose();
    }
    final Text newEditor = new Text(attrTable, SWT.MULTI | SWT.WRAP);
    newEditor.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validate(newEditor.getText(), item);
        }
    });
    newEditor.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            if (isChanging) {
                return;
            }
            isChanging = true;
            if (validate(newEditor.getText(), item)) {
                item.setText(EDIT_COLUMN, newEditor.getText());
            }
            newEditor.dispose();
            validate();
            isChanging = false;
        }
    });
    //add listener for key pressed
    newEditor.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                if (validate(newEditor.getText(), item)) {
                    item.setText(EDIT_COLUMN, newEditor.getText());
                }
                newEditor.dispose();
                validate();
                isChanging = false;
                event.doit = true;
                int selItem = (attrTable.getSelectionIndex() + 1) % attrTable.getItemCount();
                if (selItem == 0) {
                    getButton(BTN_INSERT_ID).setFocus();
                } else {
                    attrTable.setSelection(selItem);
                    handleValue(attrTable.getItem(selItem));
                }
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                newEditor.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(newEditor, item, EDIT_COLUMN);
    newEditor.setText(item.getText(EDIT_COLUMN));
    newEditor.selectAll();
    newEditor.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) Control(org.eclipse.swt.widgets.Control) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 14 with TraverseListener

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

the class ImportDataFromFileDialog method handleValue.

/**
	 *
	 * Handle value modify event
	 *
	 * @param item TableItem
	 */
protected void handleValue(final TableItem item) {
    String[] items = fileColumnList.toArray(new String[] {});
    final int editColumn = 2;
    final Combo fileColumnCombo = new Combo(parameterTable, SWT.BORDER | SWT.FULL_SELECTION);
    fileColumnCombo.setItems(items);
    fileColumnCombo.setVisibleItemCount(20);
    final String paraName = item.getText(0);
    fileColumnCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            validateFileColumn(paraName, fileColumnCombo.getText());
        }
    });
    fileColumnCombo.addFocusListener(new FocusAdapter() {

        public void focusLost(FocusEvent event) {
            if (isChanging) {
                return;
            }
            isChanging = true;
            if (validateFileColumn(paraName, fileColumnCombo.getText())) {
                item.setText(editColumn, fileColumnCombo.getText());
            }
            fileColumnCombo.dispose();
            isChanging = false;
            validate();
        }
    });
    //add listener for key pressed
    fileColumnCombo.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent event) {
            if (event.detail == SWT.TRAVERSE_RETURN) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                if (validateFileColumn(paraName, fileColumnCombo.getText())) {
                    item.setText(editColumn, fileColumnCombo.getText());
                }
                fileColumnCombo.dispose();
                isChanging = false;
                validate();
                event.doit = true;
                handleValue(item);
            } else if (event.detail == SWT.TRAVERSE_ESCAPE) {
                if (isChanging) {
                    return;
                }
                isChanging = true;
                fileColumnCombo.dispose();
                event.doit = false;
                isChanging = false;
            }
        }
    });
    tableEditor.setEditor(fileColumnCombo, item, editColumn);
    fileColumnCombo.setText(item.getText(editColumn));
    fileColumnCombo.setFocus();
}
Also used : FocusAdapter(org.eclipse.swt.events.FocusAdapter) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) TraverseListener(org.eclipse.swt.events.TraverseListener) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent)

Example 15 with TraverseListener

use of org.eclipse.swt.events.TraverseListener in project cogtool by cogtool.

the class WebCrawlImportDialog method buildSecondGroup.

public void buildSecondGroup() {
    typeHTMLGroup2 = new Group(useSelectionGroup, SWT.SHADOW_NONE);
    typeHTMLGroup2.setText("Starting URL #2");
    typeHTMLGroup2.setLayout(new FormLayout());
    urlText2 = new TextWithEnableFix(typeHTMLGroup2, SWT.BORDER | SWT.SINGLE);
    urlText2.setText("http://");
    urlText2.setVisible(false);
    urlText2.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
                e.detail = SWT.TRAVERSE_NONE;
                questionMarkButtonDomain.forceFocus();
            }
        }
    });
    urlPath4 = new Label(typeHTMLGroup2, SWT.NONE);
    urlPath5 = new Label(typeHTMLGroup2, SWT.NONE);
    urlPath6 = new Label(typeHTMLGroup2, SWT.NONE);
    urlPath6b = new Label(typeHTMLGroup2, SWT.NONE);
    urlPath6b.setText("path");
    urlPath6b.setFont(URL_PATH_FONT);
    urlPath6b.setVisible(false);
    useHTML4 = new Button(typeHTMLGroup2, SWT.RADIO);
    useHTML4.addSelectionListener(domainListener);
    useHTML4.setSelection(true);
    useHTML5 = new Button(typeHTMLGroup2, SWT.RADIO);
    useHTML5.addSelectionListener(domainListener);
    useHTML6 = new Button(typeHTMLGroup2, SWT.RADIO);
    useHTML6.addSelectionListener(domainListener);
    plusButton2 = makeToolBarButton(typeHTMLGroup2, addGroupListener, questionImages.PLUS_IMAGE);
    minusButton2 = makeToolBarButton(typeHTMLGroup2, minusGroupListener2, questionImages.MINUS_IMAGE);
    questionMarkButtonDepth2 = makeToolBarButton(typeHTMLGroup2, depthListener, questionImages.QUESTION_SHADOW);
    maximumDepthToCrawlLabel2 = new Label(typeHTMLGroup2, SWT.NONE);
    maximumDepthToCrawlLabel2.setText("Maximum Depth To Crawl: ");
    maxDepthCombo2 = new ComboWithEnableFix(typeHTMLGroup2, SWT.DROP_DOWN | SWT.READ_ONLY);
    maxDepthCombo2.add("Unlimited");
    for (int i = 0; i < 100; i++) {
        maxDepthCombo2.add("" + i);
    }
    maxDepthCombo2.select(2);
    maxDepthCombo2.setVisibleItemCount(21);
    maxDepthCombo2.addSelectionListener(comboListener);
    restrictDomainLabel2 = new Label(typeHTMLGroup2, SWT.NONE);
    restrictDomainLabel2.setText("Restrict Domain: ");
    questionMarkButtonDomain2 = makeToolBarButton(typeHTMLGroup2, domainHelpListener, questionImages.QUESTION_SHADOW);
    questionMarkButtonDomain2.setVisible(false);
    questionMarkButtonDomain2.addTraverseListener(new TraverseListener() {

        public void keyTraversed(TraverseEvent e) {
            if (e.detail == SWT.TRAVERSE_TAB_NEXT) {
                if (numOfGroups > 2) {
                    e.detail = SWT.TRAVERSE_NONE;
                    urlText3.forceFocus();
                }
            }
        }
    });
    urlText2.addFocusListener(new TextFocusListener(urlText2, urlPath5, urlPath6, useHTML4, useHTML5, useHTML6, 2));
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) Group(org.eclipse.swt.widgets.Group) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) Button(org.eclipse.swt.widgets.Button) TextWithEnableFix(edu.cmu.cs.hcii.cogtool.util.TextWithEnableFix) Label(org.eclipse.swt.widgets.Label) ComboWithEnableFix(edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix) Point(org.eclipse.swt.graphics.Point)

Aggregations

TraverseEvent (org.eclipse.swt.events.TraverseEvent)26 TraverseListener (org.eclipse.swt.events.TraverseListener)26 FocusAdapter (org.eclipse.swt.events.FocusAdapter)9 FocusEvent (org.eclipse.swt.events.FocusEvent)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Text (org.eclipse.swt.widgets.Text)7 StyledText (org.eclipse.swt.custom.StyledText)6 ModifyEvent (org.eclipse.swt.events.ModifyEvent)6 ModifyListener (org.eclipse.swt.events.ModifyListener)6 MouseEvent (org.eclipse.swt.events.MouseEvent)6 Point (org.eclipse.swt.graphics.Point)6 Button (org.eclipse.swt.widgets.Button)6 KeyEvent (org.eclipse.swt.events.KeyEvent)5 MouseAdapter (org.eclipse.swt.events.MouseAdapter)5 Composite (org.eclipse.swt.widgets.Composite)5 GridData (org.eclipse.swt.layout.GridData)4 Label (org.eclipse.swt.widgets.Label)4 ComboWithEnableFix (edu.cmu.cs.hcii.cogtool.util.ComboWithEnableFix)3 TextWithEnableFix (edu.cmu.cs.hcii.cogtool.util.TextWithEnableFix)3