Package org.eclipse.ui.dialogs

Examples of org.eclipse.ui.dialogs.ElementListSelectionDialog


          Activator.getLogger().info("Using existing launch configuration");
          return matchingConfigs.get(0);
        } else if (matchingConfigs.size() > 1) {
          final IDebugModelPresentation labelProvider = DebugUITools
              .newDebugModelPresentation();
          ElementListSelectionDialog dialog = new ElementListSelectionDialog(
              getShell(), //
              new ILabelProvider() {
                @Override
                public Image getImage(Object element) {
                  return labelProvider.getImage(element);
                }

                @Override
                public String getText(Object element) {
                  if (element instanceof ILaunchConfiguration) {
                    ILaunchConfiguration configuration = (ILaunchConfiguration) element;
                    try {
                      return labelProvider
                          .getText(element)
                          + " : "
                          + configuration
                          .getAttribute(
                              MavenLaunchConstants.ATTR_GOALS,
                              "");
                    } catch (CoreException ex) {
                      // ignore
                    }
                  }
                  return labelProvider.getText(element);
                }

                @Override
                public boolean isLabelProperty(Object element,
                    String property) {
                  return labelProvider.isLabelProperty(
                      element, property);
                }

                @Override
                public void addListener(
                    ILabelProviderListener listener) {
                  labelProvider.addListener(listener);
                }

                @Override
                public void removeListener(
                    ILabelProviderListener listener) {
                  labelProvider.removeListener(listener);
                }

                @Override
                public void dispose() {
                  labelProvider.dispose();
                }
              });
          dialog.setElements(matchingConfigs
              .toArray(new ILaunchConfiguration[matchingConfigs
                                                .size()]));
          dialog.setTitle("Select Configuration");
          if (mode.equals(ILaunchManager.DEBUG_MODE)) {
            dialog.setMessage("Select a launch configuration to debug:");
          } else {
            dialog.setMessage("Select a launch configuration to run:");
          }
          dialog.setMultipleSelection(false);
          int result = dialog.open();
          labelProvider.dispose();
          return result == Window.OK ? (ILaunchConfiguration) dialog
              .getFirstResult() : null;
        }

      } catch (CoreException ex) {
        Activator.getLogger().error("Unable to get the launch configuration.", ex);
View Full Code Here


    protected ILaunchConfiguration chooseConfig(List<ILaunchConfiguration> configs) {
        if (configs.isEmpty()) {
            return null;
        }
        ILabelProvider labelProvider = DebugUITools.newDebugModelPresentation();
        ElementListSelectionDialog dialog = new ElementListSelectionDialog(Display.getDefault().getActiveShell(),
                labelProvider);
        dialog.setElements(configs.toArray(new ILaunchConfiguration[configs.size()]));
        dialog.setTitle("Pick a Python configuration");
        dialog.setMessage("Choose a python configuration to run");
        dialog.setMultipleSelection(false);
        int result = dialog.open();
        labelProvider.dispose();
        if (result == Window.OK)
            return (ILaunchConfiguration) dialog.getFirstResult();
        else
            return null;
    }
View Full Code Here

                        if (props.size() > 0) {
                            edit.selectAndReveal(start, end - start);
                            treatedVars.add(string);
                            Shell activeShell = Display.getCurrent().getActiveShell();

                            ElementListSelectionDialog dialog = new ElementListSelectionDialog(activeShell,
                                    new LabelProvider() {

                                        //get the image and text for each completion

                                        @Override
                                        public Image getImage(Object element) {
                                            CtxInsensitiveImportComplProposal comp = ((CtxInsensitiveImportComplProposal) element);
                                            return comp.getImage();
                                        }

                                        @Override
                                        public String getText(Object element) {
                                            CtxInsensitiveImportComplProposal comp = ((CtxInsensitiveImportComplProposal) element);
                                            return comp.getDisplayString();
                                        }

                                    }) {

                                //override things to return the last position of the dialog correctly

                                /**
                                 * @see org.eclipse.ui.dialogs.SelectionDialog#getDialogBoundsSettings()
                                 */
                                protected IDialogSettings getDialogBoundsSettings() {
                                    IDialogSettings section = dialogSettings.getSection(DIALOG_SETTINGS);
                                    if (section == null) {
                                        section = dialogSettings.addNewSection(DIALOG_SETTINGS);
                                    }
                                    return section;
                                }

                                /* (non-Javadoc)
                                 * @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
                                 */
                                protected Point getInitialSize() {
                                    IDialogSettings settings = getDialogBoundsSettings();
                                    if (settings != null) {
                                        try {
                                            int width = settings.getInt("DIALOG_WIDTH"); //$NON-NLS-1$
                                            int height = settings.getInt("DIALOG_HEIGHT"); //$NON-NLS-1$
                                            if (width > 0 & height > 0) {
                                                return new Point(width, height);
                                            }
                                        } catch (NumberFormatException nfe) {
                                            //make the default return
                                        }
                                    }
                                    return new Point(300, 300);
                                }
                            };

                            dialog.setTitle("Choose import");
                            dialog.setMessage("Which import should be added?");
                            dialog.setElements(props.toArray());
                            int returnCode = dialog.open();
                            if (returnCode == Window.OK) {
                                ICompletionProposalExtension2 firstResult = (ICompletionProposalExtension2) dialog
                                        .getFirstResult();

                                completionsToApply.add(firstResult);
                            } else if (returnCode == Window.CANCEL) {
                                keepGoing[0] = false;
View Full Code Here

        final List<IFile> selected = new ArrayList<IFile>();

        Runnable r = new Runnable() {
            public void run() {
                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
                ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new PyFileLabelProvider());
                dialog.setElements(files);
                dialog.setTitle("Select Workspace File");
                dialog.setMessage("File may be matched to multiple files in the workspace.");
                if (dialog.open() == Window.OK) {
                    selected.add((IFile) dialog.getFirstResult());
                }
            }

        };
        if (Display.getCurrent() == null) { //not ui-thread
View Full Code Here

        setFocusOn(textProject, "project");

        btBrowseProject.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(),
                        new WorkbenchLabelProvider());
                dialog.setTitle("Project selection");
                dialog.setTitle("Select a project.");
                dialog.setElements(ResourcesPlugin.getWorkspace().getRoot().getProjects());
                dialog.open();

                Object[] result = dialog.getResult();
                if (result != null && result.length > 0) {
                    textProject.setText(((IProject) result[0]).getName());
                }
            }
View Full Code Here

                //the user has to choose which is the correct definition...
                final Display disp = shell.getDisplay();
                disp.syncExec(new Runnable() {

                    public void run() {
                        ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new ILabelProvider() {

                            public Image getImage(Object element) {
                                return PyCodeCompletionImages.getImageForType(IToken.TYPE_PACKAGE);
                            }

                            public String getText(Object element) {
                                ItemPointer pointer = (ItemPointer) element;
                                File f = (File) (pointer).file;
                                int line = pointer.start.line;
                                return f.getName() + "  (" + f.getParent() + ") - line:" + line;
                            }

                            public void addListener(ILabelProviderListener listener) {
                            }

                            public void dispose() {
                            }

                            public boolean isLabelProperty(Object element, String property) {
                                return false;
                            }

                            public void removeListener(ILabelProviderListener listener) {
                            }
                        });
                        dialog.setTitle("Found matches");
                        dialog.setTitle("Select the one you believe matches most your search.");
                        dialog.setElements(where);
                        dialog.open();
                        Object[] result = dialog.getResult();
                        if (result != null && result.length > 0) {
                            doOpen((ItemPointer) result[0], pyEdit, shell);

                        }
                    }
View Full Code Here

                }
                projects = pythonProjects.toArray(new IProject[pythonProjects.size()]);

                // Only allow the selection of projects, do not present directories
                ILabelProvider labelProvider = new PythonLabelProvider();
                ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
                dialog.setTitle("Project selection");
                dialog.setMessage("Choose a project for the run");
                dialog.setElements(projects);

                dialog.open();

                Object object = dialog.getFirstResult();
                if ((object != null) && (object instanceof IProject)) {
                    IProject project = (IProject) object;
                    PythonNature pythonNature = PythonNature.getPythonNature(project);
                    if (pythonNature == null) {
                        // The project does not have an associated python nature...
View Full Code Here

      @Override
      public void run() {
            IDebugModelPresentation labelProvider = null;
          try {
            labelProvider = DebugUITools.newDebugModelPresentation();
              ElementListSelectionDialog dialog= new ElementListSelectionDialog(JDIDebugUIPlugin.getActiveWorkbenchShell(), labelProvider);
              dialog.setElements(configList.toArray());
              dialog.setTitle("Choose a Clojure launch configuration")
              dialog.setMessage(LauncherMessages.JavaLaunchShortcut_2);
              dialog.setMultipleSelection(false);
              dialog.setAllowDuplicates(true);
              int result = dialog.open();
              if (result == Window.OK) {
                ret.set((ILaunchConfiguration) dialog.getFirstResult());
              }
          } finally {
            if (labelProvider != null) {
              labelProvider.dispose();
            }
View Full Code Here

          // only one baseline, no selection to do
          selectedBaseline = baselines[0];
          break;
        default:
          // select the baseline from list
          ElementListSelectionDialog dialog = new ElementListSelectionDialog(getSite().getShell(), new LabelProvider());
          dialog.setTitle(getTitleToolTip());
          dialog.setMessage("Select the baseline to use while generating results:");
          String[] defaultBaseline = new String[] { baselines[baselines.length - 1] };
          dialog.setInitialSelections(defaultBaseline);
          dialog.setElements(baselines);
          dialog.open();
          Object[] selected = dialog.getResult();
          if (selected == null)
            return;
          selectedBaseline = (String) selected[0];
          break;
      }
View Full Code Here

    }
    fWorkbenchAction.run();
  }

  private void internalRun() {
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(
        getShell(), new ModelElementLabelProvider());
    dialog.setTitle(PHPUIMessages.OpenProjectAction_dialog_title);
    dialog.setMessage(PHPUIMessages.OpenProjectAction_dialog_message);
    dialog.setElements(getClosedProjects());
    dialog.setMultipleSelection(true);
    int result = dialog.open();
    if (result != Window.OK)
      return;
    final Object[] projects = dialog.getResult();
    IWorkspaceRunnable runnable = createRunnable(projects);
    try {
      PlatformUI.getWorkbench().getProgressService().run(true, true,
          new WorkbenchRunnableAdapter(runnable));
    } catch (InvocationTargetException e) {
View Full Code Here

TOP

Related Classes of org.eclipse.ui.dialogs.ElementListSelectionDialog

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.