Search in sources :

Example 41 with TextCellEditor

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

the class FilterColumnDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite createDialogArea = (Composite) super.createDialogArea(parent);
    createDialogArea.setLayout(new GridLayout(2, false));
    createDialogArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    tabView = CheckboxTableViewer.newCheckList(createDialogArea, SWT.FULL_SELECTION);
    tab = tabView.getTable();
    Composite btnComposite = new Composite(createDialogArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginTop = 15;
    btnComposite.setLayout(layout);
    btnComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    checkAll = new Button(btnComposite, SWT.PUSH);
    //$NON-NLS-1$
    checkAll.setText(Messages.getString("FilterTraceColumnAction.SelectAll"));
    checkAll.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    checkNo = new Button(btnComposite, SWT.PUSH);
    //$NON-NLS-1$
    checkNo.setText(Messages.getString("FilterTraceColumnAction.UnselectAll"));
    checkNo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
    TableColumn tableColumn = new TableColumn(tab, SWT.NONE);
    //$NON-NLS-1$
    tableColumn.setText(Messages.getString("FilterTraceColumnAction.Column"));
    tableColumn.setWidth(100);
    // PTODO if enable trace condition, only active this.
    // tableColumn = new TableColumn(tab, SWT.NONE);
    // tableColumn.setText(Messages.getString("FilterTraceColumnAction.Condition")); //$NON-NLS-1$
    // tableColumn.setWidth(200);
    tab.setHeaderVisible(true);
    tab.setLinesVisible(true);
    tabView.setContentProvider(ArrayContentProvider.getInstance());
    tabView.setLabelProvider(new TableLabelProvider());
    tabView.setInput(conn.getMetadataTable().clone());
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 150;
    gridData.minimumHeight = 150;
    gridData.widthHint = 180;
    gridData.minimumWidth = 180;
    tab.setLayoutData(gridData);
    checkAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            tabView.setAllChecked(true);
        }
    });
    checkNo.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            tabView.setAllChecked(false);
        }
    });
    cellEditor = new CellEditor[2];
    cellEditor[0] = null;
    cellEditor[1] = new TextCellEditor(tab);
    tabView.setColumnProperties(coluName);
    tabView.setCellEditors(cellEditor);
    tabView.setCellModifier(new TableModify(tabView));
    initChecked();
    return createDialogArea;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 42 with TextCellEditor

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

the class HL7OutputUI method addXMLViewer.

/**
     * create xml viewer.
     *
     * @param mainComposite
     * @param form
     * @param width
     * @param height
     */
