Java 类org.eclipse.ui.dialogs.SelectionDialog 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:ProblemSeveritiesConfigurationBlock.java   
private void doBrowseTypes(StringButtonDialogField dialogField) {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, dialogField.getText());
        dialog.setTitle(PreferencesMessages.NullAnnotationsConfigurationDialog_browse_title);
        dialog.setMessage(PreferencesMessages.NullAnnotationsConfigurationDialog_choose_annotation);
        if (dialog.open() == Window.OK) {
            IType res= (IType) dialog.getResult()[0];
            dialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), PreferencesMessages.NullAnnotationsConfigurationDialog_error_title, PreferencesMessages.NullAnnotationsConfigurationDialog_error_message);
    }
}
项目:agui_eclipse_plugin    文件:ConfigPage.java   
/**
 * Uses the standard container selection dialog to
 * choose the new value for the container field.
 */

private void handleManifestmainclassBrowse() {

    String mainClass = getManifestmainclass();

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

    IResource[] res=jproject.getResource();
    IJavaSearchScope searchScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true);
    SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false);
    dialog.setMessage("Select Main-Class for JAR file");
    dialog.setTitle("Fat Jar Config");

    if (dialog.open() == SelectionDialog.OK) {
        Object[] elements= dialog.getResult();
        if (elements.length == 1) {
            SourceType mainElement = (SourceType)elements[0];
            mainClass = mainElement.getFullyQualifiedName();
            manifestmainclassText.setText(mainClass);
        }
    }
}
项目:OpenSPIFe    文件:EnsembleOpenResourceHandler.java   
/**
 * Query the user for the resources that should be opened
 * 
 * @return the resource that should be opened.
 */
