Example usage for org.eclipse.jface.viewers SelectionChangedEvent getSelectionProvider

List of usage examples for org.eclipse.jface.viewers SelectionChangedEvent getSelectionProvider

Introduction

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

Prototype

public ISelectionProvider getSelectionProvider() 

Source Link

Document

Returns the selection provider that is the source of this event.

Usage

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

License:Open Source License

/**
 * Receives notification from one viewer, and maps selection to all other members.
 * @param event the selection event//w  ww .j a  va2s .c  om
 */
public void selectionChanged(SelectionChangedEvent event) {
    if (isDispatching)
        return;
    EditPartViewer source = (EditPartViewer) event.getSelectionProvider();
    if (disabled > 0) {
        pendingSelection = source;
    } else {
        ISelection selection = event.getSelection();
        syncSelection(source, selection);
    }
}

From source file:com.buglabs.dragonfly.ui.wizards.bugProject.OSGiServiceBindingPage.java

License:Open Source License

/**
 * Creates TableViewer that has all BUGs currently available in MyBUGs view
 * //from  w ww .j a v a  2 s  . com
 * @param composite
 */
private void createTargetArea(final Composite parent) {
    Group composite = new Group(parent, SWT.NONE);
    composite.setText(TARGET_BUG_TITLE);
    composite.setLayout(new GridLayout(2, false));

    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.grabExcessHorizontalSpace = true;

    composite.setLayoutData(gridData);

    GridData gdLabel = new GridData(GridData.FILL_HORIZONTAL);
    gdLabel.horizontalSpan = 2;

    Label label = new Label(composite, SWT.NONE);
    label.setText(TARGET_BUG_INSTRUCTIONS);
    label.setLayoutData(gdLabel);

    GridData fillHorizontal = new GridData(GridData.FILL_HORIZONTAL);
    GridData gdViewer = GridDataFactory.createFrom(fillHorizontal).create();
    gdViewer.heightHint = BUGS_VIEWER_HEIGHT_HINT;
    bugsViewer = new TableViewer(composite, SWT.BORDER | SWT.V_SCROLL);
    bugsViewer.getTable().setLayoutData(gdViewer);

    // set up change listener
    bugsViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(final SelectionChangedEvent event) {
            // not sure why this would be the case, but return if nothing there
            if (((BaseTreeNode) bugsViewer.getInput()).getChildren().size() == 0)
                return;

            // don't do anything if it's the same as the previous selection
            ISelection selection = event.getSelection();
            if (currentBugSelection != null && currentBugSelection.equals(selection))
                return;

            if (!reloadListDialog(parent.getShell())) {
                if (currentBugSelection != null)
                    event.getSelectionProvider().setSelection(currentBugSelection);
                return;
            }

            // Make sure we can connect to the given BUG
            final BugConnection connection = (BugConnection) ((StructuredSelection) event.getSelection())
                    .getFirstElement();
            if (connection == null)
                return;

            // set the saved currentBugSelection to the selection
            currentBugSelection = selection;

            // prepare to launch refresh services job
            refreshServiceDefintions.setEnabled(true);

            // clear selections
            clearSelections();

            launchRefreshServicesJob(connection);
        }

    });

    bugsViewer.setContentProvider(new MyBugsViewContentProvider() {
        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof BaseTreeNode) {
                return ((BaseTreeNode) parentElement).getChildren().toArray();
            }
            return new Object[0];
        }
    });

    bugsViewer.setLabelProvider(new LabelProvider() {
        public String getText(Object element) {
            if (element instanceof BugConnection) {
                return ((BugConnection) element).getName();
            } else {
                return super.getText(element);
            }
        }

        public Image getImage(Object element) {
            if (element instanceof BugConnection) {
                return Activator.getDefault().getImageRegistry().get(Activator.IMAGE_COLOR_UPLOAD);
            }
            return super.getImage(element);
        }
    });

    BaseTreeNode root = (BaseTreeNode) BugConnectionManager.getInstance().getBugConnectionsRoot();
    bugsViewer.setInput(root);

    btnStartVBUG = new Button(composite, SWT.PUSH);
    btnStartVBUG.setText(START_VIRTUAL_BUG_LABEL);
    btnStartVBUG.setToolTipText(START_VIRTUAL_BUG_TOOLTIP);
    GridData gdButton = new GridData();
    gdButton.verticalAlignment = SWT.TOP;
    btnStartVBUG.setLayoutData(gdButton);
    btnStartVBUG.addSelectionListener(((SelectionListener) new StartVBUGSelectionListener()));

    setPageMessage(root.getChildren().size());
}

From source file:com.google.dart.tools.ui.callhierarchy.CallHierarchyViewPart.java

License:Open Source License

@Override
public void selectionChanged(SelectionChangedEvent e) {
    if (e.getSelectionProvider() == callHierarchyViewer) {
        methodSelectionChanged(e.getSelection());
    }/*from  w  w w.  j a  v  a  2 s .com*/
}

