Package org.eclipse.ui.dialogs

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


              boxToSet.setText(file);
            }
        }
       
        private String chooseFile(Object rootDirectory) {
            final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(getShell(),
                            new FileLabelProvider(),
                            new FileTreeContentProvider(false));
            dialog.setAllowMultiple(true);
            dialog.setTitle("MuClipse");
            dialog.setMessage("Select a java class");
            dialog.setInput(rootDirectory);
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFile.class}, false));
            if(dialog.open() == Window.OK) {
              IResource rc = (IResource)dialog.getFirstResult();
              return rc.getFullPath()
              .removeFirstSegments(1).toString();
             
            }
            return null;
View Full Code Here

            });
        }
       
        private String chooseFolder() {
          IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
            final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(getShell(),
                            new FileLabelProvider(),
                            new FileTreeContentProvider(true));
            dialog.setAllowMultiple(false);
            dialog.setTitle("MuClipse");
            dialog.setMessage("Select a folder");
            dialog.setInput(project);
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFolder.class}, false));
            if(dialog.open() == Window.OK) {
                IResource rc = (IResource)dialog.getFirstResult();
                if (rc != null)
                    return rc.getFullPath().removeFirstSegments(1).toString();
            }
            return null;
        }
View Full Code Here

        }
       
        private String chooseMutantRoot() {
          IFolder project = MuClipsePlugin.getProject(txtProject.
              getText().trim()).getFolder(txtOutput.getText());
            final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(getShell(),
                            new FileLabelProvider(),
                            new FileTreeContentProvider(true));
            dialog.setAllowMultiple(false);
            dialog.setTitle("MuClipse");
            dialog.setMessage("Select a mutated class");
            dialog.setInput(project);
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFolder.class}, false));
            if(dialog.open() == Window.OK) {
                IResource rc = (IResource)dialog.getFirstResult();
                if (rc != null)
                    return rc.getFullPath().removeFirstSegments(2).toString();
            }
            return null;
        }
View Full Code Here

        return chooseFile(false);
    }
   
    private String chooseFile(boolean multiple) {
       //IProject project = MuClipsePlugin.getProject(currentProject);
        final ElementTreeSelectionDialog dialog =
                new ElementTreeSelectionDialog(getShell(),
                        new FileLabelProvider(),
                        new FileTreeContentProvider(false));
        dialog.setAllowMultiple(multiple);
        dialog.setTitle("Choose file");
        dialog.setSorter(new FileViewerSorter());
        //dialog.setInput(project);
        if(multiple) {
            dialog.setMessage("Select resources. Press CTRL or SHIFT" +
                    " to select multiple resources.");
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFile.class, IFolder.class}, true));
            if(dialog.open() == Window.OK) {
                Object[] results = dialog.getResult();
                StringBuffer ret = new StringBuffer();
                if (results != null) {
                    for (int i = 0; i < results.length; i++) {
                        IResource rc = (IResource)results[i];
                        ret.append(rc.getFullPath().removeFirstSegments(1));
                        ret.append(";");
                    }
                    return ret.toString();
                   
                }
            }
        } else {
            dialog.setMessage("Select a .class file");
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFile.class}, false));
            if(dialog.open() == Window.OK) {
                IResource rc = (IResource)dialog.getFirstResult();
                if (rc != null)
                    return rc.getFullPath().removeFirstSegments(1).toString();
            }
        }
        return null;
View Full Code Here

            }
        }
       
        private String chooseFolder() {
            IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
            final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(getShell(),
                            new FileLabelProvider(),
                            new FileTreeContentProvider(true));
            dialog.setAllowMultiple(false);
            dialog.setTitle("MuClipse");
            dialog.setMessage("Select a folder");
            dialog.setInput(project);
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFolder.class}, false));
            if(dialog.open() == Window.OK) {
                IResource rc = (IResource)dialog.getFirstResult();
                if (rc != null)
                    return rc.getFullPath().removeFirstSegments(1).toString();
            }
            return null;
        }
