use of org.eclipse.jface.viewers.CellEditor in project cubrid-manager by CUBRID.
the class SqlmapNavigatorView method createCondView.
/**
* Create the main view.
*
* @param parent {@link Composite} the parent composite
*/
private void createCondView(Composite parent) {
String[] columnNames = { Messages.lblSqlmapUse, Messages.lblSqlmapCondition };
Label lblCondTitle = new Label(parent, SWT.NONE);
lblCondTitle.setText(Messages.lblSqlmapConditions);
condView = CommonUITool.createCommonTableViewer(parent, null, columnNames, CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 80));
condView.setColumnProperties(columnNames);
condView.setContentProvider(new TableContentProvider());
condView.setLabelProvider(new SqlmapLabelProvider(this));
condView.setCellModifier(new SqlmapCellModifier(this));
CellEditor[] cellEditor = new CellEditor[columnNames.length];
cellEditor[0] = new CheckboxCellEditor(condView.getTable());
condView.setCellEditors(cellEditor);
TableLayout tableLayout = new TableLayout();
tableLayout.addColumnData(new ColumnPixelData(30));
tableLayout.addColumnData(new ColumnPixelData(160));
condView.getTable().setLayout(tableLayout);
condView.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.character == ' ') {
toggleUsedBySelectedCondition();
}
super.keyPressed(e);
}
});
}
use of org.eclipse.jface.viewers.CellEditor 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.CellEditor 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.CellEditor in project cubrid-manager by CUBRID.
the class DataCompareEditorPart method createContent.
private void createContent(Composite parent) {
compareTableViewer = new TableViewer(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
compareTableViewer.setUseHashlookup(true);
compareTableViewer.setColumnProperties(columnNames);
CommonUITool.createGridLayout(compareTableViewer.getTable(), 1, 0, 10, 0, 10, 0, 0, 0, 0);
compareTableViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
compareTableViewer.getTable().setLinesVisible(true);
compareTableViewer.getTable().setHeaderVisible(true);
sorter = new DataCompareSchemaListViewSorter();
sorter.setSortType(DataCompareSchemaListViewSorter.SORT_TABLE);
compareTableViewer.setSorter(sorter);
makeContextMenu(compareTableViewer);
final TableViewerColumn firstCol = new TableViewerColumn(compareTableViewer, SWT.NONE);
firstCol.getColumn().setWidth(30);
firstCol.getColumn().setResizable(false);
firstCol.getColumn().setAlignment(SWT.CENTER);
firstCol.getColumn().setImage(CommonUIPlugin.getImage("icons/unchecked.gif"));
firstCol.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
TableItem[] items = compareTableViewer.getTable().getItems();
if (items == null) {
return;
}
for (TableItem item : items) {
DataCompare dataCompare = (DataCompare) item.getData();
dataCompare.setUse(isSelectAll);
}
compareTableViewer.refresh();
Image image = null;
if (isSelectAll) {
image = CommonUIPlugin.getImage("icons/checked.gif");
} else {
image = CommonUIPlugin.getImage("icons/unchecked.gif");
}
firstCol.getColumn().setImage(image);
isSelectAll = !isSelectAll;
}
});
TableViewerColumn col = new TableViewerColumn(compareTableViewer, SWT.NONE);
col.getColumn().setWidth(200);
col.getColumn().setText(Messages.lblDataCompareTable);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TABLE);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordSource);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_SOURCE_RECORDS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordTarget);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_TARGET_RECORDS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordProgress);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_PROGRESS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordMatch);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_MATCHES);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordNoMatch);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_MATCHES);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(100);
col.getColumn().setText(Messages.lblDataCompareRecordNotExist);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_NOT_EXISTS);
col = new TableViewerColumn(compareTableViewer, SWT.LEFT);
col.getColumn().setWidth(300);
col.getColumn().setText(Messages.lblDataCompareRecordError);
makeSortTableColumn(col, DataCompareSchemaListViewSorter.SORT_ERROR);
CellEditor[] cellEditor = new CellEditor[1];
cellEditor[0] = new CheckboxCellEditor(compareTableViewer.getTable());
compareTableViewer.setCellEditors(cellEditor);
compareTableViewer.setCellModifier(new DataCompareCellModifier(this));
compareTableViewer.setContentProvider(new DataCompareSchemaListContentProvider());
compareTableViewer.setLabelProvider(new DataCompareSchemaListLabelProvider());
compareList = new ArrayList<DataCompare>();
compareTableViewer.setInput(compareList);
txtProgress = new StyledText(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
txtProgress.setEditable(false);
txtProgress.setWordWrap(true);
txtProgress.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 100));
txtProgress.setBackground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_BLACK));
txtProgress.setForeground(txtProgress.getDisplay().getSystemColor(SWT.COLOR_GREEN));
compareTableViewer.getTable().setToolTipText(Messages.msgYouCanSeeDetailDblclick);
compareTableViewer.getTable().addKeyListener(new KeyAdapter() {
public void keyReleased(KeyEvent e) {
if (e.character == ' ') {
TableItem[] items = compareTableViewer.getTable().getSelection();
if (items == null) {
return;
}
for (TableItem item : items) {
DataCompare dataCompare = (DataCompare) item.getData();
dataCompare.setUse(!dataCompare.isUse());
}
compareTableViewer.refresh();
}
}
});
compareTableViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
if (!refreshedRecordCounts) {
CommonUITool.openWarningBox(Messages.msgClickRefreshToEsimateDiff);
return;
}
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
DataCompare model = (DataCompare) selection.getFirstElement();
if (!model.isSameSchema()) {
CommonUITool.openWarningBox(Messages.msgTheSchemaDiff);
return;
}
if (model.getRecordsTarget() == -1) {
CommonUITool.openWarningBox(Messages.msgTargetNotFound);
return;
}
if (model.getRecordsSource() == 0 && model.getRecordsTarget() > 0) {
CommonUITool.openWarningBox(Messages.msgTargetNoData);
return;
}
if (model.getRecordsSource() == 0) {
CommonUITool.openWarningBox(Messages.msgNoDataToCompare);
return;
}
if (model.getProgressPosition() == 0) {
CommonUITool.openWarningBox(Messages.msgNotYetCompared);
return;
}
if (model.getNotMatches() == 0 && model.getNotExists() == 0) {
CommonUITool.openWarningBox(Messages.msgSameData);
return;
}
showDataCompareDetailEditor(model.getSchemaInfo());
}
});
}
use of org.eclipse.jface.viewers.CellEditor 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));
}
Aggregations