Package org.eclipse.ui.dialogs

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog


            // 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


     * @return
     *      a {@link Dialog} to select a single file in the workspace
     */
    private ElementTreeSelectionDialog createWorkspaceFileSelectionDialog()
    {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( editor.getSite().getShell(),
            new WorkbenchLabelProvider(), new WorkbenchContentProvider() );
        dialog.setInput( ResourcesPlugin.getWorkspace().getRoot() );
        dialog.setMessage( Messages.getString("EditorImportConfigurationAction.SelectConfigurationFileToImport") ); //$NON-NLS-1$
        dialog.setTitle( DIALOG_TITLE );
        dialog.setAllowMultiple( false );
        dialog.setStatusLineAboveButtons( false );
        dialog.setValidator( new ISelectionStatusValidator()
        {
            /** The validated status */
            private Status validated = new Status( IStatus.OK, ApacheDS2ConfigurationPluginConstants.PLUGIN_ID,
                IStatus.OK, "", null ); //$NON-NLS-1$

View Full Code Here

                labelProvider = new FileSystemLabelProvider( p );
                viewerComparator = new FileSystemNodeComparator();
                input = new Object();
            }
       
            final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( p.shell(), labelProvider, contentProvider );
           
            dialog.setTitle( property.definition().getLabel( false, CapitalizationType.TITLE_STYLE, false ) );
            dialog.setMessage( createBrowseDialogMessage( property.definition().getLabel( true, CapitalizationType.NO_CAPS, false ) ) );
            dialog.setAllowMultiple( false );
            dialog.setHelpAvailable( false );
            dialog.setInput( input );
            dialog.setComparator( viewerComparator );
           
            final Path currentPathAbsolute = convertToAbsolute( (Path) ( (Value<?>) property ).content() );
           
            if( currentPathAbsolute != null )
            {
                Object initialSelection = null;
               
                if( contentProvider instanceof WorkspaceContentProvider )
                {
                    final URI uri = currentPathAbsolute.toFile().toURI();
                    final IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
                   
                    final IFile[] files = wsroot.findFilesForLocationURI( uri );
                   
                    if( files.length > 0 )
                    {
                        final IFile file = files[ 0 ];
                       
                        if( file.exists() )
                        {
                            initialSelection = file;
                        }
                    }
                   
                    if( initialSelection == null )
                    {
                        final IContainer[] containers = wsroot.findContainersForLocationURI( uri );
                       
                        if( containers.length > 0 )
                        {
                            final IContainer container = containers[ 0 ];
                           
                            if( container.exists() )
                            {
                                initialSelection = container;
                            }
                        }                      
                    }
                }
                else
                {
                    initialSelection = ( (FileSystemContentProvider) contentProvider ).find( currentPathAbsolute );
                }
               
                if( initialSelection != null )
                {
                    dialog.setInitialSelection( initialSelection );
                }
            }
           
            if( this.type == FileSystemResourceType.FILE )
            {
                dialog.setValidator( new FileSelectionStatusValidator() );
            }
            else if( this.type == FileSystemResourceType.FOLDER )
            {
                dialog.addFilter( new ContainersOnlyViewerFilter() );
            }
           
            if( ! extensions.isEmpty() )
            {
                dialog.addFilter( new ExtensionBasedViewerFilter( extensions ) );
            }
           
            if( dialog.open() == Window.OK )
            {
                final Object firstResult = dialog.getFirstResult();
               
                if( firstResult instanceof IResource )
                {
                    selectedAbsolutePath = ( (IResource) firstResult ).getLocation().toString();
                }
                else
                {
                    selectedAbsolutePath = ( (FileSystemNode) firstResult ).getFile().getPath();
                }
            }
        }
        else if( this.type == FileSystemResourceType.FOLDER )
        {
            final DirectoryDialog dialog = new DirectoryDialog( p.shell() );
            dialog.setText( property.definition().getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false ) );
            dialog.setMessage( createBrowseDialogMessage( property.definition().getLabel( true, CapitalizationType.NO_CAPS, false ) ) );
           
            final Value<?> value = (Value<?>) property;
            final Path path = (Path) value.content();
           
            if( path != null )
            {
                dialog.setFilterPath( path.toOSString() );
            }
            else if( roots.size() > 0 )
            {
                dialog.setFilterPath( roots.get( 0 ).toOSString() );
            }
           
            selectedAbsolutePath = dialog.open();
        }
        else
        {
            final FileDialog dialog = new FileDialog( p.shell() );
            dialog.setText( property.definition().getLabel( true, CapitalizationType.FIRST_WORD_ONLY, false ) );
           
            final Value<?> value = (Value<?>) property;
            final Path path = (Path) value.content();
           
            if( path != null && path.segmentCount() > 1 )
            {
                dialog.setFilterPath( path.removeLastSegments( 1 ).toOSString() );
                dialog.setFileName( path.lastSegment() );
            }
            else if( roots.size() > 0 )
            {
                dialog.setFilterPath( roots.get( 0 ).toOSString() );
            }
           
            if( ! extensions.isEmpty() )
            {
                final StringBuilder buf = new StringBuilder();
               
                for( String extension : extensions )
                {
                    if( buf.length() > 0 )
                    {
                        buf.append( ';' );
                    }
                   
                    buf.append( "*." );
                    buf.append( extension );
                }
               
                dialog.setFilterExtensions( new String[] { buf.toString() } );
            }
           
            selectedAbsolutePath = dialog.open();
        }
   
        if( selectedAbsolutePath != null )
        {
            final Path relativePath = convertToRelative( new Path( selectedAbsolutePath ) );
View Full Code Here

      }
    });
  }

  protected void handleManifestFileBrowseButtonPressed() {
    ElementTreeSelectionDialog dialog = createWorkspaceFileSelectionDialog(
        PharPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_title,
        PharPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_message);
    if (pharData.getStubFile() != null && pharData.isStubAccessible())
      dialog.setInitialSelections(new IResource[] { pharData
          .getStubFile() });
    if (dialog.open() == Window.OK) {
      Object[] resources = dialog.getResult();
      if (resources.length != 1)
        setErrorMessage(PharPackagerMessages.JarManifestWizardPage_error_onlyOneManifestMustBeSelected);
      else {
        // setErrorMessage("");
        if (resources[0] instanceof ISourceModule) {
View Full Code Here

        .getPreferenceStore();
    final DecoratingLabelProvider provider = new DecoratingLabelProvider(
        new PHPExplorerLabelProvider(treeContentProvider, store),
        new ProblemsLabelDecorator(null));

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        getShell(), provider, treeContentProvider);
    // dialog.setComparator(new JavaElementComparator());
    dialog.setAllowMultiple(false);
    dialog.setValidator(new ISelectionStatusValidator() {
      public IStatus validate(Object[] selection) {
        StatusInfo res = new StatusInfo();
        // only single selection
        if (selection.length == 1
            && (selection[0] instanceof IFile || selection[0] instanceof ISourceModule))
          res.setOK();
        // else
        // res.setError("");
        return res;
      }
    });
    dialog.addFilter(new EmptyInnerPackageFilter());
    // dialog.addFilter(new LibraryFilter());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(DLTKCore.create(ResourcesPlugin.getWorkspace()
        .getRoot()));
    return dialog;
  }
