Java 类org.eclipse.ui.dialogs.ElementTreeSelectionDialog 实例源码

项目:neoscada    文件:HiveTab.java   
protected void chooseWorkspace ()
{
    final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (), new WorkbenchLabelProvider (), new WorkbenchContentProvider () );
    dialog.setTitle ( "Select driver exporter configuration file" );
    dialog.setMessage ( "Choose a driver exporter file for the configuration" );
    dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () );
    dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) );
    dialog.setAllowMultiple ( true );
    dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE );
    if ( dialog.open () == IDialogConstants.OK_ID )
    {
        final IResource resource = (IResource)dialog.getFirstResult ();
        if ( resource != null )
        {
            final String arg = resource.getFullPath ().toString ();
            final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc", arg ); //$NON-NLS-1$
            this.fileText.setText ( fileLoc );
            makeDirty ();
        }
    }
}
项目:bdf2    文件:XmlReader.java   
static public void main(String[] arg) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new PropertyLabelProvider(),
            new PropertyContentProvider());

    dialog.setInput(loadXmlReader(null));
    dialog.open();
    try {
        loadXmlReader(null);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
项目:depan    文件:WorkspaceTools.java   
/**
 * Open a dialog box asking the user to select an existing project under the
 * current workspace.
 *
 * @param parentShell
 * @param title 
 */
public static IResource selectFile(Shell parentShell, String title) {
  ElementTreeSelectionDialog dialog =
      new ElementTreeSelectionDialog(
          parentShell,
          new WorkbenchLabelProvider(),
          new WorkbenchContentProvider()
      );

  dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
  dialog.setTitle(title);
  dialog.setAllowMultiple(false);

  if(dialog.open() == ElementTreeSelectionDialog.OK) {
    return (IResource) dialog.getFirstResult();
  }
  return null;
}
项目:ModelDebugging    文件:DSLLaunchConfigurationTab.java   
/**
 * Opens the {@link EObject first instruction} selection dialog.
 * 
 * @param shell
 *            the {@link Shell} to use for display
 * @param resourceSet
 *            the {@link ResourceSet} to get the first instruction from
 * @return the selected first instruction {@link URI} if any selected, <code>null</code> otherwise
 */
public static EObject openFirstInstructionSelection(final Shell shell, ResourceSet resourceSet) {
    final EObject res;
    final ComposedAdapterFactory fatory = new ComposedAdapterFactory(
            ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    fatory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
    fatory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
            new AdapterFactoryLabelProvider(fatory), new AdapterFactoryContentProvider(fatory));
    dialog.setTitle("Select first instruction");
    dialog.setMessage("Select the first instruction:");
    dialog.setInput(resourceSet);
    if (dialog.open() == Window.OK) {
        res = (EObject)dialog.getFirstResult();
    } else {
        res = null;
    }
    fatory.dispose();
    return res;
}
项目:eclipse-transpiler-plugin    文件:PathDialog.java   
private void createFolderDestination() {
    Composite row = new Composite(destRow, SWT.NONE);
    row.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    GridLayout gl_folderSource = new GridLayout(2, false);
    gl_folderSource.marginRight = -5;
    gl_folderSource.marginLeft = -5;
    row.setLayout(gl_folderSource);

    destFolder = new Text(row, SWT.BORDER | SWT.READ_ONLY);
    destFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    Button destFolderButton = new Button(row, SWT.NONE);
    destFolderButton.setImage(folder);
    destFolderButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    destFolderButton.setText("Folder");
    destFolderButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            ElementTreeSelectionDialog diag = createFolderDialog("Destination Folder Selection", entry.getDestination());
            if (diag.open() == Dialog.OK) {
                setDestination((IFolder)diag.getFirstResult());
            }
        }
    });
}
项目:ant-ivyde    文件:PathEditor.java   
private void selectInProject() {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
            new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
    dialog.setTitle("Select a file in the project:");
    dialog.setMessage("Select a file in the project:");
    // Filter to the project
    dialog.addFilter(new ViewerFilter() {
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IProject) {
                return ((IProject) element).getName().equals(project.getName());
            }
            // we want a folder
            return defaultExtension != null || element instanceof IContainer;
        }
    });
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    // TODO try to preselect the current file
    dialog.open();
    Object[] results = dialog.getResult();
    if ((results != null) && (results.length > 0) && (results[0] instanceof IResource)) {
        IPath path = ((IResource) results[0]).getFullPath();
        setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
    }
}
项目:jisocreator    文件:AddFileAction.java   
@Override
   public void run() {
ElementTreeSelectionDialog isoTreeSelectionDialog = new ElementTreeSelectionDialog(
    Display.getDefault().getActiveShell(), new IsoTreeLabelProvider(), new IsoTreeContentProvider());
isoTreeSelectionDialog.setTitle("Iso tree");
isoTreeSelectionDialog.setMessage("Select the destination directory to place the selected files.");
isoTreeSelectionDialog.setInput(IsoExplorerSashForm.getInstance().getIsoDirectoriesTree().getInput());

switch (isoTreeSelectionDialog.open()) {
case Window.OK:
    executeAddFiles((ITreeNode) isoTreeSelectionDialog.getFirstResult());
    executeAction();
    isoTreeSelectionDialog.close();
default:
    return;
}
   }
