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

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

Introduction

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

Prototype

public Object[] toArray();

Source Link

Document

Returns the elements in this selection as an array.

Usage

From source file:com.sap.dirigible.ide.repository.ui.command.AbstractClipboardHandler.java

License:Open Source License

public void execute(ExecutionEvent event, IStructuredSelection selection) {
    Comparator<IEntity> comparator = new ResourceComparator();
    SortedSet<IEntity> resources = new TreeSet<IEntity>(comparator);
    for (Object element : selection.toArray()) {
        if (element instanceof IEntity) {
            resources.add((IEntity) element);
        }//from ww  w  .j a  v a 2s. c  o  m
    }
    execute(event, resources);
}

From source file:com.sap.dirigible.ide.repository.ui.command.DeleteHandler.java

License:Open Source License

public void execute(IStructuredSelection selection) {
    Comparator<IEntity> comparator = new ResourceComparator();
    SortedSet<IEntity> resources = new TreeSet<IEntity>(comparator);
    for (Object element : selection.toArray()) {
        if (element instanceof IEntity) {
            resources.add((IEntity) element);
        }/*  w  w w.  ja v a  2  s .  co  m*/
    }
    execute(resources);
}

From source file:com.sap.dirigible.ide.repository.ui.command.OpenHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    boolean successful = true;
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toArray()) {
            successful &= openEditorFor(element);
        }//from   w w w. j  a  va 2 s .  c  om
    }
    if (!successful) {
        logger.error(COULD_NOT_OPEN_ONE_OR_MORE_FILES);
        MessageDialog.openError(null, OPEN_FAILURE, COULD_NOT_OPEN_ONE_OR_MORE_FILES);
    }
    return null;
}

From source file:com.sap.dirigible.ide.ui.widgets.connection.ConnectionViewer.java

License:Open Source License

/**
 * {@inheritDoc}//  w w  w  .j  a v  a2  s . co m
 */
@Override
public void setSelection(ISelection selection, boolean reveal) {
    assertSelection(selection);
    final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    this.selection.clear();
    for (Object element : structuredSelection.toArray()) {
        this.selection.add(element);
    }
    refresh();
}

From source file:com.sap.dirigible.ide.workspace.ui.commands.AbstractClipboardHandler.java

License:Open Source License

public void execute(ExecutionEvent event, IStructuredSelection selection) {
    Comparator<IResource> comparator = new ResourceComparator();
    SortedSet<IResource> resources = new TreeSet<IResource>(comparator);
    for (Object element : selection.toArray()) {
        if (element instanceof IResource) {
            resources.add((IResource) element);
        }/*  www .  j a v a  2s.  c om*/
    }
    execute(event, resources);
}

From source file:com.sap.dirigible.ide.workspace.ui.commands.DeleteHandler.java

License:Open Source License

public void execute(IStructuredSelection selection) {
    Comparator<IResource> comparator = new ResourceComparator();
    SortedSet<IResource> resources = new TreeSet<IResource>(comparator);
    for (Object element : selection.toArray()) {
        if (element instanceof IResource) {
            resources.add((IResource) element);
        }/* w w w . j  av a  2s . c om*/
    }
    execute(resources);
}

From source file:com.sap.dirigible.ide.workspace.ui.commands.OpenHandler.java

License:Open Source License

public Object execute(ExecutionEvent event) throws ExecutionException {
    boolean successful = true;
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toArray()) {
            if (element instanceof IFile) {
                successful &= (openEditorFor(element) != null);
            } else {
                successful &= true;//from   w  ww.jav a 2  s . c o  m
                //               WorkspaceViewerUtils.expandElement(element);
            }
        }
    }
    if (!successful) {
        logger.error(COULD_NOT_OPEN_ONE_OR_MORE_FILES);
        MessageDialog.openError(null, OPEN_FAILURE2, COULD_NOT_OPEN_ONE_OR_MORE_FILES);
    }
    return null;
}

From source file:com.sap.dirigible.ide.workspace.ui.view.WorkspaceExplorerView.java

License:Open Source License

private void onWorkspaceViewerDoubleClicked(DoubleClickEvent event) {
    ICommandService commandService = (ICommandService) getSite().getService(ICommandService.class);
    IHandlerService handlerService = (IHandlerService) getSite().getService(IHandlerService.class);
    Command command = commandService.getCommand(OPEN_COMMAND_ID);
    ExecutionEvent executionEvent = handlerService.createExecutionEvent(command, null);
    try {/*w  ww  .ja v a  2  s  .co m*/
        command.executeWithChecks(executionEvent);
    } catch (Exception ex) {
        logger.error(COULD_NOT_EXECUTE_OPEN_COMMAND, ex);
        MessageDialog.openError(null, OPERATION_FAILED,
                COULD_NOT_EXECUTE_OPEN_COMMAND_DUE_TO_THE_FOLLOWING_ERROR + ex.getMessage()
                        + CHECK_LOGS_FOR_MORE_INFO);
    }
    ISelection selection = event.getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        for (Object element : structuredSelection.toArray()) {
            if (element instanceof IFolder || element instanceof IProject) {
                WorkspaceViewerUtils.doubleClickedElement(element);
            }
        }
    }
}

From source file:com.siteview.mde.internal.runtime.registry.RegistryBrowser.java

License:Open Source License

private boolean isBundleSelected() {
    IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
    if (selection != null) {
        Object[] elements = selection.toArray();
        for (int i = 0; i < elements.length; i++) {
            if (!(elements[i] instanceof Bundle)) {
                return false;
            }//from  www  .j  a  v  a 2  s . co  m
        }
    }

    return true;
}

From source file:com.siteview.mde.internal.runtime.registry.RegistryBrowser.java

License:Open Source License

private List getSelectedBundles() {
    List bundles = new ArrayList();
    IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
    if (selection != null) {
        Object[] elements = selection.toArray();
        for (int i = 0; i < elements.length; i++) {
            if (elements[i] instanceof Bundle) {
                bundles.add(elements[i]);
            }/*from   ww w  .  j a va  2s  .c o m*/
        }
    }
    return bundles;
}