Search in sources :

Example 41 with ISelection

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

the class SWTResourcesPage method createSashFormControls.

/*
     * @see AbstractSashForm#createSashFormControls(SashForm, IActionBars)
     */
@Override
protected void createSashFormControls(SashForm sashForm, IActionBars actionBars) {
    resourceFilteredTree = new SWTResourceFilteredTree(sashForm, actionBars);
    TreeViewer resourceViewer = resourceFilteredTree.getViewer();
    resourceViewer.setContentProvider(new SWTResourceContentProvider(resourceViewer));
    resourceViewer.setLabelProvider(new SWTResourceLabelProvider());
    resourceViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                selection = null;
            }
            stackTraceViewer.setInput(selection);
        }
    });
    stackTraceViewer = new StackTraceViewer(sashForm, actionBars);
}
Also used : StackTraceViewer(org.talend.designer.runtime.visualization.internal.ui.properties.StackTraceViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 42 with ISelection

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

the class CreateFTPConnectionAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.actions.AContextualAction#doRun()
     */
@Override
protected void doRun() {
    RepositoryNode dbConnectionNode = getCurrentRepositoryNode();
    if (isToolbar()) {
        if (dbConnectionNode != null && dbConnectionNode.getContentType() != ERepositoryObjectType.METADATA_FILE_FTP) {
            dbConnectionNode = null;
        }
        if (dbConnectionNode == null) {
            dbConnectionNode = getRepositoryNodeForDefault(ERepositoryObjectType.METADATA_FILE_FTP);
        }
    }
    RepositoryNode metadataNode = dbConnectionNode.getParent();
    if (metadataNode != null) {
        // Force focus to the repositoryView and open Metadata and DbConnection nodes
        IRepositoryView viewPart = getViewPart();
        if (viewPart != null) {
            viewPart.setFocus();
            viewPart.expand(metadataNode, true);
            viewPart.expand(dbConnectionNode, true);
        }
    }
    FTPConnection connection = null;
    IPath pathToSave = null;
    // Define the RepositoryNode, by default Metadata/DbConnection
    RepositoryNode node = dbConnectionNode;
    ISelection selection = null;
    // When the userSelection is an element of metadataNode, use it !
    if (!isToolbar()) {
        Object userSelection = ((IStructuredSelection) getSelection()).getFirstElement();
        if (userSelection instanceof RepositoryNode) {
            switch(((RepositoryNode) userSelection).getType()) {
                case REPOSITORY_ELEMENT:
                case SIMPLE_FOLDER:
                case SYSTEM_FOLDER:
                    node = (RepositoryNode) userSelection;
                    break;
            }
        }
        selection = getSelection();
    }
    boolean creation = false;
    // Define the repositoryObject DatabaseConnection and his pathToSave
    switch(node.getType()) {
        case REPOSITORY_ELEMENT:
            // pathToSave = null;
            connection = (FTPConnection) ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
            creation = false;
            break;
        case SIMPLE_FOLDER:
            pathToSave = RepositoryNodeUtilities.getPath(node);
            connection = ConnectionFactory.eINSTANCE.createFTPConnection();
            creation = true;
            break;
        case SYSTEM_FOLDER:
            //$NON-NLS-1$
            pathToSave = new Path("");
            connection = ConnectionFactory.eINSTANCE.createFTPConnection();
            creation = true;
            break;
    }
    // Init the content of the Wizard
    init(node);
    FTPWizard ftpWizard;
    if (isToolbar()) {
        ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, node, getExistingNames());
        ftpWizard.setToolBar(true);
    } else {
        ftpWizard = new FTPWizard(PlatformUI.getWorkbench(), creation, selection, getExistingNames());
    }
    // Open the Wizard
    WizardDialog wizardDialog = new WizardDialog(Display.getCurrent().getActiveShell(), ftpWizard);
    wizardDialog.setPageSize(700, 550);
    wizardDialog.create();
    wizardDialog.open();
    IRepositoryView view = getViewPart();
    if (view != null) {
        view.expand(dbConnectionNode, true);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) FTPConnectionItem(org.talend.core.model.properties.FTPConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryView(org.talend.repository.ui.views.IRepositoryView) FTPConnection(org.talend.core.model.metadata.builder.connection.FTPConnection) FTPWizard(org.talend.repository.ftp.ui.wizards.FTPWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 43 with ISelection

use of org.eclipse.jface.viewers.ISelection 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 44 with ISelection

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

the class CreateNewJobAction method getSelectedRepositoryNode.

private RepositoryNode getSelectedRepositoryNode() {
    ISelection selection = getSelection();
    if (selection == null) {
        return null;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    return (RepositoryNode) obj;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) PortRepositoryObject(org.talend.repository.services.utils.PortRepositoryObject) OperationRepositoryObject(org.talend.repository.services.utils.OperationRepositoryObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 45 with ISelection

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

the class OpenJobAction method init.

@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
    if (selection.size() != 1) {
        setEnabled(false);
        return;
    }
    IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
    if (!ERepositoryObjectType.SERVICESOPERATION.equals((ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE)) || !WSDLUtils.isOperationInBinding(node)) {
        // not enabled if the operation doesn't define in binding
        setEnabled(false);
        return;
    }
    String jobId = getReferenceJobId(node);
    if (jobId == null) {
        setEnabled(false);
        return;
    }
    IRepositoryNode repoNode = RepositorySeekerManager.getInstance().searchRepoViewNode(jobId, false);
    jobNode = repoNode == null ? null : (RepositoryNode) repoNode;
    if (jobNode == null) {
        removeReferenecJobId(node);
        setEnabled(false);
        return;
    }
    final IStructuredSelection jobSelection = new StructuredSelection(jobNode);
    setSpecialSelection(new ISelectionProvider() {

        public void setSelection(ISelection arg0) {
        }

        public void removeSelectionChangedListener(ISelectionChangedListener arg0) {
        }

        public ISelection getSelection() {
            return jobSelection;
        }

        public void addSelectionChangedListener(ISelectionChangedListener arg0) {
        }
    });
    super.init(viewer, jobSelection);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)306 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)183 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)44 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)41 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)40 GridData (org.eclipse.swt.layout.GridData)40 SelectionEvent (org.eclipse.swt.events.SelectionEvent)34 ArrayList (java.util.ArrayList)33 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)30 IEditorPart (org.eclipse.ui.IEditorPart)30 Composite (org.eclipse.swt.widgets.Composite)29 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)29 WizardDialog (org.eclipse.jface.wizard.WizardDialog)26 IResource (org.eclipse.core.resources.IResource)24 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)24 TableViewer (org.eclipse.jface.viewers.TableViewer)24 IFile (org.eclipse.core.resources.IFile)23 GridLayout (org.eclipse.swt.layout.GridLayout)23 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)23 TreeViewer (org.eclipse.jface.viewers.TreeViewer)22