List of usage examples for com.google.gwt.eclipse.core.runtime GWTRuntime validate
@Override
public abstract IStatus validate();
From source file:com.google.gdt.eclipse.maven.launch.MavenClasspathProvider.java
License:Open Source License
private static void addGwtDevjarIfPossible(IJavaProject proj, Set<IRuntimeClasspathEntry> classpath) throws CoreException { GWTRuntime runtime = GWTRuntime.findSdkFor(proj); IStatus validationStatus = runtime.validate(); if (!validationStatus.isOK()) { throw new CoreException(validationStatus); }/*from w ww . ja v a 2s . co m*/ try { if (runtime != null) { IPath devJarPath = Path.fromOSString(runtime.getDevJar().getAbsolutePath()); IRuntimeClasspathEntry devJarCpEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(devJarPath); classpath.add(devJarCpEntry); } else { Activator.getDefault().getLog().log( new Status(IStatus.WARNING, Activator.PLUGIN_ID, "Unable to find a GWT Runtime for project " + proj.getElementName() + ". Cannot add gwt-dev to the runtime classpath.")); } } catch (SdkException sdke) { throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to add gwt-dev.jar to the runtime classpath.", sdke)); } }
From source file:com.google.gdt.eclipse.suite.wizards.NewWebAppProjectWizardPage.java
License:Open Source License
private void validatePageAndSetCompletionStatus() { IStatus status;/*w ww . ja va 2s . c o m*/ boolean pageComplete = false; try { // Project name cannot be blank if (getProjectName().length() == 0) { setMessage("Enter a name for the project"); return; } // Verify that project name is valid status = ResourcesPlugin.getWorkspace().validateName(getProjectName(), IResource.PROJECT); if (!validateFromStatus(status)) { return; } // Make sure project doesn't already exist in workspace if (existingProjectNames.contains(getProjectName())) { setMessage("A project with this name already exists.", ERROR); return; } // Output directory cannot be blank if (getOutputDirectory().length() == 0) { setMessage("Enter the output directory"); return; } // If the user wants to use a custom output directory, // verify that the directory exists if (outDirCustomButton.getSelection()) { File outDir = new Path(getOutputDirectory()).toFile(); if (!outDir.isDirectory()) { setMessage("The output directory does not exist", ERROR); return; } } // Make sure resource with project's name doesn't already exist in output // directory IPath outPath = new Path(getOutputDirectory()); if (outDirWorkspaceButton.getSelection()) { if (outPath.toFile().exists()) { setMessage("A resource with the project name already exists in the workspace root", ERROR); return; } } // Make sure output directory doesn't already contain an Eclipse project if (outDirCustomButton.getSelection()) { outPath = outPath.append(IProjectDescription.DESCRIPTION_FILE_NAME); if (outPath.toFile().exists()) { setMessage("The output directory already contains a project file", ERROR); return; } } // Package name cannot be blank if (getPackage().length() == 0) { setMessage("Enter a package name"); return; } String complianceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.compliance"); String sourceLevel = JavaCore.getOption("org.eclipse.jdt.core.compiler.source"); // Verify that package name is valid status = JavaConventions.validatePackageName(getPackage(), complianceLevel, sourceLevel); if (!validateFromStatus(status)) { return; } // If we are using GAE then an SDK must be selected if (useGaeCheckbox.getSelection()) { Sdk selectedGaeSdk = getSelectedGaeSdk(); if (selectedGaeSdk == null) { setMessage("Please configure an App Engine SDK.", ERROR); return; } IStatus gaeSdkValidationStatus = selectedGaeSdk.validate(); if (!gaeSdkValidationStatus.isOK()) { setMessage("The selected App Engine SDK is not valid: " + gaeSdkValidationStatus.getMessage(), ERROR); return; } } // If we are using GWT then an SDK must be selected if (useGwtCheckbox.getSelection()) { IStatus gwtRuntimeValidationStatus; GWTRuntime selectedGwtRuntime = getSelectedGwtSdk(); if (selectedGwtRuntime == null) { setMessage("Please configure a GWT SDK.", ERROR); return; } else if (!(gwtRuntimeValidationStatus = selectedGwtRuntime.validate()).isOK()) { setMessage("The selected GWT SDK is not valid: " + gwtRuntimeValidationStatus.getMessage(), ERROR); return; } else { if (!selectedGwtRuntime.containsSCL()) { if (useGaeCheckbox.getSelection()) { setMessage( "Web Application Projects that use Google Web Toolkit and App Engine require a GWT SDK versioned 1.6 or later.", ERROR); return; } } } } // Verify that at least one of "Use GWT" or "Use GAE" is checked. if (!useGwtCheckbox.getSelection() && !useGaeCheckbox.getSelection()) { setMessage("Web Application projects require the use of GWT and/or AppEngine.", ERROR); return; } pageComplete = true; setMessage(null); } finally { setPageComplete(pageComplete); } }
From source file:com.google.gwt.eclipse.testing.GwtRuntimeTestUtilities.java
License:Open Source License
/** * Adds a default GWT runtime to the {@link GWTPreferences}. Uses the {@code GWT_HOME} environment * variable if it is set, otherwise extracts a GWT SDK from this testing bundle and sets * {@code GWT_HOME} to the location where it is extracted. *///from ww w. j av a 2s. co m public static void addDefaultRuntime() throws Exception { String gwtHomePath = getGwtTestSdkPath(); TestEnvironmentUtil.updateEnvironmentVariable("GWT_HOME", gwtHomePath); System.out.println("SETTING: GWT_HOME=" + gwtHomePath); SdkSet<GWTRuntime> sdkSet = GWTPreferences.getSdks(); if (sdkSet.getDefault() == null) { assert (sdkSet.size() == 0); GWTRuntime sdk = GWTRuntime.getFactory().newInstance("Default GWT SDK", new Path(gwtHomePath)); IStatus status = sdk.validate(); if (!status.isOK()) { throw new CoreException(status); } sdkSet.add(sdk); GWTPreferences.setSdks(sdkSet); } }