Search in sources :

Example 81 with IStructuredSelection

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

the class CamelDependenciesPanel method moveUp.

private void moveUp() {
    ManifestItem selected = (ManifestItem) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
    List input = (List) tableViewer.getInput();
    int index = input.indexOf(selected);
    int size = input.size();
    int targetIndex = index - 1;
    if (targetIndex < 0 || ((ManifestItem) input.get(targetIndex)).isBuiltIn()) {
        targetIndex = size - 1;
    }
    input.remove(selected);
    input.add(targetIndex, selected);
    tableViewer.refresh();
    tableViewer.setSelection(new StructuredSelection(selected));
    tableViewer.getTable().showSelection();
    fireDependenciesChangedListener();
}
Also used : ManifestItem(org.talend.designer.camel.dependencies.core.model.ManifestItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 82 with IStructuredSelection

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

the class ComponentSettingsView method createPartControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    this.parent = parent;
    tabFactory.initComposite(parent, true);
    tabFactory.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            TalendPropertyTabDescriptor descriptor = (TalendPropertyTabDescriptor) selection.getFirstElement();
            if (descriptor == null) {
                return;
            }
            if (currentSelectedTab != null && (!currentSelectedTab.getData().equals(descriptor.getData()) || currentSelectedTab.getCategory() != descriptor.getCategory())) {
                for (Control curControl : tabFactory.getTabComposite().getChildren()) {
                    curControl.dispose();
                }
            }
            if (element == null || !element.equals(descriptor.getData()) || currentSelectedTab == null || currentSelectedTab.getCategory() != descriptor.getCategory() || selectedPrimary) {
                element = (Element) descriptor.getData();
                currentSelectedTab = descriptor;
                if (descriptor.getData() instanceof ConnectionLabel) {
                    createDynamicComposite(tabFactory.getTabComposite(), ((ConnectionLabel) descriptor.getData()).getConnection(), descriptor.getCategory());
                } else {
                    createDynamicComposite(tabFactory.getTabComposite(), (Element) descriptor.getData(), descriptor.getCategory());
                }
                selectedPrimary = false;
            }
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Element(org.talend.core.model.process.Element) IElement(org.talend.core.model.process.IElement) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TalendPropertyTabDescriptor(org.talend.core.ui.properties.tab.TalendPropertyTabDescriptor) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel)

Example 83 with IStructuredSelection

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

the class MemoryRuntimeComposite method initContextInput.

@SuppressWarnings("unchecked")
private void initContextInput() {
    List<IContext> contextList = (List<IContext>) viewPart.getContextComposite().getContextComboInput();
    if (contextList != null) {
        contextCombo.setSelection(new StructuredSelection(contextList.get(0)));
        contextCombo.setInput(contextList);
        ComboViewer processContextComboViewer = viewPart.getContextComposite().getContextComboViewer();
        IContext selectedContext = (IContext) ((IStructuredSelection) processContextComboViewer.getSelection()).getFirstElement();
        for (int i = 0; i < contextList.size(); i++) {
            if (contextList.get(i).getName().equals(selectedContext.getName())) {
                contextCombo.getCombo().select(i);
            }
        }
        contextCombo.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                viewPart.getContextComposite().runSelectionChange(event);
            }
        });
    } else {
        contextCombo.getCombo().setEnabled(false);
    }
}
Also used : IContext(org.talend.core.model.process.IContext) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) List(java.util.List) ArrayList(java.util.ArrayList) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Point(org.eclipse.swt.graphics.Point)

Example 84 with IStructuredSelection

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

the class JobVMArgumentsComposite method removePressed.

private void removePressed() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.isEmpty()) {
        return;
    }
    for (Object obj : selection.toArray()) {
        list.remove(obj);
    }
    viewer.refresh();
    doSave();
    selectionChanged();
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 85 with IStructuredSelection

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

the class JobVMArgumentsComposite method editItem.

protected void editItem(ISelection sel) {
    IStructuredSelection selection = (IStructuredSelection) sel;
    String existing = (String) selection.getFirstElement();
    String value = getExistingInputObject(existing.trim());
    if (value != null) {
        int indexOf = list.indexOf(existing);
        list.remove(existing);
        list.add(indexOf, value);
        viewer.refresh();
        doSave();
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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