Search in sources :

Example 56 with StructuredSelection

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

the class StatsAndLogsTabPropertySection method setInput.

public void setInput(final IWorkbenchPart workbenchPart, final ISelection selection) {
    Object input = ((IStructuredSelection) selection).getFirstElement();
    if (input instanceof RepositoryNode) {
        // This is the only RepositoryNode that displays the Job.
        Process process = StatsAndLogsSectionFilter.getProcessPartByRepositoryNode((RepositoryNode) input);
        if (process == null) {
            return;
        }
        // make a mock processPart here for super.setInput();
        ProcessPart part = new ProcessPart();
        part.setModel(process);
        StructuredSelection sel = new StructuredSelection(part);
        super.setInput(workbenchPart, sel);
    } else {
        super.setInput(workbenchPart, selection);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Process(org.talend.designer.core.ui.editor.process.Process) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 57 with StructuredSelection

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

the class TalendConnectionCreationTool method selectAddedObject.

protected void selectAddedObject(EditPartViewer viewer, Collection objects) {
    final List editparts = new ArrayList();
    final EditPart[] primaryEP = new EditPart[1];
    for (Iterator i = objects.iterator(); i.hasNext(); ) {
        Object object = i.next();
        if (object instanceof IAdaptable) {
            Object editPart = viewer.getEditPartRegistry().get(((IAdaptable) object).getAdapter(View.class));
            if (editPart instanceof GraphicalEditPart) {
                editparts.add(editPart);
            }
        }
    }
    if (!editparts.isEmpty()) {
        viewer.setSelection(new StructuredSelection(editparts));
        // automatically put the first shape into edit-mode
        Display.getCurrent().asyncExec(new Runnable() {

            @Override
            public void run() {
                if (primaryEP[0] == null) {
                    primaryEP[0] = (EditPart) editparts.get(0);
                }
                // code is being executed. (see RATLC00527114)
                if (primaryEP[0].isActive()) {
                    primaryEP[0].performRequest(new Request("direct edit"));
                }
            }
        });
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractEditPart(org.eclipse.gef.editparts.AbstractEditPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Request(org.eclipse.gef.Request) View(org.eclipse.gmf.runtime.notation.View) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 58 with StructuredSelection

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

the class ShowInTimelineAction method selectionChanged.

/*
     * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
     */
@Override
public void selectionChanged(SelectionChangedEvent event) {
    IActiveJvm jvm = section.getJvm();
    if (!(event.getSelection() instanceof StructuredSelection) || jvm == null || !jvm.isConnected()) {
        setEnabled(false);
        return;
    }
    Object[] elements = ((StructuredSelection) event.getSelection()).toArray();
    if (elements.length == 0) {
        setEnabled(false);
        return;
    }
    boolean enabled = true;
    selections.clear();
    for (Object element : elements) {
        MBeanAttribute attribute = getMBeanAttribute(element);
        if (attribute != null) {
            selections.add(attribute);
        }
        if (!getEnabled(element)) {
            enabled = false;
        }
    }
    setEnabled(enabled);
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MBeanAttribute(org.talend.designer.runtime.visualization.internal.ui.properties.timeline.MBeanAttribute)

Example 59 with StructuredSelection

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

the class NewJvmConnectionWizard method performFinish.

/*
     * @see Wizard#performFinish()
     */
@Override
public boolean performFinish() {
    // add active JVM
    IActiveJvm jvm = addActiveJvm();
    if (jvm == null) {
        return false;
    }
    // select item on JVM explorer
    viewer.refresh();
    viewer.setSelection(new StructuredSelection(jvm));
    // connect to JVM
    try {
        int period = Activator.getDefault().getPreferenceStore().getInt(IConstants.UPDATE_PERIOD);
        jvm.connect(period);
    } catch (JvmCoreException e) {
        Activator.log(NLS.bind(Messages.connectJvmFailedMsg, jvm.getPid()), e);
    }
    page.storeDialogSettings();
    return true;
}
Also used : IActiveJvm(org.talend.designer.runtime.visualization.IActiveJvm) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 60 with StructuredSelection

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

the class UseDynamicJobSelectionDialog method setCheckingNodes.

private void setCheckingNodes() {
    final IContentProvider contentProvider = getItemsTreeViewer().getContentProvider();
    final Object input = getItemsTreeViewer().getInput();
    if (contentProvider instanceof ITreeContentProvider && input instanceof ProjectRepositoryNode && getNeedCheckedjobs() != null && getNeedCheckedjobs().length > 0) {
        ITreeContentProvider cnfContentProvider = (ITreeContentProvider) contentProvider;
        List<IRepositoryNode> checkingNodes = new ArrayList<IRepositoryNode>();
        List<String> needCheckedJobIds = new ArrayList(Arrays.asList(getNeedCheckedjobs()));
        final ProjectRepositoryNode root = (ProjectRepositoryNode) input;
        final RepositoryNode rootRepositoryNode = root.getRootRepositoryNode(getSupportType());
        if (rootRepositoryNode == null) {
            return;
        }
        withReferenceProjects(cnfContentProvider, rootRepositoryNode, needCheckedJobIds, checkingNodes);
        // set check for node
        getItemsTreeViewer().setCheckedElements(checkingNodes.toArray());
        // select and will expand the selected node auto
        getItemsTreeViewer().setSelection(new StructuredSelection(checkingNodes), true);
        // let scroll bar on top
        getItemsTreeViewer().setSelection(new StructuredSelection(rootRepositoryNode));
        getItemsTreeViewer().setSelection(StructuredSelection.EMPTY);
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)256 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)133 ArrayList (java.util.ArrayList)59 ISelection (org.eclipse.jface.viewers.ISelection)43 List (java.util.List)35 GridData (org.eclipse.swt.layout.GridData)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)25 Composite (org.eclipse.swt.widgets.Composite)24 SelectionEvent (org.eclipse.swt.events.SelectionEvent)21 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)20 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)20 IFile (org.eclipse.core.resources.IFile)19 Label (org.eclipse.swt.widgets.Label)19 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)18 GridLayout (org.eclipse.swt.layout.GridLayout)18 Shell (org.eclipse.swt.widgets.Shell)17 IViewPart (org.eclipse.ui.IViewPart)15 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)15 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)14 Button (org.eclipse.swt.widgets.Button)14