Examples of ElementTreeSelectionDialog


Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    setControl(container);
    checkPage();
  }
 
  protected String handleBrowse(String title) {
    ElementTreeSelectionDialog etsd = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
    etsd.setInput(refactoring.getProject().getWorkspace());
    etsd.addFilter(new ViewerFilter() {

      @Override
      public boolean select(Viewer viewer, Object parentElement, Object element) {
       
        if (element == null) {
          return false;
        }
       
        if (element instanceof IFile) {
          IFile file = ((IFile)element);
          String extension = file.getFileExtension();
          return (extension != null && extension.equals("xml")); //$NON-NLS-1$
        }
       
        if (element instanceof IProject) {
          return ((IProject)element).equals(refactoring.getProject());
        }
       
        return true;
      }
     
    });
   
    etsd.setValidator(new ISelectionStatusValidator() {
      public IStatus validate(Object[] selection) {
        return (selection.length == 1 && selection[0] instanceof IFile) ? SELECTION_OK_STATUS : SELECTION_NOT_OK_STATUS;
      }
    });
   
    etsd.open();
   
    Object[] results = etsd.getResult();
    if (results.length == 1) {
      if (results[0] instanceof IFile) {
        return ((IFile)results[0]).getProjectRelativePath().toPortableString();
      }
    }
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.