private final Object[] queryFileResource() {
    final IWorkbenchWindow window = PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow();
    if (window == null) {
        return null;
    }
    final Shell parent = window.getShell();
    final IContainer input = ResourcesPlugin.getWorkspace().getRoot();

    final SelectionDialog selectionDialog = getNewSelectionDialogInstance(parent, input, IResource.FILE);

    final int resultCode = selectionDialog.open();
    if (resultCode != Window.OK) {
        return null;
    }

    final Object[] result = selectionDialog.getResult();

    return result;
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
protected void handleMainClassBrowseButtonPressed() {
    List<IResource> resources= JarPackagerUtil.asResources(fJarPackage.getElements());
    if (resources == null) {
        setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_noResourceSelected);
        return;
    }
    IJavaSearchScope searchScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(resources.toArray(new IResource[resources.size()]), true);
    SelectionDialog dialog= JavaUI.createMainTypeDialog(getContainer().getShell(), getContainer(), searchScope, 0, false, ""); //$NON-NLS-1$
    dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_mainTypeSelectionDialog_title);
    dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_mainTypeSelectionDialog_message);
    if (fJarPackage.getManifestMainClass() != null)
        dialog.setInitialSelections(new Object[] {fJarPackage.getManifestMainClass()});

    if (dialog.open() == Window.OK) {
        fJarPackage.setManifestMainClass((IType)dialog.getResult()[0]);
        fMainClassText.setText(JarPackagerUtil.getMainClassName(fJarPackage));
    } else if (!fJarPackage.isMainClassValid(getContainer())) {
        // user did not cancel: no types were found
        fJarPackage.setManifestMainClass(null);
        fMainClassText.setText(JarPackagerUtil.getMainClassName(fJarPackage));
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:GotoTypeAction.java   
@Override
public void run() {
    Shell shell= JavaPlugin.getActiveWorkbenchShell();
    SelectionDialog dialog= null;
    try {
        dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
            SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
    } catch (JavaModelException e) {
        String title= getDialogTitle();
        String message= PackagesMessages.GotoType_error_message;
        ExceptionHandler.handle(e, title, message);
        return;
    }

    dialog.setTitle(getDialogTitle());
    dialog.setMessage(PackagesMessages.GotoType_dialog_message);
    if (dialog.open() == IDialogConstants.CANCEL_ID) {
        return;
    }

    Object[] types= dialog.getResult();
    if (types != null && types.length > 0) {
        gotoType((IType) types[0]);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ExpandWithConstructorsConfigurationBlock.java   
/**
 * Creates the type hierarchy for type selection.
 */
private void doBrowseTypes() {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
        dialog.setTitle(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title);
        dialog.setMessage(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description);
        if (dialog.open() == Window.OK) {
            IType res= (IType)dialog.getResult()[0];
            fNameDialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title,
                CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:GenerateToStringDialog.java   
private void browseForBuilderClass() {
    try {
        IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() });
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope,
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$
        dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle);
        dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message);
        dialog.open();
        if (dialog.getReturnCode() == OK) {
            IType type= (IType)dialog.getResult()[0];
            fBuilderClassName.setText(type.getFullyQualifiedParameterizedName());
            List<String> suggestions= fValidator.getAppendMethodSuggestions(type);
            if (!suggestions.contains(fAppendMethodName.getText()))
                fAppendMethodName.setText(suggestions.get(0));
            suggestions= fValidator.getResultMethodSuggestions(type);
            if (!suggestions.contains(fResultMethodName.getText()))
                fResultMethodName.setText(suggestions.get(0));
        }
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeAssistFavoritesConfigurationBlock.java   
private void doBrowseTypes() {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
        dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title);
        dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description);
        if (dialog.open() == Window.OK) {
            IType res= (IType) dialog.getResult()[0];
            fNameDialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ImportOrganizeInputDialog.java   
private void doBrowseTypes() {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
        dialog.setTitle(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title);
        dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_description);
        if (dialog.open() == Window.OK) {
            IType res= (IType) dialog.getResult()[0];
            fNameDialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title, PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_error_message);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
protected void handleMainClassBrowseButtonPressed() {
    List<IResource> resources= JarPackagerUtil.asResources(fJarPackage.getElements());
    if (resources == null) {
        setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_noResourceSelected);
        return;
    }
    IJavaSearchScope searchScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(resources.toArray(new IResource[resources.size()]), true);
    SelectionDialog dialog= JavaUI.createMainTypeDialog(getContainer().getShell(), getContainer(), searchScope, 0, false, ""); //$NON-NLS-1$
    dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_mainTypeSelectionDialog_title);
    dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_mainTypeSelectionDialog_message);
    if (fJarPackage.getManifestMainClass() != null)
        dialog.setInitialSelections(new Object[] {fJarPackage.getManifestMainClass()});

    if (dialog.open() == Window.OK) {
        fJarPackage.setManifestMainClass((IType)dialog.getResult()[0]);
        fMainClassText.setText(JarPackagerUtil.getMainClassName(fJarPackage));
    } else if (!fJarPackage.isMainClassValid(getContainer())) {
        // user did not cancel: no types were found
        fJarPackage.setManifestMainClass(null);
        fMainClassText.setText(JarPackagerUtil.getMainClassName(fJarPackage));
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GotoTypeAction.java   
@Override
public void run() {
    Shell shell= JavaPlugin.getActiveWorkbenchShell();
    SelectionDialog dialog= null;
    try {
        dialog= JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell),
            SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false);
    } catch (JavaModelException e) {
        String title= getDialogTitle();
        String message= PackagesMessages.GotoType_error_message;
        ExceptionHandler.handle(e, title, message);
        return;
    }

    dialog.setTitle(getDialogTitle());
    dialog.setMessage(PackagesMessages.GotoType_dialog_message);
    if (dialog.open() == IDialogConstants.CANCEL_ID) {
        return;
    }

    Object[] types= dialog.getResult();
    if (types != null && types.length > 0) {
        gotoType((IType) types[0]);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExpandWithConstructorsConfigurationBlock.java   
/**
 * Creates the type hierarchy for type selection.
 */
private void doBrowseTypes() {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
        dialog.setTitle(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title);
        dialog.setMessage(CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_description);
        if (dialog.open() == Window.OK) {
            IType res= (IType)dialog.getResult()[0];
            fNameDialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_title,
                CallHierarchyMessages.CallHierarchyTypesOrMembersDialog_ChooseTypeDialog_error_message);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenerateToStringDialog.java   
private void browseForBuilderClass() {
    try {
        IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { getType().getJavaProject() });
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), PlatformUI.getWorkbench().getProgressService(), scope,
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*ToString", fExtension); //$NON-NLS-1$
        dialog.setTitle(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_windowTitle);
        dialog.setMessage(JavaUIMessages.GenerateToStringDialog_customBuilderConfig_classSelection_message);
        dialog.open();
        if (dialog.getReturnCode() == OK) {
            IType type= (IType)dialog.getResult()[0];
            fBuilderClassName.setText(type.getFullyQualifiedParameterizedName());
            List<String> suggestions= fValidator.getAppendMethodSuggestions(type);
            if (!suggestions.contains(fAppendMethodName.getText()))
                fAppendMethodName.setText(suggestions.get(0));
            suggestions= fValidator.getResultMethodSuggestions(type);
            if (!suggestions.contains(fResultMethodName.getText()))
                fResultMethodName.setText(suggestions.get(0));
        }
    } catch (JavaModelException e) {
        JavaPlugin.log(e);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeAssistFavoritesConfigurationBlock.java   
private void doBrowseTypes() {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
        dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title);
        dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description);
        if (dialog.open() == Window.OK) {
            IType res= (IType) dialog.getResult()[0];
            fNameDialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ProblemSeveritiesConfigurationBlock.java   
private void doBrowseTypes(StringButtonDialogField dialogField) {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, dialogField.getText());
        dialog.setTitle(PreferencesMessages.NullAnnotationsConfigurationDialog_browse_title);
        dialog.setMessage(PreferencesMessages.NullAnnotationsConfigurationDialog_choose_annotation);
        if (dialog.open() == Window.OK) {
            IType res= (IType) dialog.getResult()[0];
            dialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), PreferencesMessages.NullAnnotationsConfigurationDialog_error_title, PreferencesMessages.NullAnnotationsConfigurationDialog_error_message);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ImportOrganizeInputDialog.java   
private void doBrowseTypes() {
    IRunnableContext context= new BusyIndicatorRunnableContext();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    try {
        SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
        dialog.setTitle(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title);
        dialog.setMessage(PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_description);
        if (dialog.open() == Window.OK) {
            IType res= (IType) dialog.getResult()[0];
            fNameDialogField.setText(res.getFullyQualifiedName('.'));
        }
    } catch (JavaModelException e) {
        ExceptionHandler.handle(e, getShell(), PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_title, PreferencesMessages.ImportOrganizeInputDialog_ChooseTypeDialog_error_message);
    }
}
项目:n4js    文件:AssignWorkingSetsAction.java   
@Override
public void run() {
    // fail if the action hasn't been initialized
    if (site == null) {
        return;
    }

    final Object[] selectionElements = getStructuredSelection().toArray();

    // get Iterable of selected project names
    Iterable<String> selectionProjectNames = Arrays.asList(selectionElements)
            .stream().filter(item -> item instanceof IProject)
            .map(item -> ((IProject) item).getName())
            .collect(Collectors.toList());

    // double-check that the active Working Sets Manager is {@link ManualAssociationAwareWorkingSetManager}
    if (!(broker.getActiveManager() instanceof ManualAssociationAwareWorkingSetManager)) {
        return;
    }

    // open the dialog
    SelectionDialog dialog = createDialog(Arrays.asList(((ManualAssociationAwareWorkingSetManager) broker
            .getActiveManager()).getWorkingSets()), selectionElements.length);

    dialog.open();

    // Abort if user didn't press OK
    if (dialog.getReturnCode() != Window.OK) {
        return;
    }

    // perform specified working set updates
    performWorkingSetUpdate(dialog.getResult(), selectionProjectNames);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:LocalMapReduceLaunchTabGroup.java   
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  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
        e.printStackTrace();
      }
    }
  });
}
项目:hadoop-EAR    文件:LocalMapReduceLaunchTabGroup.java   
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  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
        e.printStackTrace();
      }
    }
  });
}
项目:typescript.java    文件:DialogUtils.java   
public static IProject openProjectDialog(String initialProject, Shell shell) {
    SelectionDialog dialog = createFolderDialog(initialProject, null, true, false, shell);
    if (dialog.open() != Window.OK) {
        return null;
    }
    Object[] results = dialog.getResult();
    if (results != null && results.length > 0) {
        return (IProject) results[0];
    }
    return null;
}
项目:typescript.java    文件:DialogUtils.java   
public static IResource openFolderDialog(String initialFolder, IProject project, boolean showAllProjects,
        Shell shell) {
    SelectionDialog dialog = createFolderDialog(initialFolder, project, showAllProjects, true, shell);
    if (dialog.open() != Window.OK) {
        return null;
    }
    Object[] results = dialog.getResult();
    if (results != null && results.length > 0) {
        return (IResource) results[0];
    }
    return null;
}
项目:agui_eclipse_plugin    文件:FJExportWizardConfigPage.java   
/**
 * Uses the standard container selection dialog to choose the new value for
 * the container field.
 */

