Examples of ElementTreeSelectionDialog


Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    // return null;
    // }

    // TODO: preselect entered text entry

    final ElementTreeSelectionDialog fileSelectionDialog = new ElementTreeSelectionDialog(
            getShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());

    fileSelectionDialog.addFilter(new FileElementFilter());
    fileSelectionDialog.setInput(mProject);
    fileSelectionDialog.setTitle(title);
    fileSelectionDialog.setMessage(message);
    fileSelectionDialog.setValidator(new ISelectionStatusValidator() {
      public IStatus validate(Object[] selection) {
        if (selection.length == 1 && selection[0] instanceof IFile) {
          return new Status(IStatus.OK, CasEditorPlugin.ID, 0, "", null);
        }

        return new Status(IStatus.ERROR, CasEditorPlugin.ID, 0, "Please select a file!", null);
      }
    });

    fileSelectionDialog.open();

    Object[] results = fileSelectionDialog.getResult();

    if (results != null) {
      return ((IFile) results[0]).getFullPath().removeFirstSegments(1).toString();
    }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

  @Override
  protected String changePressed() {
    // TODO: preselect entered text entry

    final ElementTreeSelectionDialog folderSelectionDialog = new ElementTreeSelectionDialog(
            getShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());

    folderSelectionDialog.setInput(mProject);
    folderSelectionDialog.setTitle(getLabelText());
    folderSelectionDialog.setMessage(getPreferenceName());
    folderSelectionDialog.setValidator(new ISelectionStatusValidator() {
      public IStatus validate(Object[] selection) {
        if (selection.length == 1 && selection[0] instanceof IFolder) {
          return new Status(IStatus.OK, CasEditorPlugin.ID, 0, "", null);
        }

        return new Status(IStatus.ERROR, CasEditorPlugin.ID, 0, "Please select a folder!", null);
      }
    });

    folderSelectionDialog.open();

    Object[] results = folderSelectionDialog.getResult();

    if (results.length != 1) {
      return null;
    }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

  }

  @Override
  protected String getNewInputObject() {
    final ElementTreeSelectionDialog folderSelectionDialog = new ElementTreeSelectionDialog(
            getShell(), new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());

    folderSelectionDialog.addFilter(new FolderElementFilter());
    folderSelectionDialog.setInput(mProject);
    folderSelectionDialog.setTitle(title);
    folderSelectionDialog.setMessage(message);
    folderSelectionDialog.setValidator(new ISelectionStatusValidator() {
      public IStatus validate(Object[] selection) {
        if (selection.length == 1 && selection[0] instanceof IFolder) {
          return new Status(IStatus.OK, CasEditorPlugin.ID, 0, "", null);
        }

        return new Status(IStatus.ERROR, CasEditorPlugin.ID, 0, "Please select a folder!", null);
      }
    });

    folderSelectionDialog.open();

    Object[] results = folderSelectionDialog.getResult();

    if (results != null) {
      return ((IFolder) results[0]).getFullPath().removeFirstSegments(1).toString();
    }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

            }
        });
    }

    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());
                }
                if (defaultExtension == null) {
                    // we want a folder
                    return element instanceof IContainer;
                }
                return true;
            }
        });
        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());
        }
    }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

            setProjectLoc(path.removeFirstSegments(1).makeRelative().toString());
        }
    }

    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();
                }
                if (defaultExtension == null) {
                    // we want a folder
                    return element instanceof IContainer;
                }
                return true;
            }
        });
        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 {
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

        btn.setText("Browse");
        btn.addSelectionListener(new SelectionAdapter() {
            public void widgetSelected(SelectionEvent e) {
                String path = null;
                if (project != null) {
                    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(Display
                            .getDefault().getActiveShell(), new WorkbenchLabelProvider(),
                            new WorkbenchContentProvider());
                    dialog.setValidator(new ISelectionStatusValidator() {
                        private final IStatus errorStatus = new Status(IStatus.ERROR, IvyPlugin.ID,
                                0, "", null);

                        public IStatus validate(Object[] selection) {
                            if (selection.length == 0) {
                                return errorStatus;
                            }
                            for (int i = 0; i < selection.length; i++) {
                                Object o = selection[i];
                                if (!(o instanceof IFile)) {
                                    return errorStatus;
                                }
                            }
                            return Status.OK_STATUS;
                        }

                    });
                    dialog.setTitle("choose ivy file");
                    dialog.setMessage("choose the ivy file to use to resolve dependencies");
                    dialog.setInput(project.getProject());
                    dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));

                    if (dialog.open() == Window.OK) {
                        Object[] elements = dialog.getResult();
                        if (elements.length > 0 && elements[0] instanceof IFile) {
                            IPath p = ((IFile) elements[0]).getProjectRelativePath();
                            path = p.toString();
                        }
                    }
                } else {
                    FileDialog dialog = new FileDialog(IvyPlugin.getActiveWorkbenchShell(),
                            SWT.OPEN);
                    dialog.setText("Choose an ivy.xml");
                    path = dialog.open();
                }

                if (path != null) {
                    conf.ivyXmlPath = path;
                    ivyFilePathText.setText(path);
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

        btnAdd.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                // IResource newFile = ResourcesPlugin.getWorkspace().getRoot();
                // if(newFile != null) {
                ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider());
                dialog.setValidator(new ISelectionStatusValidator() {
                    public IStatus validate(Object[] selection) {
                        if (selection.length > 0 && selection[0] instanceof IFile) {
                            return new Status(IStatus.OK, Plugin.PLUGIN_ID, IStatus.OK, "", null); //$NON-NLS-1$
                        }
                        return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, IStatus.ERROR, "", null); //$NON-NLS-1$
                    }
                });
                dialog.setAllowMultiple(true);
                dialog.setTitle("JAR File Selection");
                dialog.setMessage("Select one or more JAR files.");
                dialog.addFilter(new FileExtensionFilter("jar")); //$NON-NLS-1$
                dialog.setInput(ResourcesPlugin.getWorkspace());

                if (dialog.open() == Window.OK) {
                    Object[] files = dialog.getResult();
                    List<IPath> added = new ArrayList<IPath>(files.length);
                    for (Object file : files) {
                        added.add(((IResource) file).getFullPath().makeRelative());
                    }
                    if (!added.isEmpty()) {
                        addToPaths(added);
                        viewer.add(added.toArray(new IPath[added.size()]));
                    }
                }
                // }
                update();
            }
        });
        btnAddExternal.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
                dialog.setFilterExtensions(new String[] {
                    "*.jar"}); //$NON-NLS-1$
                String res = dialog.open();
                if (res != null) {
                    IPath filterPath = new Path(dialog.getFilterPath());

                    String[] fileNames = dialog.getFileNames();
                    List<IPath> added = new ArrayList<IPath>(fileNames.length);
                    for (String fileName : fileNames) {
                        added.add(filterPath.append(fileName));
                    }
                    if (!added.isEmpty()) {
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

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

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    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;
 
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

   
    Button browseButton = new Button(composite, SWT.PUSH);
    browseButton.setText("Browse ...");
    browseButton.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle("Select descriptor");
        dialog.setMessage("Select descriptor");
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setInitialSelection(ResourcesPlugin.getWorkspace().getRoot().
                findMember(typeSystemText.getText()));
        if (dialog.open() == IDialogConstants.OK_ID) {
          IResource resource = (IResource) dialog.getFirstResult();
          if (resource != null) {
            String fileLoc = resource.getFullPath().toString();
            typeSystemText.setText(fileLoc);
          }
        }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

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