Search in sources :

Example 1 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project cogtool by cogtool.

the class DictionaryEditorUIModel method createEmptyRow.

public TableItem createEmptyRow(int index) {
    final TableItem emptyRow = new TableItem(dictTable, SWT.NONE, index);
    emptyRow.setText(GOAL_COL, "");
    emptyRow.setText(SEARCH_COL, "");
    emptyRow.setText(SIMIL_COL, "");
    emptyRow.setText(DATE_COL, "");
    TableEditor editor = new TableEditor(dictTable);
    editor.grabHorizontal = true;
    Combo algCombo = createAlgCombo(dictTable, dictionary.getCurrentAlgorithm(), algListener);
    algCombo.setData(emptyRow);
    emptyRow.setData(algCombo);
    editor.setEditor(algCombo, emptyRow, 3);
    return emptyRow;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Combo(org.eclipse.swt.widgets.Combo) TableEditor(org.eclipse.swt.custom.TableEditor)

Example 2 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class MultipleSurrogateSection method initTableItem.

/**
     * DOC hcw Comment method "initTableItem".
     * 
     * @param key
     * @param item
     */
private void initTableItem(final SurrogateKey key, final TableItem item) {
    item.setData(key);
    // text editor
    TableEditor editor = editorManager.createTextEditor(table, key.getColumn(), item, COLUMN_INDEX, new IPropertySetter<String>() {

        public void set(String value) {
            key.setColumn(value);
        }
    });
    // combo editor
    // final List<String> outputColumns = scdManager.getOutputColumnNames();
    // int index = editorManager.getComboIndex(outputColumns, key.getColumn());
    // final TableEditor editor = editorManager.createComboEditor(table,
    // outputColumns.toArray(new String[outputColumns.size()]), item, COLUMN_INDEX, index,
    // new IPropertySetter<Integer>() {
    //
    // public void set(Integer value) {
    // key.setColumn(outputColumns.get(value));
    // }
    // });
    editor.layout();
    TableEditor comboEditor = editorManager.createComboEditor(table, getScdManager().getSurrogateCreationTypeNames(), item, CREATION_INDEX, key.getCreation().getIndex(), new IPropertySetter<Integer>() {

        public void set(Integer value) {
            key.setCreation(SurrogateCreationType.getTypeByIndex(value));
            // remove value from model
            //$NON-NLS-1$
            key.setComplement("");
            creationComplement(value, key, item);
        }
    });
    creationComplement(key.getCreation().getIndex(), key, item);
}
Also used : TableEditor(org.eclipse.swt.custom.TableEditor)

Example 3 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class MavenVersionManagementProjectSettingPage method addItemElements.

@Override
protected void addItemElements(List<ItemVersionObject> elements) {
    if (elements == null || elements.isEmpty()) {
        return;
    }
    itemTable.setRedraw(false);
    for (final ItemVersionObject object : elements) {
        final TableItem tableItem = new TableItem(itemTable, SWT.CENTER);
        tableItem.setData(object);
        Item item = object.getItem();
        IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
        Image itemsImage = null;
        if (labelProvider instanceof NavigatorDecoratingLabelProvider) {
            NavigatorDecoratingLabelProvider navigatorProvider = (NavigatorDecoratingLabelProvider) labelProvider;
            itemsImage = navigatorProvider.getImage(object.getRepositoryNode());
        } else {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
            itemsImage = getItemsImage(CoreImageProvider.getIcon(itemType));
        }
        tableItem.setImage(itemsImage);
        tableItem.setText(item.getProperty().getLabel());
        // old version
        tableItem.setText(1, MavenVersionUtils.getItemMavenVersion(item.getProperty()));
        TableEditor versionEditor = null;
        if (fixedVersionButton.getSelection()) {
            tableItem.setText(2, appliedFixedVersion);
        } else if (useJobVersionButton.getSelection()) {
            String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(item.getProperty().getVersion());
            tableItem.setText(2, jobDefaultVersion);
            object.setNewVersion(jobDefaultVersion);
        } else {
            // new version
            versionEditor = new TableEditor(itemTable);
            Composite versionComposite = new Composite(itemTable, SWT.NONE);
            GridLayout layout = new GridLayout(1, false);
            layout.marginHeight = 0;
            layout.marginWidth = 0;
            layout.marginLeft = 0;
            layout.marginRight = 1;
            versionComposite.setLayout(layout);
            final Text text = new Text(versionComposite, SWT.CENTER | SWT.BORDER);
            GridData data = new GridData(GridData.FILL_BOTH);
            text.setLayoutData(data);
            String newVersion = object.getNewVersion();
            if (newVersion == null || "".equals(newVersion.trim())) {
                //$NON-NLS-1$
                newVersion = appliedFixedVersion;
                object.setNewVersion(newVersion);
            }
            text.setText(newVersion);
            checkVersionPattern(text, newVersion);
            text.addModifyListener(new ModifyListener() {

                @Override
                public void modifyText(ModifyEvent e) {
                    String version = text.getText();
                    checkVersionPattern(text, version);
                    object.setNewVersion(version);
                    checkValid();
                }
            });
            versionEditor.minimumWidth = itemTable.getColumn(2).getWidth();
            versionEditor.setEditor(versionComposite, tableItem, 2);
        }
        TableEditor delEditor = new TableEditor(itemTable);
        Label delLabel = new Label(itemTable, SWT.CENTER);
        delLabel.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
        delLabel.setImage(ImageProvider.getImage(EImage.DELETE_ICON));
        //$NON-NLS-1$
        delLabel.setToolTipText(Messages.getString("VersionManagementDialog.DeletedTip"));
        delLabel.pack();
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                checkedObjects.remove(object);
                removeTableItem(tableItem);
                refreshCheckedTreeView();
                checkButtonsState();
                checkButtonsState(false);
            }
        });
        delEditor.minimumWidth = 25;
        delEditor.horizontalAlignment = SWT.CENTER;
        delEditor.setEditor(delLabel, tableItem, 3);
        if (fixedVersionButton.getSelection() || useJobVersionButton.getSelection()) {
            tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { delEditor });
        } else if (versionEditor != null) {
            tableItem.setData(ITEM_EDITOR_KEY, new TableEditor[] { versionEditor, delEditor });
        }
        itemTable.setRedraw(true);
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) NavigatorDecoratingLabelProvider(org.eclipse.ui.internal.navigator.NavigatorDecoratingLabelProvider) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Text(org.eclipse.swt.widgets.Text) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage) TableEditor(org.eclipse.swt.custom.TableEditor) Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IBaseLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider) GridData(org.eclipse.swt.layout.GridData) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 4 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method removeTableItem.