private void handleManifestmainclassBrowse() {
    try {
        String mainClass = getManifestmainclass();

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

        IResource[] res = { jproject.getCorrespondingResource() };
        IJavaSearchScope searchScope = JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true);
        SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false);
        dialog.setMessage("Select Main-Class for JAR file");
        dialog.setTitle("Fat Jar Config");

        if (dialog.open() == SelectionDialog.OK) {
            Object[] elements = dialog.getResult();
            if (elements.length == 1) {
                SourceType mainElement = (SourceType) elements[0];
                mainClass = mainElement.getFullyQualifiedName();
                manifestmainclassText.setText(mainClass);
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaUI.java   
/**
 * Creates a selection dialog that lists all packages of the given Java project.
 * The caller is responsible for opening the dialog with <code>Window.open</code>,
 * and subsequently extracting the selected package (of type
 * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
 *
 * @param parent the parent shell of the dialog to be created
 * @param project the Java project
 * @param style flags defining the style of the dialog; the valid flags are:
 *   <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>, indicating that
 *   packages from binary package fragment roots should be included in addition
 *   to those from source package fragment roots;
 *   <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>, indicating that
 *   packages from required projects should be included as well.
 * @param filter the initial pattern to filter the set of packages. For example "com" shows
 * all packages starting with "com". The meta character '?' representing any character and
 * '*' representing any string are supported. Clients can pass an empty string if no filtering
 * is required.
 * @return a new selection dialog
 * @exception JavaModelException if the selection dialog could not be opened
 *
 * @since 2.0
 */
public static SelectionDialog createPackageDialog(Shell parent, IJavaProject project, int style, String filter) throws JavaModelException {
    Assert.isTrue((style | IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) ==
        (IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS));

    IPackageFragmentRoot[] roots= null;
    if ((style & IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) != 0) {
        roots= project.getAllPackageFragmentRoots();
    } else {
        roots= project.getPackageFragmentRoots();
    }

    List<IPackageFragmentRoot> consideredRoots= null;
    if ((style & IJavaElementSearchConstants.CONSIDER_BINARIES) != 0) {
        consideredRoots= Arrays.asList(roots);
    } else {
        consideredRoots= new ArrayList<IPackageFragmentRoot>(roots.length);
        for (int i= 0; i < roots.length; i++) {
            IPackageFragmentRoot root= roots[i];
            if (root.getKind() != IPackageFragmentRoot.K_BINARY)
                consideredRoots.add(root);

        }
    }

    IJavaSearchScope searchScope= SearchEngine.createJavaSearchScope(consideredRoots.toArray(new IJavaElement[consideredRoots.size()]));
    BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
    if (style == 0 || style == IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) {
        return createPackageDialog(parent, context, searchScope, false, true, filter);
    } else {
        return createPackageDialog(parent, context, searchScope, false, false, filter);
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
protected void handleSealPackagesDetailsButtonPressed() {
    SelectionDialog dialog= createPackageDialog(getPackagesForSelectedResources());
    dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_sealedPackagesSelectionDialog_title);
    dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_sealedPackagesSelectionDialog_message);
    dialog.setInitialSelections(fJarPackage.getPackagesToSeal());
    if (dialog.open() == Window.OK)
        fJarPackage.setPackagesToSeal(getPackagesFromDialog(dialog));
    updateSealingInfo();
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
protected void handleUnSealPackagesDetailsButtonPressed() {
    SelectionDialog dialog= createPackageDialog(getPackagesForSelectedResources());
    dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_unsealedPackagesSelectionDialog_title);
    dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_unsealedPackagesSelectionDialog_message);
    dialog.setInitialSelections(fJarPackage.getPackagesToUnseal());
    if (dialog.open() == Window.OK)
        fJarPackage.setPackagesToUnseal(getPackagesFromDialog(dialog));
    updateSealingInfo();
}
项目:Eclipse-Postfix-Code-Completion    文件:GotoPackageAction.java   
@Override
public void run() {
    Shell shell= JavaPlugin.getActiveWorkbenchShell();
    SelectionDialog dialog= createAllPackagesDialog(shell);
    dialog.setTitle(getDialogTitle());
    dialog.setMessage(PackagesMessages.GotoPackage_dialog_message);
    dialog.open();
    Object[] res= dialog.getResult();
    if (res != null && res.length == 1)
        gotoPackage((IPackageFragment)res[0]);
}
项目:Eclipse-Postfix-Code-Completion    文件:GotoPackageAction.java   
private SelectionDialog createAllPackagesDialog(Shell shell) {
    IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int flag= PackageSelectionDialog.F_HIDE_EMPTY_INNER;
    PackageSelectionDialog dialog= new PackageSelectionDialog(shell, progressService, flag, scope);
    dialog.setFilter(""); //$NON-NLS-1$
    dialog.setIgnoreCase(false);
    dialog.setMultipleSelection(false);
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaUI.java   
/**
 * Creates a selection dialog that lists all packages of the given Java project.
 * The caller is responsible for opening the dialog with <code>Window.open</code>,
 * and subsequently extracting the selected package (of type
 * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
 *
 * @param parent the parent shell of the dialog to be created
 * @param project the Java project
 * @param style flags defining the style of the dialog; the valid flags are:
 *   <code>IJavaElementSearchConstants.CONSIDER_BINARIES</code>, indicating that
 *   packages from binary package fragment roots should be included in addition
 *   to those from source package fragment roots;
 *   <code>IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS</code>, indicating that
 *   packages from required projects should be included as well.
 * @param filter the initial pattern to filter the set of packages. For example "com" shows
 * all packages starting with "com". The meta character '?' representing any character and
 * '*' representing any string are supported. Clients can pass an empty string if no filtering
 * is required.
 * @return a new selection dialog
 * @exception JavaModelException if the selection dialog could not be opened
 *
 * @since 2.0
 */
public static SelectionDialog createPackageDialog(Shell parent, IJavaProject project, int style, String filter) throws JavaModelException {
    Assert.isTrue((style | IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) ==
        (IJavaElementSearchConstants.CONSIDER_BINARIES | IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS));

    IPackageFragmentRoot[] roots= null;
    if ((style & IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) != 0) {
        roots= project.getAllPackageFragmentRoots();
    } else {
        roots= project.getPackageFragmentRoots();
    }

    List<IPackageFragmentRoot> consideredRoots= null;
    if ((style & IJavaElementSearchConstants.CONSIDER_BINARIES) != 0) {
        consideredRoots= Arrays.asList(roots);
    } else {
        consideredRoots= new ArrayList<IPackageFragmentRoot>(roots.length);
        for (int i= 0; i < roots.length; i++) {
            IPackageFragmentRoot root= roots[i];
            if (root.getKind() != IPackageFragmentRoot.K_BINARY)
                consideredRoots.add(root);

        }
    }

    IJavaSearchScope searchScope= SearchEngine.createJavaSearchScope(consideredRoots.toArray(new IJavaElement[consideredRoots.size()]));
    BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
    if (style == 0 || style == IJavaElementSearchConstants.CONSIDER_REQUIRED_PROJECTS) {
        return createPackageDialog(parent, context, searchScope, false, true, filter);
    } else {
        return createPackageDialog(parent, context, searchScope, false, false, filter);
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
protected void handleSealPackagesDetailsButtonPressed() {
    SelectionDialog dialog= createPackageDialog(getPackagesForSelectedResources());
    dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_sealedPackagesSelectionDialog_title);
    dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_sealedPackagesSelectionDialog_message);
    dialog.setInitialSelections(fJarPackage.getPackagesToSeal());
    if (dialog.open() == Window.OK)
        fJarPackage.setPackagesToSeal(getPackagesFromDialog(dialog));
    updateSealingInfo();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
protected void handleUnSealPackagesDetailsButtonPressed() {
    SelectionDialog dialog= createPackageDialog(getPackagesForSelectedResources());
    dialog.setTitle(JarPackagerMessages.JarManifestWizardPage_unsealedPackagesSelectionDialog_title);
    dialog.setMessage(JarPackagerMessages.JarManifestWizardPage_unsealedPackagesSelectionDialog_message);
    dialog.setInitialSelections(fJarPackage.getPackagesToUnseal());
    if (dialog.open() == Window.OK)
        fJarPackage.setPackagesToUnseal(getPackagesFromDialog(dialog));
    updateSealingInfo();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GotoPackageAction.java   
@Override
public void run() {
    Shell shell= JavaPlugin.getActiveWorkbenchShell();
    SelectionDialog dialog= createAllPackagesDialog(shell);
    dialog.setTitle(getDialogTitle());
    dialog.setMessage(PackagesMessages.GotoPackage_dialog_message);
    dialog.open();
    Object[] res= dialog.getResult();
    if (res != null && res.length == 1)
        gotoPackage((IPackageFragment)res[0]);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GotoPackageAction.java   
private SelectionDialog createAllPackagesDialog(Shell shell) {
    IProgressService progressService= PlatformUI.getWorkbench().getProgressService();
    IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
    int flag= PackageSelectionDialog.F_HIDE_EMPTY_INNER;
    PackageSelectionDialog dialog= new PackageSelectionDialog(shell, progressService, flag, scope);
    dialog.setFilter(""); //$NON-NLS-1$
    dialog.setIgnoreCase(false);
    dialog.setMultipleSelection(false);
    return dialog;
}
项目:checker-framework    文件:CheckerPreferencePage.java   
private void searchForClass() {
    OpenTypeSelectionDialog dialog = new OpenTypeSelectionDialog(
            getShell(), true, null, null, IJavaSearchConstants.CLASS);
    dialog.setTitle("Search for checker classes");
    dialog.setMessage("Select additional checkers to use.");

    if (dialog.open() == SelectionDialog.OK) {
        Object[] results = dialog.getResult();
        Set<String> classNames = new LinkedHashSet<String>();

        for (Object result : results) {
            if (result instanceof IType) {
                IType type = (IType) result;
                classNames.add(type.getFullyQualifiedName());
            }
        }

        //TODO: CHECK FOR DUPLICATES?

        final List<String> classesInTable = classesFromTableItems();
        for(final String cn : classNames) {
            final CheckerInfo ci = CheckerInfo.fromClassPath(cn, null);
            if(!classesInTable.contains(cn)) { //TODO: ADD A DIALOG TO WARN IF ALREADY CONTAINED
                addProcTableItem(ci, false);
            }
        }
    }
}
项目:checker-framework    文件:CheckerPreferencePage.java   
private void addOption() {
    final InputDialog inputDialog = new InputDialog( getShell(), "Add Option",
            "Please enter your option exactly as it would appear on the command line. " +
            "Include any space that would appear between the option name and value.",
            "",
            null);

    if (inputDialog.open() == SelectionDialog.OK) {
        final String result = inputDialog.getValue();
        addOptTableItem(new OptionLine(result, true));
    }
}
项目:checker-framework    文件:CustomPreferencesPage.java   
private void searchForClass()
{
    OpenTypeSelectionDialog dialog = new OpenTypeSelectionDialog(
            getShell(), true, null, null, IJavaSearchConstants.CLASS);
    dialog.setTitle("Search for checker classes");
    dialog.setMessage("Select additional checkers to use.");

    if (dialog.open() == SelectionDialog.OK)
    {
        Object[] results = dialog.getResult();
        List<String> classNames = new ArrayList<String>();

        for (Object result : results)
        {
            if (result instanceof IType)
            {
                IType type = (IType) result;
                classNames.add(type.getFullyQualifiedName());
            }
        }

        for(final String cn : classNames) { 
            if(!contains(cn)) { //TODO: ADD A DIALOG TO WARN IF ALREADY CONTAINED
                customCheckers.add(cn);
            }
        }
    }
}
项目:hadoop-on-lustre    文件:LocalMapReduceLaunchTabGroup.java   
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  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
        e.printStackTrace();
      }
    }
  });
}
项目:birt    文件:DateTimeCellEditor.java   
protected Object openDialogBox( Control cellEditorWindow )
{
    TimeOptionDialog dialog = new TimeOptionDialog( cellEditorWindow.getShell( ) );
    Object value =  getValue( );
    Date dateValue = new Date( );
    try {
        if ( value != null )
        {
            TimeDialogInfo time = new TimeDialogInfo( );
            if( value instanceof String && !value.toString().trim().equals("") ) //$NON-NLS-1$
            {
                dateValue  = new SimpleDateFormat( time.getFormat()).parse(value.toString() );
            }
            else if( value instanceof Date )
            {
                dateValue  = (Date)value;
            }
            time.setTime( dateValue.getTime( ) );
            dialog.setInfo( time );
        }
    } catch ( Exception e ) {
        logger.log(Level.SEVERE, e.getMessage(),e);
    }

    dialog.open( );
    if ( dialog.getReturnCode( ) == SelectionDialog.OK )
    {
        TimeDialogInfo result = ( TimeDialogInfo ) dialog.getInfo( );
        dateValue = new Date( result.getTime( ) );
    }
    return dateValue;
}
项目:RDFS    文件:LocalMapReduceLaunchTabGroup.java   
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  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
        e.printStackTrace();
      }
    }
  });
}
项目:hadoop-0.20    文件:LocalMapReduceLaunchTabGroup.java   
private void createRow(final Composite parent, Composite panel,
    final Text text) {
  text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  Button button = new Button(panel, SWT.BORDER);
  button.setText("Browse...");
  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
        e.printStackTrace();
      }
    }
  });
}
项目:Pydev    文件:GlobalsDialogFactory.java   
/**
 * Creates the dialog according to the Eclipse version we have (on 3.2, the old API is used)
 * @param pythonNatures 
 */
public static SelectionDialog create(Shell shell, List<AbstractAdditionalTokensInfo> additionalInfo,
        String selectedText) {
    boolean expectedError = true;
    try {
        GlobalsTwoPanelElementSelector2 newDialog = new GlobalsTwoPanelElementSelector2(shell, true, selectedText);
        //If we were able to instance it, the error is no longer expected!
        expectedError = false;

        newDialog.setElements(additionalInfo);
        return newDialog;
    } catch (Throwable e) {
        //That's OK: it's only available for Eclipse 3.3 onwards.
        if (expectedError) {
            Log.log(e);
        }
    }

    //If it got here, we were unable to create the new dialog (show the old -- compatible with 3.2)
    GlobalsTwoPaneElementSelector dialog;
    dialog = new GlobalsTwoPaneElementSelector(shell);
    dialog.setMessage("Filter");
    if (selectedText != null && selectedText.length() > 0) {
        dialog.setFilter(selectedText);
    }

    List<IInfo> lst = new ArrayList<IInfo>();

    for (AbstractAdditionalTokensInfo info : additionalInfo) {
        lst.addAll(info.getAllTokens());
    }

    dialog.setElements(lst.toArray());
    return dialog;
}