Search in sources :

Example 41 with IStructuredSelection

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

the class UIManager method moveRecord.

public void moveRecord(TreeViewer schemaTreeViewer, boolean left) {
    if (schemaTreeViewer == null) {
        return;
    }
    ISelection selection = schemaTreeViewer.getSelection();
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof SchemasKeyData) {
            SchemasKeyData data = (SchemasKeyData) element;
            SchemasKeyData parent = data.getParent();
            if (left) {
                SchemasKeyData grandfather = parent.getParent();
                if (grandfather != null) {
                    // not in root.
                    List<SchemasKeyData> children = grandfather.getChildren();
                    int index = -1;
                    for (int i = 0; i < children.size(); i++) {
                        if (children.get(i) == parent) {
                            index = i;
                            break;
                        }
                    }
                    if (index > -1) {
                        int index2 = index + 1;
                        if (index2 > children.size()) {
                            grandfather.addChild(data);
                        } else {
                            grandfather.addChild(index2, data);
                        }
                    }
                }
            } else {
                SchemasKeyData sibling = null;
                for (SchemasKeyData skd : parent.getChildren()) {
                    if (skd == data) {
                        break;
                    } else {
                        sibling = skd;
                    }
                }
                if (sibling != null) {
                    sibling.addChild(data);
                }
            }
            schemaTreeViewer.refresh();
        }
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SchemasKeyData(org.talend.designer.filemultischemas.data.SchemasKeyData)

Example 42 with IStructuredSelection

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

the class HL7UI method initTableViewer.

private void initTableViewer() {
    List<IMetadataTable> tables = externalNode.getMetadataList();
    for (IMetadataTable table : tables) {
        MetadataTable loaded = ConvertionHelper.convert(table);
        List<MetadataColumn> columns = loaded.getColumns();
        String trueTableName = table.getLabel();
        if (trueTableName.split("_").length > 2) {
            // get true table name from node draged from repository
            //$NON-NLS-N$  
            trueTableName = trueTableName.split("_")[1];
        }
        if (hl7Manager.getSchemaRelationMap().get(trueTableName) != null) {
            hl7Manager.getSchemaRelationMap().remove(trueTableName);
            hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
        } else {
            hl7Manager.getSchemaRelationMap().put(trueTableName, columns);
        }
        MetadataColumn[] array = new MetadataColumn[columns.size()];
        int i = 0;
        for (MetadataColumn column : columns) {
            MetadataColumn newColumn = copyColumn(column);
            array[i] = newColumn;
            i++;
        }
        if (this.getMetaTableViewer().getSelection() instanceof IStructuredSelection) {
            IStructuredSelection selection = (IStructuredSelection) this.getMetaTableViewer().getSelection();
            if (selection.getFirstElement() != null) {
                String name = ((IModel) selection.getFirstElement()).getDisplayName();
                if (name.equals(trueTableName)) {
                    for (int j = 0; j < array.length; j++) {
                        hl7SchemaEditorView.getMetadataEditor().add(array[j]);
                    }
                // hl7SchemaEditorView.getMetadataEditor().addAll(columns);
                }
            }
        }
    }
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 43 with IStructuredSelection

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

the class HL7MetadataEmfTableEditorView method getDbColumnNameAccessor.

@Override
protected IBeanPropertyAccessors<MetadataColumn, String> getDbColumnNameAccessor() {
    return new IBeanPropertyAccessors<MetadataColumn, String>() {

        public String get(MetadataColumn bean) {
            return bean.getOriginalField();
        }

        public void set(MetadataColumn bean, String value) {
            bean.setOriginalField(value);
            IStructuredSelection selection = (IStructuredSelection) ((HL7MultiSchemaUI) linker.getMainui()).getMetaTableViewer().getSelection();
            Object selectedObj = selection.getFirstElement();
            if (selectedObj != null) {
                String key = ((IModel) selectedObj).getDisplayName();
                linker.getManager().updateRelationMapping(key, bean, false);
            // if (columns.indexOf(bean) > 0) {
            // columns.get(columns.indexOf(bean)).setOriginalField(value);
            // }
            }
        }
    };
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) IModel(org.talend.designer.hl7.model.IModel) HL7MultiSchemaUI(org.talend.designer.hl7.ui.HL7MultiSchemaUI) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 44 with IStructuredSelection

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

the class CpuDumpEditor method createHotSpotsPage.

/**
     * Creates the hot spots page.
     */
private void createHotSpotsPage() {
    Composite panel = new Composite(getContainer(), SWT.NONE);
    panel.setLayout(new FillLayout());
    final HotSpotsFilteredTree hotSpotsFilteredTree = new HotSpotsFilteredTree(panel, getEditorSite().getActionBars());
    TreeViewer hotSpotsViewer = hotSpotsFilteredTree.getViewer();
    hotSpotsViewer.setContentProvider(new AbstractContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICpuModel) {
                return ((ICpuModel) inputElement).getHotSpotRoots();
            }
            return new Object[0];
        }
    });
    hotSpotsViewer.setLabelProvider(new HotSpotsLabelProvider(hotSpotsFilteredTree));
    hotSpotsViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            hotSpotsFilteredTree.updateStatusLine((IStructuredSelection) event.getSelection());
        }
    });
    hotSpotsViewer.setUseHashlookup(true);
    hotSpotsViewer.setInput(cpuModel);
    hotSpotsFilteredTree.sortColumn(hotSpotsViewer.getTree().getColumn(1));
    int page = addPage(panel);
    trees.put(hotSpotsFilteredTree, page);
    setPageText(page, Messages.hotSpotsPageLabel);
    setPageImage(page, getHotSpotsImage());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) HotSpotsFilteredTree(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.HotSpotsFilteredTree) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) HotSpotsLabelProvider(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.HotSpotsLabelProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICpuModel(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModel) AbstractContentProvider(org.talend.designer.runtime.visualization.internal.ui.properties.cpu.AbstractContentProvider)

Example 45 with IStructuredSelection

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

the class EditJSONPropertiesAction method init.

public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = selection.size() == 1;
    if (canWork) {
        Object o = ((IStructuredSelection) selection).getFirstElement();
        if (o instanceof RepositoryNode) {
            RepositoryNode node = (RepositoryNode) o;
            switch(node.getType()) {
                case REPOSITORY_ELEMENT:
                    if (node.getObjectType() == JSONRepositoryNodeType.JSON) {
                        canWork = true;
                    } else {
                        canWork = false;
                    }
                    break;
                default:
                    canWork = false;
                    break;
            }
            if (canWork) {
                canWork = (node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED);
            }
            if (canWork) {
                canWork = isLastVersion(node);
            }
        }
    }
    setEnabled(canWork);
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode)

Aggregations

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)600 ISelection (org.eclipse.jface.viewers.ISelection)177 GridData (org.eclipse.swt.layout.GridData)97 ArrayList (java.util.ArrayList)88 Composite (org.eclipse.swt.widgets.Composite)80 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)78 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)77 SelectionEvent (org.eclipse.swt.events.SelectionEvent)74 GridLayout (org.eclipse.swt.layout.GridLayout)73 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)67 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)60 List (java.util.List)56 TableViewer (org.eclipse.jface.viewers.TableViewer)51 Button (org.eclipse.swt.widgets.Button)51 Iterator (java.util.Iterator)46 IResource (org.eclipse.core.resources.IResource)42 RepositoryNode (org.talend.repository.model.RepositoryNode)41 IFile (org.eclipse.core.resources.IFile)40 TreeViewer (org.eclipse.jface.viewers.TreeViewer)39 Label (org.eclipse.swt.widgets.Label)38