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.architexa.diagrams.jdt.utils.ArrayMultipleElementSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    viewer = new TableViewer(composite, SWT.BORDER | SWT.CHECK);
    viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(arrProvider);
    viewer.setInput(arr);//from  w ww.ja v a  2  s .c o m
    viewer.setSelection(new StructuredSelection(arr[0]));
    return composite;
}

From source file:com.architexa.diagrams.jdt.utils.ArraySingleElementSelectionDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    viewer = new ListViewer(composite, SWT.BORDER);
    viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(arrProvider);
    viewer.setInput(arr);/*from w  w  w  .j a  v  a2 s.c o m*/
    viewer.setSelection(new StructuredSelection(arr[0]));
    return composite;
}

From source file:com.architexa.org.eclipse.gef.print.PrintGraphicalViewerOperation.java

License:Open Source License

/**
 * @see com.architexa.org.eclipse.draw2d.PrintOperation#restorePrintSource()
 *//*ww  w . j  a  v a 2  s  .  co  m*/
protected void restorePrintSource() {
    super.restorePrintSource();
    viewer.setSelection(new StructuredSelection(selectedEditParts));
}

From source file:com.architexa.org.eclipse.gef.SelectionManager.java

License:Open Source License

/**
 * Returns the current selection.//from w w  w .  j  av a2 s  .  c o m
 * @return the selection
 * @since 3.2
 */
public ISelection getSelection() {
    if (selection.isEmpty() && viewer.getContents() != null)
        return new StructuredSelection(viewer.getContents());
    return new StructuredSelection(selection);
}

From source file:com.architexa.org.eclipse.gef.tools.MarqueeSelectionTool.java

License:Open Source License

private void performMarqueeSelect() {
    EditPartViewer viewer = getCurrentViewer();
    Collection newSelections = new LinkedHashSet(), deselections = new HashSet();
    calculateNewSelection(newSelections, deselections);
    if (getSelectionMode() != DEFAULT_MODE) {
        newSelections.addAll(viewer.getSelectedEditParts());
        newSelections.removeAll(deselections);
    }/*w w  w  . j  av  a  2 s  .  c o m*/
    viewer.setSelection(new StructuredSelection(newSelections.toArray()));
}

From source file:com.architexa.org.eclipse.gef.ui.actions.SelectAllAction.java

License:Open Source License

/**
 * Selects all edit parts in the active workbench part.
 *///from ww  w. j a v  a  2  s  .c om
public void run() {
    GraphicalViewer viewer = (GraphicalViewer) part.getAdapter(GraphicalViewer.class);
    if (viewer != null)
        viewer.setSelection(new StructuredSelection(viewer.getContents().getChildren()));
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * The dialog area contains the following:
 * <UL>/*from  www .j  a  v a 2 s.co m*/
 *       <LI>Outline ({@link #createOutline(Composite)})</LI>
 *       <LI>Properties Panel ({@link #createPropertiesPanel(Composite)})</LI>
 * </UL>
 * 
 * <p>
 * It is recommended that this method not be overridden. Override one of the methods that
 * this method calls in order to customize the appearance of the dialog.
 * </p>
 * 
 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite)
 */
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    GridLayout gridLayout = (GridLayout) composite.getLayout();
    gridLayout.numColumns = 2;
    gridLayout.horizontalSpacing = 10;

    // Create the tree
    Control child = createOutline(composite);
    GridData data = new GridData(GridData.VERTICAL_ALIGN_FILL);
    data.verticalSpan = 2;
    child.setLayoutData(data);

    // Create the panel where the properties of the selected palette entry will
    // be shown
    child = createPropertiesPanel(composite);
    child.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Create the separator b/w the dialog area and the button bar
    Label label = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    // Select an element in the outline and set focus on the outline.
    if (initialSelection == null) {
        // We have to manually select the first item in the tree, because otherwise the
        // will scroll to show the last item, and then will select the first visible item.
        List children = getPaletteRoot().getChildren();
        if (!children.isEmpty()) {
            initialSelection = (PaletteEntry) children.get(0);
        }
    }
    if (initialSelection != null) {
        treeviewer.setSelection(new StructuredSelection(initialSelection));
    } else {
        setActiveEntry(null);
    }
    isSetup = false;
    tree.setFocus();

    return composite;
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * This method is called when the "Move Down" action is run (either through the context
 * menu or the toolbar).  It moves the selected palette entry down.
 */// w  w  w .  java 2 s .c  om
protected void handleMoveDown() {
    PaletteEntry entry = getSelectedPaletteEntry();
    getCustomizer().performMoveDown(entry);
    treeviewer.setSelection(new StructuredSelection(entry), true);
    updateActions();
}

From source file:com.architexa.org.eclipse.gef.ui.palette.customize.PaletteCustomizerDialog.java

License:Open Source License

/**
 * This method is called when the "Move Up" action is run (either through the context
 * menu or the toolbar).  It moves the selected entry up.
 */// w  w w  . ja v a2  s  .c  o  m
protected void handleMoveUp() {
    PaletteEntry entry = getSelectedPaletteEntry();
    getCustomizer().performMoveUp(entry);
    treeviewer.setSelection(new StructuredSelection(entry), true);
    updateActions();
}

From source file:com.architexa.org.eclipse.gef.ui.parts.SelectionSynchronizer.java

License:Open Source License

private void setViewerSelection(EditPartViewer viewer, ISelection selection) {
    ArrayList result = new ArrayList();
    Iterator iter = ((IStructuredSelection) selection).iterator();
    while (iter.hasNext()) {
        EditPart part = convert(viewer, (EditPart) iter.next());
        if (part != null)
            result.add(part);//from w ww.  j  a v  a2s.  c  o  m
    }
    viewer.setSelection(new StructuredSelection(result));
    if (result.size() > 0)
        viewer.reveal((EditPart) result.get(result.size() - 1));
}