Examples of IStructuredSelection


Examples of org.eclipse.jface.viewers.IStructuredSelection

    }
    fViewer.getTree().setFocus();
  }

  private void onDelete() {
    IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
    if (!selection.isEmpty()) {
      ILabel label = (ILabel) selection.getFirstElement();

      String msg = "Are you sure you want to delete the Label '" + label.getName() + "'?";
      ConfirmDeleteDialog dialog = new ConfirmDeleteDialog(getShell(), "Confirm Delete", "This action can not be undone", msg, null);
      if (dialog.open() == IDialogConstants.OK_ID) {
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

    new EntityGroupItem(group, label2);
    new EntityGroupItem(group, label3);

    Object selectedItems[] = new Object[] { label1, group };

    IStructuredSelection sel = new StructuredSelection(selectedItems);
    List<IEntity> entities = ModelUtils.getEntities(sel);

    assertEquals(3, entities.size());

    int l1 = 0, l2 = 0, l3 = 0;
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

  public MediaViewPart() {
    listener = new ISelectionListener() {
      public void selectionChanged(IWorkbenchPart part, ISelection sel) {
        if (!(sel instanceof IStructuredSelection))
          return;
        IStructuredSelection ss = (IStructuredSelection) sel;
        Object o = ss.getFirstElement();

// ********************* CB TODO
// We force an inspection on the bookmark first.
        if (o instanceof IBookMark) {
          IBookMark lBookMark = (IBookMark) o;
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

    } else {
      lControl = mMediaView.getItemViewer().mTreeViewer.getControl();
      lProvider = mMediaView.getItemViewer().mTreeViewer;
    }

    final IStructuredSelection selection = (IStructuredSelection) lProvider
        .getSelection();

    if (selection.isEmpty()) {
      // CB TODO decide what to do on an empty selection.
    }

    menuMgr.addMenuListener(new IMenuListener() {
      public void menuAboutToShow(IMenuManager manager) {
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

  /*
   * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
   */
  public void selectionChanged(SelectionChangedEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    String text = formatElements(selection.toArray());

    /* Replace & with && */
    text = text.replaceAll("&", "&&"); //$NON-NLS-1$//$NON-NLS-2$

    /* Show Message */
 
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

    fFolderViewer.setLabelProvider(new BookMarkLabelProvider(false));
    fFolderViewer.setInput(new Object());

    fFolderViewer.addSelectionChangedListener(new ISelectionChangedListener() {
      public void selectionChanged(SelectionChangedEvent event) {
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        if (!selection.isEmpty())
          onFolderSelected((IFolder) selection.getFirstElement());
      }
    });

    fFolderViewer.addDoubleClickListener(new IDoubleClickListener() {
      public void doubleClick(DoubleClickEvent event) {
        IStructuredSelection selection = (IStructuredSelection) event.getSelection();
        IFolder folder = (IFolder) selection.getFirstElement();

        /* Expand / Collapse Folder */
        if (!folder.getFolders().isEmpty()) {
          boolean expandedState = !fFolderViewer.getExpandedState(folder);
          fFolderViewer.setExpandedState(folder, expandedState);
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

    /* Make sure Folder-List is visible */
    if (((GridData) fFolderViewerContainer.getLayoutData()).exclude)
      onToggle();

    /* Create new Folder */
    IStructuredSelection selection = (IStructuredSelection) fFolderViewer.getSelection();
    NewFolderAction action = new NewFolderAction(fFolderViewer.getTree().getShell(), (IFolder) selection.getFirstElement(), null);
    action.run(null);
  }
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

    }
  }

  private void updateSelectionAfterDelete(Runnable runnable) {
    Tree tree = (Tree) getControl();
    IStructuredSelection selection = (IStructuredSelection) getSelection();

    /* Nothing to do, since no selection */
    if (selection.isEmpty()) {
      runnable.run();
      return;
    }

    /* Look for the minimal Index of all selected Elements */
    int minSelectedIndex = Integer.MAX_VALUE;
    TreeItemAdapter parentOfMinSelected = new TreeItemAdapter(tree);

    /* For each selected Element */
    Object[] selectedElements = selection.toArray();
    for (Object selectedElement : selectedElements) {
      Widget widget = findItem(selectedElement);
      if (widget instanceof TreeItem) {
        TreeItem item = (TreeItem) widget;
        TreeItemAdapter parent = new TreeItemAdapter(item).getParent();

        int index = parent.indexOf(item);
        minSelectedIndex = Math.min(minSelectedIndex, index);
        if (index == minSelectedIndex)
          parentOfMinSelected.setItem(parent.getItem());
      }
    }

    /* Perform Deletion */
    runnable.run();

    Object data = null;

    /* Parent itself has been deleted */
    if (parentOfMinSelected.getItem().isDisposed())
      return;

    /* Restore selection to next Element */
    if (parentOfMinSelected.getItemCount() > minSelectedIndex)
      data = parentOfMinSelected.getItem(minSelectedIndex).getData();

    /* Restore selection to last Element */
    else if (parentOfMinSelected.getItemCount() > 0)
      data = parentOfMinSelected.getItem(parentOfMinSelected.getItemCount() - 1).getData();

    /* Restore selection on actual Element */
    else
      data = parentOfMinSelected.getItem().getData();

    /* Apply selection */
    if (data != null) {
      IStructuredSelection newSelection = new StructuredSelection(data);
      setSelection(newSelection);
    }
  }
View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

      });
    }
  }

  private void onMouseDoubleClick(DoubleClickEvent event) {
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
    if (selection.isEmpty())
      return;

    Object firstElem = selection.getFirstElement();

    /* Open News */
    if (firstElem instanceof INews)
      new OpenInBrowserAction(selection).run();

View Full Code Here

Examples of org.eclipse.jface.viewers.IStructuredSelection

    /* Check if settings disable the tracker */
    if (!fPreferences.getBoolean(DefaultPreferences.MARK_READ_STATE))
      return;

    /* Retrieve all NewsReferences of the Selection */
    IStructuredSelection selection = (IStructuredSelection) event.getSelection();

    /* Only responsible for single Selection of a News */
    if (selection.size() != 1 || !(selection.getFirstElement() instanceof INews)) {
      fNewsStateTracker.cancel();
      return;
    }

    /* Trigger the Tracker if news is not read already */
    final INews selectedNews = (INews) selection.getFirstElement();
    if (selectedNews.getState() != INews.State.READ && selectedNews.isVisible()) {
      fNewsStateTracker.run(new TaskAdapter() {
        public IStatus run(IProgressMonitor monitor) {
          setNewsState(Arrays.asList(new INews[] { selectedNews }), INews.State.READ);
          return Status.OK_STATUS;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.