Search in sources :

Example 76 with IStructuredSelection

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

the class CamelEditorDropTargetListener method checkSelectionSource.

/**
     * Routelet and context types are validated
     * 
     * @return true if validated
     */
private boolean checkSelectionSource() {
    isContextSource = false;
    selectSourceList.clear();
    boolean isRouteletSource = false;
    LocalSelectionTransfer transfer = (LocalSelectionTransfer) getTransfer();
    IStructuredSelection selection = (IStructuredSelection) transfer.getSelection();
    Iterator iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof RepositoryNode) {
            RepositoryNode sourceNode = (RepositoryNode) obj;
            if (sourceNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.PROCESS_ROUTELET) {
                selectSourceList.add(obj);
                isRouteletSource = true;
            }
            Item item = sourceNode.getObject().getProperty().getItem();
            if (item instanceof ContextItem) {
                selectSourceList.add(obj);
                isContextSource = true;
            }
        } else if (obj instanceof PaletteEditPart) {
            selectSourceList.add(obj);
            Object newObject = ((CreateRequest) getTargetRequest()).getNewObject();
            if (newObject != null && newObject instanceof INode) {
                if (((INode) newObject).getComponent().getComponentType() == EComponentType.JOBLET) {
                    selectSourceList.add(newObject);
                    isRouteletSource = true;
                }
            }
        }
    }
    if (selectSourceList.size() == 0) {
        return false;
    }
    if (isRouteletSource) {
        List<String> routeletList = new ArrayList<String>();
        for (INode node : editor.getProcess().getGraphicalNodes()) {
            if (node.getComponent().getComponentType() == EComponentType.JOBLET) {
                routeletList.add(node.getComponent().getName());
            }
        }
        boolean isDuplicateRoutelet = false;
        String duplicatesName = "";
        for (Object object : selectSourceList) {
            if (object instanceof RepositoryNode) {
                RepositoryNode sourceNode = (RepositoryNode) object;
                if (sourceNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.PROCESS_ROUTELET) {
                    if (routeletList.contains(sourceNode.getProperties(EProperties.LABEL))) {
                        isDuplicateRoutelet = true;
                        //$NON-NLS-1$
                        duplicatesName += " ," + sourceNode.getProperties(EProperties.LABEL);
                    }
                }
            } else if (object instanceof INode) {
                INode node = (INode) object;
                if (node.getComponent().getComponentType() == EComponentType.JOBLET) {
                    if (routeletList.contains(node.getComponent().getName())) {
                        isDuplicateRoutelet = true;
                        //$NON-NLS-1$                            
                        duplicatesName += " ," + node.getComponent().getName();
                    }
                }
            }
        }
        if (isDuplicateRoutelet) {
            //$NON-NLS-1$
            MessageDialog.openInformation(//$NON-NLS-1$
            editor.getEditorSite().getShell(), //$NON-NLS-1$
            "Adding Routelet", //$NON-NLS-1$
            "Do not allow duplicate Routelets\nRoutelet \"" + duplicatesName.substring(2) + "\" already exist.");
            return false;
        }
    }
    return true;
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) PaletteEditPart(org.eclipse.gef.ui.palette.editparts.PaletteEditPart) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) Iterator(java.util.Iterator) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 77 with IStructuredSelection

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

the class JobScriptsExportWizard method init.

/*
     * (non-Javadoc) Method declared on IWorkbenchWizard.
     */
@Override
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    selection = currentSelection;
    List selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        selection = new StructuredSelection(selectedResources);
    }
    populateUIMessage();
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 78 with IStructuredSelection

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

the class PublishOnSpagoExportWizard method init.

/*
     * (non-Javadoc) Method declared on IWorkbenchWizard.
     */
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.selection = currentSelection;
    List selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.selection = new StructuredSelection(selectedResources);
    }
    //$NON-NLS-1$
    setWindowTitle(Messages.getString("PublishOnSpagoExportWizard.publishJob"));
    //        setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportzip_wiz.png"));//$NON-NLS-1$
    setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(IDEWorkbenchPlugin.IDE_WORKBENCH, //$NON-NLS-1$
    "$nl$/icons/full/wizban/exportzip_wiz.png"));
    setNeedsProgressMonitor(true);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 79 with IStructuredSelection

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

the class SpagicDeployWizard method init.

/*
     * (non-Javadoc) Method declared on IWorkbenchWizard.
     */
public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.selection = currentSelection;
    List selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.selection = new StructuredSelection(selectedResources);
    }
    //$NON-NLS-1$
    setWindowTitle(Messages.getString("SapgicDeployWizard.exporttospagic"));
    //        setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/exportzip_wiz.png"));//$NON-NLS-1$
    setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(IDEWorkbenchPlugin.IDE_WORKBENCH, //$NON-NLS-1$
    "$nl$/icons/full/wizban/exportzip_wiz.png"));
    setNeedsProgressMonitor(true);
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) List(java.util.List)

Example 80 with IStructuredSelection

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

the class JobCamelScriptsExportWizard method init.

public void init(IWorkbench workbench, IStructuredSelection currentSelection) {
    this.selection = currentSelection;
    List<?> selectedResources = IDE.computeSelectedResources(currentSelection);
    if (!selectedResources.isEmpty()) {
        this.selection = new StructuredSelection(selectedResources);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

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