Example usage for org.eclipse.jface.viewers StructuredSelection StructuredSelection

List of usage examples for org.eclipse.jface.viewers StructuredSelection StructuredSelection

Introduction

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

Prototype

public StructuredSelection(List elements) 

Source Link

Document

Creates a structured selection from the given List.

Usage

From source file:com.aptana.ide.debug.internal.ui.actions.BreakpointPropertiesRulerAction.java

License:Open Source License

/**
 * @see org.eclipse.jface.action.IAction#run()
 *//* w w  w  .j av a2 s.  c  o  m*/
public void run() {
    if (getBreakpoint() != null) {
        PropertyDialogAction action = new PropertyDialogAction(
                new SameShellProvider(getTextEditor().getEditorSite().getShell()), new ISelectionProvider() {
                    public void addSelectionChangedListener(ISelectionChangedListener listener) {
                    }

                    public ISelection getSelection() {
                        return new StructuredSelection(getBreakpoint());
                    }

                    public void removeSelectionChangedListener(ISelectionChangedListener listener) {
                    }

                    public void setSelection(ISelection selection) {
                    }
                });
        action.run();
    }
}

From source file:com.aptana.ide.debug.internal.ui.dialogs.AddExceptionBreakpointDialog.java

License:Open Source License

private boolean createBreakpoint() {
    final Object[] selected = getSelectedElements();
    if (selected.length != 1) {
        return false;
    }/*from  www . ja  v a  2  s  .  c om*/

    new Job(Messages.AddExceptionBreakpointDialog_AddJavaScriptExceptionBreakpoint) {

        protected IStatus run(IProgressMonitor monitor) {
            try {
                IResource resource = null;
                if (resource == null) {
                    resource = ResourcesPlugin.getWorkspace().getRoot();
                }
                IJSExceptionBreakpoint breakpoint = JSDebugModel.createExceptionBreakpoint(resource,
                        (String) selected[0]);
                final List<IBreakpoint> list = new ArrayList<IBreakpoint>(1);
                list.add(breakpoint);
                Runnable r = new Runnable() {
                    public void run() {
                        IViewPart part = DebugUiPlugin.getActivePage()
                                .findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
                        if (part instanceof IDebugView) {
                            Viewer viewer = ((IDebugView) part).getViewer();
                            if (viewer instanceof StructuredViewer) {
                                StructuredViewer sv = (StructuredViewer) viewer;
                                sv.setSelection(new StructuredSelection(list), true);
                            }
                        }
                    }
                };
                DebugUiPlugin.getStandardDisplay().asyncExec(r);
                return Status.OK_STATUS;
            } catch (CoreException e) {
                updateStatus(e.getStatus());
                return Status.CANCEL_STATUS;
            }
        }

    }.schedule();
    return true;
}

From source file:com.aptana.ide.debug.internal.ui.launchConfigurations.HttpServerSettingsTab.java

License:Open Source License

private void addPath() {
    HttpServerPathDialog dlg = new HttpServerPathDialog(getShell(), Messages.HttpServerSettingsTab_AddNewPath);
    if (dlg.open() == Window.OK) {
        PathElement element = new PathElement(true, dlg.getServerPath(),
                dlg.getWorkspaceResource().getFullPath().toPortableString());
        elements.add(element);/*from  w w  w .j  a  v  a 2 s.c o  m*/
        fListViewer.refresh();
        fListViewer.setSelection(new StructuredSelection(element));

        refreshViewer();
        setDirty(true);
        updateLaunchConfigurationDialog();
    }
}

From source file:com.aptana.ide.debug.internal.ui.launchConfigurations.HttpServerSettingsTab.java

License:Open Source License

private void removePaths() {
    IStructuredSelection selection = (IStructuredSelection) fListViewer.getSelection();
    Object first = selection.getFirstElement();
    int index = -1;
    for (int i = 0; i < elements.size(); i++) {
        Object object = elements.get(i);
        if (object.equals(first)) {
            index = i;/*w  w w .  j  a  v  a 2s . c  o  m*/
            break;
        }
    }
    elements.removeAll(selection.toList());
    if (index > elements.size() - 1) {
        index = elements.size() - 1;
    }
    if (index >= 0) {
        fListViewer.setSelection(new StructuredSelection(elements.get(index)));
    }
    setDirty(true);
    updateLaunchConfigurationDialog();
}