项目:seasar2-assistant    文件:Seasar2AssistantPropertyPage.java   
private IFolder selectFolderInProject() {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getControl().getShell(),
            new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
    dialog.setTitle("Select View Root");
    dialog.setMessage("select the view root:");
    dialog.setInput(getProject());
    dialog.addFilter(new ViewerFilter() {

        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return element instanceof IFolder && ((IFolder) element).isAccessible();
        }
    });
    if (Window.OK == dialog.open()) {
        Object[] result = dialog.getResult();
        if (result.length > 0) {
            return (IFolder) result[0];
        }
    }
    return null;
}
项目:teavm    文件:TeaVMProfileDialog.java   
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;
        }
    }
    return null;
}
项目:gemoc-studio-modeldebugging    文件:DSLLaunchConfigurationTab.java   
/**
 * Opens the model selection dialog.
 * 
 * @param parent
 *            the parent {@link Composite}
 */
private void openSiriusModelSelection(final Composite parent) {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(),
            new WorkbenchLabelProvider(), new FilteredFileContentProvider(new String[] {
                    SiriusUtil.SESSION_RESOURCE_EXTENSION }));
    dialog.setTitle("Select model file");
    dialog.setMessage("Select the model file to execute:");
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (dialog.open() == Window.OK) {
        siriusResourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString());
    }
}
项目:gemoc-studio-modeldebugging    文件:DSLLaunchConfigurationTab.java   
/**
 * Opens the model selection dialog.
 * 
 * @param parent
 *            the parent {@link Composite}
 */
