use of org.eclipse.swt.events.ModifyEvent in project cubrid-manager by CUBRID.
the class CreateViewDialog method init.
/**
* initializes some values
*/
private void init() {
String ownerOld = null;
fillOwnerCombo();
if (isNewTableFlag) {
tableText.setText("");
tableText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
valid();
}
});
ownerOld = database.getUserName();
setTitle(Messages.newViewMsgTitle);
setMessage(Messages.newViewMsg);
getShell().setText(Messages.newViewShellTitle);
} else {
if (classInfo == null) {
return;
}
tableText.setEditable(false);
tableText.setText(classInfo.getClassName());
if (isCommentSupport) {
if (!classInfo.isSystemClass()) {
String comment = getViewComment();
if (comment != null) {
viewDescriptionText.setText(comment);
}
} else {
viewDescriptionText.setEditable(false);
}
}
ownerOld = classInfo.getOwnerName();
String[] strs = new String[] { classInfo.getClassName(), isPropertyQuery ? Messages.msgPropertyInfo : Messages.msgEditInfo };
setTitle(Messages.bind(Messages.editViewMsgTitle, strs));
setMessage(Messages.editViewMsg);
strs = new String[] { classInfo.getClassName(), isPropertyQuery ? Messages.msgPropertyInfo : Messages.msgEditInfo };
String title = Messages.bind(Messages.editViewShellTitle, strs);
getShell().setText(title);
for (String sql : vclassList) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", sql);
queryListData.add(map);
}
if (!vclassList.isEmpty()) {
querydescText.setText(formatSql(vclassList.get(0)));
}
// "Name", "Data type", "Default type", "Default value"
for (DBAttribute attr : attrList) {
Map<String, String> map = new HashMap<String, String>();
map.put("0", attr.getName());
String type = attr.getType();
if (type.startsWith(DATATYPE_VARNCHAR)) {
type = type.replaceAll(DATATYPE_VARNCHAR, DataType.DATATYPE_NCHAR_VARYING);
}
if (type.startsWith(DATATYPE_VARBIT)) {
type = type.replaceAll(DATATYPE_VARBIT, DataType.DATATYPE_BIT_VARYING);
}
if (DataType.DATATYPE_OBJECT.equalsIgnoreCase(type)) {
if (attr.getDomainClassName() == null || "".equals(attr.getDomainClassName())) {
type = DataType.DATATYPE_OBJECT;
} else {
type = attr.getDomainClassName();
}
}
map.put("1", type);
map.put("2", defaultType[0]);
map.put("3", defaultType[0]);
if (isCommentSupport) {
map.put("4", attr.getDescription());
}
String dfltType = null;
String value = null;
if (attr.getDefault() != null && !attr.getDefault().equals("")) {
if (attr.isShared()) {
dfltType = defaultType[1];
} else {
dfltType = defaultType[2];
}
value = attr.getDefault();
}
if (value == null) {
value = "";
}
if (type != null && (type.startsWith(DataType.DATATYPE_CHAR) || type.startsWith(DataType.DATATYPE_STRING) || type.startsWith(DataType.DATATYPE_VARCHAR)) && (value.startsWith("'") && value.endsWith("'") && value.length() > 1)) {
value = value.substring(1, value.length() - 1);
}
map.put("2", dfltType);
map.put("3", value);
viewColListData.add(map);
}
viewColTableViewer.refresh();
for (int i = 0; i < viewColTableViewer.getTable().getColumnCount(); i++) {
viewColTableViewer.getTable().getColumn(i).pack();
}
queryTableViewer.getTable().select(0);
}
for (int i = 0; i < ownerCombo.getItemCount(); i++) {
String ownerNew = ownerCombo.getItem(i);
boolean isSame = StringUtil.isEqualIgnoreCase(ownerNew, ownerOld);
if (isSame) {
ownerCombo.select(i);
break;
}
}
queryTableViewer.refresh();
}
use of org.eclipse.swt.events.ModifyEvent in project cubrid-manager by CUBRID.
the class CloneTableDialog method createDialogArea.
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.lblTargetName);
label1.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
targetNameText = new Text(composite, SWT.BORDER);
targetNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
if (originTableName != null) {
targetNameText.setText(originTableName);
}
targetNameText.setFocus();
targetNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
setErrorMessage(null);
getButton(IDialogConstants.OK_ID).setEnabled(false);
String newTable = targetNameText.getText();
if (!ValidateUtil.isValidIdentifier(newTable)) {
setErrorMessage(Messages.bind(Messages.errInvalidName, targetNameText.getText()));
return;
}
if (existNameList.indexOf(newTable.toLowerCase(Locale.getDefault())) != -1) {
setErrorMessage(Messages.bind(Messages.errExistTable, newTable));
return;
}
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
});
setTitle(Messages.titleCloneTable);
setMessage(Messages.msgCloneTable);
return parent;
}
use of org.eclipse.swt.events.ModifyEvent 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.ModifyEvent in project cubrid-manager by CUBRID.
the class TableEditorPart method createGeneralTabItem.
/**
* Create general tab item
*
* @param tabFolder the object of TabFolder
*/
private void createGeneralTabItem(final TabFolder tabFolder) {
final TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE);
generalTabItem.setText(Messages.infoGeneralTab);
final Composite compositeGenaral = new Composite(tabFolder, SWT.NONE);
GridLayout gridLayout = new GridLayout();
compositeGenaral.setLayout(gridLayout);
generalTabItem.setControl(compositeGenaral);
final Group group = new Group(compositeGenaral, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
gridLayout = new GridLayout();
gridLayout.numColumns = 2;
group.setLayout(gridLayout);
group.setText(Messages.lblTableInfo);
final Label tableNameLabel = new Label(group, SWT.NONE);
tableNameLabel.setData(Messages.dataNewKey, null);
tableNameLabel.setText(Messages.lblTableName);
tableNameComp = new Composite(group, SWT.NONE);
{
GridLayout gl = new GridLayout();
gl.numColumns = 5;
gl.marginWidth = 0;
tableNameComp.setLayout(gl);
tableNameComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
tableNameText = new Text(tableNameComp, SWT.BORDER);
tableNameText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
{
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd.widthHint = 200;
tableNameText.setLayoutData(gd);
}
tableNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
if (tableNameText.getText().length() == 0) {
CommonUITool.hideErrorBaloon(errorBaloon);
} else if (verifyTableName()) {
String tableName = tableNameText.getText();
newSchemaInfo.setClassname(tableName);
}
}
});
tableNameText.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
CommonUITool.hideErrorBaloon(errorBaloon);
}
});
final Label ownerLabel = new Label(tableNameComp, SWT.NONE);
ownerLabel.setText(Messages.lblOwner);
ownerCombo = new Combo(tableNameComp, SWT.READ_ONLY);
{
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd.widthHint = 100;
ownerCombo.setLayoutData(gd);
}
ownerCombo.setVisibleItemCount(10);
fillOwnerCombo();
if (supportCharset) {
final Label collationLabel = new Label(tableNameComp, SWT.NONE);
collationLabel.setText(Messages.lblCollation);
collationCombo = new Combo(tableNameComp, SWT.READ_ONLY);
{
GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gd.widthHint = 100;
collationCombo.setLayoutData(gd);
}
collationCombo.setVisibleItemCount(10);
fillCollationCombo();
String collation = collationCombo.getText();
newSchemaInfo.setCollation(collation);
collationCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
String collation = collationCombo.getText();
newSchemaInfo.setCollation(collation);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
if (!isNewTableFlag && newSchemaInfo.getCollation() != null) {
collationCombo.setText(newSchemaInfo.getCollation());
}
} else {
new Label(tableNameComp, SWT.NONE);
new Label(tableNameComp, SWT.NONE);
}
}
final Label tableDescLabel = new Label(group, SWT.NONE);
tableDescLabel.setText(Messages.lblTableDesc);
tableDescText = new Text(group, SWT.BORDER);
tableDescText.setTextLimit(512);
tableDescText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
if (newSchemaInfo != null && newSchemaInfo.getDescription() != null) {
tableDescText.setText(newSchemaInfo.getDescription());
}
tableDescText.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
if (!isSupportTableComment) {
CommonUITool.showErrorBaloon(group, tableDescText, errorBaloon, "", Messages.errNotSupportTableCommentNotice);
tableDescText.setFocus();
}
}
public void focusLost(FocusEvent e) {
CommonUITool.hideErrorBaloon(errorBaloon);
}
});
tableDescText.setEditable(isSupportTableComment);
if (database == null) {
return;
}
if (CompatibleUtil.isSupportReuseOID(database.getDatabaseInfo())) {
reuseOIDBtn = new Button(group, SWT.CHECK);
reuseOIDBtn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
reuseOIDBtn.setText(Messages.btnReuseOid);
if (!isNewTableFlag) {
reuseOIDBtn.setEnabled(false);
}
}
final Label columnsLabel = new Label(compositeGenaral, SWT.NONE);
columnsLabel.setText(Messages.lblColumn);
// create attribute table
columnTableView = new TableViewer(compositeGenaral, SWT.FULL_SELECTION | SWT.BORDER);
columnTableView.setUseHashlookup(true);
columnTableView.setColumnProperties(columnProperites);
columnsTable = columnTableView.getTable();
//columnsTable.pack();
final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
gdColumnsTable.heightHint = 189;
columnsTable.setLayoutData(gdColumnsTable);
columnsTable.setLinesVisible(true);
columnsTable.setHeaderVisible(true);
// The empty column
final TableColumn emptyColumn = new TableColumn(columnsTable, SWT.NONE);
emptyColumn.setWidth(0);
// The flag column
final TableColumn flagColumn = new TableColumn(columnsTable, SWT.RIGHT_TO_LEFT);
flagColumn.setWidth(28);
// NAME
final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
nameColumn.setWidth(140);
nameColumn.setText(Messages.tblColumnName);
// DATATYPE
final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
dataTypeColumn.setWidth(120);
dataTypeColumn.setText(Messages.tblColumnDataType);
// DEFAULT
final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
defaultColumn.setWidth(98);
defaultColumn.setText(Messages.tblColumnDefault);
defaultColumn.setToolTipText(Messages.tblColumnDefaultHint);
// AUTO INCREMENT
final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
autoIncrTableColumn.setAlignment(SWT.LEFT);
autoIncrTableColumn.setWidth(100);
autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
autoIncrTableColumn.setToolTipText(Messages.tblColumnAutoIncrHint);
// NOT NULL
final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
notNullColumn.setWidth(65);
notNullColumn.setText(Messages.tblColumnNotNull);
notNullColumn.setAlignment(SWT.LEFT);
notNullColumn.setToolTipText(Messages.tblColumnNotNullHint);
// PK
final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
pkColumn.setAlignment(SWT.CENTER);
pkColumn.setWidth(90);
pkColumn.setText(Messages.tblColumnPK);
// UK
final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
uniqueColumn.setWidth(55);
uniqueColumn.setText(Messages.tblColumnUnique);
uniqueColumn.setAlignment(SWT.LEFT);
uniqueColumn.setToolTipText(Messages.tblColumnUniqueHint);
// SHARED
sharedColumn = new TableColumn(columnsTable, SWT.NONE);
sharedColumn.setWidth(65);
sharedColumn.setText(Messages.tblColumnShared);
sharedColumn.setAlignment(SWT.LEFT);
sharedColumn.setToolTipText(Messages.tblColumnSharedHint);
if (supportCharset) {
final TableColumn collationColumn = new TableColumn(columnsTable, SWT.NONE);
collationColumn.setWidth(120);
collationColumn.setText(Messages.tblColumnColumnCollation);
collationColumn.setAlignment(SWT.LEFT);
}
final TableColumn descColumn = new TableColumn(columnsTable, SWT.NONE);
descColumn.setWidth(180);
descColumn.setText(Messages.tblColumnColumnDesc);
descColumn.setAlignment(SWT.LEFT);
boolean canEdit = true;
if (!editor.isNewTableFlag() && !editor.isSupportChange()) {
canEdit = false;
}
attrContentProvider = new AttributeContentProvider();
attrLabelProvider = new AttributeLabelProvider(database.getDatabaseInfo(), newSchemaInfo, canEdit, editorAdaptor);
columnTableView.setContentProvider(attrContentProvider);
columnTableView.setLabelProvider(attrLabelProvider);
CellEditor[] cellEditor = new CellEditor[columnProperites.length];
{
int index = 0;
// Empty
cellEditor[index++] = null;
// Flag
cellEditor[index++] = null;
// NAME
cellEditor[index++] = new TextCellEditor(columnsTable);
// DATATYPE
cellEditor[index++] = new DataTypeCellEditor((Composite) columnsTable, listDataTypes(), editorAdaptor);
// DEFAULT
cellEditor[index++] = new TextCellEditor(columnsTable);
// AUTO INCREMENT
cellEditor[index++] = new AutoIncrementCellEditor(columnsTable, editorAdaptor);
// NOT NULL
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// PK
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// UK
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// SHARD
cellEditor[index++] = new CheckboxCellEditor(columnsTable);
// COLLATION
if (supportCharset) {
cellEditor[index++] = new ComboBoxCellEditor(columnsTable, getCollationArray(), SWT.READ_ONLY);
}
// MEMO
cellEditor[index++] = new TextCellEditor(columnsTable);
}
columnTableView.setCellEditors(cellEditor);
columnTableView.setCellModifier(new AttributeCellModifier(editorAdaptor));
loadColumnData();
CommonUITool.hackForYosemite(columnsTable);
// Create button
final Composite btnRowComposite = new Composite(compositeGenaral, SWT.NONE);
btnRowComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
{
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginWidth = 5;
btnRowComposite.setLayout(layout);
}
final Composite optComposite = new Composite(btnRowComposite, SWT.NONE);
optComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
{
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginWidth = 0;
optComposite.setLayout(layout);
}
final Composite btnComposite = new Composite(btnRowComposite, SWT.NONE);
btnComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
{
GridLayout layout = new GridLayout();
layout.marginRight = 0;
layout.numColumns = 6;
layout.marginWidth = 0;
btnComposite.setLayout(layout);
}
final Button setPkButton = new Button(btnComposite, SWT.NONE);
setPkButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
setPkButton.setText(Messages.btnPK);
setPkButton.addSelectionListener(new PkBtnListenerOnGeneTab(isNewTableFlag));
final GridData gdUpDown = new GridData(60, SWT.DEFAULT);
upColumnBtn = new Button(btnComposite, SWT.NONE);
upColumnBtn.setLayoutData(gdUpDown);
upColumnBtn.setEnabled(false);
upColumnBtn.setText(Messages.btnUp);
upColumnBtn.addSelectionListener(new UpBtnListenerOnGeneTab());
downColumnBtn = new Button(btnComposite, SWT.DOWN);
downColumnBtn.setLayoutData(gdUpDown);
downColumnBtn.setEnabled(false);
downColumnBtn.setText(Messages.btnDown);
downColumnBtn.addSelectionListener(new DownBtnListenerOnGeneTab());
final Button addButton = new Button(btnComposite, SWT.NONE);
final GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gdAddButton.horizontalIndent = 10;
addButton.setLayoutData(gdAddButton);
addButton.setText(Messages.btnAddColumn);
addButton.addSelectionListener(new AddBtnListenerOnGeneTab());
deleteColumnBtn = new Button(btnComposite, SWT.NONE);
final GridData gdDeleteButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
gdDeleteButton.horizontalIndent = 10;
deleteColumnBtn.setLayoutData(gdDeleteButton);
deleteColumnBtn.setEnabled(false);
deleteColumnBtn.setText(Messages.btnDelColumn);
deleteColumnBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
deleteColumn();
}
});
columnsTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
handleSelectionChangeInColumnTable();
}
});
buildColumnTableMenu();
}
use of org.eclipse.swt.events.ModifyEvent in project cubrid-manager by CUBRID.
the class ExportQueryResultDialog method createComposite.
/**
* Create the composite
*
* @param parent Composite
*/
private void createComposite(Composite parent) {
final boolean isOneResult = queryExecuterList.size() == 1;
String tableName = null;
try {
tableName = UIQueryUtil.getTableNameFromQuery(queryExecuterList.get(0).getConnection().checkAndConnectQuietly(), queryExecuterList.get(0).getOrignQuery());
} finally {
if (queryExecuterList.get(0).getConnection().isAutoClosable()) {
queryExecuterList.get(0).getConnection().close();
}
}
boolean isTable = isOneResult && !StringUtil.isEmpty(tableName);
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout());
composite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
// where to export group
Group whereOptionGroup = new Group(composite, SWT.None);
whereOptionGroup.setText(Messages.grpWhereExport);
whereOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
whereOptionGroup.setLayout(new GridLayout(2, false));
Label fileTypeLabel = new Label(whereOptionGroup, SWT.None);
fileTypeLabel.setText(Messages.lblFileType);
fileTypeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
Composite fileTypeComposite = new Composite(whereOptionGroup, SWT.None);
fileTypeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
int layoutCount = 0;
if (isTable) {
sqlButton = new Button(fileTypeComposite, SWT.RADIO);
sqlButton.setText("SQL");
sqlButton.setLayoutData(CommonUITool.createGridData(1, 1, 50, -1));
sqlButton.setSelection(true);
sqlButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(false);
setNullWidgetStatus(false);
setDelimiterWidgetStatus(false);
fileCharsetCombo.setText(DEFAULT_FILE_CHARSET);
changeFileSuffix();
verify();
}
});
layoutCount++;
}
csvButton = new Button(fileTypeComposite, SWT.RADIO);
csvButton.setText("CSV");
csvButton.setSelection(isTable ? false : true);
csvButton.setLayoutData(CommonUITool.createGridData(1, 1, 50, -1));
csvButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(false);
fileCharsetCombo.setText(DEFAULT_FILE_CHARSET);
changeFileSuffix();
verify();
}
});
layoutCount++;
xlsButton = new Button(fileTypeComposite, SWT.RADIO);
xlsButton.setText("XLS");
xlsButton.setLayoutData(CommonUITool.createGridData(1, 1, 50, -1));
xlsButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(false);
String charset = StringUtil.getDefaultCharset();
if (charset != null) {
fileCharsetCombo.setText(charset);
}
changeFileSuffix();
verify();
}
});
layoutCount++;
xlsxButton = new Button(fileTypeComposite, SWT.RADIO);
xlsxButton.setText("XLSX");
xlsxButton.setLayoutData(CommonUITool.createGridData(1, 1, 57, -1));
xlsxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(false);
fileCharsetCombo.setText(DEFAULT_FILE_CHARSET);
changeFileSuffix();
verify();
}
});
layoutCount++;
txtButton = new Button(fileTypeComposite, SWT.RADIO);
txtButton.setText("TXT");
txtButton.setLayoutData(CommonUITool.createGridData(1, 1, 50, -1));
txtButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(true);
fileCharsetCombo.setText(DEFAULT_FILE_CHARSET);
changeFileSuffix();
verify();
}
});
layoutCount++;
fileTypeComposite.setLayout(new GridLayout(layoutCount, false));
Label pathLabel = new Label(whereOptionGroup, SWT.None);
pathLabel.setText(Messages.lblFilePath);
pathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
Composite fileComposite = new Composite(whereOptionGroup, SWT.None);
fileComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
fileComposite.setLayout(new GridLayout(2, false));
filePathText = new Text(fileComposite, SWT.BORDER);
filePathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
Button browseButton = new Button(fileComposite, SWT.None);
browseButton.setText(Messages.btnBrowse);
browseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
browseButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
File file = FileDialogUtils.getDataExportedFile(getShell(), new String[] { "*.*" }, new String[] { "*.*" }, null);
if (file == null) {
return;
}
filePathText.setText(file.getAbsolutePath() + getFileExtName(getFileType()));
verify();
}
});
Group parsingGroup = new Group(composite, SWT.None);
parsingGroup.setText(Messages.grpParsingOption);
parsingGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
parsingGroup.setLayout(new GridLayout(4, false));
Label threadCountLabel = new Label(parsingGroup, SWT.None);
threadCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, 100, -1));
threadCountLabel.setText(Messages.lblThreadCount);
threadCountSpinner = new Spinner(parsingGroup, SWT.BORDER | SWT.LEFT);
threadCountSpinner.setValues(queryExecuterList.size(), 1, queryExecuterList.size(), 0, 1, 1);
threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, 100, -1));
exportFromCacheBtn = new Button(parsingGroup, SWT.CHECK);
{
exportFromCacheBtn.setText(Messages.lblExportFromCache);
exportFromCacheBtn.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 2, 1, -1, -1));
exportFromCacheBtn.setSelection(false);
exportFromCacheBtn.setToolTipText(Messages.tipExportFromCache);
}
Label dbCharsetLabel = new Label(parsingGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, 110, -1));
dbCharsetLabel.setText(Messages.lblJDBCCharset);
dbCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 100, 21));
String dbCharset = database.getDatabaseInfo().getCharSet();
dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
if (dbCharset != null && dbCharset.length() > 0) {
dbCharsetCombo.setText(dbCharset);
}
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(parsingGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 100, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.setText(DEFAULT_FILE_CHARSET);
fileCharsetCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
verify();
}
});
Group dataOptionGroup = new Group(composite, SWT.None);
dataOptionGroup.setText(Messages.grpDataOptions);
dataOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
dataOptionGroup.setLayout(new GridLayout(2, false));
useFirstAsColumnBtn = new Button(dataOptionGroup, SWT.CHECK);
{
useFirstAsColumnBtn.setText(Messages.btnFirstLineAsCol);
GridData gridData = new GridData();
gridData.widthHint = 400;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 0;
gridData.horizontalSpan = 2;
useFirstAsColumnBtn.setLayoutData(gridData);
useFirstAsColumnBtn.setSelection(true);
}
Group delimiterOptionGroup = new Group(dataOptionGroup, SWT.None);
delimiterOptionGroup.setText(Messages.grpDelimiter);
delimiterOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
delimiterOptionGroup.setLayout(new GridLayout(2, false));
Label rowLabel = new Label(delimiterOptionGroup, SWT.None);
rowLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
rowLabel.setText(Messages.lblRow);
rowDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
rowDelimiterCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
rowDelimiterCombo.setTextLimit(32);
rowDelimiterCombo.setItems(rowDelimeterName);
rowDelimiterCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
verify();
}
});
Label columnLabel = new Label(delimiterOptionGroup, SWT.None);
columnLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
columnLabel.setText(Messages.lblCol);
columnDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
columnDelimiterCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
columnDelimiterCombo.setTextLimit(32);
columnDelimiterCombo.setItems(columnDelimeterName);
columnDelimiterCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
verify();
}
});
Group nullValueGroup = new Group(dataOptionGroup, SWT.None);
nullValueGroup.setText(Messages.grpNullOption);
nullValueGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
nullValueGroup.setLayout(new GridLayout(3, false));
nullOneButton = new Button(nullValueGroup, SWT.RADIO);
nullOneButton.setText(NULL_VALUES[0]);
nullOneButton.setLayoutData(CommonUITool.createGridData(1, 1, 70, -1));
nullOneButton.setSelection(true);
nullTwoButton = new Button(nullValueGroup, SWT.RADIO);
nullTwoButton.setText(NULL_VALUES[1]);
nullTwoButton.setLayoutData(CommonUITool.createGridData(2, 1, 70, -1));
nullThreeButton = new Button(nullValueGroup, SWT.RADIO);
nullThreeButton.setText(NULL_VALUES[2]);
nullThreeButton.setLayoutData(CommonUITool.createGridData(1, 1, 70, -1));
otherButton = new Button(nullValueGroup, SWT.RADIO);
otherButton.setText(Messages.btnOther);
otherButton.setLayoutData(CommonUITool.createGridData(1, 1, 70, -1));
otherButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
verify();
}
});
otherText = new Text(nullValueGroup, SWT.BORDER);
otherText.setLayoutData(CommonUITool.createGridData(1, 1, 60, 14));
otherText.setTextLimit(64);
otherText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
verify();
}
});
if (sqlButton != null && sqlButton.getSelection()) {
useFirstAsColumnBtn.setEnabled(false);
setDelimiterWidgetStatus(false);
setNullWidgetStatus(false);
} else {
useFirstAsColumnBtn.setEnabled(true);
setDelimiterWidgetStatus(false);
setNullWidgetStatus(true);
}
}
Aggregations