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.gdt.eclipse.maven.launch.processors.XXMaxPermSizeArgumentProcessor.java
License:Open Source License
@Override public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject, List<String> programArgs, List<String> vmArgs) throws CoreException { if (!MavenUtils.hasMavenNature(javaProject.getProject()) || !MavenUtils.hasSpringNature(javaProject.getProject())) { return;/*from ww w . j av a 2s. c om*/ } int xmxArgIndex = StringUtilities.indexOfThatStartsWith(vmArgs, ARG_XMX_PREFIX, 0); if (xmxArgIndex == -1) { vmArgs.add(0, ARG_XMX_PREFIX + DEFAULT_MEMORY); } }
From source file:com.google.gdt.eclipse.maven.sdk.GWTMavenSdkFactory.java
License:Open Source License
@Override public ProjectBoundSdk newInstance(IJavaProject javaProject) { if (!MavenUtils.hasMavenNature(javaProject.getProject())) { return null; }/*from w ww . ja va 2 s . c om*/ return new GWTMavenRuntime(javaProject); }
From source file:com.google.gdt.eclipse.mobile.android.wizards.helpers.AndroidProjectCreator.java
License:Open Source License
/** * Adds the given folder to the project's class path. * //from w w w . j ava 2 s . c o m * @param javaProject The Java Project to update. * @param sourceFolder Template Parameters. * @param monitor An existing monitor. * @throws CoreException */ private void setupSourceFolders(IJavaProject javaProject, String[] sourceFolders, IProgressMonitor monitor) throws CoreException { IProject project = javaProject.getProject(); // get the list of entries. IClasspathEntry[] entries = javaProject.getRawClasspath(); // remove the project as a source folder (This is the default) entries = removeSourceClasspath(entries, project); // add the source folders. for (String sourceFolder : sourceFolders) { IFolder srcFolder = project.getFolder(sourceFolder); // remove it first in case. entries = removeSourceClasspath(entries, srcFolder); entries = addEntryToClasspath(entries, JavaCore.newSourceEntry(srcFolder.getFullPath())); } IProject gaeProject = ResourcesPlugin.getWorkspace().getRoot() .getProject(projectName + AppEngineRPCPlugin.GAE_PROJECT_NAME_SUFFIX); IFolder sharedFolder = gaeProject.getFolder(ProjectCreationConstants.SHARED_FOLDER_NAME); if (sharedFolder.exists()) { IFolder androidLinkedFolder = androidProject.getFolder(ProjectCreationConstants.SHARED_FOLDER_NAME); /* The variable workspaceLoc is required only for Eclipse 3.5. * For Eclipses after 3.5, the project specific path variable WORKSPACE_LOC * can be used instead. */ String workspaceLoc = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString(); // use variables for shared folder path IPath sharedFolderPath = new Path(workspaceLoc + "/" + gaeProject.getName() + "/" //$NON-NLS-N$ + ProjectCreationConstants.SHARED_FOLDER_NAME); androidLinkedFolder.createLink(sharedFolderPath, IResource.ALLOW_MISSING_LOCAL, new SubProgressMonitor(monitor, 1)); entries = addEntryToClasspath(entries, JavaCore.newSourceEntry(androidLinkedFolder.getFullPath())); } // add .apt_generated to classpath IClasspathAttribute[] attributes = new IClasspathAttribute[] { JavaCore.newClasspathAttribute("optional", "true") }; //$NON-NLS-N$ IFolder aptFolder = project.getFolder(ProjectCreationConstants.APT_FOLDER); IClasspathEntry entry = JavaCore.newSourceEntry(aptFolder.getFullPath(), ClasspathEntry.INCLUDE_ALL, ClasspathEntry.EXCLUDE_NONE, null, attributes); entries = addEntryToClasspath(entries, entry); javaProject.setRawClasspath(entries, new SubProgressMonitor(monitor, 10)); }
From source file:com.google.gdt.eclipse.suite.launch.processors.AppengineClasspathProvider.java
License:Open Source License
@Override public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration config) throws CoreException { IRuntimeClasspathEntry[] unresolvedClasspathEntries = super.computeUnresolvedClasspath(config); IJavaProject project = JavaRuntime.getJavaProject(config); if (project == null || !project.getProject().hasNature(GaeNature.NATURE_ID)) { return unresolvedClasspathEntries; }//from w w w. j a va 2 s . c om boolean useDefault = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); if (!useDefault) { return unresolvedClasspathEntries; } if (!GaeNature.isGaeProject(project.getProject())) { return unresolvedClasspathEntries; } if (!GoogleCloudSqlProperties.getGoogleCloudSqlEnabled(project.getProject())) { return unresolvedClasspathEntries; } IPath jdbcDriverPath = Path.fromOSString(GaeSdk.findSdkFor(project).getInstallationPath() + AppEngineBridge.APPENGINE_CLOUD_SQL_JAR_PATH_IN_SDK + AppEngineBridge.APPENGINE_CLOUD_SQL_JAR); if (!jdbcDriverPath.isAbsolute()) { return unresolvedClasspathEntries; } IRuntimeClasspathEntry jdbcJar = JavaRuntime.newArchiveRuntimeClasspathEntry(jdbcDriverPath); Set<IRuntimeClasspathEntry> updatedUnresolvedClasspathEntries = Sets .newLinkedHashSet(Arrays.asList(unresolvedClasspathEntries)); updatedUnresolvedClasspathEntries.add(jdbcJar); return updatedUnresolvedClasspathEntries .toArray(new IRuntimeClasspathEntry[updatedUnresolvedClasspathEntries.size()]); }
From source file:com.google.gdt.eclipse.suite.launch.processors.ClasspathProviderProcessor.java
License:Open Source License
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject, List<String> programArgs, List<String> vmArgs) throws CoreException { launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, ModuleClasspathProvider.computeProviderId(javaProject.getProject())); }
From source file:com.google.gdt.eclipse.suite.launch.processors.LaunchConfigAffectingChangesListener.java
License:Open Source License
private void updateLaunchConfigs(IJavaProject javaProject) { try {// w w w. ja v a 2s . co m List<ILaunchConfiguration> launchConfigs = LaunchConfigurationUtilities.getLaunchConfigurations( javaProject.getProject(), LaunchConfigurationUpdater.APPLICABLE_LAUNCH_CONFIGURATION_TYPE_IDS.toArray(new String[0])); ArrayList<LaunchConfigurationUpdater> launchConfigurationUpdaters = new ArrayList<LaunchConfigurationUpdater>(); for (ILaunchConfiguration launchConfig : launchConfigs) { launchConfigurationUpdaters.add(new LaunchConfigurationUpdater(launchConfig, javaProject)); } asyncUpdate(launchConfigurationUpdaters); } catch (CoreException e) { CorePluginLog.logError(e, "Could not update launch configuration after project nature or classpath change"); } }
From source file:com.google.gdt.eclipse.suite.launch.processors.MainTypeProcessor.java
License:Open Source License
private static String computeMainTypeName(ILaunchConfigurationWorkingCopy config, IJavaProject javaProject, ClassFinder classFinder) throws CoreException { IProject project = javaProject.getProject(); ExtensionQuery<MainTypeProcessor.MainTypeFinder> extQuery = new ExtensionQuery<MainTypeProcessor.MainTypeFinder>( GdtPlugin.PLUGIN_ID, "mainTypeFinder", "class"); List<ExtensionQuery.Data<MainTypeProcessor.MainTypeFinder>> mainTypeFinders = extQuery.getData(); for (ExtensionQuery.Data<MainTypeProcessor.MainTypeFinder> mainTypeFinder : mainTypeFinders) { String mainTypeFromExtension = mainTypeFinder.getExtensionPointData().findMainType(javaProject); if (mainTypeFromExtension != null) { return mainTypeFromExtension; }/*from ww w . ja v a 2 s . co m*/ } if (GWTNature.isGWTProject(project)) { ClassLoader classLoader = LaunchConfigurationProcessorUtilities.getClassLoaderFor(config); if (classFinder.exists(classLoader, MainType.GWT_DEV_MODE.mainTypeName)) { return MainType.GWT_DEV_MODE.mainTypeName; } return MainType.GWT_DEV_MODE.mainTypeName; } else { // TODO would this work? return MainType.GWT_DEV_MODE.mainTypeName; } }
From source file:com.google.gdt.eclipse.suite.launch.processors.PortArgumentProcessor.java
License:Open Source License
@Override public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject, List<String> programArgs, List<String> vmArgs) throws CoreException { boolean isAuto = WebAppLaunchConfigurationWorkingCopy.getAutoPortSelection(launchConfig); String port = WebAppLaunchConfigurationWorkingCopy.getServerPort(launchConfig); PortParser parser = PortParser.parse(programArgs); int insertionIndex = parser.isPresent ? LaunchConfigurationProcessorUtilities.removeArgsAndReturnInsertionIndex( programArgs, parser.portArgIndex, parser.portArgStyle.isPortASeparateArg) : 0;//w w w . java 2 s . c om if (!NoServerArgumentProcessor.hasNoServerArg(programArgs)) { IProject project = javaProject.getProject(); boolean isGwtProject = GWTNature.isGWTProject(project); PortArgStyle portArgStyle = null; if (isGwtProject) { portArgStyle = PortArgStyle.GWT; } else { // This processor is not applicable for the given project return; } List<String> portArgs = portArgStyle.getPortArgs(isAuto, port); if (portArgs != null) { programArgs.addAll(insertionIndex, portArgs); } } }
From source file:com.google.gdt.eclipse.suite.launch.processors.PortArgumentProcessor.java
License:Open Source License
@Override public String validate(ILaunchConfiguration launchConfig, IJavaProject javaProject, List<String> programArgs, List<String> vmArgs) throws CoreException { // Only validate for main types we know about if (!MainTypeProcessor.isMainTypeFromSdk(launchConfig)) { return null; }/*from w ww .j a v a 2 s . co m*/ /* * Speed Tracer launch configurations require a port to be defined. Parse the current arguments and ensure the * launch is not using automatic port selection. */ PortParser portParser = PortParser.parse(programArgs); if (!portParser.isPresent) { return null; } IProject project = javaProject.getProject(); boolean isGwtProject = GWTNature.isGWTProject(project); if (isGwtProject && portParser.portArgStyle != PortArgStyle.GWT && !isGwtProject && !portParser.portArgStyle.isGae()) { return INVALID_PORT_ARGUMENT_STYLE; } return null; }
From source file:com.google.gdt.eclipse.suite.launch.processors.ServerArgumentProcessor.java
License:Open Source License
@Override public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject, List<String> programArgs, List<String> vmArgs) throws CoreException { boolean runServer = WebAppLaunchConfiguration.getRunServer(launchConfig); int serverArgIndex = programArgs.indexOf(ARG_SERVER); IProject project = javaProject.getProject(); if (runServer && GWTNature.isGWTProject(project)) { if (serverArgIndex == -1) { // Add if it is not present programArgs.add(0, ARG_SERVER); programArgs.add(1, SCL);/* w w w. ja va 2 s . c om*/ } } else { if (serverArgIndex >= 0) { String server = LaunchConfigurationProcessorUtilities.getArgValue(programArgs, serverArgIndex + 1); if (server != null && server.equals(SCL)) { // Only if the parameter is what we set LaunchConfigurationProcessorUtilities.removeArgsAndReturnInsertionIndex(programArgs, serverArgIndex, true); } } } }