Search in sources :

Example 46 with StructuredSelection

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

the class MBeanSashForm method createSashFormControls.

/*
     * @see AbstractSashForm#createSashFormControls(SashForm, IActionBars)
     */
@Override
protected void createSashFormControls(SashForm sashForm, final IActionBars actionBars) {
    mBeanViewer = new MBeanFilteredTree(sashForm, section).getViewer();
    mBeanContentProvider = new MBeanContentProvider();
    mBeanViewer.setContentProvider(mBeanContentProvider);
    mBeanViewer.setLabelProvider(new MyDecoratingStyledCellLabelProvider());
    selectionChangedListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof StructuredSelection) {
                mBeanTabFolder.selectionChanged((StructuredSelection) selection);
            }
        }
    };
    mBeanViewer.addSelectionChangedListener(selectionChangedListener);
    mBeanViewer.setInput(new Object());
    mBeanTabFolder = new MBeanTabFolder(sashForm, section);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 47 with StructuredSelection

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

the class NotesPasteCommand method undo.

@SuppressWarnings("unchecked")
@Override
public void undo() {
    // remove the current selection
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    if (!multipleCommand) {
        viewer.deselectAll();
    }
    for (Note note : noteList) {
        process.removeNote(note);
    }
    // set the old selection active
    if (!multipleCommand) {
        StructuredSelection s = new StructuredSelection(oldSelection);
        viewer.setSelection(s);
    }
    process.checkStartNodes();
    process.checkProcess();
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Note(org.talend.designer.core.ui.editor.notes.Note) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 48 with StructuredSelection

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

the class OpenExistVersionProcessWizard method refreshNewJob.

protected boolean refreshNewJob() {
    if (alreadyEditedByUser) {
        return false;
    }
    boolean lastVersion = true;
    StructuredSelection selection = (StructuredSelection) mainPage.getSelection();
    if (selection != null && !selection.isEmpty()) {
        RepositoryNode node = (RepositoryNode) selection.getFirstElement();
        lastVersion = node.getObject().getVersion().equals(originalVersion);
        if (!lastVersion) {
            originalVersion = node.getObject().getVersion();
            String newVersion = mainPage.getNewVersion();
            processObject = node.getObject();
            processObject.getProperty().setVersion(newVersion);
        }
    }
    if (lastVersion) {
        getProperty().setVersion(mainPage.getNewVersion());
    }
    IProxyRepositoryFactory repositoryFactory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
    try {
        repositoryFactory.save(getProperty(), this.originaleObjectLabel, this.originalVersion);
        ExpressionPersistance.getInstance().jobNameChanged(originaleObjectLabel, processObject.getLabel());
        ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
        return true;
    } catch (PersistenceException e) {
        MessageBoxExceptionHandler.process(e);
        return false;
    }
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNode(org.talend.repository.model.RepositoryNode) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 49 with StructuredSelection

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

the class ShowCallersCalleesAction method selectionChanged.

/*
     * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent)
     */
@Override
public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (!(selection instanceof StructuredSelection)) {
        return;
    }
    Object element = ((StructuredSelection) selection).getFirstElement();
    if (element instanceof IMethodNode) {
        callesCalleesTargetNode = (IMethodNode) element;
        setEnabled(true);
    } else {
        setEnabled(false);
    }
}
Also used : IMethodNode(org.talend.designer.runtime.visualization.internal.core.cpu.IMethodNode) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 50 with StructuredSelection

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

the class NodesMoveCommond method execute.

@SuppressWarnings("unchecked")
@Override
public void execute() {
    // create the node container list to paste
    createNodeContainerList();
    AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
    // save old selection
    if (!multipleCommand) {
        oldSelection = new ArrayList<EditPart>();
        for (EditPart editPart : (List<EditPart>) viewer.getSelectedEditParts()) {
            oldSelection.add(editPart);
        }
        // remove the old selection
        viewer.deselectAll();
    }
    // creates the different nodes
    for (NodeContainer nodeContainer : nodeContainerList) {
        ((Process) process).addNodeContainer(nodeContainer);
    }
    // check that the created connections exists now, or create them if needed
    for (String newConnectionName : createdNames) {
        if (process.checkValidConnectionName(newConnectionName, true)) {
            process.addUniqueConnectionName(newConnectionName);
        }
    }
    process.checkStartNodes();
    process.checkProcess();
    // set the new node as the current selection
    if (!multipleCommand) {
        EditPart processPart = (EditPart) viewer.getRootEditPart().getChildren().get(0);
        if (processPart instanceof ProcessPart) {
            // can only be
            // ProcessPart but still
            // test
            List<EditPart> sel = new ArrayList<EditPart>();
            for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
                if (editPart instanceof SubjobContainerPart) {
                    for (EditPart subjobChildsPart : (List<EditPart>) editPart.getChildren()) {
                        if (subjobChildsPart instanceof NodeContainerPart) {
                            if (nodeContainerList.contains(((NodeContainerPart) subjobChildsPart).getModel())) {
                                NodePart nodePart = ((NodeContainerPart) subjobChildsPart).getNodePart();
                                if (nodePart != null) {
                                    sel.add(nodePart);
                                }
                            }
                        }
                    }
                }
                if (editPart instanceof NodePart) {
                    Node currentNode = (Node) editPart.getModel();
                    if (nodeContainerList.contains(currentNode.getNodeContainer())) {
                        sel.add(editPart);
                    }
                }
            }
            StructuredSelection s = new StructuredSelection(sel);
            viewer.setSelection(s);
        }
    }
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) AbstractMultiPageTalendEditor(org.talend.designer.core.ui.AbstractMultiPageTalendEditor) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) List(java.util.List) ArrayList(java.util.ArrayList) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

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