Search in sources :

Example 31 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 32 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 33 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 34 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)

Example 35 with StructuredSelection

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

the class ProjectSettingsPreferenceDialog method openPage.

@Override
public boolean openPage(String nodeId, Object data) {
    if (this instanceof IWorkbenchPreferenceContainer) {
        ((IWorkbenchPreferenceContainer) this).openPage(nodeId, data);
    } else {
        // impl by self
        final IPreferenceNode node = findNodeMatching(nodeId);
        if (node != null) {
            getTreeViewer().setSelection(new StructuredSelection(node));
            showPage(node);
        }
        IPreferencePage page = getCurrentPage();
        if (page instanceof PreferencePage) {
            ((PreferencePage) page).applyData(data);
        }
        return true;
    }
    return false;
}
Also used : PreferencePage(org.eclipse.jface.preference.PreferencePage) IPreferencePage(org.eclipse.jface.preference.IPreferencePage) IWorkbenchPreferenceContainer(org.eclipse.ui.preferences.IWorkbenchPreferenceContainer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IPreferencePage(org.eclipse.jface.preference.IPreferencePage) IPreferenceNode(org.eclipse.jface.preference.IPreferenceNode)

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