Search in sources :

Example 6 with ComboBoxCellEditor

use of org.eclipse.jface.viewers.ComboBoxCellEditor in project tdi-studio-se by Talend.

the class AbstractHL7MetadataTableEditorView method configureTalendTypeColumn.

/**
     * DOC amaumont Comment method "initTalendTypeColumn".
     * 
     * @param tableViewerCreator
     * @param comboValueAdapter
     * @param arrayTalendTypes
     */
private TableViewerCreatorColumn configureTalendTypeColumn(final TableViewerCreator<B> tableViewerCreator) {
    CellEditorValueAdapter comboValueAdapter = null;
    ECodeLanguage codeLanguage = LanguageManager.getCurrentLanguage();
    if (codeLanguage == ECodeLanguage.JAVA) {
        comboValueAdapter = new JavaTypeComboValueAdapter<B>(JavaTypesManager.getDefaultJavaType(), getNullableAccessor());
    } else if (codeLanguage == ECodeLanguage.PERL) {
        comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor();
    }
    String[] arrayTalendTypes = new String[0];
    try {
        arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
    } catch (NoClassDefFoundError e) {
        // shouln't be happend
        // e.printStackTrace();
        ExceptionHandler.process(e);
    } catch (ExceptionInInitializerError e) {
        // shouln't be happend
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MetadataTableEditorView.TypleTitle"));
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.TypleTitle"));
    column.setId(ID_COLUMN_TYPE);
    column.setBeanPropertyAccessors(getTalendTypeAccessor());
    column.setModifiable(!isReadOnly());
    column.setWeight(10);
    column.setMinimumWidth(30);
    ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayTalendTypes, SWT.READ_ONLY);
    CCombo typeCombo = (CCombo) typeComboEditor.getControl();
    typeCombo.setEditable(false);
    column.setCellEditor(typeComboEditor, comboValueAdapter);
    return column;
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 7 with ComboBoxCellEditor

use of org.eclipse.jface.viewers.ComboBoxCellEditor in project tdi-studio-se by Talend.

the class XmlMapNodeDirectEditManager method initCellEditor.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
     */
@Override
protected void initCellEditor() {
    DirectEditType directEditType = cellAndType.get(getCellEditor());
    if (model instanceof AbstractNode) {
        final AbstractNode abstractNode = (AbstractNode) model;
        if (directEditType != null) {
            switch(directEditType) {
                case EXPRESSION:
                    String expression = abstractNode.getExpression() == null ? "" : abstractNode.getExpression();
                    getCellEditor().setValue(expression);
                    Text text = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
                    text.selectAll();
                    break;
                case NODE_NAME:
                    String variable = abstractNode.getName();
                    if (variable == null) {
                        variable = "";
                    }
                    getCellEditor().setValue(variable);
                    final Text nametext = (Text) ((TextCellEditor) getCellEditor()).getControl();
                    nametext.selectAll();
                    if (model instanceof VarNode) {
                        nametext.addModifyListener(new ModifyListener() {

                            @Override
                            public void modifyText(ModifyEvent e) {
                                List<VarNode> children = new ArrayList<VarNode>();
                                children.addAll(((VarTable) abstractNode.eContainer()).getNodes());
                                children.remove(model);
                                String message = XmlMapUtil.isValidColumnName(children, ((Text) e.widget).getText());
                                if (message != null) {
                                    nametext.setBackground(ColorConstants.red);
                                } else {
                                    nametext.setBackground(ColorConstants.white);
                                }
                            }
                        });
                    }
                    break;
                case VAR_NODE_TYPE:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(getTypeDisplayValue((VarNode) abstractNode));
                    }
                    break;
            }
        }
    } else if (model instanceof InputXmlTree) {
        InputXmlTree inputxmlTree = (InputXmlTree) model;
        if (directEditType != null) {
            switch(directEditType) {
                case EXPRESSION_FILTER:
                    String expressionFilter = inputxmlTree.getExpressionFilter();
                    if (expressionFilter == null) {
                        expressionFilter = "";
                    }
                    getCellEditor().setValue(expressionFilter);
                    Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
                    textarea.selectAll();
                    break;
                case LOOKUP_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(getLookupDisplayName(inputxmlTree.getLookupMode()));
                    }
                    break;
                case MATCH_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(getMatchModelDisplayName(inputxmlTree.getMatchingMode()));
                    }
                    break;
                case JOIN_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        String join = "";
                        if (inputxmlTree.isInnerJoin()) {
                            join = joinModel[0];
                        } else {
                            join = joinModel[1];
                        }
                        combo.setText(join);
                    }
                    break;
                case PERSISTENT_MODEL:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(inputxmlTree.isPersistent()));
                    }
                    break;
            }
        }
    } else if (model instanceof OutputXmlTree) {
        OutputXmlTree outputTree = (OutputXmlTree) model;
        if (directEditType != null) {
            switch(directEditType) {
                case EXPRESSION_FILTER:
                    String expressionFilter = outputTree.getExpressionFilter();
                    if (expressionFilter == null) {
                        expressionFilter = "";
                    }
                    getCellEditor().setValue(expressionFilter);
                    Text textarea = ((ExtendedTextCellEditor) getCellEditor()).getTextControl();
                    textarea.selectAll();
                    break;
                case OUTPUT_REJECT:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isReject()));
                    }
                    break;
                case LOOK_UP_INNER_JOIN_REJECT:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isRejectInnerJoin()));
                    }
                    break;
                case ALL_IN_ONE:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isAllInOne()));
                    }
                    break;
                case ENABLE_EMPTY_ELEMENT:
                    if (getCellEditor() instanceof ComboBoxCellEditor) {
                        CCombo combo = (CCombo) getCellEditor().getControl();
                        combo.setText(String.valueOf(outputTree.isEnableEmptyElement()));
                    }
            }
        }
    } else if (model instanceof XmlMapData) {
        XmlMapData xmlMapData = (XmlMapData) model;
        if (directEditType != null) {
            switch(directEditType) {
                case SERACH:
                    Text text = (Text) getCellEditor().getControl();
                    text.selectAll();
                    break;
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) ModifyListener(org.eclipse.swt.events.ModifyListener) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) Text(org.eclipse.swt.widgets.Text) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ModifyEvent(org.eclipse.swt.events.ModifyEvent) DirectEditType(org.talend.designer.gefabstractmap.part.directedit.DirectEditType) CCombo(org.eclipse.swt.custom.CCombo) List(java.util.List) ArrayList(java.util.ArrayList) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 8 with ComboBoxCellEditor

use of org.eclipse.jface.viewers.ComboBoxCellEditor in project tdi-studio-se by Talend.

the class OutputDataMapTableView method getMapSettingValueAccess.

@Override
protected IBeanPropertyAccessors<GlobalMapEntry, Object> getMapSettingValueAccess(final CellEditor cellEditor) {
    return new IBeanPropertyAccessors<GlobalMapEntry, Object>() {

        public Object get(GlobalMapEntry bean) {
            IDataMapTable parent = bean.getParent();
            OutputTable outputTable = (OutputTable) parent;
            if (cellEditor instanceof ComboBoxCellEditor) {
                ComboBoxCellEditor functComboBox = (ComboBoxCellEditor) cellEditor;
                functComboBox.setItems(new String[] { "true", "false" });
                if (OUTPUT_REJECT.equals(bean.getName())) {
                    return String.valueOf(outputTable.isReject());
                } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                    return String.valueOf(outputTable.isRejectInnerJoin());
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    functComboBox.setItems(new String[] { BUILT_IN, REPOSITORY });
                    return outputTable.isRepository() ? REPOSITORY : BUILT_IN;
                }
            } else if (cellEditor instanceof CustomDialogCellEditor) {
                CustomDialogCellEditor customDialogCellEditor = (CustomDialogCellEditor) cellEditor;
                if (OUTPUT_REJECT.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    return String.valueOf(outputTable.isReject());
                } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.BOOL);
                    return String.valueOf(outputTable.isRejectInnerJoin());
                } else if (SCHEMA_TYPE.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_TYPE);
                    enableDiaplayViewer(outputTable.isRepository());
                    return outputTable.isRepository() ? REPOSITORY : BUILT_IN;
                } else if (SCHEMA_ID.equals(bean.getName())) {
                    customDialogCellEditor.setType(CellValueType.SCHEMA_ID);
                    return getSchemaDisplayName(outputTable.getId());
                }
            }
            return "";
        }

        public void set(GlobalMapEntry bean, Object value) {
            if (value == null) {
                return;
            }
            IDataMapTable parent = bean.getParent();
            OutputTable outputTable = (OutputTable) parent;
            if (OUTPUT_REJECT.equals(bean.getName())) {
                outputTable.setReject(Boolean.valueOf(value.toString()));
            } else if (LOOK_UP_INNER_JOIN_REJECT.equals(bean.getName())) {
                outputTable.setRejectInnerJoin(Boolean.valueOf(value.toString()));
            } else if (SCHEMA_TYPE.equals(bean.getName())) {
                outputTable.setRepository(REPOSITORY.equals(value));
                showSchemaIDSetting(REPOSITORY.equals(value));
                enableDiaplayViewer(REPOSITORY.equals(value));
            } else if (SCHEMA_ID.equals(bean.getName())) {
                outputTable.setId(String.valueOf(value));
            }
            refreshCondensedImage(outputTable, bean.getName());
        }
    };
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 9 with ComboBoxCellEditor

