List of usage examples for org.eclipse.jdt.core IJavaProject getElementName
String getElementName();
From source file:test.fede.workspace.domain.internal.TestWorkingLogiqueCopy.java
License:Apache License
public void checkError(IJavaProject jp, IProgressMonitor monitor) throws CoreException { jp.getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor); if (!jp.hasBuildState()) return;//from www .j av a 2s . com IMarker[] markers = jp.getProject().findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); if (markers == null) return; StringBuilder errors = new StringBuilder(); for (IMarker iMarker : markers) { Integer severity = (Integer) iMarker.getAttribute(IMarker.SEVERITY); if (severity != null && severity == IMarker.SEVERITY_ERROR) { errors.append(iMarker.getAttribute(IMarker.MESSAGE)).append("\n"); } } if (errors.length() != 0) { fail("compilation error on " + jp.getElementName() + "\n" + errors); } }
From source file:testlink.eclipse.plugin.handlers.ChooseProjectHandler.java
License:Open Source License
public void handle(Label wLabel, Text text, Button button) { super.handle(wLabel, text, button); IJavaProject project = chooseJavaProject(); if (project == null) { return;/*from w ww . j a v a 2s . c om*/ } String projectName = project.getElementName(); text.setText(projectName); }
From source file:thahn.java.agui.ide.eclipse.project.ProjectChooserHelper.java
License:Open Source License
/** * Helper method to get the Android project with the given name * * @param projectName the name of the project to find * @return the {@link IProject} for the Android project. <code>null</code> if not found. *//*w ww . ja va2 s. c om*/ public IProject getAguiProject(String projectName) { IProject iproject = null; IJavaProject[] javaProjects = getAguiProjects(null); if (javaProjects != null) { for (IJavaProject javaProject : javaProjects) { if (javaProject.getElementName().equals(projectName)) { iproject = javaProject.getProject(); break; } } } return iproject; }
From source file:x10dt.ui.launch.core.utils.ProjectUtils.java
License:Open Source License
/** * Returns the collection of source folders for a given project. * //w w w. j a v a2s. c om * @param project The project of interest. * @return A non-null collection of workspace-relative strings representing the src folders of the project. * @throws JavaModelException Occurs if we could not resolve the project class path. */ public static Collection<String> collectSourceFolders(final IJavaProject project) throws JavaModelException { final Collection<String> result = new ArrayList<String>(); for (final IClasspathEntry cpEntry : project.getResolvedClasspath(true)) { if (cpEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { final IPath entryPath = cpEntry.getPath(); if (!entryPath.segment(0).equals(project.getElementName())) { continue; } result.add(entryPath.toOSString()); } } return result; }
From source file:x10dt.ui.launch.java.launching.X10LaunchConfigurationDelegate.java
License:Open Source License
private void runCommand(final ILaunchConfiguration configuration, final String mode, final IJavaProject javaProject, final IProgressMonitor monitor) throws CoreException { try {//from w ww . j a v a2s. c om final MessageConsole messageConsole = UIUtils.findOrCreateX10Console(); final MessageConsoleStream mcStream = messageConsole.newMessageStream(); messageConsole.activate(); messageConsole.clearConsole(); final String mainTypeName = this.fLocalConfDelegate.getMainTypeName(configuration); final File workingDir = getWorkingDir(configuration, javaProject, mainTypeName); final boolean isLocal = ConfUtils.isLocalConnection(configuration); final IPath jarPath; if (!isLocal) { jarPath = transferJar(createJarFile(workingDir, javaProject.getElementName(), mainTypeName), configuration.getName(), getOutputFolder(configuration)); } else { jarPath = null; } // if (isLocal){ // ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); // if (manager != null) { // ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); // if (type != null) { // ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, "X10-Java-backend-launch"); // // // workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false); // // workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, getClassPath(configuration)); // // workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,getVMArguments(configuration, false)); // // workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "x10.x10rt.Launcher"); // // workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir.getAbsolutePath()); // // final String attrProgArgs = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, ""); //$NON-NLS-1$ // final String progArgs = mainTypeName + " " + VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(attrProgArgs); // // workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, progArgs); // ILaunchConfiguration conf = workingCopy.doSave(); // workingCopy.launch(mode, monitor); // //DebugUITools.launch(conf, ILaunchManager.DEBUG_MODE); // // // // if (mode.equals(ILaunchManager.DEBUG_MODE)){ // ILaunchConfigurationWorkingCopy remoteDebugLaunchConfig = createRemoteDebugLaunchConfiguration(javaProject.getProject().getName(), "54729"); // remoteDebugLaunchConfig.launch(ILaunchManager.DEBUG_MODE, monitor); // //DebugUITools.launch(remoteDebugLaunchConfig, ILaunchManager.DEBUG_MODE); // } // // // } // } // } final Map<String, String> env = new HashMap<String, String>(); final int NPlaces = ConfUtils.getNPlaces(configuration); env.put(NPLACES, (new Integer(NPlaces)).toString()); int sel = ConfUtils.hostSelectionMode(configuration); if (sel == HOST_FILE) { env.put(HOSTFILE, ConfUtils.getHostFile(configuration)); } else if (sel == HOST_LIST) { env.put(HOSTLIST, ConfUtils.getHostList(configuration)); } Map<String, String> launchEnv = configuration.getAttribute(ATTR_ENV, (Map<String, String>) null); if (launchEnv != null) { for (String key : launchEnv.keySet()) { env.put(key, launchEnv.get(key)); } } final List<String> command = new ArrayList<String>(); final String x10DistFolder = getX10DistributionFolder(configuration, !isLocal); this.fExecPath = getExecutablePath(x10DistFolder, isLocal, configuration.getName()); final String cmd = this.fExecPath.toString(); if (!isLocal) { command.add(cmd); } final String[] argArr = getProgArguments(configuration, mainTypeName, jarPath, !isLocal, mode); for (String s : argArr) { command.add(s); } this.fTargetOpHelper = TargetOpHelperFactory.create(ConfUtils.isLocalConnection(configuration), this.fIsCygwin, ConfUtils.getConnectionName(configuration)); this.fWorkspaceDir = getWorkspaceDir(configuration, javaProject.getProject(), isLocal); this.fTargetOpHelper.run(command, this.fWorkspaceDir, env, new IProcessOuputListener() { public void read(final String line) { mcStream.println(line); } public void readError(final String line) { if (this.fCounter == 0) { //mcStream.println(NLS.bind(LaunchMessages.CLCD_CmdUsedMsg, cmd)); this.fCounter = 1; } if (mode.equals(ILaunchManager.DEBUG_MODE) && donePorts != NPlaces) { donePorts++; try { ILaunchConfigurationWorkingCopy remoteDebugLaunchConfig = createRemoteDebugLaunchConfiguration( configuration, javaProject.getProject().getName(), getPort(line), getPlace(line)); remoteDebugLaunchConfig.launch(ILaunchManager.DEBUG_MODE, new NullProgressMonitor()); } catch (CoreException e) { } } else { mcStream.println(line); } } // --- Fields int fCounter; int donePorts = 0; }, monitor); mcStream.flush(); mcStream.close(); } catch (InterruptedException e) { throw new CoreException( new Status(IStatus.ERROR, CppLaunchCore.PLUGIN_ID, LaunchMessages.CLCD_Interrupted, e)); } catch (IOException e) { throw new CoreException( new Status(IStatus.ERROR, CppLaunchCore.PLUGIN_ID, LaunchMessages.CLCD_IOError, e)); } }