List of usage examples for org.eclipse.jdt.core IJavaProject getElementName
String getElementName();
From source file:org.grails.ide.eclipse.core.internal.classpath.GrailsClasspathContainerUpdateJob.java
License:Open Source License
/** * Private constructor to create an instance * @param javaProject the {@link IJavaProject} the class path container should be updated for * @param showOutput // w w w.ja va 2 s . c o m * @param types the change types happened to the manifest */ private GrailsClasspathContainerUpdateJob(IJavaProject javaProject, boolean showOutput) { super("Updating Grails dependencies for project '" + javaProject.getElementName() + "'"); this.javaProject = javaProject; this.showOutput = showOutput; }
From source file:org.grails.ide.eclipse.core.launch.GrailsSourcePathComputer.java
License:Open Source License
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { List<IRuntimeClasspathEntry> entries = new ArrayList<IRuntimeClasspathEntry>(); IRuntimeClasspathEntry jreEntry = JavaRuntime.computeJREEntry(configuration); if (jreEntry != null) { entries.add(jreEntry);//from www. j a v a 2s . c o m } String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { IJavaProject javaProject = JavaCore.create(project); if (javaProject != null && javaProject.isOpen() && ("".equals(projectName) || projectName.equals(javaProject.getElementName()))) { entries.add(JavaRuntime.newDefaultProjectClasspathEntry(javaProject)); } } IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath( // entries.toArray(new IRuntimeClasspathEntry[entries.size()]), configuration); return JavaRuntime.getSourceContainers(resolved); }
From source file:org.grails.ide.eclipse.ui.internal.importfixes.GrailsOutputFolderFixer.java
License:Open Source License
/** * Called by project version fixer when it detects a new grails project in the workspace. * <p>// www . ja va 2 s . c o m * This is called after the version fixer has already applied its fixer logic. (But beware that * the fixer actually shedules most of its work as jobs so the actually fixes probably * have not yet been applied. */ public void fix(IProject project) { try { if (project.hasNature(JavaCore.NATURE_ID)) { final IJavaProject javaProject = JavaCore.create(project); IPath outputFolder = javaProject.getOutputLocation(); if (isBadOutputFolder(outputFolder)) { WorkspaceJob job = new WorkspaceJob("Fix output folder") { @Override public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { try { //We recheck the fixing condition because, it may have changed by the time the job is scheduled. //This is because version fixer in some cases calls eclipsify (also from a scheduled job) and //this also fixes the output folder. It is probably harmless to fix twice, but it does //cause a potential build, so it is best not to do it. IPath outputFolder = javaProject.getOutputLocation(); if (isBadOutputFolder(outputFolder)) { GrailsCommandUtils.setDefaultOutputFolder(javaProject); } return Status.OK_STATUS; } catch (Exception e) { return new Status(IStatus.WARNING, GrailsCoreActivator.PLUGIN_ID, "Error while fixing output folder for project " + javaProject.getElementName()); } } }; job.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule()); job.setPriority(Job.INTERACTIVE); job.schedule(); } } } catch (Exception e) { GrailsCoreActivator.log(e); } }
From source file:org.grails.ide.eclipse.ui.internal.inplace.GrailsLaunchUtils.java
License:Open Source License
/** * Special handling for run-app and run-war, see https://issuetracker.springsource.com/browse/STS-3155 * https://issuetracker.springsource.com/browse/STS-3299 * /*ww w.j av a2s.c om*/ * @throws CoreException */ private static void launchNoTimeout(final IJavaProject javaProject, final String script) { final String title = "Launching " + javaProject.getElementName() + ": " + script; new UIJob(title) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { monitor.beginTask(title, 3); try { try { ILaunchConfiguration launchConf = GrailsLaunchConfigurationDelegate .getLaunchConfiguration(javaProject.getProject(), script, false); monitor.worked(1); DebugUITools.launch(launchConf, ILaunchManager.RUN_MODE); } catch (CoreException e) { return new Status(IStatus.ERROR, GrailsCoreActivator.PLUGIN_ID, "Problem executing: " + script, e); } return Status.OK_STATUS; } finally { monitor.done(); } } }.schedule(); }
From source file:org.grails.ide.eclipse.ui.internal.launch.GrailsLaunchMainTab.java
License:Open Source License
/** * Show a dialog that lets the user select a project. This in turn provides context for the main type, allowing the * user to key a main type name, or constraining the search for main types to the specified project. *///from w ww.j a v a2s . com protected void handleProjectButtonSelected() { IJavaProject project = chooseJavaProject(); if (project == null) { return; } String projectName = project.getElementName(); fProjText.setText(projectName); initializeContentAssist(); }
From source file:org.gw4e.eclipse.launching.offline.GW4ELaunchConfigurationTab.java
License:Open Source License
/** * Here is what happen when the button is selected (Selection of a project) *///from w w w. j av a 2 s . c o m private void handleProjectButtonSelected() { IJavaProject project = GraphWalkerContextManager.chooseGW4EProject(getJavaProject()); if (project == null) { return; } String projectName = project.getElementName(); fProjText.setText(projectName); }
From source file:org.gw4e.eclipse.launching.test.GW4ELaunchConfigurationTab.java
License:Open Source License
private void handleProjectButtonSelected() { IJavaProject project = chooseJavaProject(); if (project == null) { return;/*w w w .jav a 2s. c o m*/ } String projectName = project.getElementName(); fProjectText.setText(projectName); }
From source file:org.hibernate.eclipse.console.wizards.ConsoleConfigurationWizardPage.java
License:Open Source License
static protected void setProjAttribute(ILaunchConfigurationWorkingCopy currentLaunchConfig, String attr, IJavaProject proj) { if (proj != null) { currentLaunchConfig.setAttribute(attr, nonEmptyTrimOrNull(proj.getElementName())); currentLaunchConfig.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS, Collections .singletonList(new Path(nonEmptyTrimOrNull(proj.getElementName())).makeAbsolute().toString())); currentLaunchConfig.setAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES, Collections.singletonList(Integer.toString(IResource.PROJECT))); } else {/* w ww . j a va 2 s .co m*/ currentLaunchConfig.setAttribute(attr, (String) null); currentLaunchConfig.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_PATHS); currentLaunchConfig.removeAttribute(LaunchConfiguration.ATTR_MAPPED_RESOURCE_TYPES); } }
From source file:org.hibernate.eclipse.console.workbench.ProjectCompilerVersionChecker.java
License:Open Source License
/** * // w w w. ja v a 2s . c o m * @param ccfg * @return false if Projects jdk version is bigger than Eclipse jdk version */ public static boolean validateProjectComplianceLevel(final ConsoleConfiguration ccfg) { IJavaProject[] javaProjects = ProjectUtils.findJavaProjects(ccfg); if (javaProjects.length > 0) { for (final IJavaProject iJavaProject : javaProjects) { if (iJavaProject.exists()) { String projectTarget = iJavaProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true); String eclipseCompilerVersion = System.getProperty("java.specification.version"); //$NON-NLS-1$ long projectJdkLevel = versionToJdkLevel(projectTarget); long eclipseJdkLevel = versionToJdkLevel(eclipseCompilerVersion); if (eclipseJdkLevel < projectJdkLevel) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { MessageDialog.openWarning(null, Messages.ProjectCompilerVersionChecker_title, NLS.bind(Messages.ProjectCompilerVersionChecker_message, iJavaProject.getElementName())); } }); return false; } } } } return true; }
From source file:org.hibernate.eclipse.jdt.ui.wizards.NewHibernateMappingFileWizard.java
License:Open Source License
protected void cleanUpGenFolders() { Set<IJavaProject> projs = previewPage.getJavaProjects(); for (IJavaProject proj : projs) { // cleanup gen folder //final IPath projPath = proj.getProject().getLocation(); IPath place2Gen = previewPage.getRootPlace2Gen().append(proj.getElementName()); File folder2Gen = new File(place2Gen.toOSString()); FileUtils.delete(folder2Gen);// w w w. ja v a 2 s .c o m } }