private void addXMLViewer(final Composite mainComposite, final int width, final int height) {
    // Group Schema Viewer
    Group group = Form.createGroup(mainComposite, 1, "Linker Target", height);
    // group.setBackgroundMode(SWT.INHERIT_FORCE);
    xmlViewer = new TreeViewer(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    xmlViewer.getControl().setLayoutData(gridData);
    xmlViewer.setUseHashlookup(true);
    Tree tree = xmlViewer.getTree();
    if (canModify || isRespo) {
        tree.setEnabled(false);
    }
    tree.setLinesVisible(true);
    tree.setBackground(tree.getDisplay().getSystemColor(SWT.COLOR_WHITE));
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("HL7 Structure");
    column1.setWidth(170);
    // Related Column
    TreeColumn column2 = new TreeColumn(tree, SWT.CENTER);
    column2.setText("Related Column");
    column2.setWidth(100);
    TreeColumn column3 = new TreeColumn(tree, SWT.CENTER);
    column3.setText("Node Status");
    column3.setWidth(90);
    TreeColumn column4 = new TreeColumn(tree, SWT.CENTER);
    column4.setText("Default Value");
    column4.setWidth(90);
    tree.setHeaderVisible(true);
    // tree.setBackgroundMode(SWT.INHERIT_NONE);
    HL7TargetTreeViewerProvider provider = new HL7TargetTreeViewerProvider();
    xmlViewer.setLabelProvider(provider);
    xmlViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(Object element, String property) {
            HL7TreeNode node = (HL7TreeNode) element;
            if (property.equals("C1")) {
                if (node.getLabel() != null && node.getLabel().length() > 0) {
                    return true;
                }
            }
            if (property.equals("C4")) {
                if (node.getDefaultValue() != null && node.getDefaultValue().length() > 0) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public Object getValue(Object element, String property) {
            HL7TreeNode node = (HL7TreeNode) element;
            if (property.equals("C1")) {
                return node.getLabel();
            }
            if (property.equals("C4")) {
                return node.getDefaultValue();
            }
            return null;
        }

        @Override
        public void modify(Object element, String property, Object value) {
            TreeItem treeItem = (TreeItem) element;
            HL7TreeNode node = (HL7TreeNode) treeItem.getData();
            if (property.equals("C1")) {
                if (value != null && value.toString().length() == 0) {
                    value = node.getLabel();
                }
                node.setLabel((String) value);
            }
            if (property.equals("C4")) {
                node.setDefaultValue((String) value);
            }
            xmlViewer.refresh(node);
        }
    });
    //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    xmlViewer.setColumnProperties(new String[] { "C1", "C2", "C3", "C4" });
    CellEditor editor = new TextCellEditor(xmlViewer.getTree());
    editor.addListener(new DialogErrorXMLLabelCellEditor(editor, "C1"));
    // add by wzhang for bug 8572. set Default value column to be edit.
    CellEditor editorDefault = new TextCellEditor(xmlViewer.getTree());
    editorDefault.addListener(new DialogErrorXMLLabelCellEditor(editorDefault, "C4"));
    xmlViewer.setCellEditors(new CellEditor[] { editor, null, null, editorDefault });
    xmlViewer.setContentProvider(provider);
    xmlViewer.setInput(this.hl7Manager.getTreeData());
    xmlViewer.expandAll();
    createAction();
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            HL7OutputUI.this.fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(xmlViewer.getControl());
    xmlViewer.getControl().setMenu(menu);
    xmlViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
        // TODO Auto-generated method stub
        }
    });
    refreshXMLViewer(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) TreeColumn(org.eclipse.swt.widgets.TreeColumn) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Tree(org.eclipse.swt.widgets.Tree) HL7TargetTreeViewerProvider(org.talend.designer.hl7.ui.edit.HL7TargetTreeViewerProvider) HL7TreeNode(org.talend.designer.hl7.ui.data.HL7TreeNode) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 43 with TextCellEditor

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

the class AbstractHL7MetadataTableEditorView method configureDefaultColumn.

/**
     * DOC amaumont Comment method "configureDefaultColumn".
     * 
     * @param tableViewerCreator
     */
protected void configureDefaultColumn(TableViewerCreator<B> tableViewerCreator) {
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MetadataTableEditorView.DefaultTitle"));
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.DefaultTitle"));
    column.setId(ID_COLUMN_DEFAULT);
    column.setBeanPropertyAccessors(getDefaultValueAccessor());
    column.setWeight(8);
    column.setModifiable(!isReadOnly());
    column.setMinimumWidth(30);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    column.setCellEditor(new TextCellEditor(tableViewerCreator.getTable()));
}
Also used : TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 44 with TextCellEditor

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

the class AbstractHL7MetadataTableEditorView method configureDbColumnName.

/**
     * DOC amaumont Comment method "configureNameColumn".
     * 
     * @param tableViewerCreator
     */