private void removeTableItem(TableItem item) {
    if (item == null) {
        return;
    }
    TableEditor[] editors = (TableEditor[]) item.getData(ITEM_EDITOR_KEY);
    if (editors != null) {
        for (TableEditor editor : editors) {
            editor.getEditor().dispose();
            editor.dispose();
        }
    }
    item.dispose();
}
Also used : TableEditor(org.eclipse.swt.custom.TableEditor)

Example 5 with TableEditor

use of org.eclipse.swt.custom.TableEditor in project tdi-studio-se by Talend.

the class PromptDefaultValueDialog method createComboEditor.

private void createComboEditor(TableItem item, int column, String[] displayText, int selectIndex) {
    TableEditor editor = new TableEditor(table);
    final CCombo combo = new CCombo(table, SWT.READ_ONLY);
    for (String text : displayText) {
        combo.add(text);
    }
    combo.select(selectIndex);
    editor.grabHorizontal = true;
    editor.setEditor(combo, item, column);
    // editor.minimumWidth = combo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    editor.layout();
    editors.add(editor);
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) TableEditor(org.eclipse.swt.custom.TableEditor)

Aggregations

TableEditor (org.eclipse.swt.custom.TableEditor)62 TableItem (org.eclipse.swt.widgets.TableItem)28 GridData (org.eclipse.swt.layout.GridData)27 SelectionEvent (org.eclipse.swt.events.SelectionEvent)19 Point (org.eclipse.swt.graphics.Point)19 Button (org.eclipse.swt.widgets.Button)19 GridLayout (org.eclipse.swt.layout.GridLayout)18 Text (org.eclipse.swt.widgets.Text)17 Table (org.eclipse.swt.widgets.Table)15 Composite (org.eclipse.swt.widgets.Composite)14 Label (org.eclipse.swt.widgets.Label)14 CCombo (org.eclipse.swt.custom.CCombo)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Control (org.eclipse.swt.widgets.Control)11 TableColumn (org.eclipse.swt.widgets.TableColumn)11 Rectangle (org.eclipse.swt.graphics.Rectangle)10 SWT (org.eclipse.swt.SWT)8 MouseEvent (org.eclipse.swt.events.MouseEvent)8 Event (org.eclipse.swt.widgets.Event)8 Group (org.eclipse.swt.widgets.Group)8