private void openModelSelection(final Composite parent) {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(),
            new WorkbenchLabelProvider(), new FilteredFileContentProvider(extensions));
    dialog.setTitle("Select model file");
    dialog.setMessage("Select the model file to execute:");
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (dialog.open() == Window.OK) {
        resourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString());
    }
}
项目:angular-eclipse    文件:NgGenerateBlueprintWizardPage.java   
private void handleLocationBrowseButtonPressed() {
    IContainer folder = getFolder();
    String initialFolder = folder != null ? folder.getProjectRelativePath().toString() : null;
    final IProject project = folder != null ? folder.getProject() : null;
    ElementTreeSelectionDialog dialog = DialogUtils.createFolderDialog(initialFolder, project, project == null,
            true, getShell());
    dialog.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IProject) {
                // Show only project which are angular-cli project
                IProject p = (IProject) element;
                return AngularCLIProject.isAngularCLIProject(p);
            } else if (element instanceof IContainer) {
                // Check if the given container is included in the
                // angular-cli root-path
                IContainer container = (IContainer) element;
                return isValidAppsLocation(container, true);
            }
            return false;
        }
    });
    dialog.setTitle(AngularCLIMessages.NgGenerateBlueprintWizardPage_browse_location_title);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        if (result.length == 1) {
            Object selectedFolder = result[0];
            if (selectedFolder instanceof IContainer) {
                setFolder((IContainer) selectedFolder, true);
            }
        }
    }
}
项目:typescript.java    文件:DialogUtils.java   
public static ElementTreeSelectionDialog createFolderDialog(String initialFolder, final IProject project,
        final boolean showAllProjects, final boolean showFolder, Shell shell) {

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();
    FolderSelectionDialog dialog = new FolderSelectionDialog(shell, lp, cp);
    // dialog.setTitle(TypeScriptUIMessages.TernModuleOptionsPanel_selectPathDialogTitle);
    IContainer folder = StringUtils.isEmpty(initialFolder) ? project
            : (project != null ? project.getFolder(initialFolder)
                    : ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(initialFolder)));
    if (folder != null && folder.exists()) {
        dialog.setInitialSelection(folder);
    }
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    ViewerFilter filter = new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IProject) {
                if (showAllProjects)
                    return true;
                IProject p = (IProject) element;
                return (p.equals(project));
            } else if (element instanceof IContainer) {
                IContainer container = (IContainer) element;
                if (showFolder && container.getType() == IResource.FOLDER) {
                    return true;
                }
                return false;
            }
            return false;
        }
    };
    dialog.addFilter(filter);
    return dialog;
}
项目:eavp    文件:TreeSelectionDialogProvider.java   
/**
 * Creates a dialog used to select exactly <i>one</i> value from the input
 * tree.
 * 
 * @param shell
 *            The parent shell for the dialog.
 * @param labelProvider
 *            The label provider for the tree.
 * @param contentProvider
 *            The content provider for the tree.
 * @return The new dialog.
 */
private ElementTreeSelectionDialog createElementTreeSelectionDialog(
        Shell shell, ILabelProvider labelProvider,
        ITreeContentProvider contentProvider) {

    // Create a custom selection listener to update the selected elements on
    // the fly.
    final ISelectionChangedListener selectionListener = createSelectionChangedListener();

    ElementTreeSelectionDialog treeDialog = new ElementTreeSelectionDialog(
            shell, labelProvider, contentProvider) {
        /*
         * (non-Javadoc)
         * @see org.eclipse.ui.dialogs.ElementTreeSelectionDialog#createTreeViewer(org.eclipse.swt.widgets.Composite)
         */
        @Override
        protected TreeViewer createTreeViewer(Composite parent) {
            TreeViewer viewer = super.createTreeViewer(parent);

            // Add the selection changed listener.
            viewer.addSelectionChangedListener(selectionListener);

            return viewer;
        }
    };

    // Do not allow multi-selection here.
    treeDialog.setAllowMultiple(false);

    return treeDialog;
}
项目:statecharts    文件:BuilderPropertyPage.java   
protected void addAddBtn(final Composite btnComposite) {
    Button add = new Button(btnComposite, SWT.FLAT);
    GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).applyTo(add);
    add.setText("Add...");
    add.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            super.widgetSelected(e);
            ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(btnComposite.getShell(),
                    new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());

            dialog.setValidator(new CheaderBlacklistSelectionStatusValidator());

            dialog.setTitle("Add blacklist item");
            dialog.setMessage("Select a blacklist item:");
            dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
            dialog.addFilter(new CHeaderViewerFilter(getActualProject()));

            if (!values.isEmpty())
                dialog.setInitialSelection(values.get(values.size() - 1));

            dialog.setDialogBoundsSettings(BuilderActivator.getDefault().getDialogSettings(),
                    Dialog.DIALOG_PERSISTLOCATION);
            dialog.open();
            Object[] result = dialog.getResult();
            if (result != null) {
                for (Object selection : result) {
                    if (selection instanceof IResource) {
                        values.add((IResource) selection);
                    }
                }
                blackListViewer.refresh();
            }
        }
    });

}
项目:agui_eclipse_plugin    文件:FJExportWizardConfigPage.java   
/**
 * Uses the standard container selection dialog to choose the new value for
 * the container field.
 */

