Example usage for org.eclipse.jface.viewers IStructuredSelection toList

List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IStructuredSelection toList.

Prototype

public List toList();

Source Link

Document

Returns the elements in this selection as a List.

Usage

From source file:eu.geclipse.batch.ui.views.BatchJobView.java

License:Open Source License

/**
 * Get a list of all currently selected tokens.
 * /*  w  w w. j  a v a  2  s .c o  m*/
 * @return A list containing all currently selected tokens.
 */
public List<IBatchJobInfo> getSelectedJobs() {
    IStructuredSelection selection = (IStructuredSelection) this.jobList.getSelection();
    List<?> selectionList = selection.toList();
    List<IBatchJobInfo> result = new ArrayList<IBatchJobInfo>();
    for (Object element : selectionList) {
        if (element instanceof IBatchJobInfo) {
            IBatchJobInfo token = (IBatchJobInfo) element;
            result.add(token);
        }
    }
    return result;
}

From source file:eu.geclipse.jsdl.ui.preference.ApplicationParametersPreferencePage.java

License:Open Source License

/**
 * Returns {@link GridApplicationParameters} corresponding to entry selected
 * in table./*w  w w. j a  va2 s .  c  o m*/
 * 
 * @return ApplicationSpecificObject selected in table
 */
public List<GridApplicationParameters> getSelectedAppSpecificObjects() {
    List<GridApplicationParameters> selectedASO = new ArrayList<GridApplicationParameters>();
    IStructuredSelection selection = (IStructuredSelection) this.appsViewer.getSelection();
    for (Object selObject : selection.toList()) {
        if (selObject instanceof GridApplicationParameters) {
            selectedASO.add((GridApplicationParameters) selObject);
        }
    }
    return selectedASO;
}

From source file:eu.geclipse.servicejob.ui.actions.ServiceJobComputingAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    this.selecedComputingEls = new ArrayList<IGridResource>();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sselection = (IStructuredSelection) selection;
        if (!sselection.isEmpty()) {
            if (sselection.getFirstElement() instanceof IGridComputing) {
                this.selectedProject = ((IGridComputing) sselection.getFirstElement()).getProject();
                for (Object selObj : sselection.toList()) {
                    if (selObj instanceof IGridComputing && ((IGridComputing) selObj).getProject() != null
                            && ((IGridComputing) selObj).getProject().equals(this.selectedProject)) {
                        this.selecedComputingEls.add((IGridComputing) selObj);
                    }//from  w  w w. ja v  a  2 s .  c  o  m
                }
            }
        }
    }
}

From source file:eu.geclipse.servicejob.ui.actions.ServiceJobServiceAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    this.serviceElements = new ArrayList<IGridResource>();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sselection = (IStructuredSelection) selection;
        if (!sselection.isEmpty() && sselection.getFirstElement() instanceof IGridService) {
            this.selectedProject = ((IGridService) sselection.getFirstElement()).getProject();
            if (this.selectedProject != null) {
                for (Object selObj : sselection.toList()) {
                    if (selObj instanceof IGridService
                            && ((IGridService) selObj).getProject().equals(this.selectedProject)) {
                        this.serviceElements.add((IGridService) selObj);
                    }/* w  ww.ja  v a 2 s.  co  m*/
                }
            }
        }
    }
}

From source file:eu.geclipse.servicejob.ui.actions.ServiceJobStorageAction.java

License:Open Source License

public void selectionChanged(final IAction action, final ISelection selection) {
    this.storageElements = new ArrayList<IGridResource>();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sselection = (IStructuredSelection) selection;
        if (!sselection.isEmpty() && sselection.getFirstElement() instanceof IGridStorage) {
            this.selectedProject = ((IGridStorage) sselection.getFirstElement()).getProject();
            if (this.selectedProject != null) {
                for (Object selObj : sselection.toList()) {
                    if (selObj instanceof IGridStorage
                            && ((IGridStorage) selObj).getProject().equals(this.selectedProject)) {
                        this.storageElements.add((IGridStorage) selObj);
                    }/*from   www.j  a  va2  s .c  o  m*/
                }
            }
        }
    }
}

From source file:eu.geclipse.servicejob.ui.views.ServiceJobView.java

License:Open Source License