From source file:com.aptana.ide.debug.internal.ui.preferences.JSDetailFormattersPreferencePage.java

License:Open Source License

private void removeTypes() {
    Object[] list = formatters.toArray();
    IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
    Object first = selection.getFirstElement();
    int index = -1;
    for (int i = 0; i < list.length; i++) {
        if (list[i].equals(first)) {
            index = i;/* w w  w  .j  a  v a 2s .  c o m*/
            break;
        }
    }

    removeDetailFormatters(selection.toArray());

    list = formatters.toArray();
    if (index > list.length - 1) {
        index = list.length - 1;
    }
    if (index >= 0) {
        listViewer.setSelection(new StructuredSelection(list[index]));
    }
}

From source file:com.aptana.ide.debug.internal.ui.preferences.JSDetailFormattersPreferencePage.java

License:Open Source License

private void addDetailFormatter(DetailFormatter detailFormatter) {
    formatters.add(detailFormatter);/*from w w  w .j  a v  a 2  s .c  o m*/
    types.add(detailFormatter.getTypeName());
    listViewer.refresh();
    updateViewerCheckboxes();
    IStructuredSelection selection = new StructuredSelection(detailFormatter);
    listViewer.setSelection(selection);
    updatePage(selection);
}

From source file:com.aptana.ide.debug.internal.ui.views.AJAXMonitorView.java

License:Open Source License

/**
 * @see org.eclipse.debug.ui.AbstractDebugView#becomesVisible()
 *///from   w w w.j  a v  a2s .co m
protected void becomesVisible() {
    super.becomesVisible();
    if (current != null) {
        getViewer().setInput(current);
        showViewer();
    } else {
        setViewerInput(getCurrentXHRService());
    }
    if (getViewer().getSelection().isEmpty() && (current != null) && (current.getTransfersCount() > 0)) {
        getViewer().setSelection(new StructuredSelection(current.getTransfers()[0]));
    }
}

From source file:com.aptana.ide.editors.internal.ui.preferences.TableViewerEditor.java

License:Open Source License

/**
 * Replace an element.//from   w  w w . ja v a 2s. c o m
 */
private void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException {
    int idx = fElements.indexOf(oldElement);
    if (idx != -1) {
        fElements.set(idx, newElement);
        if (isOkToUse(fTableControl)) {
            List selected = getSelectedElements();
            if (selected.remove(oldElement)) {
                selected.add(newElement);
            }
            fTable.refresh();
            selectElements(new StructuredSelection(selected));
        }
        selectionChanged();
    } else {
        throw new IllegalArgumentException();
    }
}

From source file:com.aptana.ide.editors.internal.ui.preferences.TableViewerEditor.java

License:Open Source License

/**
 * Adds an element at a position./*from w  ww  .ja  v  a2  s .co m*/
 */
public boolean addElement(Object element, int index) {
    if (fElements.contains(element)) {
        return false;
    }
    fElements.add(index, element);
    if (isOkToUse(fTableControl)) {
        fTable.refresh();
        fTable.setSelection(new StructuredSelection(element));
    }

    selectionChanged();
    return true;
}

From source file:com.aptana.ide.installer.wizard.PluginsTreeViewer.java

License:Open Source License

/**
 * Makes the specific categories expanded.
 * //from   w  w w.  j a v a  2  s  .com
 * @param categoryIDs the array of category ids
 */
public void setExpandedCategories(String[] categoryIDs) {
    if (categoryIDs == null || categoryIDs.length == 0) {
        return;
    }
    // finds the categories that need to be expanded
    List<PluginTreeNode> categories = new ArrayList<PluginTreeNode>();
    PluginTreeNode category;
    for (String id : categoryIDs) {
        category = fModel.getCategory(id);
        if (category != null) {
            categories.add(category);
        }
    }
    fTreeViewer.setExpandedElements(categories.toArray(new PluginTreeNode[categories.size()]));
    if (categories.size() > 0) {
        // auto-selects the first element
        fTreeViewer.setSelection(new StructuredSelection(categories.get(0)));
    }
}