private void handleManifestfileBrowse() {
    String manifestFilename = getManifestfile();

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(null);
    dialog.setAllowMultiple(false);
    dialog.setTitle("Select Manifest File"); //$NON-NLS-1$
    //        dialog.setMessage("msg?"); //$NON-NLS-1$
    // dialog.addFilter(filter);
    // dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    dialog.setInput(jproject.getProject());
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == ElementTreeSelectionDialog.OK) {
        Object[] elements = dialog.getResult();
        if (elements.length == 1) {
            manifestFilename = ((IResource) elements[0]).getFullPath().toOSString();
            int n = manifestFilename.indexOf(File.separatorChar, 1);
            if (n != -1)
                manifestFilename = manifestFilename.substring(n + 1);
            manifestfileText.setText(manifestFilename);
        }
    }
}
项目:agui_eclipse_plugin    文件:FJExportWizardFilesSelectPage.java   
private String selectWorkspaceDir() {

        String result = null;
        ILabelProvider lp = new WorkbenchLabelProvider();
        ITreeContentProvider cp = new WorkbenchContentProvider();

        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
                getShell(), lp, cp);
        dialog.setValidator(null);
        dialog.setAllowMultiple(false);
        dialog.setTitle("Select base directory to add"); //$NON-NLS-1$
        dialog.setMessage("msg?"); //$NON-NLS-1$
        ViewerFilter filter = new ViewerFilter() {
            public boolean select(Viewer viewer, Object parentElement,
                    Object element) {
                boolean ok = (element instanceof Folder)
                        || (element instanceof Project);
                return ok;
            }
        };
        dialog.addFilter(filter);

        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

        if (dialog.open() == ElementTreeSelectionDialog.OK) {
            Object[] elements = dialog.getResult();
            if (elements.length == 1) {
                result = ((IResource) elements[0]).getFullPath().toOSString();
            }
        }
        return result;
    }
项目:agui_eclipse_plugin    文件:ConfigPage.java   
/**
     * Uses the standard container selection dialog to
     * choose the new value for the container field.
     */

    private void handleManifestfileBrowse() {

        String manifestFilename = getManifestfile();

        ILabelProvider lp= new WorkbenchLabelProvider();
        ITreeContentProvider cp= new WorkbenchContentProvider();

        ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(
                getShell(), lp, cp);
        dialog.setValidator(null);
        dialog.setAllowMultiple(false);
        dialog.setTitle("Select Manifest File"); //$NON-NLS-1$
//        dialog.setMessage("msg?"); //$NON-NLS-1$
        //dialog.addFilter(filter);
//        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());   
        //TODO: Validate Input, Make project list IAdaptable
//        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());   
        dialog.setInput(jproject.getProject());
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

        if (dialog.open() == ElementTreeSelectionDialog.OK) {
            Object[] elements= dialog.getResult();
            if (elements.length == 1) {
                manifestFilename = ((IResource)elements[0]).getLocation().toOSString();
//                int n = manifestFilename.indexOf(File.separatorChar,1);
//                if (n!=-1)
//                    manifestFilename = manifestFilename.substring(n+1);
                manifestfileText.setText(manifestFilename);
            }
        }
    }
