/** * Converts selection dialog results into an array of IPackageFragments. * An empty array is returned in case of errors. * @throws ClassCastException if results are not IPackageFragments */ protected IPackageFragment[] getPackagesFromDialog(SelectionDialog dialog) { if (dialog.getReturnCode() == Window.OK && dialog.getResult().length > 0) return (IPackageFragment[])Arrays.asList(dialog.getResult()).toArray(new IPackageFragment[dialog.getResult().length]); else return new IPackageFragment[0]; } /**
/** * Converts selection dialog results into an array of IPackageFragments. * An empty array is returned in case of errors. * @throws ClassCastException if results are not IPackageFragments */ protected IPackageFragment[] getPackagesFromDialog(SelectionDialog dialog) { if (dialog.getReturnCode() == Window.OK && dialog.getResult().length > 0) return (IPackageFragment[])Arrays.asList(dialog.getResult()).toArray(new IPackageFragment[dialog.getResult().length]); else return new IPackageFragment[0]; } /**
/** * Converts selection dialog results into an array of IPackageFragments. * An empty array is returned in case of errors. * @param dialog the dialog * @return the selected IPackageFragments * @throws ClassCastException if results are not IPackageFragments */ protected IPackageFragment[] getPackagesFromDialog(SelectionDialog dialog) { if (dialog.getReturnCode() == Window.OK && dialog.getResult().length > 0) return Arrays.asList(dialog.getResult()).toArray(new IPackageFragment[dialog.getResult().length]); else return new IPackageFragment[0]; } /**
/** * Converts selection dialog results into an array of IPackageFragments. * An empty array is returned in case of errors. * @param dialog the dialog * @return the selected IPackageFragments * @throws ClassCastException if results are not IPackageFragments */ protected IPackageFragment[] getPackagesFromDialog(SelectionDialog dialog) { if (dialog.getReturnCode() == Window.OK && dialog.getResult().length > 0) return Arrays.asList(dialog.getResult()).toArray(new IPackageFragment[dialog.getResult().length]); else return new IPackageFragment[0]; } /**
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); } } }
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); } } }