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.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Create a library entry and add it to the raw classpath. *//*from w w w. j av a 2 s.c om*/ private static void addAndCreateFolderLibraryEntry(IJavaProject javaProject, String folderName) throws CoreException, UnsupportedEncodingException { IFolder projLibFolder = javaProject.getProject().getFolder(folderName); ResourceUtils.createFolderStructure(javaProject.getProject(), projLibFolder.getProjectRelativePath()); JavaProjectUtilities.addRawClassPathEntry(javaProject, JavaCore.newLibraryEntry(projLibFolder.getFullPath(), null, null, true /* exported */)); }
From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Create a JAR library entry and add it to the raw classpath. * <p>/*from w ww. j a v a 2 s.c o m*/ * This ensures a file exist at the target library path, but no guarantees on * its contents or its validity as a JAR. */ private static void addAndCreateJarLibraryEntry(IJavaProject javaProject, IPath projectRelativeLibraryPath) throws CoreException, UnsupportedEncodingException { IFile lib = javaProject.getProject().getFile(projectRelativeLibraryPath); // Create the parent dirs and a dummy file for the library ResourceUtils.createFolderStructure(javaProject.getProject(), projectRelativeLibraryPath.removeLastSegments(1)); ResourceUtils.createFile(lib.getFullPath(), ""); JavaProjectUtilities.addRawClassPathEntry(javaProject, JavaCore.newLibraryEntry(lib.getFullPath(), null, null, true /* exported */)); }
From source file:com.google.gwt.eclipse.core.compile.GWTCompileRunnerTest.java
License:Open Source License
/** * Create a source entry (including the dir structure) and add it to the raw * classpath./*from w w w. jav a 2 s. com*/ * * @param javaProject The Java project that receives the source entry * @param directoryName The source directory name * @param outputDirectoryName The optional output location of this source * directory. Pass null for the default output location. */ private static void addAndCreateSourceEntry(IJavaProject javaProject, String directoryName, String outputDirectoryName) throws CoreException { IFolder srcFolder = javaProject.getProject().getFolder(directoryName); ResourceUtils.createFolderStructure(javaProject.getProject(), srcFolder.getProjectRelativePath()); IPath workspaceRelOutPath = null; if (outputDirectoryName != null) { // Ensure output directory exists IFolder outFolder = javaProject.getProject().getFolder(outputDirectoryName); ResourceUtils.createFolderStructure(javaProject.getProject(), outFolder.getProjectRelativePath()); workspaceRelOutPath = outFolder.getFullPath(); } JavaProjectUtilities.addRawClassPathEntry(javaProject, JavaCore.newSourceEntry(srcFolder.getFullPath(), ClasspathEntry.EXCLUDE_NONE, workspaceRelOutPath)); }
From source file:com.google.gwt.eclipse.core.compile.ui.GWTCompileDialog.java
License:Open Source License
private IJavaProject chooseProject() { IJavaProject[] javaProjects;// w w w . j a v a 2 s . c o m try { javaProjects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects(); } catch (JavaModelException e) { GWTPluginLog.logError(e); javaProjects = new IJavaProject[0]; } // Filter the list to only show GWT projects List<IJavaProject> gwtProjects = new ArrayList<IJavaProject>(); for (IJavaProject javaProject : javaProjects) { if (GWTNature.isGWTProject(javaProject.getProject())) { gwtProjects.add(javaProject); } } ILabelProvider labelProvider = new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT); ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider); dialog.setTitle("Project Selection"); dialog.setMessage("Choose a project to compile"); dialog.setElements(gwtProjects.toArray(new IJavaProject[0])); dialog.setInitialSelections(new Object[] { JavaCore.create(project) }); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { return (IJavaProject) dialog.getFirstResult(); } return null; }
From source file:com.google.gwt.eclipse.core.dialogs.ModuleSelectionDialogButtonField.java
License:Open Source License
public void setGWTProject(IJavaProject javaProject) { if (JavaProjectUtilities.isJavaProjectNonNullAndExists(javaProject) && GWTNature.isGWTProject(javaProject.getProject())) { this.javaProjectWithGWTNature = javaProject; } else {/*from w w w .j a va2 s . c o m*/ this.javaProjectWithGWTNature = null; } validate(); ((ModuleCompletionProcessor) getContentAssistProcessor()).setProject(javaProjectWithGWTNature); }
From source file:com.google.gwt.eclipse.core.editors.java.GWTJavaEditor.java
License:Open Source License
@Override protected void doSetInput(IEditorInput input) throws CoreException { IJavaProject javaProject = EditorUtility.getJavaProject(input); if (javaProject != null && GWTNature.isGWTProject(javaProject.getProject())) { // Use GWT partitioning if the compilation unit is in a GWT project inputPartitioning = GWTPartitions.GWT_PARTITIONING; } else {//w w w . j av a 2 s . com // Otherwise, use Java partitioning to emulate the Java editor inputPartitioning = IJavaPartitions.JAVA_PARTITIONING; } super.doSetInput(input); }
From source file:com.google.gwt.eclipse.core.editors.java.GWTJavaEditor.java
License:Open Source License
private boolean formatOnSaveEnabled(IJavaProject javaProject) { SaveParticipantRegistry spr = JavaPlugin.getDefault().getSaveParticipantRegistry(); IPostSaveListener[] listeners = spr.getEnabledPostSaveListeners(javaProject.getProject()); for (IPostSaveListener listener : listeners) { if (listener instanceof CleanUpPostSaveListener) { Map<String, String> settings = CleanUpPreferenceUtil .loadSaveParticipantOptions(new ProjectScope(javaProject.getProject())); if (settings == null) { return false; }//from ww w . j a v a2 s .c om return (CLEAN_UP_OPTION_TRUE.equals(settings.get(CleanUpConstants.FORMAT_SOURCE_CODE))); } } return false; }
From source file:com.google.gwt.eclipse.core.editors.java.JsniFormattingUtil.java
License:Open Source License
/** * Same as format(IDocument, Map, String[]), except the formatting options * are taken from the given project.// www .j a va 2 s .c o m * */ public static TextEdit format(IDocument document, IJavaProject project, String[] originalJsniMethods) { @SuppressWarnings("unchecked") // safe by IJavaScriptProject.getOptions spec Map<String, String> jsOptions = JavaScriptCore.create(project.getProject()).getOptions(true); @SuppressWarnings("unchecked") // safe by IJavaScriptProject.getOptions spec Map<String, String> jOptions = project.getOptions(true); return format(document, jOptions, jsOptions, originalJsniMethods); }
From source file:com.google.gwt.eclipse.core.GWTDeploymentParticipant.java
License:Open Source License
@Override public void predeploy(IJavaProject javaProject, DeploymentSet deploymentSet, IPath warLocation, OutputStream consoleOutputStream, IProgressMonitor monitor) throws CoreException { if (!GWTNature.isGWTProject(javaProject.getProject())) { // Only compile if the project has the GWT nature return;// www.ja va 2s .co m } try { IProject project = javaProject.getProject(); long curStamp = ProjectChangeTimestampTracker.getProjectTimestamp(project); if (curStamp != ProjectChangeTimestampTracker.getTimestampFromKey(project, PREVIOUS_DEPLOYMENT_BUILD_PROJECT_CHANGE_STAMP_KEY)) { GWTCompileSettings settings = GWTProjectProperties.getGwtCompileSettings(project); settings.setEntryPointModules(GWTProjectProperties.getEntryPointModules(project)); // Watch the monitor for cancellations, and destroy the process TerminateProcessAction processTerminator = new TerminateProcessAction(); GWTCompileRunner.compileWithCancellationSupport(javaProject, warLocation, settings, consoleOutputStream, processTerminator, monitor, processTerminator); } else { PrintWriter printWriter = new PrintWriter(consoleOutputStream); printWriter.println( "Skipping GWT compilation since no relevant changes have occurred since the last deploy."); printWriter.flush(); } project.setPersistentProperty(PREVIOUS_DEPLOYMENT_BUILD_PROJECT_CHANGE_STAMP_KEY, String.valueOf(curStamp)); } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, e.getLocalizedMessage(), e)); } catch (InterruptedException e) { throw new CoreException(new Status(IStatus.ERROR, GWTPlugin.PLUGIN_ID, e.getLocalizedMessage(), e)); } }
From source file:com.google.gwt.eclipse.core.GWTProjectUtilities.java
License:Open Source License
/** * Returns the GWT-applicable source folder paths from a project (note: this * will not traverse into the project's dependencies, for this behavior, see * {@link #getGWTSourceFolderPathsFromProjectAndDependencies(IJavaProject, boolean)} * )./* w ww . j av a 2s . c o m*/ * * @param javaProject Reference to the project * @param sourceEntries The list to be filled with the entries corresponding * to the source folder paths * @param includeTestSourceEntries Whether to include the entries for test * source * @throws SdkException */ private static void fillGWTSourceFolderPathsFromProject(IJavaProject javaProject, Collection<? super IRuntimeClasspathEntry> sourceEntries, boolean includeTestSourceEntries) throws SdkException { assert (javaProject != null); if (GWTProjectsRuntime.isGWTRuntimeProject(javaProject)) { // TODO: Do we still need to handle this here since Sdk's report their // own runtime classpath entries? sourceEntries.addAll( GWTProjectsRuntime.getGWTRuntimeProjectSourceEntries(javaProject, includeTestSourceEntries)); } else { try { for (IClasspathEntry curClasspathEntry : javaProject.getRawClasspath()) { if (curClasspathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath sourcePath = curClasspathEntry.getPath(); // If including tests, include all source, or if not including tests, ensure // it is not a test path if (includeTestSourceEntries || !GWTProjectUtilities.isTestPath(sourcePath)) { if (!isOptional(curClasspathEntry) || exists(sourcePath)) { sourceEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(sourcePath)); } } } } IFolder folder = javaProject.getProject().getFolder("super"); if (folder.exists()) { sourceEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(folder.getFullPath())); } } catch (JavaModelException jme) { GWTPluginLog.logError(jme, "Unable to retrieve raw classpath for project " + javaProject.getProject().getName()); } } }