项目:agui_eclipse_plugin    文件:FilesSelectPage.java   
private String selectWorkspaceDir() {

        String result = null;
        ILabelProvider lp= new WorkbenchLabelProvider();
        ITreeContentProvider cp= new WorkbenchContentProvider();

        ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(
                getShell(), lp, cp);
        dialog.setValidator(null);
        dialog.setAllowMultiple(false);
        dialog.setTitle("Select base directory to add"); //$NON-NLS-1$
        dialog.setMessage("msg?"); //$NON-NLS-1$
        ViewerFilter filter = new ViewerFilter() {
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                boolean ok = (element instanceof Folder) || (element instanceof Project);
                return ok;
            }
        };
        dialog.addFilter(filter);

        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());   
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

        if (dialog.open() == ElementTreeSelectionDialog.OK) {
            Object[] elements= dialog.getResult();
            if (elements.length == 1) {
                result = ((IResource)elements[0]).getFullPath().toOSString();
            }
        }
        return result;
    }
项目:testability-explorer    文件:TestabilityLaunchConfigurationTab.java   
private void setUpWhitelistPackagesDialog() {
  IJavaProject project = getSelectedProject();
  ElementTreeSelectionDialog dialog =
      new ElementTreeSelectionDialog(getControl().getShell(),
          new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS),
          new JavaPackageElementContentProvider());
  dialog.setInput(project);
  dialog.addFilter(new ViewerFilter() {

    @Override
    public boolean select(Viewer viewer, Object parentElement, Object element) {
      if (element instanceof IPackageFragment) {
        return !((IPackageFragment) element).getElementName().equals("");
      }
      if (element instanceof ICompilationUnit) {
        return false;
      }
      return true;
    }

  });
  dialog.setMessage("Choose packages to whitelist:");

  if (dialog.open() == Window.OK) {
    Object[] results = dialog.getResult();
    String[] stringArray = new String[results.length];
    for (int i = 0; i < results.length; i++) {
      if (results[i] instanceof IJavaElement) {
        stringArray[i] = ((IJavaElement) results[i]).getElementName();
      }
    }
    whiteListList.add(stringArray);
    setTabDirty();
  }
}
项目:eclox    文件:DoxyfileSelector.java   
/**
 * Opens the selection dialog and tells if the user validated to selection.
 *
 * @return  true when a selection was made, false otherwise.
 */
public boolean open() {
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
            .getSelection();
    IStructuredSelection structuredSelection = (selection != null && selection instanceof IStructuredSelection)
            ? (IStructuredSelection) selection
            : new StructuredSelection();
    boolean result = false;

    try {
        ResourceCollector collector = root != null ? ResourceCollector.run(root) : ResourceCollector.run();

        hadDoxyfiles = collector.isEmpty() == false;

        if (collector.isEmpty() == false) {
            MyDoxyfileSelectionDialog selectionDialog = new MyDoxyfileSelectionDialog(shell, new MyLabelProvider(),
                    new MyContentProvider());

            selectionDialog.setAllowMultiple(false);
            selectionDialog.setInput(collector.getDoxyfiles());
            selectionDialog.setValidator(new MySelectionValidator());
            selectionDialog.setEmptyListMessage("No Doxyfile found in opened projects.");
            selectionDialog.setMessage("Select a Doxyfile:");
            selectionDialog.setTitle("Doxyfile Selection");
            selectionDialog.setInitialSelections(structuredSelection.toArray());

            // Opens the selection dialog and save the selection.
            if (selectionDialog.open() == ElementTreeSelectionDialog.OK) {
                doxyfile = (IFile) selectionDialog.getFirstResult();
                result = true;
            }
        }
    } catch (Throwable t) {
        eclox.ui.Plugin.log(t);
    }

    return result;
}
项目:ModelDebugging    文件:DSLLaunchConfigurationTab.java   
/**
 * Opens the model selection dialog.
 * 
 * @param parent
 *            the parent {@link Composite}
 */