protected void configureDbColumnName(TableViewerCreator<B> tableViewerCreator) {
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setId(ID_COLUMN_DBCOLUMNNAME);
    //$NON-NLS-1$ 
    column.setTitle("Mapping Column");
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.ColumnTitle"));
    column.setBeanPropertyAccessors(getDbColumnNameAccessor());
    column.setWeight(25);
    column.setModifiable(!isReadOnly());
    column.setMinimumWidth(45);
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
    column.setCellEditor(cellEditor);
    column.setColumnCellModifier(new ColumnCellModifier(column) {

        @Override
        public boolean canModify(Object bean) {
            return super.canModify(bean) && canModifyDBColumn(bean);
        }
    });
    column.setCellEditorAppliedListener(new ITableCellValueModifiedListener() {

        public void cellValueModified(TableCellValueModifiedEvent e) {
            linker.getMainui().redrawLinkers();
            linker.getBackgroundRefresher().refreshBackground();
        }
    });
    if (!dbColumnNameWritable) {
        column.setColorProvider(new IColumnColorProvider() {

            public Color getBackgroundColor(Object bean) {
                return READONLY_CELL_BG_COLOR;
            }

            public Color getForegroundColor(Object bean) {
                return null;
            }
        });
    }
}
Also used : Color(org.eclipse.swt.graphics.Color) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) TableCellValueModifiedEvent(org.talend.commons.ui.runtime.swt.tableviewer.behavior.TableCellValueModifiedEvent) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider) ITableCellValueModifiedListener(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ITableCellValueModifiedListener) ColumnCellModifier(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)

Example 45 with TextCellEditor

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

the class AbstractHL7MetadataTableEditorView method configureNameColumn.

/**
     * DOC amaumont Comment method "configureNameColumn".
     * 
     * @param tableViewerCreator
     */
protected void configureNameColumn(TableViewerCreator<B> tableViewerCreator) {
    TableViewerCreatorColumn column;
    column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setId(ID_COLUMN_NAME);
    //$NON-NLS-1$
    column.setTitle("User Column(Click to edit)");
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.ColumnTitle"));
    column.setBeanPropertyAccessors(getLabelAccessor());
    final Image imageKey = ImageProvider.getImage(EImage.KEY_ICON);
    final Image imageEmpty = org.talend.commons.ui.runtime.image.ImageProvider.getImage(EImage.EMPTY);
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
    column.setCellEditor(cellEditor);
    cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {

        @Override
        public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
        }

        @Override
        public String validateValue(String newValue, int beanPosition) {
            return validateColumnName(newValue, beanPosition);
        }
    });
    column.setImageProvider(new IColumnImageProvider() {

        public Image getImage(Object element) {
            if (getKeyAccesor().get((B) element)) {
                return imageKey;
            } else {
                return imageEmpty;
            }
        }
    });
    column.setWeight(25);
    column.setModifiable(!isReadOnly());
    column.setMinimumWidth(45);
    // final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreator.getTable());
    // cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {
    //
    // @Override
    // public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state)
    // {
    // }
    //
    // @Override
    // public String validateValue(String newValue, int beanPosition) {
    // return validateColumnName(newValue, beanPosition);
    // }
    //
    // });
    // column.setCellEditor(cellEditor);
    nameColumn = column;
}
Also used : IColumnImageProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnImageProvider) CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Aggregations

TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)61 CellEditor (org.eclipse.jface.viewers.CellEditor)46 GridData (org.eclipse.swt.layout.GridData)22 ICellModifier (org.eclipse.jface.viewers.ICellModifier)21 SelectionEvent (org.eclipse.swt.events.SelectionEvent)21 Composite (org.eclipse.swt.widgets.Composite)21 GridLayout (org.eclipse.swt.layout.GridLayout)19 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)15 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)15 TableViewer (org.eclipse.jface.viewers.TableViewer)14 Label (org.eclipse.swt.widgets.Label)14 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)14 Map (java.util.Map)13 Button (org.eclipse.swt.widgets.Button)12 HashMap (java.util.HashMap)11 Item (org.eclipse.swt.widgets.Item)11 TableColumn (org.eclipse.swt.widgets.TableColumn)10 TableItem (org.eclipse.swt.widgets.TableItem)10 Text (org.eclipse.swt.widgets.Text)10 Group (org.eclipse.swt.widgets.Group)8