use of org.eclipse.swt.events.TraverseEvent 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();
}
use of org.eclipse.swt.events.TraverseEvent 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();
}
use of org.eclipse.swt.events.TraverseEvent 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();
}
use of org.eclipse.swt.events.TraverseEvent 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();
}
use of org.eclipse.swt.events.TraverseEvent 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));
}
Aggregations