View Full Code Here

        return chooseFile(false);
    }
   
    private String chooseFile(boolean multiple) {
       //IProject project = MuClipsePlugin.getProject(currentProject);
        final ElementTreeSelectionDialog dialog =
                new ElementTreeSelectionDialog(getShell(),
                        new FileLabelProvider(),
                        new FileTreeContentProvider(false));
        dialog.setAllowMultiple(multiple);
        dialog.setTitle("Choose file");
        dialog.setSorter(new FileViewerSorter());
        //dialog.setInput(project);
        if(multiple) {
            dialog.setMessage("Select resources. Press CTRL or SHIFT" +
                    " to select multiple resources.");
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFile.class, IFolder.class}, true));
            if(dialog.open() == Window.OK) {
                Object[] results = dialog.getResult();
                StringBuffer ret = new StringBuffer();
                if (results != null) {
                    for (int i = 0; i < results.length; i++) {
                        IResource rc = (IResource)results[i];
                        ret.append(rc.getFullPath().removeFirstSegments(1));
                        ret.append(";");
                    }
                    return ret.toString();
                   
                }
            }
        } else {
            dialog.setMessage("Select a .class file");
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFile.class}, false));
            if(dialog.open() == Window.OK) {
                IResource rc = (IResource)dialog.getFirstResult();
                if (rc != null)
                    return rc.getFullPath().removeFirstSegments(1).toString();
            }
        }
        return null;
View Full Code Here

        }
       
        private String chooseFiles() {
            IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
            IFolder input = project.getFolder(txtSelectedFolderSource.getText());
            final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(getShell(),
                            new FileLabelProvider(),
                            new FileTreeContentProvider(false));
            dialog.setAllowMultiple(true);
            dialog.setTitle("MuClipse");
            dialog.setMessage("Select a java class");
            dialog.setInput(input);
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFile.class}, true));
            if(dialog.open() == Window.OK) {
                Object[] rc = dialog.getResult();
                String toReturn = "";
                for (int i=0;i<rc.length;i++)
                {
                  IResource thisone = (IResource) rc[i];
                  toReturn += thisone.getFullPath()
View Full Code Here

            return null;
        }
       
        private String chooseFolder() {
            IProject project = MuClipsePlugin.getProject(txtProject.getText().trim());
            final ElementTreeSelectionDialog dialog =
                    new ElementTreeSelectionDialog(getShell(),
                            new FileLabelProvider(),
                            new FileTreeContentProvider(true));
            dialog.setAllowMultiple(false);
            dialog.setTitle("MuClipse");
            dialog.setMessage("Select a folder");
            dialog.setInput(project);
            dialog.setValidator(new TypedElementSelectionValidator(
                    new Class[]{IFolder.class}, false));
            if(dialog.open() == Window.OK) {
                IResource rc = (IResource)dialog.getFirstResult();
                if (rc != null)
                    return rc.getFullPath().removeFirstSegments(1).toString();
            }
            return null;
        }
View Full Code Here

            // detect IDE or RCP:
            boolean isIDE = CommonUIUtils.isIDEEnvironment();
            if ( isIDE )
            {
                // Opening a dialog for file selection
                ElementTreeSelectionDialog dialog = createWorkspaceFileSelectionDialog();
                if ( dialog.open() == Dialog.OK )
                {
                    // Getting the input stream for the selected file
                    Object firstResult = dialog.getFirstResult();
                    if ( ( firstResult != null ) && ( firstResult instanceof IFile ) )
                    {
                        inputStream = ( ( IFile ) firstResult ).getContents();
                    }
                }
                else
                {
                    // Cancel button has been clicked
                    return;
                }
            }
            else
            {
                // Opening a dialog for file selection
                FileDialog dialog = new FileDialog( editor.getSite().getShell(), SWT.OPEN | SWT.SINGLE );
                dialog.setText( DIALOG_TITLE );
                dialog.setFilterPath( System.getProperty( "user.home" ) ); //$NON-NLS-1$
                String filePath = dialog.open();
                if ( filePath == null )
                {
                    // Cancel button has been clicked
                    return;
                }
View Full Code Here

TOP

Related Classes of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

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.