Search in sources :

Example 16 with CellEditor

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);
        }
    });
}
Also used : CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) KeyEvent(org.eclipse.swt.events.KeyEvent) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) TableLayout(org.eclipse.jface.viewers.TableLayout)

Example 17 with CellEditor

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();
        }
    });
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TabItem(org.eclipse.swt.widgets.TabItem) Item(org.eclipse.swt.widgets.Item) ICellModifier(org.eclipse.jface.viewers.ICellModifier) ArrayList(java.util.ArrayList) List(java.util.List) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 18 with CellEditor

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);
        }
    });
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Item(org.eclipse.swt.widgets.Item) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ICellModifier(org.eclipse.jface.viewers.ICellModifier) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 19 with CellEditor

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());
        }
    });
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) KeyEvent(org.eclipse.swt.events.KeyEvent) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DataCompare(com.cubrid.common.ui.compare.data.model.DataCompare) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 20 with CellEditor

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));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) GridLayout(org.eclipse.swt.layout.GridLayout) TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) ICellEditorListener(org.eclipse.jface.viewers.ICellEditorListener) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

CellEditor (org.eclipse.jface.viewers.CellEditor)142 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)88 TableViewer (org.eclipse.jface.viewers.TableViewer)45 GridData (org.eclipse.swt.layout.GridData)44 Composite (org.eclipse.swt.widgets.Composite)37 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)35 ICellModifier (org.eclipse.jface.viewers.ICellModifier)32 GridLayout (org.eclipse.swt.layout.GridLayout)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)29 TableColumn (org.eclipse.swt.widgets.TableColumn)29 CheckboxCellEditor (org.eclipse.jface.viewers.CheckboxCellEditor)25 Table (org.eclipse.swt.widgets.Table)24 Button (org.eclipse.swt.widgets.Button)23 ArrayList (java.util.ArrayList)21 Label (org.eclipse.swt.widgets.Label)21 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)20 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 Text (org.eclipse.swt.widgets.Text)19 Map (java.util.Map)18 EditingSupport (org.eclipse.jface.viewers.EditingSupport)18