use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class BrokerParameterPropertyPage method linkEditorForTable.
/**
* Links the editable column of table
*/
private void linkEditorForTable() {
paraTableViewer.setColumnProperties(columnNameArrs);
CellEditor[] editors = new CellEditor[3];
editors[0] = null;
editors[1] = null;
editors[2] = new TextCellEditor(paraTable);
paraTableViewer.setCellEditors(editors);
paraTableViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(columnNameArrs[2])) {
return true;
}
return false;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArrs[2])) {
return map.get("2");
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
}
if (obj == null) {
return;
}
Map<String, String> map = (Map<String, String>) obj;
String paramName = map.get("0");
String type = map.get("1");
boolean isValid = true;
if (type.indexOf("int") >= 0) {
boolean isInt = ValidateUtil.isInteger(value.toString());
if (!isInt) {
isValid = false;
}
} else if (type.startsWith("string")) {
String valueStr = value.toString().trim();
int start = type.indexOf("(");
int end = type.indexOf(")");
if (start > 0) {
String valueStrs = type.substring(start + 1, end);
String[] values = valueStrs.split("\\|");
boolean isExist = false;
for (String val : values) {
if (valueStr.equals(val)) {
isExist = true;
}
}
if (!isExist) {
isValid = false;
}
}
}
if (!isValid) {
CommonUITool.openErrorBox(Messages.bind(Messages.errParameterValue, new Object[] { paramName }));
}
if (type.indexOf("int") >= 0 && isValid) {
int intValue = Integer.parseInt(value.toString());
if (paramName.equalsIgnoreCase(ConfConstants.MAX_STRING_LENGTH)) {
if (intValue == 0 || intValue < -1) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errMaxStringLengthValue, new Object[] { paramName }));
}
} else {
if (intValue <= 0) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errPositiveValue, new Object[] { paramName }));
}
List<Map<String, String>> parameterList = (List<Map<String, String>>) paraTableViewer.getInput();
if (paramName.equalsIgnoreCase(ConfConstants.MIN_NUM_APPL_SERVER)) {
Map<String, String> dataMap = parameterList.get(3);
String maxNumApplServer = dataMap.get("2");
if (maxNumApplServer.trim().length() > 0 && intValue > Integer.parseInt(maxNumApplServer.trim())) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errMinNumApplServerValue, new Object[] { paramName }));
}
}
if (paramName.equalsIgnoreCase(ConfConstants.MAX_NUM_APPL_SERVER)) {
Map<String, String> dataMap = parameterList.get(2);
String minNumApplServer = dataMap.get("2");
if (minNumApplServer.trim().length() > 0 && intValue < Integer.parseInt(minNumApplServer.trim())) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errMaxNumApplServeValue, new Object[] { paramName }));
}
}
}
}
if (paramName.equalsIgnoreCase(ConfConstants.BROKER_PORT) && isValid) {
int port = Integer.parseInt(value.toString());
if (port < 1024 || port > 65535) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errBrokerPortAndShmId, paramName));
}
if (isValid) {
String paramValue = value.toString().trim();
for (Map.Entry<String, Map<String, String>> entry : oldConfParaMap.entrySet()) {
if (entry.getKey().equals(node.getLabel())) {
isValid = true;
continue;
} else {
String otherPort = entry.getValue().get(ConfConstants.BROKER_PORT);
if (paramValue.equalsIgnoreCase(otherPort)) {
isValid = false;
CommonUITool.openErrorBox(Messages.errReduplicatePort);
break;
} else {
isValid = true;
}
}
}
Map<String, String> brokerSectionMap = oldConfParaMap.get(ConfConstants.BROKER_SECTION_NAME);
String masterShmId = brokerSectionMap.get(ConfConstants.MASTER_SHM_ID);
if (paramValue.equals(masterShmId)) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errUseMasterShmId, paramValue));
}
}
if (isValid) {
String paramValue = value.toString().trim();
int intServerPortValue = Integer.parseInt(paramValue) + 1;
List<Map<String, String>> parameterList = (List<Map<String, String>>) paraTableViewer.getInput();
for (Map<String, String> dataMap : parameterList) {
if (dataMap.get("0").equalsIgnoreCase(ConfConstants.APPL_SERVER_PORT)) {
String serverPortValue = Integer.toString(intServerPortValue);
dataMap.put("2", serverPortValue);
}
}
}
}
if (paramName.equalsIgnoreCase(ConfConstants.APPL_SERVER_SHM_ID) && isValid) {
int port = Integer.parseInt(value.toString());
if (port < 1024 || port > 65535) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errBrokerPortAndShmId, paramName));
}
if (isValid) {
String paramValue = value.toString().trim();
for (Map.Entry<String, Map<String, String>> entry : oldConfParaMap.entrySet()) {
if (entry.getKey().equals(node.getLabel())) {
isValid = true;
continue;
} else {
String otherPort = entry.getValue().get(ConfConstants.APPL_SERVER_SHM_ID);
if (paramValue.equalsIgnoreCase(otherPort)) {
isValid = false;
CommonUITool.openErrorBox(Messages.errReduplicateShmId);
break;
} else {
isValid = true;
}
}
}
Map<String, String> brokerSectionMap = oldConfParaMap.get(ConfConstants.BROKER_SECTION_NAME);
String masterShmId = brokerSectionMap.get(ConfConstants.MASTER_SHM_ID);
if (paramValue.equals(masterShmId)) {
isValid = false;
CommonUITool.openErrorBox(Messages.bind(Messages.errUseMasterShmId, paramValue));
}
}
}
if (isValid) {
map.put("2", value.toString());
}
paraTableViewer.refresh();
}
});
}
use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class DatabaseConfigPropertyPage method linkEditorForTable.
/**
* Link editor for table
*/
private void linkEditorForTable() {
advancedOptionTableViewer.setColumnProperties(columnNameArrs);
CellEditor[] editors = new CellEditor[4];
editors[0] = null;
editors[1] = null;
editors[2] = null;
editors[3] = new TextCellEditor(advancedOptionTable);
advancedOptionTableViewer.setCellEditors(editors);
advancedOptionTableViewer.setCellModifier(new ICellModifier() {
@SuppressWarnings("unchecked")
public boolean canModify(Object element, String property) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
} else if (element instanceof Map) {
obj = element;
}
if (obj == null) {
return false;
}
Map<String, String> map = (Map<String, String>) obj;
String parameter = map.get("0");
if (parameter.equals(ConfConstants.HA_MODE) && !isCanSetOnForHaMode) {
return false;
}
if (property.equals(columnNameArrs[3])) {
return true;
}
return false;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArrs[3])) {
return map.get("3");
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
}
if (obj == null) {
return;
}
Map<String, String> map = (Map<String, String>) obj;
modifyTable(map, property, value);
}
});
}
use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class VolumeSizeValidator method createTable.
/**
* Create volume table area
*
* @param parent the parent composite
*/
private void createTable(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
composite.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
composite.setLayout(layout);
Label tipLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.msgVolumeList);
tipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
gridData = new GridData(GridData.FILL_HORIZONTAL);
tipLabel.setLayoutData(gridData);
addVolumeButton = new Button(composite, SWT.NONE);
addVolumeButton.setText(Messages.btnAddVolume);
addVolumeButton.setEnabled(false);
addVolumeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String volumeName = volumeNameText.getText();
String volumeType = volumeTypeCombo.getText();
String volumeSize = volumeSizeText.getText();
String pageNumber = String.valueOf(CreateDatabaseWizard.calcVolumePageNum(volumeSize, pageSize));
String volumePath = volumePathText.getText();
Map<String, String> map = new HashMap<String, String>();
map.put("0", volumeName);
map.put("1", volumeType);
map.put("2", volumeSize);
map.put("3", pageNumber);
map.put("4", volumePath);
volumeTableList.add(map);
volumeTableViewer.refresh();
for (int i = 0; i < volumeTable.getColumnCount(); i++) {
volumeTable.getColumn(i).pack();
}
changeVolumeName();
changeAutoVolumeButton();
}
});
deleteVolumeButton = new Button(composite, SWT.NONE);
deleteVolumeButton.setText(Messages.btnDelVolume);
deleteVolumeButton.setEnabled(false);
deleteVolumeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) volumeTableViewer.getSelection();
if (selection != null && !selection.isEmpty()) {
volumeTableList.removeAll(selection.toList());
}
volumeTableViewer.refresh();
deleteVolumeButton.setEnabled(volumeTable.getSelectionCount() > 0);
changeAutoVolumeButton();
changeVolumeName();
}
});
final String[] columnNameArr = new String[] { Messages.tblColumnVolName, Messages.tblColumnVolType, Messages.tblColumnVolSize, Messages.tblColumnVolPath };
volumeTableViewer = CommonUITool.createCommonTableViewer(parent, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
volumeTableViewer.setLabelProvider(new VolumeInfoTableProvider());
volumeTableViewer.setInput(volumeTableList);
volumeTable = volumeTableViewer.getTable();
for (int i = 0; i < volumeTable.getColumnCount(); i++) {
volumeTable.getColumn(i).pack();
}
volumeTable.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
deleteVolumeButton.setEnabled(volumeTable.getSelectionCount() > 0);
}
});
// Create the cell editors
CellEditor[] editors = new CellEditor[4];
editors[0] = new TextCellEditor(volumeTable);
editors[1] = new ComboBoxCellEditor(volumeTable, VOLUME_TYPES, SWT.READ_ONLY);
editors[2] = new TextCellEditor(volumeTable);
editors[3] = null;
editors[0].setValidator(new VolumeNameValidator(volumeTableViewer));
editors[0].addListener(new ICellEditorListener() {
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
if (!newValidState) {
VolumeInfoPage.this.setErrorMessage(Messages.errVolumeName);
} else {
VolumeInfoPage.this.setErrorMessage(null);
}
}
public void cancelEditor() {
VolumeInfoPage.this.setErrorMessage(null);
}
public void applyEditorValue() {
VolumeInfoPage.this.setErrorMessage(null);
}
});
editors[2].setValidator(new VolumeSizeValidator());
editors[2].addListener(new ICellEditorListener() {
public void editorValueChanged(boolean oldValidState, boolean newValidState) {
if (!newValidState) {
VolumeInfoPage.this.setErrorMessage(Messages.errVolumeSize);
} else {
VolumeInfoPage.this.setErrorMessage(null);
}
}
public void cancelEditor() {
VolumeInfoPage.this.setErrorMessage(null);
}
public void applyEditorValue() {
VolumeInfoPage.this.setErrorMessage(null);
}
});
volumeTableViewer.setCellEditors(editors);
volumeTableViewer.setColumnProperties(PROPS);
volumeTableViewer.setCellModifier(new VolumnCellEditor(this, volumeTableViewer));
}
use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class SettingCubridConfPage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setControl(container);
setDescription(Messages.descSettingCubridPage);
Composite leftComposite = new Composite(container, SWT.NONE);
leftComposite.setLayout(new GridLayout(3, false));
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(50, -5);
leftComposite.setLayoutData(leftData);
Label separator = new Label(container, SWT.SEPARATOR);
FormData separatorData = new FormData();
separatorData.top = new FormAttachment(0, 5);
separatorData.bottom = new FormAttachment(100, -5);
separatorData.left = new FormAttachment(50, -5);
separatorData.right = new FormAttachment(50, 5);
separator.setLayoutData(separatorData);
Composite rightComposite = new Composite(container, SWT.NONE);
rightComposite.setLayout(new GridLayout(3, false));
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 5);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
/*Create left widget*/
Label hostALabel = new Label(leftComposite, SWT.None);
hostALabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostALabel.setText(Messages.lblMaster);
masterHostLabel = new Label(leftComposite, SWT.None);
masterHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
masterViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION);
masterViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
masterViewer.getTable().setLinesVisible(true);
masterViewer.getTable().setHeaderVisible(true);
masterViewer.setContentProvider(new TableContentProvider());
masterViewer.setLabelProvider(new CubridConfTableProvider());
masterViewer.setColumnProperties(PROPS);
CellEditor[] editorsA = new CellEditor[2];
editorsA[0] = null;
editorsA[1] = new TextCellEditor(masterViewer.getTable());
masterViewer.setCellEditors(editorsA);
masterViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
masterViewer.refresh(model);
updateHAModel(masterViewer, model, false);
}
});
TableColumn keyAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
keyAColumn.setText(Messages.lblKey);
keyAColumn.setWidth(160);
TableColumn valueAColumn = new TableColumn(masterViewer.getTable(), SWT.LEFT);
valueAColumn.setText(Messages.lblValue);
valueAColumn.setWidth(200);
Label masterDBLabel = new Label(leftComposite, SWT.None);
masterDBLabel.setText(Messages.lblDatabase);
masterDBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo = new Combo(leftComposite, SWT.BORDER | SWT.READ_ONLY);
masterDBCombo.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
masterDBCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
HAModel haModel = getConfigHAWizard().getHaModel();
/*Init table data*/
initTableData(haModel.getMasterServer(), true);
HAServer haServer = haModel.getSlaveServer();
initTableData(haServer, false);
}
});
ToolBar toolBarA = new ToolBar(leftComposite, SWT.None);
toolBarA.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
ToolItem addItemA = new ToolItem(toolBarA, SWT.None);
addItemA.setToolTipText(Messages.itemAddParameter);
addItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(masterViewer);
}
});
ToolItem editItemA = new ToolItem(toolBarA, SWT.None);
editItemA.setToolTipText(Messages.itemEditParameter);
editItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(masterViewer);
}
});
ToolItem dropItemA = new ToolItem(toolBarA, SWT.None);
dropItemA.setToolTipText(Messages.itemDeleteParameter);
dropItemA.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemA.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(masterViewer);
}
});
/*Create right widget*/
Label hostBLabel = new Label(rightComposite, SWT.None);
hostBLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
hostBLabel.setText(Messages.lblSlave);
slaveHostLabel = new Label(rightComposite, SWT.None);
slaveHostLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
slaveViewer = new TableViewer(rightComposite, SWT.BORDER | SWT.FULL_SELECTION);
slaveViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, -1));
slaveViewer.getTable().setLinesVisible(true);
slaveViewer.getTable().setHeaderVisible(true);
slaveViewer.setContentProvider(new TableContentProvider());
slaveViewer.setLabelProvider(new CubridConfTableProvider());
slaveViewer.setColumnProperties(PROPS);
CellEditor[] editorsB = new CellEditor[2];
editorsB[0] = null;
editorsB[1] = new TextCellEditor(slaveViewer.getTable());
slaveViewer.setCellEditors(editorsB);
slaveViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
if (property.equals(PROPS[1])) {
return true;
}
return false;
}
public Object getValue(Object element, String property) {
DataModel model = (DataModel) element;
if (property.equals(PROPS[0])) {
return model.getKey() == null ? "" : model.getKey();
} else if (property.equals(PROPS[1])) {
return model.getValue() == null ? "" : model.getValue();
}
return "";
}
public void modify(Object element, String property, Object value) {
TableItem item = (TableItem) element;
DataModel model = (DataModel) item.getData();
model.setValue(value.toString());
slaveViewer.refresh(model);
updateHAModel(slaveViewer, model, false);
}
});
TableColumn keyBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
keyBColumn.setText(Messages.lblKey);
keyBColumn.setWidth(160);
TableColumn valueBColumn = new TableColumn(slaveViewer.getTable(), SWT.LEFT);
valueBColumn.setText(Messages.lblValue);
valueBColumn.setWidth(200);
ToolBar toolBarB = new ToolBar(rightComposite, SWT.None);
toolBarB.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 3, 1, -1, -1));
ToolItem addItemB = new ToolItem(toolBarB, SWT.None);
addItemB.setToolTipText(Messages.itemAddParameter);
addItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/add_param.gif"));
addItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
addParameter(slaveViewer);
}
});
ToolItem editItemB = new ToolItem(toolBarB, SWT.None);
editItemB.setToolTipText(Messages.itemEditParameter);
editItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/edit_param.gif"));
editItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
editParameter(slaveViewer);
}
});
ToolItem dropItemB = new ToolItem(toolBarB, SWT.None);
dropItemB.setToolTipText(Messages.itemDeleteParameter);
dropItemB.setImage(CubridManagerUIPlugin.getImage("/icons/replication/delete_param.gif"));
dropItemB.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
dropParameter(slaveViewer);
}
});
}
use of org.eclipse.jface.viewers.TextCellEditor in project cubrid-manager by CUBRID.
the class TableConfigCellEditor method createControl.
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(1, false));
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(55, 0);
leftComposite.setLayoutData(leftData);
Group grpButtons = new Group(leftComposite, SWT.NONE);
{
grpButtons.setLayout(new GridLayout(4, false));
grpButtons.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
grpButtons.setText(Messages.grpAddRemove);
}
Button sqlSchemaFileButton = new Button(grpButtons, SWT.NONE);
sqlSchemaFileButton.setText(Messages.btnAddSchemaFile);
sqlSchemaFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlSchemaFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_SCHEMA);
}
});
Button sqlDataFileButton = new Button(grpButtons, SWT.NONE);
sqlDataFileButton.setText(Messages.btnAddDataFile);
sqlDataFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlDataFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_DATA);
}
});
Button sqlIndexFileButton = new Button(grpButtons, SWT.NONE);
sqlIndexFileButton.setText(Messages.btnAddIndexFile);
sqlIndexFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
sqlIndexFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
addFile(TableConfig.TYPE_INDEX);
}
});
delFileButton = new Button(grpButtons, SWT.NONE);
delFileButton.setText(Messages.btnDelFiles);
delFileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
delFileButton.setEnabled(false);
delFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
deleteSelectedFile();
}
});
sqlFileTableViewer = new TableViewer(leftComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
sqlFileTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 4, 1, -1, -1));
sqlFileTableViewer.getTable().setLinesVisible(true);
sqlFileTableViewer.getTable().setHeaderVisible(true);
final TableViewerColumn fileNameCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileNameCol.getColumn().setWidth(300);
fileNameCol.getColumn().setText(Messages.columnImportFileName);
final TableViewerColumn fileTypeCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileTypeCol.getColumn().setWidth(100);
fileTypeCol.getColumn().setText(Messages.columnImportFileType);
CellEditor[] editors = new CellEditor[4];
editors[0] = new TextCellEditor(sqlFileTableViewer.getTable());
editors[1] = new ComboBoxCellEditor(sqlFileTableViewer.getTable(), TYPE_ITEMS, SWT.READ_ONLY);
sqlFileTableViewer.setColumnProperties(PROPS);
sqlFileTableViewer.setContentProvider(new SQLFileTableContentProvider());
sqlFileTableViewer.setLabelProvider(new SQLFileTableLabelProvider());
sqlFileTableViewer.setCellModifier(new TableConfigCellEditor(sqlFileTableViewer, this));
sqlFileTableViewer.setCellEditors(editors);
sqlFileTableViewer.getTable().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
delFileButton.setEnabled(delCanEnable());
}
});
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(55, 0);
rightData.right = new FormAttachment(100, -5);
rightComposite.setLayoutData(rightData);
GridLayout rightCompositeLayout = new GridLayout();
rightCompositeLayout.verticalSpacing = 10;
rightComposite.setLayout(rightCompositeLayout);
Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
enCodingOptionGroup.setText(Messages.grpEncodingOption);
enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
enCodingOptionGroup.setLayout(new GridLayout(4, false));
Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
dbCharsetLabel.setText(Messages.lblDBCharset);
dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
dbCharsetCombo.setEnabled(false);
Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetLabel.setText(Messages.lblFileCharset);
fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.select(0);
fileCharsetCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
getImportDataWizard().getImportConfig().setFilesCharset(fileCharsetCombo.getText());
}
});
Group importOptionGroup = new Group(rightComposite, SWT.None);
importOptionGroup.setText(Messages.grpImportOptions);
importOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
importOptionGroup.setLayout(new GridLayout(2, false));
Label threadCountLabel = new Label(importOptionGroup, SWT.None);
threadCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
threadCountLabel.setText(Messages.lblThreadNum);
threadCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
threadCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
threadCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_THREAD_COUNT);
threadCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_THREAD_COUNT);
threadCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_THREAD_COUNT);
threadCountSpinner.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
validate();
}
});
Label commitCountLabel = new Label(importOptionGroup, SWT.None);
commitCountLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
commitCountLabel.setText(Messages.lblCommitCount);
commitCountSpinner = new Spinner(importOptionGroup, SWT.BORDER);
commitCountSpinner.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
commitCountSpinner.setMaximum(ImportConfig.MAX_IMPORT_COMMIT_COUNT);
commitCountSpinner.setMinimum(ImportConfig.MIN_IMPORT_COMMIT_COUNT);
commitCountSpinner.setIncrement(ImportConfig.IMPORT_COMMIT_STEP);
commitCountSpinner.setSelection(ImportConfig.DEFAULT_IMPORT_COMMIT_COUNT);
final Button haModeButton = new Button(rightComposite, SWT.CHECK);
haModeButton.setText(Messages.btnInHaMode);
haModeButton.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
haModeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ImportConfig importConfig = getImportDataWizard().getImportConfig();
importConfig.setHaMode(haModeButton.getSelection());
Collections.sort(fileList, new TableConfigComparator(getImportDataWizard().getImportConfig()));
sqlFileTableViewer.refresh();
}
});
registerContextMenu();
}
Aggregations