Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.TreeSelection


    }
  }
 
  protected IConnectionWrapper findParent(IStructuredSelection sel) {
    if( sel instanceof TreeSelection ) {
      TreeSelection sel2 = ((TreeSelection)sel);
      TreePath[] paths = sel2.getPathsFor(sel.getFirstElement());
      if( paths != null && paths.length == 1 ) {
        if( paths[0].getFirstSegment() instanceof IConnectionWrapper )
          return (IConnectionWrapper) paths[0].getFirstSegment();
      }
    }
View Full Code Here


  }

  @Override
  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if (selection instanceof TreeSelection) {
      TreeSelection treeSelection = (TreeSelection) selection;
      tableViewer.setInput(treeSelection.getFirstElement());
    }
  }
View Full Code Here

     * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
     */
    public void doubleClick(DoubleClickEvent event) {
        logger.debug("viewer double-clicked");

        TreeSelection selection = (TreeSelection)event.getSelection();
        logger.trace("selection: " + selection);
        Object item = selection.getFirstElement();
        logger.trace("item: " + item);

        if(item instanceof AbstractCampaign) {
            // open campaign properties editor
            logger.debug("open campaign editor");
View Full Code Here

     */
    public void doubleClick(DoubleClickEvent event)
    {
        logger.debug("viewer double-clicked: " + event);
       
        TreeSelection selection = (TreeSelection)event.getSelection();
        logger.trace("selection: " + selection);
        Object item = selection.getFirstElement();
        logger.trace("item: " + item);

        if(!(item instanceof AdminSection))
        {
            // open campaign properties editor
View Full Code Here

     */
    public void doubleClick(DoubleClickEvent event)
    {
        logger.debug("viewer double-clicked");
       
        TreeSelection selection = (TreeSelection)event.getSelection();
        logger.trace("selection: " + selection);
        Object item = selection.getFirstElement();
        logger.trace("item: " + item);

        if(!(item instanceof CampaignSection))
        {
            // open campaign properties editor
View Full Code Here

     */
    public void doubleClick(DoubleClickEvent event)
    {
        logger.debug("viewer double-clicked");
       
        TreeSelection selection = (TreeSelection)event.getSelection();
        logger.trace("selection: " + selection);
        Object item = selection.getFirstElement();
        logger.trace("item: " + item);

//        if(!(item instanceof CampaignSection))
//        {
//            // open campaign properties editor
View Full Code Here

        viewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event)
            {
                logger.debug("viewer double-clicked");
                TreeSelection selection = (TreeSelection)event.getSelection();
                logger.trace("selection = " + selection.getClass().getName());
                Object item = selection.getFirstElement();
               
                if(item instanceof Campaign)
                {
                    // TODO: open campaign properties editor
                    logger.debug("open properties editor");
                   
                    try
                    {
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new CampaignEditorInput((Campaign)item), CampaignEditor.ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
                    }
                    catch(PartInitException e)
                    {
                        logger.error("unable to open campaign editor: " + e.getMessage(), e);

                        MessageDialog.openError(getViewSite().getShell(), res.getLocaleString("campaign.editor.error.opening"), e.getLocalizedMessage());
                    }
                }
                else if(item instanceof CampaignSection)
                {
                    logger.debug("campaign section");
                   
                    // TODO: nothing?
                }
                else if(item instanceof Participant)
                {
                    logger.debug("open participant editor");

                    try
                    {
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new ParticipantEditorInput((Participant)item), ParticipantEditor.ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
                    }
                    catch(PartInitException e)
                    {
                        logger.error("unable to open participant editor: " + e.getMessage(), e);
                       
                        MessageDialog.openError(getViewSite().getShell(), res.getLocaleString("participant.editor.error.opening"), e.getLocalizedMessage());
                    }
                }
                else if(item instanceof PlayerCharacter ||
                        item instanceof NonPlayerCharacter)
                {
                    logger.trace("campaign item (player/npc): " + item.getClass().getName());

                    try
                    {
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(new CharacterEditorInput((Creature)item), CharacterEditor.ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
                    }
                    catch(PartInitException e)
                    {
                        logger.error("unable to open character editor: " + e.getMessage(), e);

                        MessageDialog.openError(getViewSite().getShell(), res.getLocaleString("character.editor.error.opening"), e.getLocalizedMessage());
                    }
                }
                else if(item instanceof CampaignItem)
                {
                    logger.trace("campaign item: " + item.getClass().getName());
                   
                    // TODO: nothing?
                }
            }
        });
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {
            public void selectionChanged(SelectionChangedEvent event)
            {
                logger.debug("viewer selection changed: " + event);
               
                IStructuredSelection selection = (IStructuredSelection)event.getSelection();
                logger.trace("selection: " + selection);
                Object o = selection.getFirstElement();
                logger.trace("o: " + o);
               
                if(o instanceof CampaignSection)
                {
                    logger.trace("selection is a campaign item");
                    deleteCampaignItemAction.setEnabled(false);
                }
                else
                {                   
                    logger.trace("selection is: " + o.getClass().getName());
                    deleteCampaignItemAction.setEnabled(!selection.isEmpty());
                   
                    ((DeleteCampaignItemAction)deleteCampaignItemAction).setSelection(selection);
                }
            }
        });
View Full Code Here

    AnnotationCheckView acView;
    try {
      acView = (AnnotationCheckView) HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench()
              .getActiveWorkbenchWindow().getActivePage().showView(AnnotationCheckView.ID);
      AnnotationCheckComposite composite = acView.getComposite();
      TreeSelection selection = (TreeSelection) composite.getTreeViewer().getSelection();
      AnnotationCheckTreeNode previousSelection = (AnnotationCheckTreeNode) selection
              .getFirstElement();
      CheckAnnotationUpdateTaskJob job = new CheckAnnotationUpdateTaskJob(composite,
              previousSelection);
      job.schedule();
    } catch (Exception e) {
View Full Code Here

        TreePath oldPath = getPathTo(element, root);
        if (oldPath != null) {
          treePath = oldPath;
        }
      }
      final TreeSelection firstSelection = new TreeSelection(treePath);

      cas.release();
      composite.setOldDocs(docs);
      composite.getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {
          TreeViewer treeView = composite.getTreeViewer();
          treeView.setInput(root);
          treeView.setSelection(firstSelection, true);
          treeView.expandToLevel(
                  ((AnnotationCheckTreeNode) firstSelection.getFirstElement()).getParent(),
                  TreeViewer.ALL_LEVELS);
        }
      });

      return Status.OK_STATUS;
View Full Code Here

      public void mouseDown(MouseEvent e) {
        Object source = e.getSource();
        if (source instanceof Tree && e.button == 3) {
          Tree tree = (Tree) source;
          Composite composite = tree.getParent().getParent();
          TreeSelection teeSelection = (TreeSelection) treeView.getSelection();
          Object node = teeSelection.getFirstElement();
          Display display = Display.getDefault();
          Shell shell = new Shell(display, SWT.RESIZE | SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);
          if (node instanceof AnnotationCheckTreeNode && !(node instanceof FeatureCheckTreeNode)) {
            changeType(shell, composite, node);
          }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.TreeSelection

Copyright © 2018 www.massapicom. 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.