Search in sources :

Example 36 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class Type3Section method removeDragItems.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.scd.ui.IDragDropDelegate#removeDragItems()
     */
public void removeDragItems(String data) {
    TableItem[] items = table.getItems();
    //$NON-NLS-1$
    String[] toRemove = data.split("\\|");
    for (int i = 1; i < toRemove.length; i++) {
        // skip items[0], which is the number of selected elements
        TableItem itemToRemove = null;
        for (TableItem item : items) {
            if (toRemove[i].equals(item.getText())) {
                itemToRemove = item;
                break;
            }
        }
        if (itemToRemove != null) {
            tableModel.remove(itemToRemove.getData());
            if (scdManager.getTypeTable().contains(toRemove[i])) {
                scdManager.getTypeTable().remove(toRemove[i]);
            }
            editorManager.removeEditors(itemToRemove);
        }
    }
    table.remove(table.getSelectionIndices());
    tableViewer.refresh();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point)

Example 37 with TableItem

use of org.eclipse.swt.widgets.TableItem 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 38 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method refreshCheckedTreeView.

protected void refreshCheckedTreeView() {
    List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
    for (TableItem item : itemTable.getItems()) {
        Object data = item.getData();
        if (data instanceof ItemVersionObject) {
            nodes.add(((ItemVersionObject) data).getRepositoryNode());
        }
    }
    treeViewer.setCheckedElements(nodes.toArray());
// treeViewer.refresh();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 39 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method removeItemElements.

protected void removeItemElements(List<ItemVersionObject> objects) {
    itemTable.setRedraw(false);
    TableItem[] items = itemTable.getItems();
    for (TableItem item : items) {
        if (objects.contains(item.getData())) {
            removeTableItem(item);
        }
    }
    itemTable.setRedraw(true);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem)

Example 40 with TableItem

use of org.eclipse.swt.widgets.TableItem in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method refreshCheckedTreeView.

private void refreshCheckedTreeView() {
    List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
    for (TableItem item : itemTable.getItems()) {
        Object data = item.getData();
        if (data instanceof RepositoryObject) {
            nodes.add((RepositoryNode) ((RepositoryObject) data).getRepositoryNode());
        }
    }
    treeViewer.setCheckedElements(nodes.toArray());
// treeViewer.refresh();
}
Also used : RepositoryObject(org.talend.core.model.repository.RepositoryObject) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)475 Point (org.eclipse.swt.graphics.Point)136 Table (org.eclipse.swt.widgets.Table)125 TableColumn (org.eclipse.swt.widgets.TableColumn)79 SelectionEvent (org.eclipse.swt.events.SelectionEvent)73 GridData (org.eclipse.swt.layout.GridData)70 GridLayout (org.eclipse.swt.layout.GridLayout)61 Composite (org.eclipse.swt.widgets.Composite)56 ArrayList (java.util.ArrayList)55 Image (org.eclipse.swt.graphics.Image)55 Button (org.eclipse.swt.widgets.Button)53 Rectangle (org.eclipse.swt.graphics.Rectangle)52 Label (org.eclipse.swt.widgets.Label)51 Shell (org.eclipse.swt.widgets.Shell)49 Color (org.eclipse.swt.graphics.Color)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)43 Text (org.eclipse.swt.widgets.Text)42 FillLayout (org.eclipse.swt.layout.FillLayout)40 Test (org.junit.Test)39 SelectionListener (org.eclipse.swt.events.SelectionListener)36