private void openSiriusModelSelection(final Composite parent) {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(),
            new WorkbenchLabelProvider(), new FilteredFileContentProvider(
                    new String[] {SiriusUtil.SESSION_RESOURCE_EXTENSION }));
    dialog.setTitle("Select model file");
    dialog.setMessage("Select the model file to execute:");
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (dialog.open() == Window.OK) {
        siriusResourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString());
    }
}
项目:ModelDebugging    文件:DSLLaunchConfigurationTab.java   
/**
 * Opens the model selection dialog.
 * 
 * @param parent
 *            the parent {@link Composite}
 */
private void openModelSelection(final Composite parent) {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent.getShell(),
            new WorkbenchLabelProvider(), new FilteredFileContentProvider(extensions));
    dialog.setTitle("Select model file");
    dialog.setMessage("Select the model file to execute:");
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    if (dialog.open() == Window.OK) {
        resourceURIText.setText(((IFile)dialog.getFirstResult()).getFullPath().toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
protected void handleManifestFileBrowseButtonPressed() {
    ElementTreeSelectionDialog dialog= createWorkspaceFileSelectionDialog(JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_title, JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_message);
    if (fJarPackage.isManifestAccessible())
        dialog.setInitialSelections(new IResource[] {fJarPackage.getManifestFile()});
    if (dialog.open() ==  Window.OK) {
        Object[] resources= dialog.getResult();
        if (resources.length != 1)
            setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_onlyOneManifestMustBeSelected);
        else {
            setErrorMessage(""); //$NON-NLS-1$
            fJarPackage.setManifestLocation(((IResource)resources[0]).getFullPath());
            fManifestFileText.setText(fJarPackage.getManifestLocation().toString());
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
/**
 * Creates and returns a dialog to choose an existing workspace file.
 * @param title the title
 * @param message the dialog message
 * @return the dialog
 */
protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) {
    int labelFlags= JavaElementLabelProvider.SHOW_BASICS
                    | JavaElementLabelProvider.SHOW_OVERLAY_ICONS
                    | JavaElementLabelProvider.SHOW_SMALL_ICONS;
    final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), provider, new StandardJavaElementContentProvider());
    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))
                res.setOK();
            else
                res.setError(""); //$NON-NLS-1$
            return res;
        }
    });
    dialog.addFilter(new EmptyInnerPackageFilter());
    dialog.addFilter(new LibraryFilter());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion    文件:NativeLibrariesConfigurationBlock.java   
