use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.
the class SetPstmtValueDialog method createFileComposite.
/**
*
* Create file group
*
* @param parentComp Composite
*/
private void createFileComposite(Composite parentComp) {
Group group = new Group(parentComp, SWT.NONE);
{
group.setText(Messages.btnSelectFile);
group.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
group.setLayout(layout);
}
selectFileBtn = new Button(group, SWT.RADIO | SWT.LEFT);
selectFileBtn.setText(Messages.btnSelectFile);
selectFileBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
selectFileBtn.setSelection(false);
selectFileBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (selectFileBtn.getSelection()) {
browseBtn.setEnabled(true);
fileCharsetCombo.setEnabled(true);
inputTextBtn.setSelection(false);
paraValueText.setEnabled(false);
paraValueText.setText("");
setNullBtn.setSelection(false);
setNullBtn.setEnabled(false);
}
validate();
}
});
Label fileNameLbl = new Label(group, SWT.NONE);
fileNameLbl.setText(Messages.importFileNameLBL);
filePathText = new Text(group, SWT.BORDER);
filePathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
filePathText.setEnabled(false);
browseBtn = new Button(group, SWT.NONE);
browseBtn.setText(Messages.btnBrowse);
browseBtn.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
browseBtn.setEnabled(false);
browseBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FileDialog dlg = new FileDialog(getShell(), SWT.OPEN);
dlg.setFilterPath(filePathText.getText());
String file = dlg.open();
if (file != null) {
filePathText.setText(file);
}
validate();
}
});
final Label fileCharsetLabel = new Label(group, SWT.NONE);
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(group, SWT.NONE);
{
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
fileCharsetCombo.setLayoutData(gridData);
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
String charset = StringUtil.getDefaultCharset();
fileCharsetCombo.setText(charset);
fileCharsetCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
validate();
}
});
}
}
use of org.eclipse.swt.events.ModifyListener 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.ModifyListener in project cubrid-manager by CUBRID.
the class RenameColumnDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
Label label1 = new Label(composite, SWT.LEFT);
label1.setText(Messages.bind(Messages.renameNewTableName, Messages.metaAttribute));
label1.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
newText = new Text(composite, SWT.BORDER);
newText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
newText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
newText.setText(column);
newText.selectAll();
newText.setFocus();
newText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setErrorMessage(null);
okButton.setEnabled(false);
String newTable = newText.getText().trim();
if (!ValidateUtil.isValidIdentifier(newTable)) {
setErrorMessage(Messages.bind(Messages.renameInvalidTableNameMSG, Messages.metaAttribute, newTable));
return;
} else if (newTable.equalsIgnoreCase(column)) {
return;
}
okButton.setEnabled(true);
}
});
setTitle(Messages.bind(Messages.renameMSGTitle, Messages.metaAttribute));
setMessage(Messages.bind(Messages.renameDialogMSG, Messages.metaAttribute));
return parent;
}
use of org.eclipse.swt.events.ModifyListener in project cubrid-manager by CUBRID.
the class RenameTableDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
Label label1 = new Label(composite, SWT.LEFT);
label1.setText(Messages.bind(Messages.renameNewTableName, tableOrView));
GridData data = new GridData();
data.widthHint = 120;
data.horizontalSpan = 1;
data.verticalSpan = 1;
label1.setLayoutData(data);
newTableText = new Text(composite, SWT.BORDER);
data = new GridData();
data.horizontalSpan = 2;
data.verticalSpan = 1;
data.grabExcessHorizontalSpace = true;
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
newTableText.setLayoutData(data);
newTableText.setText(oldName);
newTableText.selectAll();
newTableText.setFocus();
newTableText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setErrorMessage(null);
getButton(IDialogConstants.OK_ID).setEnabled(false);
String newTable = newTableText.getText();
if (isPhysical && !ValidateUtil.isValidIdentifier(newTable)) {
setErrorMessage(Messages.bind(Messages.renameInvalidTableNameMSG, tableOrView, newTable));
return;
}
if (-1 != existNameList.indexOf(newTable.toLowerCase(Locale.getDefault()))) {
if (isTable) {
setErrorMessage(Messages.bind(Messages.errExistTable, newTable));
} else {
setErrorMessage(Messages.bind(Messages.errExistView, newTable));
}
return;
}
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
});
newTableText.addListener(SWT.KeyDown, new Listener() {
public void handleEvent(Event e) {
if (e.type == SWT.KeyDown && e.character == SWT.CR) {
/*For bug TOOLS-2698*/
String newSchemaName = newTableText.getText().trim();
if (StringUtil.isEqualNotIgnoreNull(oldName, newSchemaName)) {
buttonPressed(IDialogConstants.CANCEL_ID);
} else {
buttonPressed(IDialogConstants.OK_ID);
}
}
}
});
setTitle(Messages.bind(Messages.renameMSGTitle, tableOrView));
setMessage(Messages.bind(Messages.renameDialogMSG, tableOrView));
return parent;
}
use of org.eclipse.swt.events.ModifyListener 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();
}
Aggregations