Package org.eclipse.ui.dialogs

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog


     * @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


  public void run() {

    List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
    filters.add(new ClosedProjectFilter());
    filters.add(new FolderOnlyFilter());
    ElementTreeSelectionDialog dialog= SWTFactory.createAllWorkspaceFileSelectionDialog(
        getShell(),
        "Folder Selection",
        "Choose the folder to add to list",
        filters
    );

    MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, IJavaDebugUIConstants.INTERNAL_ERROR,
        "One or more exceptions occurred while adding projects.", null)//$NON-NLS-1$

    if (dialog.open() == Window.OK) {
      Object[] selections = dialog.getResult();

      List<IFolder> additions = new ArrayList<IFolder>(selections.length);
      for (int i = 0; i < selections.length; i++) {
        IFolder jp = (IFolder)selections[i];
        additions.add(jp);
View Full Code Here

  public void run() {

    List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
    filters.add(new ClosedProjectFilter());
    filters.add(new OutputFolderOnlyFilter());
    ElementTreeSelectionDialog dialog= SWTFactory.createAllWorkspaceFileSelectionDialog(
        getShell(),
        "Classes folder Selection",
        "Choose the class-folder to add to list ",
        filters
    );

    MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, IJavaDebugUIConstants.INTERNAL_ERROR,
        "One or more exceptions occurred while adding projects.", null)//$NON-NLS-1$

    if (dialog.open() == Window.OK) {
      Object[] selections = dialog.getResult();

      List<IFolder> additions = new ArrayList<IFolder>(selections.length);
      for (int i = 0; i < selections.length; i++) {
        IFolder jp = (IFolder)selections[i];
        additions.add(jp);
View Full Code Here

        | JavaElementLabelProvider.SHOW_OVERLAY_ICONS
        | JavaElementLabelProvider.SHOW_SMALL_ICONS;
    final DecoratingLabelProvider provider = new DecoratingLabelProvider(
        new JavaElementLabelProvider(labelFlags),
        new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        shell, 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 IFolder))
          res.setOK();
        else
          res.setError(""); //$NON-NLS-1$
        return res;
      }
    });
    dialog.addFilter(new ClosedProjectFilter());
    dialog.addFilter(new OutputFolderOnlyFilter());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(JavaCore.create(ResourcesPlugin.getWorkspace()
        .getRoot()));
    return dialog;
  }
View Full Code Here

        | JavaElementLabelProvider.SHOW_OVERLAY_ICONS
        | JavaElementLabelProvider.SHOW_SMALL_ICONS;
    final DecoratingLabelProvider provider = new DecoratingLabelProvider(
        new JavaElementLabelProvider(labelFlags),
        new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        shell, provider, new WorkbenchContentProvider());
    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 IFolder))
          res.setOK();
        else
          res.setError(""); //$NON-NLS-1$
        return res;
      }
    });

    if (filters != null) {
      for (ViewerFilter vf : filters) {
        dialog.addFilter(vf);
      }
    }

    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
    return dialog;
  }
