Search in sources :

Example 56 with IStructuredSelection

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

the class AttributeSelectionDialog method okPressed.

/*
     * @see Dialog#okPressed()
     */
@Override
protected void okPressed() {
    ISelection selection = viewer.getSelection();
    if (!(selection instanceof IStructuredSelection)) {
        return;
    }
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    for (Object item : structuredSelection.toArray()) {
        if (!(item instanceof AttributeNode)) {
            continue;
        }
        AttributeNode node = (AttributeNode) item;
        MBeanAttribute mBeanAttribute = new MBeanAttribute(node.getObjectName(), node.getQualifiedName(), node.getRgb());
        selectedAttributes.add(mBeanAttribute);
    }
    super.okPressed();
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 57 with IStructuredSelection

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

the class AttributeSelectionDialog method createMBeanViewer.

/**
     * Creates the MBean viewer.
     * 
     * @param parent The parent composite
     */
private void createMBeanViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    GridLayout layout = new GridLayout(3, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer = new MyFilteredTree(composite).getViewer();
    AttributeContentProvider mBeanContentProvider = new AttributeContentProvider();
    viewer.setContentProvider(mBeanContentProvider);
    viewer.setLabelProvider(new MyDecoratingStyledCellLabelProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            viewerSlectionChanged((IStructuredSelection) event.getSelection());
        }
    });
    viewer.setInput(jvm);
    mBeanContentProvider.refresh(jvm);
    viewer.refresh();
    viewer.expandToLevel(2);
    new Label(composite, SWT.NONE).setText(Messages.colorLabel);
    colorSelector = createColorSelector(composite);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 58 with IStructuredSelection

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

the class ConfigureChartDialog method createAttributesViewer.

/**
     * Creates the attributes viewer.
     * 
     * @param parent The parent composite
     * @return The attribute viewer
     */
private TreeViewer createAttributesViewer(Composite parent) {
    TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.setContentProvider(new MBeanAttributeContentProvider());
    viewer.setLabelProvider(new MBeanAttributeLabelProvider(viewer));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            viewerSlectionChanged((IStructuredSelection) event.getSelection());
        }
    });
    configureTree(viewer.getTree());
    viewer.setInput(attributes.toArray(new MBeanAttribute[attributes.size()]));
    return viewer;
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 59 with IStructuredSelection

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

the class AddListDialog method createAllTypeDialog.

private void createAllTypeDialog() {
    IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
    if (selection.size() == 1) {
        Object obj = selection.getFirstElement();
        if (obj instanceof ParameterInfo) {
            ParameterInfo info = (ParameterInfo) obj;
            if (info.getName().contains("anyType")) {
                AllTypeDialog alltype;
                try {
                    alltype = new AllTypeDialog(parentShell, info, URLValue, serverConfig);
                    if (alltype.open() == Window.OK) {
                        String selectedName = alltype.getSelectedName();
                        Map<String, String> labelAndNameSpaceMap = alltype.getLabelAndNameSpaceMap();
                        if (selectedName.contains("simpletype")) {
                            String namespace = labelAndNameSpaceMap.get(selectedName);
                            String[] ret = getNameSpaceAndType(namespace);
                            ParameterInfo newChild = new ParameterInfo();
                            newChild.setName(selectedName);
                            newChild.setType(selectedName.split(":")[1]);
                            newChild.setParent(info);
                            info.getParameterInfos().clear();
                            if (info.getName().indexOf("{") > 0) {
                                info.setName(info.getName().substring(0, info.getName().indexOf("{")));
                            }
                            info.setName(info.getName() + "{" + ret[0] + "," + ret[1] + "}");
                            info.getParameterInfos().add(newChild);
                            treeViewer.refresh();
                        } else if (selectedName.contains("complextype")) {
                            String namespace = labelAndNameSpaceMap.get(selectedName);
                            String[] ret = getNameSpaceAndType(namespace);
                            ParameterInfo selectParameterInfo = alltype.getSelectedParaInfo();
                            info.getParameterInfos().clear();
                            if (info.getName().indexOf("{") > 0) {
                                info.setName(info.getName().substring(0, info.getName().indexOf("{")));
                            }
                            info.setName(info.getName() + "{" + ret[0] + "," + ret[1] + "}");
                            List<ParameterInfo> childAttributes = selectParameterInfo.getParameterInfos();
                            for (ParameterInfo child : childAttributes) {
                                info.getParameterInfos().add(child);
                                child.setParent(info);
                            }
                            treeViewer.refresh();
                        }
                    }
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Example 60 with IStructuredSelection

use of org.eclipse.jface.viewers.IStructuredSelection 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)

Aggregations

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)600 ISelection (org.eclipse.jface.viewers.ISelection)177 GridData (org.eclipse.swt.layout.GridData)97 ArrayList (java.util.ArrayList)88 Composite (org.eclipse.swt.widgets.Composite)80 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)78 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)77 SelectionEvent (org.eclipse.swt.events.SelectionEvent)74 GridLayout (org.eclipse.swt.layout.GridLayout)73 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)67 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)60 List (java.util.List)56 TableViewer (org.eclipse.jface.viewers.TableViewer)51 Button (org.eclipse.swt.widgets.Button)51 Iterator (java.util.Iterator)46 IResource (org.eclipse.core.resources.IResource)42 RepositoryNode (org.talend.repository.model.RepositoryNode)41 IFile (org.eclipse.core.resources.IFile)40 TreeViewer (org.eclipse.jface.viewers.TreeViewer)39 Label (org.eclipse.swt.widgets.Label)38