Package org.eclipse.ui.dialogs

Examples of org.eclipse.ui.dialogs.SelectionDialog


        try {
          baseType = getPackageFragmentRoot().getJavaProject().findType(
              baseClassName);

          // edit this to limit the scope
          SelectionDialog dialog = JavaUI.createTypeDialog(
              composite.getShell(), new ProgressMonitorDialog(composite
                  .getShell()), SearchEngine.createHierarchyScope(baseType),
              IJavaElementSearchConstants.CONSIDER_CLASSES, false);

          dialog.setMessage("&Choose a type:");
          dialog.setBlockOnOpen(true);
          dialog.setTitle(dialogTitle);
          dialog.open();

          if ((dialog.getReturnCode() == Window.OK)
              && (dialog.getResult().length > 0)) {
            IType type = (IType) dialog.getResult()[0];
            text.setText(type.getFullyQualifiedName());
          }
        } catch (JavaModelException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
View Full Code Here


    Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    if (javaProject == null) {
      ErrorDialog.openError(parent, "Select a Project", "You must have selected an object within a project before using Open Component.", Status.OK_STATUS);
    }
    else {
      SelectionDialog dialog = new WOElementSelectionDialog(parent, javaProject, PlatformUI.getWorkbench().getProgressService());
      dialog.setTitle("Open Component");
      dialog.setMessage("Select a Component to Open");

      int result = dialog.open();
      if (result != IDialogConstants.OK_ID) {
        return;
      }
      Object[] typeNames = dialog.getResult();
      if (typeNames != null && typeNames.length > 0) {
        for (int i = 0; i < typeNames.length; i++) {
          String typeName = (String) typeNames[i];
          OpenComponentAction.openComponentWithTypeNamed(javaProject, typeName);
        }
View Full Code Here

   * @return the selected type name or <code>null</code>
   */
  public static String openClassSelectDialog(IJavaProject project, Control parent) {
    try {
      Shell shell = parent.getShell();
      SelectionDialog dialog = JavaUI.createTypeDialog(
          shell,new ProgressMonitorDialog(shell),
          SearchEngine.createJavaSearchScope(new IJavaElement[]{project}),
          IJavaElementSearchConstants.CONSIDER_CLASSES,false);
       
      if(dialog.open()==SelectionDialog.OK){
        Object[] result = dialog.getResult();
        return ((IType)result[0]).getFullyQualifiedName();
      }
    } catch(Exception ex){
      HTMLPlugin.logException(ex);
    }
View Full Code Here

                try {
                    IJavaProject javaProject = JavaCore.create(resource.getProject());
                    if(javaProject != null)
                    {
                        org.eclipse.jdt.core.search.IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[]{javaProject});
                        SelectionDialog sd = JavaUI.createTypeDialog(getShell(), new ApplicationWindow(getShell()), searchScope, 2, false);
                        sd.open();
                        Object objects[] = sd.getResult();
                        if(objects != null && objects.length > 0)
                        {
                            IType type = (IType)objects[0];
                            String fullyQualifiedName = type.getFullyQualifiedName('.');
                            valueText.setText(type.getFullyQualifiedName());
                            String[] interfaces = type.getSuperInterfaceNames();
                            boolean isList = false;
                            if ("java.lang.Object".equals(fullyQualifiedName)) isList = true; //$NON-NLS-1$
                            else {
                              for (int i=0; i<interfaces.length; i++) {
                                  if (interfaces[i].equals("java.util.Collection") || interfaces[i].equals("java.util.List") || interfaces[i].equals("java.util.Set")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                                      isList = true;
                                      break;
                                  }
                              }
                            }
                            if (isList) {
                                singleBrowse.setEnabled(true);
                                singleLabel.setEnabled(true);
                                singleValueText.setEnabled(true);
                            }
                            else {
                                singleBrowse.setEnabled(false);
                                singleLabel.setEnabled(false);
                                singleValueText.setEnabled(false);
                                singleValueText.setText(""); //$NON-NLS-1$
                            }
                        }
                    }
                    else {
                        MessageDialog.openError(getShell(), Messages.ContextValueDialog_JAVA_PROJECT_ERROR, Messages.ContextValueDialog_MUST_BE_JAVA_PROJECT);
                    }
                }
                catch(JavaModelException _ex) { }
            }

            @Override
      public void mouseDoubleClick(MouseEvent mouseevent)
            {
            }

            @Override
      public void mouseUp(MouseEvent mouseevent)
            {
            }

        });

        boolean enabled = false;
        if (null != contextValue && null != contextValue.singularClass) enabled = true;
    singleLabel = new Label(composite, SWT.NULL);
    singleLabel.setEnabled(enabled);
    singleLabel.setText(Messages.ContextValueDialog_LABEL_LIST_ENTRY_TYPE);
    singleValueText = new Text(composite, SWT.BORDER);
    singleValueText.setEnabled(enabled);
    singleValueText.setBackground(new Color(null, 255, 255, 255));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 250;
    singleValueText.setLayoutData(gd);
    if (enabled) singleValueText.setText(contextValue.singularClass.getName());
        singleBrowse = new Button(composite, 8);
        singleBrowse.setEnabled(enabled);
        singleBrowse.setText(Messages.ContextValueDialog_BUTTON_BROWSE);
        singleBrowse.addMouseListener(new MouseListener() {
            @Override
      public void mouseDown(MouseEvent e)
            {
                try {
                    IJavaProject javaProject = JavaCore.create(resource.getProject());
                    if(javaProject != null)
                    {
                        org.eclipse.jdt.core.search.IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[]{javaProject});
                        SelectionDialog sd = JavaUI.createTypeDialog(getShell(), new ApplicationWindow(getShell()), searchScope, 2, false);
                        sd.open();
                        Object objects[] = sd.getResult();
                        if(objects != null && objects.length > 0)
                        {
                            IType type = (IType)objects[0];
                            singleValueText.setText(type.getFullyQualifiedName());
                        }
View Full Code Here

      for (int i=0; i<items.length; i++) {
        TreeItem item = items[i];
        if (item.getData() instanceof Interpolation) {
          interpolation = (Interpolation) item.getData();
          try {
            SelectionDialog sd = JavaUI.createTypeDialog(new Shell(), null, SearchEngine.createWorkspaceScope(),
                IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false);
            sd.open();
            Object[] objects = sd.getResult();
            if (null != objects && objects.length > 0) {
              ConfigurationManager configuration = ConfigurationManager.getInstance(interpolation.getResource().getProject());
              IType type = (IType) objects[0];
              try {
                configuration.addContextValue(
View Full Code Here

     * Show a dialog that lists all main types
     */
    protected void handleSearchButtonSelected() {
        try {
            IJavaSearchScope searchScope = createSearchScope("org.nakedobjects.nof.core.persist.Fixture");
            SelectionDialog dialog = null;
                dialog = JavaUI.createTypeDialog(
                            getTab().getShell(),
                            getTab().getLaunchConfigurationDialog(),
                            searchScope,
                            IJavaElementSearchConstants.CONSIDER_CLASSES,
                            false,
                            "*"); //$NON-NLS-1$
                dialog.setTitle("Select Fixture Type"); // LauncherMessages.JavaMainTab_Choose_Main_Type_11
                dialog.setMessage("Select &type (? = any character, * = any String, TZ = TimeZone):"); // LauncherMessages.JavaMainTab_Choose_a_main__type_to_launch__12
                if (dialog.open() == Window.CANCEL) {
                    return;
                }
                Object[] results = dialog.getResult()
                IType type = (IType)results[0];
                if (type != null) {
                    fixtureText.setText(type.getFullyQualifiedName());
                }
        } catch (JavaModelException e) {
View Full Code Here

    final Property property = property();

    final IJavaProject project = property.element().adapt(IJavaProject.class);

    try {
      final SelectionDialog dlg = JavaUI.createPackageDialog(((FormComponentPresentation) context).shell(),
          project, 0, null);

      dlg.setTitle( dialogTitle.format( property.definition().getLabel( true, CapitalizationType.TITLE_STYLE, false ) ) );
      dlg.setMessage( dialogMessage.text() );

      if (dlg.open() == SelectionDialog.OK) {
        Object results[] = dlg.getResult();
        assert results != null && results.length == 1;
        if (results[0] instanceof IPackageFragment) {
          return ((IPackageFragment) results[0]).getElementName();
        }
      }
View Full Code Here

        final IProject project = property.element().adapt( IProject.class );
       
        try
        {
            final SelectionDialog dlg
                = JavaUI.createTypeDialog( ( (FormComponentPresentation) context ).shell(), null, project, browseDialogStyle, false );
           
            dlg.setTitle( dialogTitle.format( property.definition().getLabel( true, CapitalizationType.TITLE_STYLE, false ) ) );
           
            if (dlg.open() == SelectionDialog.OK) {
                Object results[] = dlg.getResult();
                assert results != null && results.length == 1;
                if (results[0] instanceof IType) {
                    return ((IType) results[0]).getFullyQualifiedName();
                }
            }
View Full Code Here

        try {
          baseType = getPackageFragmentRoot().getJavaProject().findType(
              baseClassName);

          // edit this to limit the scope
          SelectionDialog dialog = JavaUI.createTypeDialog(
              composite.getShell(), new ProgressMonitorDialog(composite
                  .getShell()), SearchEngine.createHierarchyScope(baseType),
              IJavaElementSearchConstants.CONSIDER_CLASSES, false);

          dialog.setMessage("&Choose a type:");
          dialog.setBlockOnOpen(true);
          dialog.setTitle(dialogTitle);
          dialog.open();

          if ((dialog.getReturnCode() == Window.OK)
              && (dialog.getResult().length > 0)) {
            IType type = (IType) dialog.getResult()[0];
            text.setText(type.getFullyQualifiedName());
          }
        } catch (JavaModelException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
View Full Code Here

      button.addListener(SWT.Selection, new Listener() {
        public void handleEvent(Event arg0) {
          try {
            AST ast = AST.newAST(3);

            SelectionDialog dialog = JavaUI.createTypeDialog(parent.getShell(),
                new ProgressMonitorDialog(parent.getShell()), SearchEngine
                    .createWorkspaceScope(),
                IJavaElementSearchConstants.CONSIDER_CLASSES, false);
            dialog.setMessage("Select Mapper type (implementing )");
            dialog.setBlockOnOpen(true);
            dialog.setTitle("Select Mapper Type");
            dialog.open();

            if ((dialog.getReturnCode() == Window.OK)
                && (dialog.getResult().length > 0)) {
              IType type = (IType) dialog.getResult()[0];
              text.setText(type.getFullyQualifiedName());
              setDirty(true);
            }
          } catch (JavaModelException e) {
            // TODO Auto-generated catch block
View Full Code Here

TOP

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

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.