use of org.eclipse.jface.viewers.ComboBoxCellEditor in project cubrid-manager by CUBRID.

the class EditVirtualTableDialog method createGeneralTabItem.

/**
	 * Create general tab item
	 *
	 * @param tabFolder the object of TabFolder
	 */
private void createGeneralTabItem(final TabFolder tabFolder) {
    final TabItem generalTabItem = new TabItem(tabFolder, SWT.NONE);
    generalTabItem.setText(Messages.infoGeneralTab);
    final Composite compositeGenaral = new Composite(tabFolder, SWT.NONE);
    GridLayout gridLayout = new GridLayout();
    compositeGenaral.setLayout(gridLayout);
    generalTabItem.setControl(compositeGenaral);
    createTableInformationGroup(compositeGenaral);
    if (database == null) {
        return;
    }
    final Label columnsLabel = new Label(compositeGenaral, SWT.NONE);
    columnsLabel.setText(Messages.lblColumn);
    // create attribute table
    columnTableView = new TableViewer(compositeGenaral, SWT.FULL_SELECTION | SWT.BORDER);
    columnTableView.setUseHashlookup(true);
    columnTableView.setColumnProperties(columnProperites);
    columnsTable = columnTableView.getTable();
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.heightHint = 189;
    columnsTable.setLayoutData(gdColumnsTable);
    columnsTable.setLinesVisible(true);
    columnsTable.setHeaderVisible(true);
    // The empty column
    final TableColumn emptyColumn = new TableColumn(columnsTable, SWT.NONE);
    emptyColumn.setWidth(0);
    // The flag column
    final TableColumn flagColumn = new TableColumn(columnsTable, SWT.RIGHT_TO_LEFT);
    flagColumn.setWidth(28);
    // NAME
    final TableColumn nameColumn = new TableColumn(columnsTable, SWT.NONE);
    nameColumn.setWidth(140);
    nameColumn.setText(Messages.tblColumnName);
    // DATATYPE
    final TableColumn dataTypeColumn = new TableColumn(columnsTable, SWT.NONE);
    dataTypeColumn.setWidth(120);
    dataTypeColumn.setText(Messages.tblColumnDataType);
    // DEFAULT
    final TableColumn defaultColumn = new TableColumn(columnsTable, SWT.NONE);
    defaultColumn.setWidth(98);
    defaultColumn.setText(Messages.tblColumnDefault);
    defaultColumn.setToolTipText(Messages.tblColumnDefaultHint);
    // AUTO INCREMENT
    final TableColumn autoIncrTableColumn = new TableColumn(columnsTable, SWT.NONE);
    autoIncrTableColumn.setAlignment(SWT.LEFT);
    autoIncrTableColumn.setWidth(100);
    autoIncrTableColumn.setText(Messages.tblColumnAutoIncr);
    autoIncrTableColumn.setToolTipText(Messages.tblColumnAutoIncrHint);
    // NOT NULL
    final TableColumn notNullColumn = new TableColumn(columnsTable, SWT.NONE);
    notNullColumn.setWidth(60);
    notNullColumn.setText(Messages.tblColumnNotNull);
    notNullColumn.setAlignment(SWT.LEFT);
    notNullColumn.setToolTipText(Messages.tblColumnNotNullHint);
    // PK
    final TableColumn pkColumn = new TableColumn(columnsTable, SWT.NONE);
    pkColumn.setAlignment(SWT.CENTER);
    pkColumn.setWidth(75);
    pkColumn.setText(Messages.tblColumnPK);
    // UK
    final TableColumn uniqueColumn = new TableColumn(columnsTable, SWT.NONE);
    uniqueColumn.setWidth(55);
    uniqueColumn.setText(Messages.tblColumnUnique);
    uniqueColumn.setAlignment(SWT.LEFT);
    uniqueColumn.setToolTipText(Messages.tblColumnUniqueHint);
    // SHARED
    sharedColumn = new TableColumn(columnsTable, SWT.NONE);
    sharedColumn.setWidth(50);
    sharedColumn.setResizable(false);
    sharedColumn.setText(Messages.tblColumnShared);
    sharedColumn.setAlignment(SWT.LEFT);
    sharedColumn.setToolTipText(Messages.tblColumnSharedHint);
    if (supportCharset) {
        final TableColumn collationColumn = new TableColumn(columnsTable, SWT.NONE);
        collationColumn.setWidth(120);
        collationColumn.setText(Messages.tblColumnColumnCollation);
        collationColumn.setAlignment(SWT.LEFT);
    }
    if (erSchema.isPhysicModel()) {
        final TableColumn descColumn = new TableColumn(columnsTable, SWT.NONE);
        descColumn.setWidth(180);
        descColumn.setText(Messages.tblColumnColumnDesc);
        descColumn.setAlignment(SWT.LEFT);
    }
    boolean canEdit = true;
    if (!this.isNewTableFlag() && !this.isSupportChange()) {
        canEdit = false;
    }
    attrContentProvider = new AttributeContentProvider();
    attrLabelProvider = new ERAttributeLabelProvider(database.getDatabaseInfo(), getNewSchemaInfo(), canEdit, editorAdaptor, erSchema.isPhysicModel());
    columnTableView.setContentProvider(attrContentProvider);
    columnTableView.setLabelProvider(attrLabelProvider);
    CellEditor[] cellEditor = new CellEditor[columnProperites.length];
    {
        int index = 0;
        // Empty
        cellEditor[index++] = null;
        // Flag
        cellEditor[index++] = null;
        // NAME
        cellEditor[index++] = new TextCellEditor(columnsTable);
        // DATATYPE
        cellEditor[index++] = new DataTypeCellEditor((Composite) columnsTable, listDataTypes(), editorAdaptor);
        // DEFAULT
        cellEditor[index++] = new TextCellEditor(columnsTable);
        // AUTO INCREMENT
        cellEditor[index++] = new AutoIncrementCellEditor(columnsTable, editorAdaptor);
        // NOT NULL
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // PK
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // UK
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // SHARD
        cellEditor[index++] = new CheckboxCellEditor(columnsTable);
        // COLLATION
        if (supportCharset) {
            cellEditor[index++] = new ComboBoxCellEditor(columnsTable, getCollationArray(), SWT.READ_ONLY);
        }
        // MEMO
        cellEditor[index++] = erSchema.isPhysicModel() ? new TextCellEditor(columnsTable) : null;
    }
    columnTableView.setCellEditors(cellEditor);
    ERAttributeCellModifier modifier = new ERAttributeCellModifier(editorAdaptor, erSchema.isPhysicModel());
    columnTableView.setCellModifier(modifier);
    loadColumnData();
    // Create button
    final Composite btnRowComposite = new Composite(compositeGenaral, SWT.NONE);
    btnRowComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 2;
        layout.marginWidth = 5;
        btnRowComposite.setLayout(layout);
    }
    final Composite optComposite = new Composite(btnRowComposite, SWT.NONE);
    optComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    {
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginWidth = 0;
        optComposite.setLayout(layout);
    }
    final Composite btnComposite = new Composite(btnRowComposite, SWT.NONE);
    btnComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    {
        GridLayout layout = new GridLayout();
        layout.marginRight = 0;
        layout.numColumns = 6;
        layout.marginWidth = 0;
        btnComposite.setLayout(layout);
    }
    final Button setPkButton = new Button(btnComposite, SWT.NONE);
    setPkButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    setPkButton.setText(Messages.btnPK);
    setPkButton.addSelectionListener(new PkBtnListenerOnGeneTab(isNewTableFlag));
    final GridData gdUpDown = new GridData(60, SWT.DEFAULT);
    upColumnBtn = new Button(btnComposite, SWT.NONE);
    upColumnBtn.setLayoutData(gdUpDown);
    upColumnBtn.setEnabled(false);
    upColumnBtn.setText(Messages.btnUp);
    upColumnBtn.addSelectionListener(new UpBtnListenerOnGeneTab());
    downColumnBtn = new Button(btnComposite, SWT.DOWN);
    downColumnBtn.setLayoutData(gdUpDown);
    downColumnBtn.setEnabled(false);
    downColumnBtn.setText(Messages.btnDown);
    downColumnBtn.addSelectionListener(new DownBtnListenerOnGeneTab());
    final Button addButton = new Button(btnComposite, SWT.NONE);
    final GridData gdAddButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gdAddButton.horizontalIndent = 10;
    addButton.setLayoutData(gdAddButton);
    addButton.setText(Messages.btnAddColumn);
    addButton.addSelectionListener(new AddBtnListenerOnGeneTab());
    deleteColumnBtn = new Button(btnComposite, SWT.NONE);
    final GridData gdDeleteButton = new GridData(SWT.LEFT, SWT.CENTER, false, false);
    gdDeleteButton.horizontalIndent = 10;
    deleteColumnBtn.setLayoutData(gdDeleteButton);
    deleteColumnBtn.setEnabled(false);
    deleteColumnBtn.setText(Messages.btnDelColumn);
    deleteColumnBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            deleteColumn();
        }
    });
    columnsTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            handleSelectionChangeInColumnTable();
        }
    });
    buildColumnTableMenu();
}
Also used : CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) ERAttributeLabelProvider(com.cubrid.common.ui.er.editor.ERAttributeLabelProvider) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) DataTypeCellEditor(com.cubrid.common.ui.cubrid.table.editor.DataTypeCellEditor) AutoIncrementCellEditor(com.cubrid.common.ui.cubrid.table.editor.AutoIncrementCellEditor) Label(org.eclipse.swt.widgets.Label) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AttributeContentProvider(com.cubrid.common.ui.cubrid.table.editor.AttributeContentProvider) AutoIncrementCellEditor(com.cubrid.common.ui.cubrid.table.editor.AutoIncrementCellEditor) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) ERAttributeCellModifier(com.cubrid.common.ui.er.editor.ERAttributeCellModifier) TableColumn(org.eclipse.swt.widgets.TableColumn) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) TabItem(org.eclipse.swt.widgets.TabItem) GridData(org.eclipse.swt.layout.GridData) DataTypeCellEditor(com.cubrid.common.ui.cubrid.table.editor.DataTypeCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 10 with ComboBoxCellEditor

use of org.eclipse.jface.viewers.ComboBoxCellEditor 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

ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)25 CellEditor (org.eclipse.jface.viewers.CellEditor)15 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)13 CCombo (org.eclipse.swt.custom.CCombo)10 Composite (org.eclipse.swt.widgets.Composite)8 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)8 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)8 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 SelectionEvent (org.eclipse.swt.events.SelectionEvent)7 List (java.util.List)6 GridData (org.eclipse.swt.layout.GridData)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 Label (org.eclipse.swt.widgets.Label)6 HashMap (java.util.HashMap)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 Button (org.eclipse.swt.widgets.Button)4 Text (org.eclipse.swt.widgets.Text)4 IBeanPropertyAccessors (org.talend.commons.utils.data.bean.IBeanPropertyAccessors)4 IConnection (org.talend.core.model.process.IConnection)4