private String chooseInternal() {
    String initSelection= fPathField.getText();

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();
    Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
    TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses);

    IResource initSel= null;
    IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
    if (initSelection.length() > 0) {
        initSel= root.findMember(new Path(initSelection));
    }
    if (initSel == null) {
        initSel= root.findMember(fEntry.getPath());
    }

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp);
    dialog.setAllowMultiple(false);
    dialog.setValidator(validator);
    dialog.addFilter(filter);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setTitle(NewWizardMessages.NativeLibrariesDialog_intfiledialog_title);
    dialog.setMessage(NewWizardMessages.NativeLibrariesDialog_intfiledialog_message);
    dialog.setInput(root);
    dialog.setInitialSelection(initSel);
    dialog.setHelpAvailable(false);
    if (dialog.open() == Window.OK) {
        IResource res= (IResource) dialog.getFirstResult();
        return res.getFullPath().makeRelative().toString();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:NewSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fCurrJProject.getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:AddSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fNewElement.getJavaProject().getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp) {
        @Override
        protected Control createDialogArea(Composite parent) {
            Control result= super.createDialogArea(parent);
            PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
            return result;
        }
    };
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:eclipse-transpiler-plugin    文件:PathDialog.java   
private ElementTreeSelectionDialog createFolderDialog(String title, Object selection) {
    ElementTreeSelectionDialog diag = new ElementTreeSelectionDialog(getShell(), 
            new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());

    diag.addFilter(new TypedViewerFilter(new Class[]{IFolder.class}));
    configureDialog(diag, title, "Select Folder", selection);

    return diag;
}
项目:eclipse-transpiler-plugin    文件:PathDialog.java   
private void configureDialog(ElementTreeSelectionDialog diag, String title, String message, Object selection) {
    diag.setTitle(title);
    diag.setMessage("Select Folder");
    diag.setAllowMultiple(false);
    diag.setHelpAvailable(false);
    diag.setInput(project);

    if (selection != null) {
        diag.setInitialSelection(selection);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
protected void handleManifestFileBrowseButtonPressed() {
    ElementTreeSelectionDialog dialog= createWorkspaceFileSelectionDialog(JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_title, JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_message);
    if (fJarPackage.isManifestAccessible())
        dialog.setInitialSelections(new IResource[] {fJarPackage.getManifestFile()});
    if (dialog.open() ==  Window.OK) {
        Object[] resources= dialog.getResult();
        if (resources.length != 1)
            setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_onlyOneManifestMustBeSelected);
        else {
            setErrorMessage(""); //$NON-NLS-1$
            fJarPackage.setManifestLocation(((IResource)resources[0]).getFullPath());
            fManifestFileText.setText(fJarPackage.getManifestLocation().toString());
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
/**
 * Creates and returns a dialog to choose an existing workspace file.
 * @param title the title
 * @param message the dialog message
 * @return the dialog
 */
protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) {
    int labelFlags= JavaElementLabelProvider.SHOW_BASICS
                    | JavaElementLabelProvider.SHOW_OVERLAY_ICONS
                    | JavaElementLabelProvider.SHOW_SMALL_ICONS;
    final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), provider, new StandardJavaElementContentProvider());
    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))
                res.setOK();
            else
                res.setError(""); //$NON-NLS-1$
            return res;
        }
    });
    dialog.addFilter(new EmptyInnerPackageFilter());
    dialog.addFilter(new LibraryFilter());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NativeLibrariesConfigurationBlock.java   
private String chooseInternal() {
    String initSelection= fPathField.getText();

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();
    Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
    TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses);

    IResource initSel= null;
    IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot();
    if (initSelection.length() > 0) {
        initSel= root.findMember(new Path(initSelection));
    }
    if (initSel == null) {
        initSel= root.findMember(fEntry.getPath());
    }

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp);
    dialog.setAllowMultiple(false);
    dialog.setValidator(validator);
    dialog.addFilter(filter);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setTitle(NewWizardMessages.NativeLibrariesDialog_intfiledialog_title);
    dialog.setMessage(NewWizardMessages.NativeLibrariesDialog_intfiledialog_message);
    dialog.setInput(root);
    dialog.setInitialSelection(initSel);
    dialog.setHelpAvailable(false);
    if (dialog.open() == Window.OK) {
        IResource res= (IResource) dialog.getFirstResult();
        return res.getFullPath().makeRelative().toString();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fCurrJProject.getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fNewElement.getJavaProject().getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp) {
        @Override
        protected Control createDialogArea(Composite parent) {
            Control result= super.createDialogArea(parent);
            PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
            return result;
        }
    };
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:ant-ivyde    文件:PathEditor.java   
private void selectInWorkspace() {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
            new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());
    dialog.setTitle("Select a file in the workspace:");
    dialog.setMessage("Select a file in the workspace:");
    // Filter closed projects
    dialog.addFilter(new ViewerFilter() {
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IProject) {
                return ((IProject) element).isAccessible();
            }
            // we want a folder
            return defaultExtension != null || element instanceof IContainer;
        }
    });
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    // TODO try to preselect the current file
    dialog.open();
    Object[] results = dialog.getResult();
    if (results != null && results.length > 0 && results[0] instanceof IResource) {
        IPath path = ((IResource) results[0]).getFullPath();
        if (project != null && path.segment(0).equals(project.getProject().getName())) {
            setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
        } else {
            String containerName = path.makeRelative().toString();
            setWorkspaceLoc("${workspace_loc:" + containerName + "}");
        }
    }
}
项目:vdt-plugin    文件:VerilogPrompt.java   
/**
     * Prompts the user to choose a file @see PromptExpanderBase#prompt()
     */
    public void prompt() {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle(Txt.s("Variable.Verilog.Promp.Dialog.Title")); 
        dialog.setMessage(Txt.s("Variable.Verilog.Promp.Dialog.Message")); 
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); 
        dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
        if (dialog.open() == Window.OK) {
            IResource resource = (IResource) dialog.getFirstResult();
//            dialogResultString = resource.getLocation().toOSString();
            dialogResultString = resource.getFullPath().toOSString();
        }    
    }