From source file:com.google.dart.tools.ui.internal.viewsupport.SelectionProviderMediator.java

License:Open Source License

final void doPostSelectionChanged(SelectionChangedEvent event) {
    ISelectionProvider provider = event.getSelectionProvider();
    if (provider == fViewerInFocus) {
        firePostSelectionChanged();//from   w  w  w .  java2  s.  c o m
    }
}

From source file:com.google.dart.tools.ui.internal.viewsupport.SelectionProviderMediator.java

License:Open Source License

final void doSelectionChanged(SelectionChangedEvent event) {
    ISelectionProvider provider = event.getSelectionProvider();
    if (provider == fViewerInFocus) {
        fireSelectionChanged();//  w w  w . ja  v a2  s .c  om
    }
}

From source file:com.iw.plugins.spindle.editors.spec.outline.MultiPageContentOutline.java

License:Mozilla Public License

public void selectionChanged(SelectionChangedEvent event) {
    ISelection selection = event.getSelection();
    if (selection instanceof DoubleClickSelection)
        fEditor.openTo(((DoubleClickSelection) selection).getFirstElement());
    fireSelectionChange(event.getSelectionProvider(), selection);
}

From source file:com.microsoft.tfs.client.common.ui.controls.CSSNodeComboControl.java

License:Open Source License

@Override
public Composite getPopup(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    final GridLayout layout = new GridLayout(1, true);
    layout.marginHeight = 0;/*from  w  ww  . ja va2s .  com*/
    layout.marginWidth = 0;
    composite.setLayout(layout);

    final CSSNodeControl control = new CSSNodeControl(composite, SWT.NONE, rootNode, text.getText().trim(),
            skipNode);

    control.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            selectedNode = control.getSelectedNode();
            text.setText(selectedNode.getPath());

            final Object collapseEventFlag = ((Viewer) event.getSelectionProvider())
                    .getData(COLLAPSE_EVENT_KEY);
            if (collapseEventFlag != null) {
                /*
                 * this selection event is happening because of a node
                 * collapse - do not auto-close the popup and reset the
                 * collapse flag
                 */
                ((Viewer) event.getSelectionProvider()).setData(COLLAPSE_EVENT_KEY, null);
            } else {
                closePopup();
            }
        }
    });

    control.addTreeListener(new ITreeViewerListener() {
        @Override
        public void treeCollapsed(final TreeExpansionEvent event) {
            /*
             * collapsing a tree node generates a selection event - we don't
             * want this selection event to trigger a auto-close of the
             * popup as all other selection events would
             *
             * we record that a tree collapse happened and then check for
             * this case in the selection listener
             */
            event.getTreeViewer().setData(COLLAPSE_EVENT_KEY, Boolean.TRUE);
        }

        @Override
        public void treeExpanded(final TreeExpansionEvent event) {
        }
    });

    control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    ControlSize.setCharHeightHint(control, 15);

    return composite;
}

From source file:com.microsoft.tfs.client.common.ui.framework.validation.AbstractSelectionProviderValidator.java

License:Open Source License

/**
 * Called when a {@link SelectionChangedEvent} is sent by the
 * {@link ISelectionProvider} subject. This implementation validates the new
 * {@link ISelection} value in the subject. Normally, there is no need for
 * subclasses to override or call this method.
 *
 * @param event//from   w ww .  j  a  va 2 s . c om
 *        the {@link SelectionChangedEvent} (never <code>null</code>)
 */
protected void onSelectionChanged(final SelectionChangedEvent event) {
    final ISelectionProvider subject = event.getSelectionProvider();
    validate(subject.getSelection());
}

From source file:com.mulgasoft.emacsplus.commands.ExecuteCommandHandler.java

License:Open Source License

/**
 * Call execute on checkers with an additional listener for selection change during execution
 *  //from   w  w w . jav  a 2  s  .c o m
 * @param editor
 * @param checkers
 */
protected void executeWithSelectionCheck(final ITextEditor editor, IWithSelectionCheck checkers) {

    ISelectionChangedListener listener = new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            ExecuteCommandHandler.this.showResultMessage(editor);
            removeListener(event.getSelectionProvider(), this);
        }
    };
    ITextSelection before = getCurrentSelection(editor);
    try {
        addListener(editor.getSelectionProvider(), listener);
        checkers.execute();
    } finally {
        if (before.equals(getCurrentSelection(editor))) {
            // remove it if the selection did not change
            removeListener(editor.getSelectionProvider(), listener);
        }
    }
}

From source file:com.nokia.sdt.uidesigner.ui.SelectionManager.java

License:Open Source License

public void selectionChanged(SelectionChangedEvent event) {
    currentSelection = null;/*from ww  w .  j  a  v  a  2s  .  c o m*/
    if (isDispatching)
        return;

    // this synchronizes between viewers
    EditPartViewer source = (EditPartViewer) event.getSelectionProvider();
    ISelection selection = event.getSelection();
    syncSelection(source, selection);
}