Search in sources :

Example 6 with StructuredSelection

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

the class ConfigureChartDialog method addAttributes.

/**
     * Adds the attributes.
     */
void addAttributes() {
    AttributeSelectionDialog dialog = new AttributeSelectionDialog(getShell(), jvm);
    if (dialog.open() == OK) {
        List<MBeanAttribute> selectedAttributes = dialog.getSelectedAttributes();
        if (selectedAttributes.size() == 0) {
            return;
        }
        attributes.addAll(selectedAttributes);
        attributesViewer.setInput(attributes.toArray(new MBeanAttribute[attributes.size()]));
        attributesViewer.setSelection(new StructuredSelection(selectedAttributes.get(0)), true);
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 7 with StructuredSelection

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

the class LoadChartSetDialog method createChartSetViewer.

/**
     * Creates the chart set viewer.
     * 
     * @param parent The parent composite
     * @return The chart set viewer
     */
private TableViewer createChartSetViewer(Composite parent) {
    final TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 300;
    viewer.getTable().setLayoutData(gridData);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element.equals(defaultChartSet)) {
                return NLS.bind(Messages.defaultChartSet, defaultChartSet);
            }
            return super.getText(element);
        }
    });
    viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            Object element = ((StructuredSelection) selection).getFirstElement();
            if (deleteButton != null) {
                deleteButton.setEnabled(!selection.isEmpty() && !predefinedChartSets.contains(element));
            }
            if (element != null) {
                chartSet = element.toString();
            } else {
                viewer.setSelection(new StructuredSelection(chartSet));
            }
        }
    });
    viewer.setSelection(new StructuredSelection(defaultChartSet));
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 8 with StructuredSelection

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

the class TalendImportUtil method openJob.

// private static void doSelection(List<String> itemIds) {
// List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
// RepositorySeekerManager repSeekerManager = RepositorySeekerManager.getInstance();
// for (String itemId : itemIds) {
// IRepositoryNode repoViewNode = repSeekerManager.searchRepoViewNode(itemId);
// if (repoViewNode != null) {
// nodes.add(repoViewNode);
// }
// }
//
// IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
// repositoryView.getViewer().setSelection(new StructuredSelection(nodes));
// }
public static void openJob(String jobName) {
    if (jobName == null) {
        return;
    }
    if (isJobAlreadyOpened(jobName)) {
        return;
    }
    try {
        // can't open deleted jobs
        List<IRepositoryViewObject> repViewObjectList = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS, false, false);
        Iterator<IRepositoryViewObject> repoViewObjectIter = repViewObjectList.iterator();
        while (repoViewObjectIter.hasNext()) {
            final IRepositoryViewObject current = repoViewObjectIter.next();
            if (jobName.equals(current.getLabel())) {
                Display.getDefault().syncExec(new Runnable() {

                    @Override
                    public void run() {
                        final List<IRepositoryNode> jobs = new ArrayList<IRepositoryNode>(1);
                        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(current.getId());
                        jobs.add(repositoryNode);
                        IRepositoryView repositoryView = RepositoryManagerHelper.findRepositoryView();
                        repositoryView.getViewer().setSelection(new StructuredSelection(jobs));
                        openJobs(jobs);
                    }
                });
                break;
            }
        }
    } catch (Throwable e) {
        CommonExceptionHandler.process(e);
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryView(org.talend.repository.ui.views.IRepositoryView)

Example 9 with StructuredSelection

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

the class TestComposite method installListener.

private void installListener() {
    buttonAddVar.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            List<Variable> input = (List<Variable>) variableTableViewer.getInput();
            input.add(new Variable(input.size()));
            variableTableViewer.refresh();
        }
    });
    buttonRemoveVar.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            ISelection selection = variableTableViewer.getSelection();
            List<Variable> list = ((List<Variable>) variableTableViewer.getInput());
            if (!selection.isEmpty() && selection instanceof StructuredSelection) {
                Object[] vars = ((StructuredSelection) selection).toArray();
                for (Object var : vars) {
                    list.remove(var);
                    variableTableViewer.refresh();
                }
            } else if (!list.isEmpty()) {
                list.remove(list.size() - 1);
                variableTableViewer.refresh();
            }
        }
    });
    testButton.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            new ExpressionTestMain(CategoryComposite.getSelectedFunction(), testResultText);
        }
    });
    clearButton.addMouseListener(new MouseAdapter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
             */
        @Override
        public void mouseUp(MouseEvent e) {
            //$NON-NLS-1$
            testResultText.setText("");
        }
    });
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) Variable(org.talend.commons.runtime.model.expressionbuilder.Variable) MouseAdapter(org.eclipse.swt.events.MouseAdapter) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExpressionTestMain(org.talend.expressionbuilder.test.shadow.ExpressionTestMain) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 10 with StructuredSelection

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

the class ImportDemoProjectItemsPage method checkStateChanged.

@Override
public void checkStateChanged(CheckStateChangedEvent event) {
    if (event.getChecked()) {
        wizardSelectionViewer.setSelection(new StructuredSelection(event.getElement()));
        setPageComplete(true);
    } else {
        // descriptionBrowser.setText("");
        if (getCheckedElements().size() == 0) {
            setPageComplete(false);
        } else {
            setPageComplete(true);
        }
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Aggregations

StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1376 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)782 ArrayList (java.util.ArrayList)212 ISelection (org.eclipse.jface.viewers.ISelection)177 Composite (org.eclipse.swt.widgets.Composite)167 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)133 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)128 GridData (org.eclipse.swt.layout.GridData)112 List (java.util.List)93 IFile (org.eclipse.core.resources.IFile)92 GridLayout (org.eclipse.swt.layout.GridLayout)87 SelectionEvent (org.eclipse.swt.events.SelectionEvent)82 Label (org.eclipse.swt.widgets.Label)79 TreeViewer (org.eclipse.jface.viewers.TreeViewer)78 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)68 EObject (org.eclipse.emf.ecore.EObject)67 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)66 TableViewer (org.eclipse.jface.viewers.TableViewer)64 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)61 AdapterFactoryContentProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider)60