List of usage examples for org.eclipse.jdt.core IJavaProject getProject
IProject getProject();
IProject
on which this IJavaProject
was created. From source file:com.google.gwt.eclipse.core.launch.ui.tabs.GWTSettingsTab.java
License:Open Source License
private IProject getProject() throws CoreException { IJavaProject javaProject = getJavaProject(); if (javaProject == null || !javaProject.exists()) { throw new CoreException( new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, "Could not get a valid Java project")); }// w w w.j a v a 2 s . com return javaProject.getProject(); }
From source file:com.google.gwt.eclipse.core.launch.ui.tabs.GwtSuperDevModeCodeServerSettingsTab.java
License:Open Source License
@Override public void initializeFrom(ILaunchConfiguration config) { blockUpdateLaunchConfigurationDialog = true; IJavaProject javaProject = null; try {/*from w w w .j a v a2 s.co m*/ super.initializeFrom(config); try { if (urlSelectionBlock != null) { urlSelectionBlock.initializeForm(config); } if (sdmModeBlock != null) { sdmModeBlock.initializeFrom(config); } javaProject = getJavaProject(); entryPointModulesBlock.setJavaProject(javaProject); // Can't get the project's entry point modules if this launch // configuration has not been assigned to a project if (javaProject != null) { // The default set of entry point modules is the project's // set of defined entry point modules (specified in project // properties). IProject project = javaProject.getProject(); entryPointModulesBlock .setDefaultModules(ModuleArgumentProcessor.getDefaultModules(project, config)); // Initialize the selected set of entry point modules List<String> launchConfigModules = GWTLaunchConfiguration.getEntryPointModules(config); entryPointModulesBlock.setModules(launchConfigModules); } } catch (CoreException e) { // Purposely ignored; this happens when the java project does // not exist } maybeGrayControls(javaProject); updateEnabledState(); } finally { blockUpdateLaunchConfigurationDialog = false; } }
From source file:com.google.gwt.eclipse.core.launch.ui.WebAppHostPageSelectionDialog.java
License:Open Source License
/** * Selects an HTML host page from a given project. Returns <code>null</code> * if the selection dialog was canceled. * // w w w. j a v a 2 s . c om * @param javaProject the project from which to select a host page * @return a relative URL, or null if the selection dialog was canceled. * */ public static String show(IJavaProject javaProject, boolean isExternal) { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); try { IProject project = javaProject.getProject(); WebAppUtilities.verifyIsWebApp(project); IFolder warFolder = WebAppUtilities.getWarSrc(project); if (warFolder.exists()) { WebAppHostPageSelectionDialog dialog = new WebAppHostPageSelectionDialog(shell, javaProject, warFolder, isExternal); if (dialog.open() == OK) { Object[] result = dialog.getResult(); IFile htmlFile = dialog.getSelectedFile(result); try { WebAppProjectProperties.setLaunchConfigExternalUrlPrefix(project, dialog.getExternalUrlPrefix()); } catch (BackingStoreException e) { GWTPluginLog.logError(e); } return dialog.getUrl(warFolder, htmlFile); } } } catch (CoreException e) { CorePluginLog.logError(e); } return null; }
From source file:com.google.gwt.eclipse.core.launch.ui.WebAppHostPageSelectionDialog.java
License:Open Source License
private WebAppHostPageSelectionDialog(Shell shell, IJavaProject project, IFolder warFolder, boolean isExternal) { super(shell, false, project.getProject(), IResource.FILE); assert (warFolder != null); this.project = project.getProject(); this.isExternal = isExternal; this.warFolder = warFolder; setTitle("HTML Page Selection"); setMessage(""); }
From source file:com.google.gwt.eclipse.core.modules.ModuleUtils.java
License:Open Source License
/** * Retrieve GWT Maven plugin 2 module files, *.gwt.xml files * * @param javaProject/*ww w . ja v a 2s . c om*/ * @param modules * @throws CoreException */ private static void checkGwtMavenPlugin2SrcMain(IJavaProject javaProject, Map<String, IModule> modules) throws CoreException { IFolder folderSrc = javaProject.getProject().getFolder("src"); if (folderSrc == null) { return; } IFolder folderMain = folderSrc.getFolder("main"); if (folderMain == null) { return; } IResource[] resourcesFiles = folderMain.members(); if (resourcesFiles == null) { return; } for (IResource resource : resourcesFiles) { if (resource.getType() == IResource.FILE) { IModule module = create((IFile) resource); if (module != null) { String moduleName = module.getQualifiedName(); modules.put(moduleName, module); } } } }
From source file:com.google.gwt.eclipse.core.properties.ui.GWTProjectPropertyPage.java
License:Open Source License
public static IEditorReference[] getOpenJavaEditors(IProject project) { List<IEditorReference> projectOpenJavaEditors = new ArrayList<IEditorReference>(); try {//from w w w .ja v a2s.co m IWorkbenchPage page = JavaPlugin.getActivePage(); if (page != null) { // Iterate through all the open editors IEditorReference[] openEditors = page.getEditorReferences(); for (IEditorReference openEditor : openEditors) { IEditorPart editor = openEditor.getEditor(false); // Only look for Java Editor and subclasses if (editor instanceof CompilationUnitEditor) { IEditorInput input = openEditor.getEditorInput(); IJavaProject inputProject = EditorUtility.getJavaProject(input); // See if the editor is editing a file in this project if (inputProject != null && inputProject.getProject().equals(project)) { projectOpenJavaEditors.add(openEditor); } } } } } catch (PartInitException e) { GWTPluginLog.logError(e); } return projectOpenJavaEditors.toArray(new IEditorReference[0]); }
From source file:com.google.gwt.eclipse.core.properties.ui.GWTProjectPropertyPage.java
License:Open Source License
private void updateControls() { IJavaProject javaProject = JavaCore.create(getProject()); boolean shouldEnable = !GWTProjectsRuntime.isGWTRuntimeProject(javaProject); ExtensionQuery<GWTProjectPropertyPage.GwtSdkSelectionEnablementFinder> extQuery = new ExtensionQuery<GWTProjectPropertyPage.GwtSdkSelectionEnablementFinder>( GWTPlugin.PLUGIN_ID, "gwtSdkSelectionEnablementFinder", "class"); List<ExtensionQuery.Data<GWTProjectPropertyPage.GwtSdkSelectionEnablementFinder>> enablementFinders = extQuery .getData();//from www . ja va2s. c om for (ExtensionQuery.Data<GWTProjectPropertyPage.GwtSdkSelectionEnablementFinder> enablementFinder : enablementFinders) { shouldEnable = enablementFinder.getExtensionPointData() .shouldEnableGwtSdkSelection(javaProject.getProject()); } if (shouldEnable) { sdkSelectionBlock.setEnabled(useGWT); entryPointModulesBlock.setEnabled(useGWT); } else { sdkSelectionBlock.setEnabled(false); entryPointModulesBlock.setEnabled(false); } }
From source file:com.google.gwt.eclipse.core.runtime.GWTProjectsRuntime.java
License:Open Source License
/** * FIXME - Were it not for the super source stuff, we would need this method. Can't we provide a * way for users to state which folders are super-source, etc? *//*from ww w . j av a 2 s . com*/ public static List<IRuntimeClasspathEntry> getGWTRuntimeProjectSourceEntries(IJavaProject project, boolean includeTestSourceEntries) throws SdkException { assert (isGWTRuntimeProject(project) && project.exists()); String projectName = project.getProject().getName(); List<IRuntimeClasspathEntry> sourceEntries = new ArrayList<IRuntimeClasspathEntry>(); IClasspathEntry[] gwtUserJavaProjClasspathEntries = null; try { gwtUserJavaProjClasspathEntries = project.getRawClasspath(); } catch (JavaModelException e) { throw new SdkException("Cannot extract raw classpath from " + projectName + " project."); } Set<IPath> absoluteSuperSourcePaths = new HashSet<IPath>(); for (IClasspathEntry curClasspathEntry : gwtUserJavaProjClasspathEntries) { if (curClasspathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath sourcePath = curClasspathEntry.getPath(); if (isJavadocPath(sourcePath)) { // Ignore javadoc paths. continue; } if (GWTProjectUtilities.isTestPath(sourcePath) && !includeTestSourceEntries) { // Ignore test paths, unless it is specified explicitly that we should // include them. continue; } sourceEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(sourcePath)); // Figure out the location of the super source path. IPath absoluteSuperSourcePath = sourcePath.removeLastSegments(1).append(SUPER_SOURCE_FOLDER_NAME); IPath relativeSuperSourcePath = absoluteSuperSourcePath.removeFirstSegments(1); if (absoluteSuperSourcePaths.contains(absoluteSuperSourcePath)) { // I've already included this path. continue; } if (project.getProject().getFolder(relativeSuperSourcePath).exists()) { /* * We've found the super source path, and we've not added it already. The existence test * uses a relative path, but the creation of a runtime classpath entry requires an * absolute path. */ sourceEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(absoluteSuperSourcePath)); absoluteSuperSourcePaths.add(absoluteSuperSourcePath); } IPath absoluteTestSuperSourcePath = sourcePath.removeLastSegments(1) .append(TEST_SUPER_SOURCE_FOLDER_NAME); IPath relativeTestSuperSourcePath = absoluteTestSuperSourcePath.removeFirstSegments(1); if (absoluteSuperSourcePaths.contains(absoluteTestSuperSourcePath)) { // I've already included this path. continue; } if (includeTestSourceEntries && project.getProject().getFolder(relativeTestSuperSourcePath).exists()) { /* * We've found the super source path, and we've not added it already. The existence test * uses a relative path, but the creation of a runtime classpath entry requires an * absolute path. */ sourceEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(absoluteTestSuperSourcePath)); absoluteSuperSourcePaths.add(absoluteTestSuperSourcePath); } } } if (absoluteSuperSourcePaths.isEmpty()) { GWTPluginLog.logError("There were no super source folders found for the project '{0}'", project.getProject().getName()); } return sourceEntries; }
From source file:com.google.gwt.eclipse.core.runtime.GWTProjectsRuntime.java
License:Open Source License
public static boolean isGWTRuntimeProject(IJavaProject project) { String projectName = project.getProject().getName(); return (GWT_USER_PROJECT_NAME.equals(projectName) || projectName.equals(GWT_DEV_FALLBACK_PROJECT_NAME) || projectName.equals(getPlatformSpecificDevProjectName())); }
From source file:com.google.gwt.eclipse.core.runtime.GWTRuntimeTest.java
License:Open Source License
private void checkSdkDetectionUsingClasspathContainers(IPath sdkPath, SdkClasspathContainer.Type containerType) throws CoreException { String sdkName = getName();/*from w w w . j a v a 2 s . c o m*/ GWTRuntime sdk = GWTRuntime.getFactory().newInstance(sdkName, sdkPath); SdkSet<GWTRuntime> registeredSdks = GWTPreferences.getSdks(); registeredSdks.add(sdk); GWTPreferences.setSdks(registeredSdks); IPath containerPath = SdkClasspathContainer.computeContainerPath(GWTRuntimeContainer.CONTAINER_ID, sdk, containerType); IJavaProject javaProject = JavaProjectUtilities.createJavaProject(getName()); try { JavaProjectUtilities.addRawClassPathEntry(javaProject, JavaCore.newContainerEntry(containerPath)); GWTRuntime detectedSdk = GWTRuntime.findSdkFor(javaProject); assertNotNull(detectedSdk); assertEquals(new IClasspathEntry[] { JavaCore.newContainerEntry(containerPath) }, detectedSdk.getClasspathEntries()); } finally { javaProject.getProject().delete(true, null); GWTPreferences.setSdks(new SdkSet<GWTRuntime>()); } }