View Full Code Here

  // Editing
  //
  ////////////////////////////////////////////////////////////////////////////
  @Override
  protected void openDialog(Property property) throws Exception {
    ElementTreeSelectionDialog selectionDialog;
    {
      selectionDialog = new ElementTreeSelectionDialog(m_parentShell, new LabelProvider() {
        @Override
        public Image getImage(Object element) {
          if (element instanceof ImageBundleInfo) {
            return ObjectsLabelProvider.INSTANCE.getImage(element);
          }
          if (element instanceof ImageBundlePrototypeDescription) {
            ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element;
            return prototype.getIcon();
          }
          return null;
        }

        @Override
        public String getText(Object element) {
          if (element instanceof ImageBundleInfo) {
            return ObjectsLabelProvider.INSTANCE.getText(element);
          }
          if (element instanceof ImageBundlePrototypeDescription) {
            ImageBundlePrototypeDescription prototype = (ImageBundlePrototypeDescription) element;
            return prototype.getMethod().getName() + "()";
          }
          return null;
        }
      }, new ITreeContentProvider() {
        public Object[] getElements(Object inputElement) {
          return ImageBundleContainerInfo.getBundles((JavaInfo) inputElement).toArray();
        }

        public Object[] getChildren(Object parentElement) {
          if (parentElement instanceof ImageBundleInfo) {
            return ((ImageBundleInfo) parentElement).getPrototypes().toArray();
          }
          return ArrayUtils.EMPTY_OBJECT_ARRAY;
        }

        public Object getParent(Object element) {
          if (element instanceof ImageBundlePrototypeDescription) {
            return ((ImageBundlePrototypeDescription) element).getBundle();
          }
          return null;
        }

        public boolean hasChildren(Object element) {
          return getChildren(element).length != 0;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
      }) {
        @Override
        public void create() {
          super.create();
          getTreeViewer().expandAll();
        }

        @Override
        protected Control createDialogArea(Composite parent) {
          return super.createDialogArea(parent);
        }
      };
      // validator
      selectionDialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
          if (selection.length == 1 && selection[0] instanceof ImageBundlePrototypeDescription) {
            return StatusUtils.OK_STATUS;
          } else {
            return StatusUtils.ERROR_STATUS;
          }
        }
      });
      // configure
      selectionDialog.setAllowMultiple(false);
      selectionDialog.setTitle(property.getTitle());
      selectionDialog.setMessage("Select prototype:");
      // set input
      selectionDialog.setInput(m_rootJavaInfo);
      // set initial selection
      selectionDialog.setInitialSelection(property.getValue());
    }
    // open dialog
    if (selectionDialog.open() == Window.OK) {
      ImageBundlePrototypeDescription prototype =
          (ImageBundlePrototypeDescription) selectionDialog.getFirstResult();
      property.setValue(prototype);
    }
  }
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;
            }
//            String arg = resource.getFullPath().toString();
//            String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$
View Full Code Here

    public static IResource getWorkspaceResourceElement_REMOVE (Shell shell, IResource root)
    {
        IResource resource = null;
       
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle("Select UIMA descriptor");
        dialog.setMessage("Select UIMA Xml descriptor file");
        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;
            }
//            String arg = resource.getFullPath().toString();
//            String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$
View Full Code Here

   *
   * @param shell
   *            The active window's {@link Shell}.
   */
  protected String useExistingFile(final Vertex vertex, Shell shell) {
    ElementTreeSelectionDialog tree = new ElementTreeSelectionDialog(shell,
        WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
        new WorkbenchContentProvider());
    tree.setAllowMultiple(false);
    tree.setInput(ResourcesPlugin.getWorkspace().getRoot());
    tree.setMessage("Please select an existing file:");
    tree.setTitle("Choose an existing file");
    tree.setValidator(new ISelectionStatusValidator() {

      @Override
      public IStatus validate(Object[] selection) {
        if (selection.length == 1) {
          if (selection[0] instanceof IFile) {
            IFile file = (IFile) selection[0];
            String message = "Vertex refinement: "
                + getRefinementValue(vertex, file);
            return new Status(Status.OK, PLUGIN_ID, message);
          }
        }

        return new Status(Status.ERROR, PLUGIN_ID,
            "Only files can be selected, not folders nor projects");
      }

    });

    // initial selection
    IResource resource = getRefinementFile(vertex);
    if (resource == null) {
      resource = vertex.getParent().getFile().getParent();
    }
    tree.setInitialSelection(resource);

    // opens the dialog
    if (tree.open() == Window.OK) {
      IFile file = (IFile) tree.getFirstResult();
      if (file != null) {
        return getRefinementValue(vertex, file);
      }
    }

View Full Code Here

    private class BrowseButtonListener extends SelectionAdapter {
        public void widgetSelected(SelectionEvent e) {
            String path = null;
            if (project != null && project.getProject().getLocation() != 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());
                // deprecated use as of 3.3 but we need to say compatible with 3.2
                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) {
                ivyFilePathText.setText(path);
                ivyXmlPathUpdated();
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.