use of org.eclipse.jface.viewers.TextCellEditor in project Palladio-Editors-Sirius by PalladioSimulator.
the class EventTypesEditorSection method createViewerCellEditors.
/* (non-Javadoc)
* @see org.palladiosimulator.editors.commons.tabs.generic.EditorSection#createViewerCellEditors(org.eclipse.swt.widgets.Table)
*/
@Override
protected CellEditor[] createViewerCellEditors(Table table) {
CellEditor[] editors = new CellEditor[columnNames.length];
editors[EVENTTYPENAME_COLUMN_INDEX] = new TextCellEditor(table);
// create 'DeleteCellValueListener' and as SelectionListener to the 'TableVewer'
EventTypeDeleteCellValueListener cellValueListener = new EventTypeDeleteCellValueListener(viewer);
viewer.addSelectionChangedListener(cellValueListener);
editors[PARAMETER_NAME_COLUMN_INDEX] = new TextCellEditor(table);
editors[PARAMETER_TYPE_COLUMN_INDEX] = new TypeDialogCellEditor(table, cellValueListener) {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
*/
@Override
protected Object openDialogBox(Control cellEditorWindow) {
TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(getSelectedEventType());
ArrayList<Object> filterList = new ArrayList<Object>();
filterList.add(DataType.class);
filterList.add(Repository.class);
ArrayList<EReference> additionalReferences = new ArrayList<EReference>();
CallDataTypeDialog dialog = new CallDataTypeDialog(cellEditorWindow.getShell(), filterList, additionalReferences, editingDomain.getResourceSet());
dialog.setProvidedService(DataType.class);
dialog.open();
if (!(dialog.getResult() instanceof DataType))
return null;
return dialog.getResult();
}
};
return editors;
}
use of org.eclipse.jface.viewers.TextCellEditor in project yamcs-studio by yamcs.
the class TextEditManager method createCellEditorOn.
@Override
protected CellEditor createCellEditorOn(Composite composite) {
CellEditor editor = new TextCellEditor(composite, (multiLine ? SWT.MULTI : SWT.SINGLE) | SWT.WRAP) {
@Override
protected void focusLost() {
// lose focus should cancel the editing
if (editPart.getExecutionMode() == ExecutionMode.RUN_MODE && editPart instanceof IPVWidgetEditpart && ((IPVWidgetEditpart) editPart).getPV() != null) {
if (isActivated()) {
fireCancelEditor();
deactivate();
}
editPart.getFigure().requestFocus();
} else
super.focusLost();
}
@Override
protected void handleDefaultSelection(SelectionEvent event) {
// In run mode, hit ENTER should force to write the new value even it doesn't change.
if (editPart.getExecutionMode() == ExecutionMode.RUN_MODE) {
setDirty(true);
}
super.handleDefaultSelection(event);
}
@Override
protected void keyReleaseOccured(KeyEvent keyEvent) {
// In run mode, CTRL+ENTER will always perform a write if it is multiline text input
if (keyEvent.character == '\r' && editPart.getExecutionMode() == ExecutionMode.RUN_MODE) {
// Return key
if (text != null && !text.isDisposed() && (text.getStyle() & SWT.MULTI) != 0) {
if ((keyEvent.stateMask & SWT.CTRL) != 0) {
setDirty(true);
}
}
}
super.keyReleaseOccured(keyEvent);
}
};
editor.getControl().moveAbove(null);
return editor;
}
use of org.eclipse.jface.viewers.TextCellEditor in project yamcs-studio by yamcs.
the class RuleDataEditDialog method createExpressionsTableViewer.
/**
* Creates and configures a {@link TableViewer}.
*
* @param parent
* The parent for the table
* @return The {@link TableViewer}
*/
private TableViewer createExpressionsTableViewer(final Composite parent) {
final TableViewer viewer = new TableViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
TableViewerColumn expressionColumn = new TableViewerColumn(viewer, SWT.NONE);
expressionColumn.getColumn().setText("Boolean Expression");
expressionColumn.getColumn().setMoveable(false);
expressionColumn.getColumn().setWidth(200);
expressionColumn.setEditingSupport(new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
if (element instanceof Expression)
((Expression) element).setBooleanExpression(value.toString());
viewer.refresh();
}
@Override
protected Object getValue(Object element) {
if (element instanceof Expression)
return ((Expression) element).getBooleanExpression();
return null;
}
@Override
protected CellEditor getCellEditor(Object element) {
return new TextCellEditor(viewer.getTable());
}
@Override
protected boolean canEdit(Object element) {
return true;
}
});
valueColumn = new TableViewerColumn(viewer, SWT.NONE);
valueColumn.getColumn().setText(ruleData.isOutputExpValue() ? "Output Expression" : "Output Value");
valueColumn.getColumn().setMoveable(false);
valueColumn.getColumn().setWidth(200);
EditingSupport editingSupport = new EditingSupport(viewer) {
@Override
protected void setValue(Object element, Object value) {
if (element instanceof Expression) {
((Expression) element).setValue(value);
}
viewer.refresh();
}
@Override
protected Object getValue(Object element) {
if (element instanceof Expression) {
if (((Expression) element).getValue() == null)
// $NON-NLS-1$
return "";
return ((Expression) element).getValue();
}
return null;
}
@Override
protected CellEditor getCellEditor(Object element) {
if (element instanceof Expression) {
if (ruleData.isOutputExpValue() || ruleData.getProperty().getPropertyDescriptor() == null)
return new TextCellEditor(viewer.getTable());
else
return ruleData.getProperty().getPropertyDescriptor().createPropertyEditor(viewer.getTable());
}
return null;
}
@Override
protected boolean canEdit(Object element) {
return true;
}
};
valueColumn.setEditingSupport(editingSupport);
viewer.setContentProvider(new ArrayContentProvider());
viewer.setLabelProvider(new ExpressionLabelProvider());
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
viewer.getTable().setLayoutData(gd);
return viewer;
}
use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class CreateViewDialog method createGeneralComposite.
/**
* create General Composite
*
* @return composite
*/
private Composite createGeneralComposite() {
final Composite composite = new Composite(tabFolder, SWT.NONE);
{
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.makeColumnsEqualWidth = true;
composite.setLayout(gridLayout);
}
final Group group = new Group(composite, SWT.NONE);
{
GridData gdGroup = new GridData(SWT.FILL, SWT.CENTER, true, false);
gdGroup.horizontalSpan = 2;
group.setLayoutData(gdGroup);
final GridLayout gridLayout1 = new GridLayout();
gridLayout1.numColumns = 2;
group.setLayout(gridLayout1);
}
final Label tableNameLabel = new Label(group, SWT.SHADOW_IN);
tableNameLabel.setText(Messages.lblViewName);
tableText = new Text(group, SWT.BORDER);
tableText.setTextLimit(ValidateUtil.MAX_SCHEMA_NAME_LENGTH);
final GridData gdTableText = new GridData(SWT.FILL, SWT.CENTER, true, false);
gdTableText.horizontalIndent = 30;
tableText.setLayoutData(gdTableText);
if (isCommentSupport) {
final Label viewDescriptionLabel = new Label(group, SWT.SHADOW_IN);
viewDescriptionLabel.setText(Messages.lblViewDescription);
viewDescriptionText = new Text(group, SWT.BORDER);
viewDescriptionText.setTextLimit(ValidateUtil.MAX_DB_OBJECT_COMMENT);
final GridData gdViewDescription = new GridData(SWT.FILL, SWT.CENTER, true, false);
gdViewDescription.horizontalIndent = 30;
viewDescriptionText.setLayoutData(gdViewDescription);
viewDescriptionText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (getButton(IDialogConstants.OK_ID) != null) {
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
}
});
}
final Label ownerLabel = new Label(group, SWT.NONE);
ownerLabel.setText(Messages.lblViewOwnerName);
ownerCombo = new Combo(group, SWT.DROP_DOWN | SWT.READ_ONLY);
final GridData gdCombo = new GridData(SWT.FILL, SWT.CENTER, true, false);
gdCombo.horizontalIndent = 30;
ownerCombo.setLayoutData(gdCombo);
ownerCombo.setVisibleItemCount(10);
ownerCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
if (getButton(IDialogConstants.OK_ID) != null) {
getButton(IDialogConstants.OK_ID).setEnabled(true);
}
}
});
final Label querySQLLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
querySQLLabel.setText(Messages.lblQueryList);
querySQLLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
final Label sqlDescLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
sqlDescLabel.setText(Messages.lblSelectQueryList);
sqlDescLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
final String[] columnNameArr1 = new String[] { "col1" };
queryTableViewer = CommonUITool.createCommonTableViewer(composite, null, columnNameArr1, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 100));
queryTableViewer.getTable().setHeaderVisible(false);
queryTableViewer.setInput(queryListData);
queryTableViewer.getTable().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
}
public void widgetSelected(SelectionEvent event) {
int index = queryTableViewer.getTable().getSelectionIndex();
String value = queryListData.get(index).get("0");
if (value != null) {
querydescText.setText(formatSql(value));
}
setButtonStatus();
}
});
queryTableViewer.getTable().getColumn(0).setWidth(200);
querydescText = new Text(composite, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
querydescText.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
barComp = new Composite(composite, SWT.NONE);
{
final GridData gdbarComp = new GridData(GridData.FILL_HORIZONTAL);
gdbarComp.horizontalSpan = 2;
barComp.setLayoutData(gdbarComp);
GridLayout layout = new GridLayout();
layout.marginWidth = 10;
layout.marginHeight = 10;
barComp.setLayout(layout);
}
final Label columnsLabel = new Label(composite, SWT.NONE);
columnsLabel.setText(Messages.lblTableNameColumns);
final String[] columnNameArr = isCommentSupport ? new String[] { Messages.tblColViewName, Messages.tblColViewDataType, Messages.tblColViewDefaultType, Messages.tblColViewDefaultValue, Messages.tblColViewMemo } : new String[] { Messages.tblColViewName, Messages.tblColViewDataType, Messages.tblColViewDefaultType, Messages.tblColViewDefaultValue };
viewColTableViewer = createCommonTableViewer(composite, null, columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 2, 4, -1, 200));
viewColTableViewer.setInput(viewColListData);
viewColTableViewer.setColumnProperties(columnNameArr);
CellEditor[] editors = new CellEditor[5];
editors[0] = new TextCellEditor(viewColTableViewer.getTable());
editors[1] = null;
editors[2] = new ComboBoxCellEditor(viewColTableViewer.getTable(), defaultType, SWT.READ_ONLY);
editors[3] = new TextCellEditor(viewColTableViewer.getTable());
if (isCommentSupport) {
editors[4] = new TextCellEditor(viewColTableViewer.getTable());
}
viewColTableViewer.setCellEditors(editors);
viewColTableViewer.setCellModifier(new ICellModifier() {
@SuppressWarnings("unchecked")
public boolean canModify(Object element, String property) {
if (isPropertyQuery || property.equals(columnNameArr[1])) {
return false;
}
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArr[3])) {
String defaultTypeStr = map.get("2");
if (defaultTypeStr == null || defaultType[0].equals(defaultTypeStr)) {
return false;
}
}
return true;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArr[0])) {
return map.get("0");
} else if (property.equals(columnNameArr[2])) {
String str = map.get("2");
int index = 0;
if (str != null) {
for (int i = 0; defaultType != null && i < defaultType.length; i++) {
if (str.equals(defaultType[i])) {
index = i;
break;
}
}
}
return Integer.valueOf(index);
} else if (property.equals(columnNameArr[3])) {
String type = map.get("1");
String value = map.get("3");
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);
}
return value;
} else if (isCommentSupport && property.equals(columnNameArr[4])) {
return map.get("4");
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object elementData = null;
if (element instanceof Item) {
elementData = ((Item) element).getData();
}
Map<String, String> map = (Map<String, String>) elementData;
if (map == null) {
return;
}
String type = map.get("1");
if (property.equals(columnNameArr[0])) {
map.put("0", value.toString());
} else if (property.equals(columnNameArr[2])) {
int index = Integer.parseInt(value.toString());
if (index == 0) {
map.put("3", "");
}
map.put("2", defaultType[index]);
} else if (property.equals(columnNameArr[3])) {
String val = FieldHandlerUtils.getValidDefaultValue(value, type);
if (val != null) {
map.put("3", val);
}
} else if (isCommentSupport && property.equals(columnNameArr[4])) {
map.put("4", value.toString());
}
viewColTableViewer.refresh();
valid();
}
});
return composite;
}
use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class ExportSettingPage method createControl.
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout());
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(45, 0);
leftComposite.setLayoutData(leftData);
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(45, 0);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
GridLayout rightCompositeLayout = new GridLayout();
rightCompositeLayout.verticalSpacing = 10;
rightComposite.setLayout(rightCompositeLayout);
Label tableInfoLabel = new Label(leftComposite, SWT.None);
tableInfoLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
tableInfoLabel.setText(Messages.exportWizardSourceTableLable);
treeViewer = new CheckboxTreeViewer(leftComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
treeViewer.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
treeViewer.setContentProvider(new FilterTreeContentProvider());
treeViewer.getTree().setLinesVisible(true);
treeViewer.getTree().setHeaderVisible(true);
treeViewer.addCheckStateListener(new ICheckStateListener() {
public void checkStateChanged(CheckStateChangedEvent event) {
updateDialogStatus(null);
}
});
final TreeViewerColumn dbObjectCol = new TreeViewerColumn(treeViewer, SWT.NONE);
dbObjectCol.setLabelProvider(new ExportObjectLabelProvider());
final TreeViewerColumn whereCnd = new TreeViewerColumn(treeViewer, SWT.NONE);
whereCnd.setLabelProvider(new ExportObjectLabelProvider());
whereCnd.setEditingSupport(new EditingSupport(treeViewer) {
TextCellEditor textCellEditor;
protected boolean canEdit(Object element) {
if (element instanceof ICubridNode) {
ICubridNode node = (ICubridNode) element;
if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
return true;
}
}
return false;
}
protected CellEditor getCellEditor(Object element) {
if (textCellEditor == null) {
textCellEditor = new TextCellEditor(treeViewer.getTree());
textCellEditor.addListener(new ICellEditorListener() {
public void applyEditorValue() {
}
public void cancelEditor() {
}
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
}
});
}
return textCellEditor;
}
protected Object getValue(Object element) {
final ICubridNode node = (ICubridNode) element;
String condition = (String) node.getData(ExportObjectLabelProvider.CONDITION);
if (condition == null) {
return "";
} else {
return condition;
}
}
protected void setValue(Object element, Object value) {
final ICubridNode node = (ICubridNode) element;
node.setData(ExportObjectLabelProvider.CONDITION, value);
treeViewer.refresh();
updateDialogStatus(null);
}
});
dbObjectCol.getColumn().setWidth(160);
dbObjectCol.getColumn().setText(Messages.tableLabel);
whereCnd.getColumn().setWidth(120);
whereCnd.getColumn().setText(Messages.conditionLabel);
final Button selectAllBtn = new Button(leftComposite, SWT.CHECK);
{
selectAllBtn.setText(Messages.btnSelectAll);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 0;
gridData.horizontalSpan = 3;
selectAllBtn.setLayoutData(gridData);
}
selectAllBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
boolean selection = selectAllBtn.getSelection();
for (ICubridNode node : tablesOrViewLst) {
treeViewer.setGrayed(node, false);
treeViewer.setChecked(node, selection);
}
updateDialogStatus(null);
}
});
/* Export content option */
Group exportOptionGroup = new Group(rightComposite, SWT.None);
exportOptionGroup.setText(Messages.exportWizardWhatExport);
exportOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
RowLayout layout = new RowLayout();
layout.spacing = 8;
layout.marginWidth = 5;
exportOptionGroup.setLayout(layout);
schemaButton = new Button(exportOptionGroup, SWT.CHECK);
schemaButton.setText(Messages.lblExportTargetSchema);
schemaButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
boolean selection = schemaButton.getSelection();
indexButton.setEnabled(selection);
serialButton.setEnabled(selection);
viewButton.setEnabled(selection);
startValueButton.setEnabled(selection);
updateDialogStatus(null);
}
});
dataButton = new Button(exportOptionGroup, SWT.CHECK);
dataButton.setText(Messages.lblExportTargetData);
dataButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
indexButton = new Button(exportOptionGroup, SWT.CHECK);
indexButton.setText(Messages.lblExportTargetIndex);
serialButton = new Button(exportOptionGroup, SWT.CHECK);
serialButton.setText(Messages.lblExportTargetSerial);
viewButton = new Button(exportOptionGroup, SWT.CHECK);
viewButton.setText(Messages.lblExportTargetView);
exportLobButton = new Button(exportOptionGroup, SWT.CHECK);
exportLobButton.setText(Messages.lblExportLobData);
exportLobButton.setToolTipText(Messages.lblExportLobData);
exportLobButton.setEnabled(false);
startValueButton = new Button(exportOptionGroup, SWT.CHECK);
startValueButton.setText(Messages.lblExportTargetStartValue);
startValueButton.setToolTipText(Messages.tipExportTargetStartValue);
/* Type group */
Group typeOptionGroup = new Group(rightComposite, SWT.None);
typeOptionGroup.setText(Messages.exportWizardWhereExport);
typeOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
typeOptionGroup.setLayout(new GridLayout(2, false));
Label typeLabel = new Label(typeOptionGroup, SWT.None);
typeLabel.setText(Messages.exportWizardFileType);
typeLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
Composite typeComposite = new Composite(typeOptionGroup, SWT.None);
typeComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
typeComposite.setLayout(new GridLayout(6, false));
sqlButton = new Button(typeComposite, SWT.RADIO);
sqlButton.setText("SQL");
sqlButton.setToolTipText("SQL");
sqlButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(false);
setNullWidgetStatus(false);
setDelimiterWidgetStatus(false);
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
csvButton = new Button(typeComposite, SWT.RADIO);
csvButton.setText("CSV");
csvButton.setToolTipText("CSV");
csvButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
csvButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(false);
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
xlsButton = new Button(typeComposite, SWT.RADIO);
xlsButton.setText("XLS");
xlsButton.setToolTipText("XLS");
xlsButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
xlsButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(false);
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
xlsxButton = new Button(typeComposite, SWT.RADIO);
xlsxButton.setText("XLSX");
xlsxButton.setToolTipText("XLSX");
xlsxButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
xlsxButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(false);
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
txtButton = new Button(typeComposite, SWT.RADIO);
txtButton.setText("TXT");
txtButton.setToolTipText("TXT");
txtButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
txtButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(true);
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
obsButton = new Button(typeComposite, SWT.RADIO);
obsButton.setText("OBS");
obsButton.setToolTipText("OBS");
obsButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
obsButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
useFirstAsColumnBtn.setEnabled(false);
setNullWidgetStatus(false);
setDelimiterWidgetStatus(false);
updateDialogStatus(null);
updateExportLobButtonStatus();
}
});
Label pathLabel = new Label(typeOptionGroup, SWT.None);
pathLabel.setText(Messages.exportWizardFilepath);
pathLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
Composite fileComposite = new Composite(typeOptionGroup, SWT.None);
fileComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
fileComposite.setLayout(new GridLayout(2, false));
pathText = new Text(fileComposite, SWT.BORDER);
pathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
pathText.setEditable(false);
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 savedDirFile = TableUtil.getSavedDir(getShell(), Messages.titleSelectFolderToBeExported, Messages.msgSelectFolderToBeExported, pathText.getText());
if (savedDirFile != null) {
String savePathString = null;
String[] files = savedDirFile.list();
String databaseName = getDatabase().getDatabaseInfo().getDbName();
if (files != null && files.length > 0) {
String confirmMessage = Messages.bind(Messages.errorExportExistsFilesInFolder, databaseName);
boolean useCreate = CommonUITool.openConfirmBox(confirmMessage);
if (useCreate) {
File newFolder = new File(savedDirFile.getAbsolutePath() + File.separator + databaseName);
boolean existsDbNameFolder = newFolder.exists();
files = newFolder.list();
if (existsDbNameFolder && files != null && files.length > 0) {
String newFolderName = databaseName + "_" + DateUtil.getDatetimeStringOnNow("HHmmss");
savePathString = savedDirFile.getAbsolutePath() + File.separator + newFolderName;
String warnMessage = Messages.bind(Messages.errorExportExistsFilesInFolderWithRename, newFolderName);
CommonUITool.openWarningBox(warnMessage);
} else {
savePathString = savedDirFile.getAbsolutePath() + File.separator + databaseName;
}
new File(savePathString).mkdirs();
} else {
return;
}
} else {
savePathString = savedDirFile.getAbsolutePath();
}
pathText.setText(savePathString);
}
updateDialogStatus(null);
}
});
Group parsingGroup = new Group(rightComposite, SWT.None);
parsingGroup.setText(Messages.exportWizardParsingOption);
parsingGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
GridLayout parsingGroupLayout = new GridLayout(4, false);
parsingGroupLayout.horizontalSpacing = 10;
parsingGroup.setLayout(parsingGroupLayout);
Label threadCountLabel = new Label(parsingGroup, SWT.None);
threadCountLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
threadCountLabel.setText(Messages.lblThreadCount);
threadCountSpinner = new Spinner(parsingGroup, SWT.BORDER | SWT.LEFT);
threadCountSpinner.setValues(DEFAULT_EXPORT_THREAD_COUNT, MIN_EXPORT_THREAD_COUNT, MAX_EXPORT_THREAD_COUNT, 0, 1, 2);
threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_FILL, 1, 1, -1, -1));
Label emptyLabel = new Label(parsingGroup, SWT.None);
emptyLabel.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
emptyLabel.setText("");
Label dbCharsetLabel = new Label(parsingGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbCharsetLabel.setText(Messages.lblJDBCCharset);
dbCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(parsingGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(parsingGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
Group dataOptionGroup = new Group(rightComposite, SWT.None);
dataOptionGroup.setText(Messages.exportWizardDataOption);
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.exportFirstLineFLAG);
GridData gridData = new GridData();
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalIndent = 0;
gridData.horizontalSpan = 2;
useFirstAsColumnBtn.setLayoutData(gridData);
useFirstAsColumnBtn.setSelection(false);
}
Group delimiterOptionGroup = new Group(dataOptionGroup, SWT.None);
delimiterOptionGroup.setText(Messages.exportWizardDelimiterOptions);
delimiterOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
delimiterOptionGroup.setLayout(new GridLayout(2, false));
Label columnLabel = new Label(delimiterOptionGroup, SWT.None);
columnLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
columnLabel.setText(Messages.exportWizardColumnSeperator);
columnDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
columnDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
columnDelimiterCombo.setTextLimit(32);
columnDelimiterCombo.setItems(columnDelimeterName);
columnDelimiterCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus(null);
}
});
Label rowLabel = new Label(delimiterOptionGroup, SWT.None);
rowLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
rowLabel.setText(Messages.exportWizardRowSeperator);
rowDelimiterCombo = new Combo(delimiterOptionGroup, SWT.BORDER);
rowDelimiterCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
rowDelimiterCombo.setTextLimit(32);
rowDelimiterCombo.setItems(rowDelimeterName);
rowDelimiterCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus(null);
}
});
Group nullValueGroup = new Group(dataOptionGroup, SWT.None);
nullValueGroup.setText(Messages.exportWizardNullOptions);
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'");
nullOneButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
nullTwoButton = new Button(nullValueGroup, SWT.RADIO);
nullTwoButton.setText("'\\N'");
nullTwoButton.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
nullThreeButton = new Button(nullValueGroup, SWT.RADIO);
nullThreeButton.setText("'(NULL)'");
nullThreeButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
otherButton = new Button(nullValueGroup, SWT.RADIO);
otherButton.setText(Messages.btnOther);
otherButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
otherButton.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
updateDialogStatus(null);
}
});
otherText = new Text(nullValueGroup, SWT.BORDER);
otherText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
otherText.setTextLimit(64);
otherText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
updateDialogStatus(null);
}
});
useFirstAsColumnBtn.setEnabled(false);
setNullWidgetStatus(false);
setDelimiterWidgetStatus(false);
}
Aggregations