Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.TreeSelection


  @Override
  public void init(IWorkbench workbench, IStructuredSelection selection) {
    this.workbench = workbench;
    if (selection != null && selection instanceof TreeSelection){
      TreeSelection tselection = (TreeSelection)selection;
      if (tselection.getFirstElement() instanceof IResource){
        IResource resource = (IResource)tselection.getFirstElement();
        project = resource.getProject();
       
      }
    } else {
      MessageDialog.openError(Display.getDefault().getActiveShell(), "Project Error", "No project resource selected");
View Full Code Here


    ISelection selected = HandlerUtil.getActiveWorkbenchWindow(event).getSelectionService().getSelection();
    if(selected.isEmpty())
      return null;

    if (selected instanceof TreeSelection) {
      TreeSelection ss = (TreeSelection) selected;
      Object element = ss.getFirstElement();
      String location = ((IContainer)element).getLocation().toOSString();
     
      FileDialog dialog = new FileDialog(Display.getCurrent().getActiveShell());
      dialog.setFilterPath(location);
      String file = dialog.open();
View Full Code Here

    ISelection selected = HandlerUtil.getActiveWorkbenchWindow(event).getSelectionService().getSelection();
    if(selected.isEmpty())
      return null;
   
    if (selected instanceof TreeSelection) {
      TreeSelection ss = (TreeSelection) selected;
      @SuppressWarnings("unchecked")
      Iterator<Object> iterator = ss.iterator();
      while(iterator.hasNext()){
        Object current = iterator.next();
        if(!(current instanceof IProject))
          if (current instanceof IResource) {
            IResource res = (IResource) current;
View Full Code Here

                if ( ! ( selection instanceof TreeSelection ) )
                {
                    return;
                }
               
                TreeSelection treeSelection = ( TreeSelection ) selection;

                Object selectedObject = ( ( TreeSelection ) selection ).getFirstElement();

                if ( treeSelection.size() != 1 || selectedObject == null )
                {
                    removeSchema.setEnabled( false );
                    createANewObjectClass.setEnabled( false );
                    createANewAttributeType.setEnabled( false );
                    deleteAction.setEnabled( false );
View Full Code Here

        GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(treeViewer.getControl());
        treeViewer.setContentProvider(makeContentProvider());
        treeViewer.setLabelProvider(makeLabelProvider());
        treeViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                TreeSelection selection = (TreeSelection) event.getSelection();
                if (selection.getFirstElement() == null) {
                    return;
                }
                // Use path instead of object to avoid direct object comparison
                treeViewer.setExpandedState(selection.getPaths()[0],
                        !treeViewer.getExpandedState(selection.getPaths()[0]));
            }
        });
        treeViewer.setInput(datasets);

        // DnD support
View Full Code Here

  }

  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if(selection instanceof TreeSelection) {
      TreeSelection treeSelect = (TreeSelection)selection;
      Object firstElement = treeSelect.getFirstElement();
      IType typeEl = null;
      IPackageFragment packageEl = null;
      if(firstElement instanceof IType) {
        typeEl = (IType)firstElement;
      }
View Full Code Here

     
      JsonTreeNode element = fContentProvider.findNearestElement(start, length);
      if (element != null) {
        element.setTextSelection(true);
        getTreeViewer().reveal(element);
        TreeSelection treeSelection = new TreeSelection(new TreePath(new Object[]{element}));
        getTreeViewer().setSelection(treeSelection);
      }
    }
   
  }
View Full Code Here

  @Override
  public void selectionChanged(IAction action, ISelection selection) {
    resources.clear();
    if (!(selection instanceof TreeSelection))
      return;
    TreeSelection treeSelection = (TreeSelection) selection;
    Iterator<?> iterator;
    for (iterator = treeSelection.iterator(); iterator.hasNext();) {
      Object selectedObject = iterator.next();
      if (!(selectedObject instanceof RepositoryFile))
        continue;
      RepositoryFile repositoryFile = (RepositoryFile) selectedObject;
      IRepositoryResource resource = repositoryFile
View Full Code Here

            Object selectObj = ((IStructuredSelection) selection).getFirstElement();
            if (selectObj instanceof IFile) {
                launchFile((IFile) selectObj, mode);
            }else if (selection instanceof TreeSelection) { // selectObj instanceof org.eclipse.jface.viewers.TreeSelection
              // see http://stackoverflow.com/questions/775709/eclipse-pde-navigator-view-treeselection-obtaining-the-file-type-and-name
              TreeSelection treeSelection = (TreeSelection) selection;
              IAdaptable firstElement = (IAdaptable) treeSelection.getFirstElement();

              IFile file = (IFile) firstElement.getAdapter(IFile.class);
              if (file != null && file.isAccessible()) {
                launchFile(file, mode);
              }else{
View Full Code Here

  }

  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if (selection instanceof TreeSelection
            && (part instanceof MatchedView || part instanceof FailedView)) {
      TreeSelection ts = (TreeSelection) selection;
      Object firstElement = ts.getFirstElement();

      if (firstElement instanceof RuleMatchNode) {
        RuleMatchNode match = (RuleMatchNode) firstElement;
        if (match.hasChildren()) {
          inputChange(match.getChildren().get(0));
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.