protected void handleSelectServiceButton(Text text) { PortalServiceSearchScope scope = new PortalServiceSearchScope(); scope.setResourcePattern(new String[] {".*Service.class$"}); // $NON-NLS-1$ IProject project = ProjectUtil.getProject(model); ILiferayProject liferayProject = LiferayCore.create(project); IPath serviceJarPath = liferayProject.getLibraryPath("portal-service"); scope.setEnclosingJarPaths(new IPath[] {serviceJarPath}); FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialogEx( getShell(), false, null, scope, IJavaSearchConstants.INTERFACE); dialog.setTitle(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_TITLE); dialog.setMessage(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_DESC); if (dialog.open() == Window.OK) { IType type = (IType) dialog.getFirstResult(); String classFullPath = J2EEUIMessages.EMPTY_STRING; if (type != null) { classFullPath = type.getFullyQualifiedName(); } text.setText(classFullPath); } }
protected void handleSelectImplClassButton(Text text) { if (CoreUtil.isNullOrEmpty(texts[0].getText())) { MessageDialog.openWarning(getParentShell(), Msgs.addService, Msgs.specifyServiceType); return; } IPackageFragmentRoot packRoot = (IPackageFragmentRoot) model.getProperty(INewJavaClassDataModelProperties.JAVA_PACKAGE_FRAGMENT_ROOT); if (packRoot == null) { return; } IJavaSearchScope scope = null; try { // get the Service type and replace Service with Wrapper and // make it the supertype String serviceType = texts[0].getText(); if (serviceType.endsWith("Service")) // $NON-NLS-1$ { String wrapperType = serviceType + "Wrapper"; // $NON-NLS-1$ scope = BasicSearchEngine.createHierarchyScope( packRoot.getJavaProject().findType(wrapperType)); } } catch (JavaModelException e) { HookUI.logError(e); return; } FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialogEx( getShell(), false, null, scope, IJavaSearchConstants.CLASS); dialog.setTitle(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_TITLE); dialog.setMessage(J2EEUIMessages.SUPERCLASS_SELECTION_DIALOG_DESC); if (dialog.open() == Window.OK) { IType type = (IType) dialog.getFirstResult(); String classFullPath = J2EEUIMessages.EMPTY_STRING; if (type != null) { classFullPath = type.getFullyQualifiedName(); } text.setText(classFullPath); } }
protected void browseForAccessorClass() { IProgressService service = PlatformUI.getWorkbench().getProgressService(); IPackageFragmentRoot root = fAccessorPackage.getSelectedFragmentRoot(); IJavaSearchScope scope = root != null ? SearchEngine.createJavaSearchScope(new IJavaElement[] {root}) : SearchEngine.createWorkspaceScope(); FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog( getShell(), false, service, scope, IJavaSearchConstants.CLASS); dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Accessor_Selection); dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_accessor_file); dialog.setInitialPattern("*Messages"); // $NON-NLS-1$ if (dialog.open() == Window.OK) { IType selectedType = (IType) dialog.getFirstResult(); if (selectedType != null) { fAccessorClassName.setText(selectedType.getElementName()); fAccessorPackage.setSelected(selectedType.getPackageFragment()); } } }