List of usage examples for com.google.gwt.eclipse.core.nature GWTNature isGWTProject
public static boolean isGWTProject(IProject project)
From source file:com.google.gdt.eclipse.maven.launch.MavenClasspathProvider.java
License:Open Source License
@Override public IRuntimeClasspathEntry[] computeUnresolvedClasspath(ILaunchConfiguration config) throws CoreException { IRuntimeClasspathEntry[] unresolvedClasspathEntries = super.computeUnresolvedClasspath(config); IJavaProject proj = JavaRuntime.getJavaProject(config); if (proj == null) { return unresolvedClasspathEntries; }//from www . j a va2 s .c o m /* * Figure out if we are supposed to be relying on the default classpath or * not. The default classpath is the one that is generated for a launch * configuration based on the launch configuration's project's build * classpath. * * To determine whether or not to rely on the default classpath, we look at * the ATTR_DEFAULT_CLASSPATH attribute of the launch configuration. This * attribute is set whenever the user makes a change to the launch * configuration classpath using the add/remove buttons. From this point on, * Eclipse will respect the user's changes and will not replace their * entries with the classpath that it computes. * * However, users can specify that they want to restore the behavior of * having Eclipse compute the classpath by clicking on the "Restore Default * Entries" button. This causes the ATTR_DEFAULT_ATTRIBUTE to be unset for a * launch configuration. */ boolean useDefault = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, true); if (!useDefault) { return unresolvedClasspathEntries; } if (!MavenUtils.hasMavenNature(proj.getProject())) { return unresolvedClasspathEntries; } // Use a LinkedHashSet to prevent dupes Set<IRuntimeClasspathEntry> classpath = new LinkedHashSet<IRuntimeClasspathEntry>( unresolvedClasspathEntries.length); classpath.addAll(Arrays.asList(unresolvedClasspathEntries)); // add GAE tools api jar if (GaeNature.isGaeProject(proj.getProject())) { addAppengineToolsJarIfPossible(proj, classpath); } // Add GWT dev jar if (GWTNature.isGWTProject(proj.getProject())) { addGwtDevjarIfPossible(proj, classpath); } return classpath.toArray(new IRuntimeClasspathEntry[classpath.size()]); }
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; }// ww w.j a v a2s . c o m } if (GWTNature.isGWTProject(project)) { if (!WebAppUtilities.isWebApp(project)) { // We can use GWT shell for non-WAR projects (typically these are GWT // 1.5 and older projects) return MainType.GWT_SHELL.mainTypeName; } ClassLoader classLoader = LaunchConfigurationProcessorUtilities.getClassLoaderFor(config); if (classFinder.exists(classLoader, MainType.GWT_DEV_MODE.mainTypeName)) { return MainType.GWT_DEV_MODE.mainTypeName; } if (classFinder.exists(classLoader, MainType.GWT_HOSTED_MODE.mainTypeName)) { return MainType.GWT_HOSTED_MODE.mainTypeName; } // Fallback return MainType.GWT_SHELL.mainTypeName; } else if (GaeNature.isGaeProject(project)) { return MainType.GAE_APP_SERVER.mainTypeName; } else { return null; } }
From source file:com.google.gdt.eclipse.suite.launch.processors.PortArgumentProcessor.java
License:Open Source License
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. j a v a 2s .co m*/ if (!NoServerArgumentProcessor.hasNoServerArg(programArgs)) { IProject project = javaProject.getProject(); boolean isGwtProject = GWTNature.isGWTProject(project); boolean isGaeProject = GaeNature.isGaeProject(project); PortArgStyle portArgStyle = null; if (isGwtProject) { portArgStyle = PortArgStyle.GWT; } else if (isGaeProject) { // Prefer the style that existed in the args previously portArgStyle = parser.portArgStyle != null && parser.portArgStyle.isGae() ? parser.portArgStyle : PortArgStyle.GAE_LONG; } 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
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 a2 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 (SpeedTracerLaunchConfiguration.TYPE_ID.equals(launchConfig.getType().getIdentifier()) && (!portParser.isPresent || portParser.isAuto)) { return "Please specify a port number (automatic port selection is not supported by Speed Tracer launch configurations)"; } if (!portParser.isPresent) { return null; } IProject project = javaProject.getProject(); boolean isGwtProject = GWTNature.isGWTProject(project); boolean isGaeProject = GaeNature.isGaeProject(project); if (isGwtProject && portParser.portArgStyle != PortArgStyle.GWT || isGaeProject && !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
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) && GaeNature.isGaeProject(project)) { if (serverArgIndex == -1) { // Add if it is not present programArgs.add(0, ARG_SERVER); programArgs.add(1, SCL);/*ww w. j av a 2s.c o m*/ } } 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); } } } }
From source file:com.google.gdt.eclipse.suite.launch.processors.WarArgumentProcessor.java
License:Open Source License
public void update(ILaunchConfigurationWorkingCopy launchConfig, IJavaProject javaProject, List<String> programArgs, List<String> vmArgs) throws CoreException { // First, try to get a war argument from the extensions, then try everything // else./*from ww w . ja v a2 s .co m*/ if (isWarArgsFromExtensions(launchConfig, javaProject, programArgs)) { launchConfig.setAttribute(ATTR_IS_WAR_FROM_PROJECT_PROPERTIES, false); } else { if (warDirFromLaunchConfigCreation == null) { // Check the scenarios where this processor should do nothing. If a WAR // dir is given from launch config creation, we set it regardless of // whether we would normally do nothing. if (!doesMainTypeTakeWarArgument(launchConfig)) { removeVerifiedWarArgAndDir(programArgs, javaProject); return; } if (!WebAppUtilities.isWebApp(javaProject.getProject())) { return; } if (!WebAppUtilities.hasManagedWarOut(javaProject.getProject())) { // We are not managing the runtime WAR return; } } WarParser info = WarParser.parse(programArgs, javaProject); String warFromProjProps = LaunchConfigurationProcessorUtilities.getWarDirectory(javaProject); // Did we use the WAR from the project properties when we last ran this? boolean wasWarFromProjProps = isWarFromProjectProperties(launchConfig); /* * If both dirs are the same, perfect, we'll record that it is from * project properties. Otherwise, if it is a manual user update, then we * say it is not from project properties. Finally, if we took it from the * project properties last time, or if the current last-arg-based WAR dir * is invalid then we say it is from project properties. */ boolean isWarFromProjProps = JavaUtilities.equalsWithNullCheck(warFromProjProps, info.unverifiedWarDir); if (!isWarFromProjProps && !isUserUpdate) { isWarFromProjProps = wasWarFromProjProps || (!info.isSpecifiedWithWarArg && !info.isWarDirValid); } String newWarDir; if (warDirFromLaunchConfigCreation != null) { newWarDir = warDirFromLaunchConfigCreation; } else { newWarDir = isWarFromProjProps ? warFromProjProps : info.unverifiedWarDir; } if (StringUtilities.isEmpty(newWarDir)) { // A WAR dir is required but we do not have one, leave untouched return; } if (GWTNature.isGWTProject(javaProject.getProject())) { // Ensure there is a -war arg and the WAR dir if (!info.isSpecifiedWithWarArg) { // Remove the old style, add the new "-war" and value removeVerifiedWarArgAndDir(programArgs, javaProject); programArgs.add(0, ARG_WAR); programArgs.add(1, newWarDir); } else { // It is specified with the "-war", so just update the value programArgs.remove(info.unverifiedWarDirIndex); programArgs.add(info.unverifiedWarDirIndex, newWarDir); } } else if (GaeNature.isGaeProject(javaProject.getProject())) { // Ensure there is a valid WAR dir without "-war" arg if (info.isSpecifiedWithWarArg) { // Remove the -war and WAR dir removeVerifiedWarArgAndDir(programArgs, javaProject); // Add the last arg WAR dir programArgs.add(newWarDir); } else { if (info.unverifiedWarDirIndex >= 0) { // Remove the existing WAR dir programArgs.remove(info.unverifiedWarDirIndex); } // Add the last arg WAR dir programArgs.add(newWarDir); } } launchConfig.setAttribute(ATTR_IS_WAR_FROM_PROJECT_PROPERTIES, isWarFromProjProps); } }
From source file:com.google.gdt.eclipse.suite.launch.ui.shortcuts.WebAppLaunchShortcut.java
License:Open Source License
/** * Given a resource, infer the startup URL that the resource points at, then look for an existing launch configuration * that points at this URL. If none exists, we'll create a new one. * * @param isGwtSuperDevModeEnabled// ww w. ja va 2s . co m * is used to turn on GWT super dev mode. * @return the found or newly created launch configuration */ protected ILaunchConfiguration findOrCreateLaunchConfiguration(IResource resource, String startupUrl, boolean isExternal, boolean isGwtSuperDevModeEnabled) throws CoreException, OperationCanceledException { ILaunchConfiguration config = findLaunchConfiguration(resource, startupUrl, isExternal); if (config == null) { config = createNewLaunchConfiguration(resource, startupUrl, isExternal, isGwtSuperDevModeEnabled); } else if (GWTNature.isGWTProject(resource.getProject()) && GWTLaunchConfigurationWorkingCopy.getSuperDevModeEnabled(config) != isGwtSuperDevModeEnabled) { config = turnOnOrOffSuperDevMode(config, isGwtSuperDevModeEnabled); } return config; }
From source file:com.google.gdt.eclipse.suite.launch.ui.tabs.WebAppMainTab.java
License:Open Source License
/** * Returns <code>true</code> if the project exists and it uses GWT. */// w w w . ja v a2s . com private boolean isValidProject(String projectName, ILaunchConfiguration launchConfig) { if (projectName.length() == 0) { setErrorMessage("Project was not specified"); return false; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IStatus status = workspace.validateName(projectName, IResource.PROJECT); if (status.isOK()) { IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (!project.exists()) { setErrorMessage(MessageFormat.format(LauncherMessages.JavaMainTab_20, projectName)); return false; } if (!project.isOpen()) { setErrorMessage(MessageFormat.format(LauncherMessages.JavaMainTab_21, projectName)); return false; } boolean isGwtProject = GWTNature.isGWTProject(project); if (!isGwtProject) { setErrorMessage("Project does not use GWT"); return false; } } else { setErrorMessage(MessageFormat.format(LauncherMessages.JavaMainTab_19, status.getMessage())); return false; } return true; }
From source file:com.google.gdt.eclipse.suite.launch.WebAppLaunchUtil.java
License:Open Source License
/** * Given a resource, figure out what the target URL should be for a launch * configuration corresponding to this resource. If the resource has several * possible URLs that correspond to it, this method will cause a dialog to pop * up, asking the user to choose one. If the resource's project uses GAE but * not GWT, return empty string; GAE-only projects have no startup url. If the * resource's project uses GWT 2.0+, return empty string since no URL is * started in dev mode.//from www . ja v a 2 s .c o m * * @param resource * @throws CoreException */ public static String determineStartupURL(IResource resource, boolean isExternalLaunch) throws CoreException { ILaunchShortcutStrategy strategy = null; IProject project = resource.getProject(); ExtensionQuery<ILaunchShortcutStrategyProvider> extQuery = new ExtensionQuery<ILaunchShortcutStrategyProvider>( GWTPlugin.PLUGIN_ID, "launchShortcutStrategy", "class"); List<ExtensionQuery.Data<ILaunchShortcutStrategyProvider>> strategyProviderInfos = extQuery.getData(); for (ExtensionQuery.Data<ILaunchShortcutStrategyProvider> data : strategyProviderInfos) { strategy = data.getExtensionPointData().getStrategy(project); break; } if (strategy == null) { if (WebAppLaunchUtil.projectIsGaeOnly(project)) { return ""; } if (WebAppUtilities.isWebApp(project)) { strategy = new WebAppLaunchShortcutStrategy(); } else { assert (GWTNature.isGWTProject(project)); strategy = new LegacyGWTLaunchShortcutStrategy(); } } return strategy.generateUrl(resource, isExternalLaunch); }
From source file:com.google.gdt.eclipse.suite.launch.WebAppLaunchUtil.java
License:Open Source License
public static boolean projectIsGaeOnly(IProject project) { return GaeNature.isGaeProject(project) && !GWTNature.isGWTProject(project); }