private void createButtons() {
    IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
    this.wizardAction = new OpenServiceJobDialogAction();
    this.wizardAction.setToolTipText(Messages.getString("ServiceJobsView.new_operators_job_wizard")); //$NON-NLS-1$
    ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
    this.wizardAction.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
    URL runURL = Activator.getDefault().getBundle().getEntry("icons/obj16/debugt_obj.gif"); //$NON-NLS-1$
    ImageDescriptor runDesc = ImageDescriptor.createFromURL(runURL);
    URL runDisabledURL = Activator.getDefault().getBundle().getEntry("icons/obj16/debugt_obj_disabled1.gif"); //$NON-NLS-1$
    ImageDescriptor runDisabledDesc = ImageDescriptor.createFromURL(runDisabledURL);
    this.runJobAction = new Action() {

        @Override/*from   w w w . j a  v  a 2 s  .c o  m*/
        public void run() {
            ISelection sel = ServiceJobView.this.getSelection();
            if (!sel.isEmpty()) {
                if (sel instanceof IStructuredSelection) {
                    IStructuredSelection sSel = (IStructuredSelection) sel;
                    for (Object obj : sSel.toList()) {
                        if (obj instanceof IServiceJob) {
                            IServiceJob serviceJob = (IServiceJob) obj;
                            if (serviceJob.needsSubmissionWizard()) {
                                JobSubmissionServiceWizard serviceWizard = new JobSubmissionServiceWizard(
                                        serviceJob.getParent().getProject().getVO());
                                WizardDialog dialog = new WizardDialog(
                                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                        serviceWizard);
                                if (dialog.open() == WizardDialog.OK) {
                                    serviceJob.setSubmissionService(serviceWizard.getSelectedService());
                                    serviceJob.run();
                                }
                            } else {
                                serviceJob.run();
                            }
                        }
                    }
                }
            }
            super.run();
        }
    };
    this.runJobAction.setImageDescriptor(runDesc);
    this.runJobAction.setDisabledImageDescriptor(runDisabledDesc);
    this.runJobAction.setEnabled(!getSelection().isEmpty());
    this.runJobAction.setToolTipText(Messages.getString("ServiceJobsView.run_button_tooltip"));
    mgr.add(this.runJobAction);
    mgr.add(this.wizardAction);
    refreshViewer();
}

From source file:eu.geclipse.smila.actions.CopyAllHostnames.java

License:Open Source License

public void selectionChanged(IAction action, ISelection selection) {
    boolean enable = false;
    this.instanceList.clear();

    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toList()) {
            if (element instanceof EC2Instance) {
                EC2Instance ec2Instance = (EC2Instance) element;
                this.instanceList.add(ec2Instance);
            }/*from  w w  w. ja v  a  2s .c  o  m*/
        }
    }
    if (this.instanceList.size() > 0) {
        enable = true;
    }
    action.setEnabled(enable);
}

From source file:eu.geclipse.ui.internal.actions.CopyAction.java

License:Open Source License

@Override
protected boolean updateSelection(final IStructuredSelection selection) {

    boolean enabled = super.updateSelection(selection);

    if (enabled) {

        for (Object o : selection.toList()) {
            if (o instanceof IGridElement) {
                enabled = !((IGridElement) o).isVirtual();
            } else {
                enabled = false;//w w w.j av  a  2s  .  co m
            }
        }

    }

    return enabled;

}

From source file:eu.geclipse.ui.internal.GridElementSelectionAdapter.java

License:Open Source License

/**
 * Construct a new selection from the specified selection. The newly
 * created selection is guaranteed to only contain {@link IResource}s.
 * If no {@link IResource} can be created from a element of the original
 * selection this element will not be contained in the newly created
 * selection. So it may happen that even if the specified selection
 * is not empty the returned selection may be empty.
 * //from   w  w w  . j  a v a 2  s.c o m
 * @param selection The selection to be remapped.
 * @return A new selection that only holds {@link IResource}s.
 */
protected IStructuredSelection remapSelection(final IStructuredSelection selection) {

    List<IResource> resources = new ArrayList<IResource>();

    for (Object o : selection.toList()) {
        IResource resource = remapObject(o);
        if (resource != null) {
            resources.add(resource);
        }
    }

    return new StructuredSelection(resources);

}

From source file:eu.geclipse.ui.internal.preference.VoPreferencePage.java

License:Open Source License

/**
 * Get the currently selected VOs./*from  w w  w  . ja v a  2s  .co m*/
 * 
 * @return The VOs that are currently selected in the table control.
 */
public List<IVirtualOrganization> getSelectedVos() {
    IStructuredSelection selection = (IStructuredSelection) this.voViewer.getSelection();
    List<?> selectionList = selection.toList();
    List<IVirtualOrganization> result = new ArrayList<IVirtualOrganization>();
    for (Object element : selectionList) {
        if (element instanceof IVirtualOrganization) {
            IVirtualOrganization vo = (IVirtualOrganization) element;
            result.add(vo);
        }
    }
    return result;
}