项目:goclipse    文件:ControlUtils.java   
public static String openProgramPathDialog(IProject project, Button button) throws OperationCancellation {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        button.getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
    dialog.setTitle(LangUIMessages.ProgramPathDialog_title);
    dialog.setMessage(LangUIMessages.ProgramPathDialog_message);

    dialog.setInput(project);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    if(dialog.open() == IDialogConstants.OK_ID) {
        IResource resource = (IResource) dialog.getFirstResult();
        return resource.getProjectRelativePath().toPortableString();
    }
    throw new OperationCancellation();
}
项目:dLabPro-Plugin    文件:WorkbenchUtil.java   
/**
 * Opens a dialog which prompts for a dLabPro script (extension
 * <code>*.?tp</code>)
 * 
 * @param iShell the parent shell for the dialog
 * @return the selected resource or <code>null</code> if the dialog was
 * canceled
 */
public static IFile openXtpScriptSelectionDialog(Shell iShell)
{
  ResourcePatternFilter iXtpFilter = new ResourcePatternFilter()
  {
    public boolean select(Viewer viewer, Object parentElement, Object element)
    {
      if (element instanceof IFile)
      {
        return !super.select(viewer, parentElement, element);
      }
      else
      {
        return true;
      }
    }
  };
  iXtpFilter.setPatterns(new String[] { "*.?tp" });

  WorkbenchLabelProvider iLp = new WorkbenchLabelProvider();
  WorkbenchContentProvider iCp = new WorkbenchContentProvider();
  ElementTreeSelectionDialog iDlg = new ElementTreeSelectionDialog(iShell,
      iLp,iCp);
  iDlg.setInput(ResourcesPlugin.getWorkspace().getRoot());
  iDlg.setTitle("Script Selection");
  iDlg.setMessage("Choose a dLabPro script");
  iDlg.addFilter(iXtpFilter);

  if (iDlg.open() == Window.OK)
    return (IFile)iDlg.getFirstResult();
  else
    return null;
}
项目:d-case_editor    文件:AbstractXmlConversionWizardPage.java   
/**
 * Creates a selection adaptor for a file browse button.
 * 
 * @param text the text control.
 * @param fileExtension the file extension.
 * @param title the title for a dialog to select a file.
 * @return a selection adaptor.
 */
private SelectionAdapter createFileBrowseAdapter(final Text text,
        final String fileExtension, final String title) {
    return new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {

            // create a tree selection dialog and initializes it.
            ElementTreeSelectionDialog fileDialog = new ElementTreeSelectionDialog(
                    getShell(), new DecoratingLabelProvider(
                            new WorkbenchLabelProvider(), PlatformUI
                                    .getWorkbench().getDecoratorManager()
                                    .getLabelDecorator()),
                    new FileExtensionRestrictTreeContentProvider(fileExtension));

            // set projects from workspace.
            fileDialog.setInput(ResourcesPlugin.getWorkspace().getRoot()
                    .getProjects());

            fileDialog.setAllowMultiple(false);
            fileDialog.setBlockOnOpen(true);
            fileDialog.setTitle(title);

            fileDialog.open();

            Object[] results = fileDialog.getResult();
            if (results != null && results.length == 1
                    && results[0] instanceof IResource) {
                text.setText(((IResource) results[0]).getFullPath()
                        .toString());
            }
        }
    };
}