Examples of ElementTreeSelectionDialog


Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog


    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

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

       * Opens the corpus folder chooser dialog and shows the chosen dialog in the corpus folder
       * text field.
       */
      public void widgetSelected(SelectionEvent e) {

        final ElementTreeSelectionDialog folderSelectionDialog = new ElementTreeSelectionDialog(
                getShell(), new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI
                        .getWorkbench().getDecoratorManager().getLabelDecorator()),
                new BaseWorkbenchContentProvider());

        folderSelectionDialog.addFilter(new ContainerElementFilter());

        if (containerElement != null) {
          folderSelectionDialog.setInitialSelection(containerElement);
        }

        folderSelectionDialog.setInput(ResourcesPlugin.getWorkspace().getRoot());

        folderSelectionDialog.setTitle("Choose folder");
        folderSelectionDialog.setMessage("Please choose a folder.");

        folderSelectionDialog.setValidator(new ISelectionStatusValidator() {
          public IStatus validate(Object[] selection) {

            if (selection.length == 1) {
             
              Object selectedElement = selection[0];
             
              if (selectedElement instanceof IAdaptable) {
                Object resourceElement = ((IAdaptable) selectedElement).getAdapter(IResource.class);
                if (resourceElement != null)
                  selectedElement = resourceElement;
              }
             
              if (selectedElement instanceof IContainer)
                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 && results.length > 0) {
          // validator makes sure that an IContainer or an IAdaptable
          // element which can provide an IContainer is selected
         
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    });
    Button browseDescriptor = new Button(descriptorGroup, SWT.NONE);
    browseDescriptor.setText("Browse ...");
    browseDescriptor.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(getWorkspaceRoot());
        dialog.setInitialSelection(getWorkspaceRoot().findMember(descriptorText.getText()));
        if (dialog.open() == IDialogConstants.OK_ID) {
          IResource resource = (IResource) dialog.getFirstResult();
          if (resource != null) {
            String fileLoc = resource.getFullPath().toString();
            descriptorText.setText(fileLoc);
          }
        }
      }
    });
   
    // Input Resource Group
    Group inputResourceGroup = new Group(projectComposite, SWT.None);
    inputResourceGroup.setText("Input Resource:");
   
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).applyTo(inputResourceGroup);
   
    GridLayout inputResourceGroupLayout = new GridLayout(2, false);
    inputResourceGroup.setLayout(inputResourceGroupLayout);
   
    inputText = new Text(inputResourceGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).applyTo(inputText);
    inputText.addModifyListener(new ModifyListener() {
     
      public void modifyText(ModifyEvent event) {
        updateLaunchConfigurationDialog();
      }
    });
   
    Button browseInputResource = new Button(inputResourceGroup, SWT.NONE);
    browseInputResource.setText("Browse ...");
    browseInputResource.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle("Select input folder or file");
        dialog.setMessage("Select input folder or file");
        dialog.setInput(getSelectedProject());
        dialog.setInitialSelection(getWorkspaceRoot().findMember(inputText.getText()));
        if (dialog.open() == IDialogConstants.OK_ID) {
          IResource resource = (IResource) dialog.getFirstResult();
          if (resource != null) {
            String fileLoc = resource.getFullPath().toString();
            inputText.setText(fileLoc);
          }
        }
      }
    });
   
    recursivelyButton = new Button(inputResourceGroup, SWT.CHECK);
    recursivelyButton.setText("Recursively, read all files under each directory");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).applyTo(recursivelyButton);
    recursivelyButton.addSelectionListener(new SelectionListener() {
     
      public void widgetSelected(SelectionEvent event) {
        updateLaunchConfigurationDialog();
      }
     
      public void widgetDefaultSelected(SelectionEvent event) {
      }
    });
   
    Group inputFormatGroup = new Group(projectComposite, SWT.None);
    inputFormatGroup.setText("Input Format:");
   
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).applyTo(inputFormatGroup);
   
    GridLayout inputFormatGroupLayout = new GridLayout(4, false);
    inputFormatGroup.setLayout(inputFormatGroupLayout);
   
    casButton = new Button(inputFormatGroup, SWT.RADIO);
    casButton.setText("CASes (XMI or XCAS format)");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).span(4, 1).applyTo(casButton);
    casButton.addSelectionListener(new SelectionListener() {
     
      public void widgetSelected(SelectionEvent event) {
        updateLaunchConfigurationDialog();
      }
     
      public void widgetDefaultSelected(SelectionEvent event) {
      }
    });
   
    plainTextButton = new Button(inputFormatGroup, SWT.RADIO);
    GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).
            grab(false, false).applyTo(plainTextButton);
    plainTextButton.addSelectionListener(new SelectionListener() {
     
      public void widgetSelected(SelectionEvent event) {
        encodingCombo.setEnabled(plainTextButton.getSelection());
        languageText.setEnabled(plainTextButton.getSelection());
        updateLaunchConfigurationDialog();
      }
     
      public void widgetDefaultSelected(SelectionEvent event) {
      }
    });
    plainTextButton.setText("Plain Text, encoding:");
   
    encodingCombo = new Combo(inputFormatGroup, SWT.NONE);
    GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).
        grab(false, false).applyTo(encodingCombo);
   
    encodingCombo.addModifyListener(new ModifyListener() {
     
      public void modifyText(ModifyEvent event) {
        updateLaunchConfigurationDialog();
      }
    });
 
    String defaultEncoding = Charset.defaultCharset().displayName();
   
    Set<String> charsets = new HashSet<String>();
    charsets.add("US-ASCII");
    charsets.add("ISO-8859-1");
    charsets.add("UTF-8");
    charsets.add("UTF-16BE");
    charsets.add("UTF-16LE");
    charsets.add("UTF-16");
    charsets.add(defaultEncoding);
   
    encodingCombo.setItems(charsets.toArray(new String[charsets.size()]));
    // Will be enabled by initializeForm if format is plain text
    encodingCombo.setEnabled(false);
   
    // Add language label
    Label languageLabel = new Label(inputFormatGroup, SWT.NONE);
    languageLabel.setText("Language:");
   
    // Add language text field
   languageText = new Text(inputFormatGroup, SWT.BORDER);
   GridDataFactory.swtDefaults().hint(250, SWT.DEFAULT).align(SWT.LEFT, SWT.CENTER).
            grab(true, false).applyTo(languageText);
   
   languageText.addModifyListener(new ModifyListener() {
    
     public void modifyText(ModifyEvent event) {
       updateLaunchConfigurationDialog();
     }
   });
  
    // Output Folder
    Group outputFolderGroup = new Group(projectComposite, SWT.None);
    outputFolderGroup.setText("Output Folder:");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).applyTo(outputFolderGroup);
    GridLayout outputFolderGroupLayout = new GridLayout(2, false);
    outputFolderGroup.setLayout(outputFolderGroupLayout);
    outputFolderText = new Text(outputFolderGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).
            grab(true, false).applyTo(outputFolderText);
    outputFolderText.addModifyListener(new ModifyListener() {
     
      public void modifyText(ModifyEvent event) {
        updateLaunchConfigurationDialog();
      }
    });
   
    Button browseOutputFolderButton = new Button(outputFolderGroup, SWT.NONE);
    browseOutputFolderButton.setText("Browse ...");
    browseOutputFolderButton.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
     // TODO: Only select elements within project
        String currentContainerString = outputFolderText.getText();
        IContainer currentContainer = getContainer(currentContainerString);
        ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),
                currentContainer, false, "Select output folder");
        dialog.showClosedProjects(false);
        dialog.open();
        Object[] results = dialog.getResult();
        if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
          IPath path = (IPath) results[0];
          String containerName = path.toOSString();
          outputFolderText.setText(containerName);
        }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

   
    openProgramPathDialog(project);
  }
 
  protected void openProgramPathDialog(IProject project) {
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
        getShell(), new WorkbenchLabelProvider(),
        new WorkbenchContentProvider());
    dialog.setTitle(LangUIMessages.mainTab_ProgramPath_searchButton_title);
    dialog.setMessage(LangUIMessages.mainTab_ProgramPath_searchButton_message);
   
    dialog.setInput(project);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    if (dialog.open() == IDialogConstants.OK_ID) {
      IResource resource = (IResource) dialog.getFirstResult();
      String arg = resource.getProjectRelativePath().toPortableString();
      // check extension
      programPathField.setFieldValue(arg);
    }
  }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

  }

  static IPath showWorkspaceDirectorySelectionDialog(Shell shell, String initialPath, IProject project) {
    String currentPathText = initialPath.replaceAll("\"", "");
    URI uri = URI.create(currentPathText);
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(),
        new WorkbenchContentProvider());
    IWorkspaceRoot workspaceRoot = workspaceRoot();
    dialog.setInput(project == null ? workspaceRoot : project);
    dialog.setComparator(new ResourceComparator(NAME));
    IResource container = null;
    if (uri.isAbsolute()) {
      IContainer containers[] = workspaceRoot.findContainersForLocationURI(uri);
      if (containers != null && containers.length > 0) {
        container = containers[0];
      }
    }
    dialog.setInitialSelection(container);
    dialog.setValidator(new ISelectionStatusValidator() {
      @Override public IStatus validate(Object[] selection) {
        if (selection != null && selection.length > 0 && selection[0] instanceof IFile) {
          return error(errorElementIsNotDirectory);
        }
        return OK_STATUS;
      }
    });
    dialog.setTitle(directorySelection);
    dialog.setMessage(selectWorkspaceDirectory);
    if (dialog.open() != OK) {
      return null;
    }
    IResource resource = (IResource) dialog.getFirstResult();
    return (resource == null) ? null : resource.getFullPath();
  }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    /**
     * Do the selection using a selection dialog.
     */
    private int doSelectionDialog() {

        dialog = new ElementTreeSelectionDialog(
                this.getShell(), labelProvider, contentProvider);

        try {
            DeviceRepositoryAccessorManager dram =
                    ProjectDeviceRepositoryProvider.getSingleton().
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    private class BrowseButtonListener extends 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) {
                ivyFilePathText.setText(path);
                ivyXmlPathUpdated();
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    });
    Button browseInputResource = new Button(inputResourceGroup, SWT.NONE);
    browseInputResource.setText("Browse ...");
    browseInputResource.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle("Select input folder");
        dialog.setMessage("Select input folder");

        dialog.setInput(getProject().getProject());
        dialog.setInitialSelection(getWorkspaceRoot().findMember(inputText.getText()));
        if (dialog.open() == IDialogConstants.OK_ID) {
          IResource resource = (IResource) dialog.getFirstResult();
          if (resource != null) {
            String fileLoc = resource.getFullPath().toString();
            inputText.setText(fileLoc);
          }
        }
      }
    });

    recursivelyButton = new Button(inputResourceGroup, SWT.CHECK);
    recursivelyButton.setText("Recursively");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(recursivelyButton);
    recursivelyButton.addSelectionListener(new SelectionListener() {

      public void widgetSelected(SelectionEvent event) {
        updateLaunchConfigurationDialog();
      }

      public void widgetDefaultSelected(SelectionEvent event) {
      }
    });

    Label viewLabel = new Label(inputResourceGroup, SWT.NONE);
    viewLabel.setText("View Name:");
    viewText = new Text(inputResourceGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().hint(250, SWT.DEFAULT).align(SWT.LEFT, SWT.CENTER)
            .grab(true, false).applyTo(viewText);
    viewText.addModifyListener(new ModifyListener() {
      public void modifyText(ModifyEvent event) {
        updateLaunchConfigurationDialog();
      }
    });

    Group outputFolderGroup = new Group(composite, SWT.None);
    outputFolderGroup.setText("Output Folder:");
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(outputFolderGroup);
    GridLayout outputFolderGroupLayout = new GridLayout(2, false);
    outputFolderGroup.setLayout(outputFolderGroupLayout);
    outputFolderText = new Text(outputFolderGroup, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
            .applyTo(outputFolderText);
    outputFolderText.addModifyListener(new ModifyListener() {

      public void modifyText(ModifyEvent event) {
        updateLaunchConfigurationDialog();
      }
    });

    Button browseOutputFolderButton = new Button(outputFolderGroup, SWT.NONE);
    browseOutputFolderButton.setText("Browse ...");
    browseOutputFolderButton.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent e) {
        String currentContainerString = outputFolderText.getText();
        IContainer currentContainer = getContainer(currentContainerString);
        ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(),
                currentContainer, false, "Select output folder");
        dialog.showClosedProjects(false);
        dialog.open();
        Object[] results = dialog.getResult();
        if ((results != null) && (results.length > 0) && (results[0] instanceof IPath)) {
          IPath path = (IPath) results[0];
          String containerName = path.toOSString();
          outputFolderText.setText(containerName);
        }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    fWorkspaceBrowse = createPushButton(standardGroup, LaunchConfigurationsMessages.CommonTab_12,
            null);
    fWorkspaceBrowse.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
                new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13);
        dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14);
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setSorter(new ResourceSorter(ResourceSorter.NAME));
        if (dialog.open() == IDialogConstants.OK_ID) {
          IResource resource = (IResource) dialog.getFirstResult();
          String arg = resource.getFullPath().toString();
          String fileLoc = VariablesPlugin.getDefault().getStringVariableManager()
                  .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$
          fFileText.setText(fileLoc);
        }
      }
    });
    fFileBrowse = createPushButton(standardGroup, LaunchConfigurationsMessages.CommonTab_7, null);
    fFileBrowse.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        String filePath = fFileText.getText();
        FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
        filePath = dialog.open();
        if (filePath != null) {
          fFileText.setText(filePath);
        }
      }
    });
    fVariables = createPushButton(standardGroup, LaunchConfigurationsMessages.CommonTab_9, null);
    fVariables.addSelectionListener(new SelectionListener() {
      public void widgetSelected(SelectionEvent e) {
        StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
        dialog.open();
        String variable = dialog.getVariableExpression();
        if (variable != null) {
          fFileText.insert(variable);
        }
      }
View Full Code Here

Examples of org.eclipse.ui.dialogs.ElementTreeSelectionDialog

    add.setText(HTMLPlugin.getResourceString("Button.Add"));
    add.setLayoutData(createButtonGridData());
    add.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
            parent.getShell(),
            new WorkbenchLabelProvider(),
            new WorkbenchContentProvider());
       
        dialog.setTitle(HTMLPlugin.getResourceString("JavaScriptPropertyPage.ChooseJavaScript"));
        dialog.setMessage(HTMLPlugin.getResourceString("JavaScriptPropertyPage.ChooseJavaScript.Description"));
        dialog.setInput(wsroot);
        dialog.setValidator(new ISelectionStatusValidator(){
          private IStatus okStatus = new Status(Status.OK, HTMLPlugin.getDefault().getPluginId(), Status.OK, "", null);
          private IStatus ngStatus = new Status(Status.ERROR, HTMLPlugin.getDefault().getPluginId(), Status.ERROR, "", null);
         
          public IStatus validate(Object[] selection) {
            for(int i=0;i<selection.length;i++){
              if(!(selection[i] instanceof IFile)){
                return ngStatus;
              }
              if(!((IFile)selection[i]).getName().endsWith(".js")){
                return ngStatus;
              }
            }
            if(selection.length==0){
              return ngStatus;
            }
            return okStatus;
          }
        });
        if (dialog.open() == Dialog.OK) {
          Object[] results = dialog.getResult();
          for(int i=0;i<results.length;i++){
            tableModel.add((IFile)results[i]);
          }
          tableViewer.refresh();
          modelChanged();
        }
      }
    });
   
    addExternal = new Button(buttons, SWT.PUSH);
    addExternal.setText(HTMLPlugin.getResourceString("Button.AddExternal"));
    addExternal.setLayoutData(createButtonGridData());
    addExternal.addSelectionListener(new SelectionAdapter(){
      public void widgetSelected(SelectionEvent evt){
        FileDialog dialog = new FileDialog(parent.getShell(), SWT.OPEN|SWT.MULTI);
        dialog.setFilterExtensions(new String[]{"*.js"});
        String result = dialog.open();
        if(result!=null){
          String dir = dialog.getFilterPath();
          String[] fileNames = dialog.getFileNames();
          for(int i=0;i<fileNames.length;i++){
            tableModel.add(new File(dir, fileNames[i]));
          }
          tableViewer.refresh();
          modelChanged();
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.