View Full Code Here

      }
    }
    IResource focus = initialSelection != null ? root
        .findMember(initialSelection) : null;

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        shell, new WorkbenchLabelProvider(),
        new WorkbenchContentProvider());
    dialog.setHelpAvailable(false);
    dialog.setValidator(validator);
    dialog
        .setTitle(IncludePathMessages.BuildPathDialogAccess_ZIPArchiveDialog_new_title);
    dialog
        .setMessage(IncludePathMessages.BuildPathDialogAccess_ZIPArchiveDialog_new_description);
    dialog.addFilter(new PHPArchiveFileFilter(usedPhars, true));
    dialog.setInput(root);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setInitialSelection(focus);

    if (dialog.open() == Window.OK) {
      Object[] elements = dialog.getResult();
      IPath[] res = new IPath[elements.length];
      for (int i = 0; i < res.length; i++) {
        IResource elem = (IResource) elements[i];
        res[i] = elem.getFullPath();
      }
View Full Code Here

      }
    }

    IResource existing = root.findMember(initialEntry);

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        shell, new WorkbenchLabelProvider(),
        new WorkbenchContentProvider());
    dialog.setValidator(validator);
    dialog
        .setTitle(IncludePathMessages.BuildPathDialogAccess_ZIPArchiveDialog_edit_title);
    dialog
        .setMessage(IncludePathMessages.BuildPathDialogAccess_ZIPArchiveDialog_edit_description);
    dialog.addFilter(new PHPArchiveFileFilter(usedJars, true));
    dialog.setInput(root);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setInitialSelection(existing);

    if (dialog.open() == Window.OK) {
      IResource element = (IResource) dialog.getFirstResult();
      return element.getFullPath();
    }
    return null;
  }
View Full Code Here

            }
        }
    }

    private String chooseWorkspaceDirectory(String prompt) {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(),
                new WorkbenchContentProvider());
        dialog.setTitle("Selecting directory");
        dialog.setMessage(prompt);
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
        if (dialog.open() == IDialogConstants.OK_ID) {
            IResource resource = (IResource)dialog.getFirstResult();
            if (resource != null) {
                String path = resource.getFullPath().toString();
                String fileLoc = VariablesPlugin.getDefault().getStringVariableManager()
                        .generateVariableExpression("workspace_loc", path);
                return fileLoc;
View Full Code Here

    public static IResource getWorkspaceResourceElement (Shell shell, IResource root,
                                    String dialogTitle, String dialogMessage)
    {
        IResource resource = null;
       
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle(dialogTitle);
        dialog.setMessage(dialogMessage);
        dialog.setInput(root);
        dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
        int buttonId = dialog.open();
        if (buttonId == IDialogConstants.OK_ID) {
            resource = (IResource) dialog.getFirstResult();
            if (!resource.isAccessible()) {
                return null;
            }
            if (resource instanceof IContainer) {
            }
View Full Code Here


    public static IResource getWorkspaceResourceElement (Shell shell)
    {
        IResource resource = null;
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle("Select Cpe descriptor");
        dialog.setMessage("Select Cpe Xml descriptor file");
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
        int buttonId = dialog.open();
        if (buttonId == IDialogConstants.OK_ID) {
            resource = (IResource) dialog.getFirstResult();
            if (!resource.isAccessible()) {
                return null;
            }
            String arg = resource.getFullPath().toString();
            // String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$
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.