Search in sources :

Example 61 with IPath

use of org.eclipse.core.runtime.IPath in project jop by jop-devel.

the class JOPizer method createJOPizeLaunchConfiguration.

private ILaunchConfiguration createJOPizeLaunchConfiguration(String programArguments) throws CoreException {
    String configName = "JOPize";
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
    ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);
    for (ILaunchConfiguration config : configs) {
        if (config.getName().equals(configName)) {
            config.delete();
            break;
        }
    }
    ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, configName);
    IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
    Map attributes = workingCopy.getAttributes();
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "com.jopdesign.build.JOPizer");
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArguments);
    IPreferenceStore prefs = JOPUIPlugin.getDefault().getPreferenceStore();
    String jopHome = prefs.getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME);
    IPath jopTools = new Path(jopHome).append(new Path("java/tools/dist/lib/jop-tools.jar"));
    IRuntimeClasspathEntry jopToolsEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jopTools);
    jopToolsEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
    IPath jopClasses = new Path(jopHome).append(new Path("java/target/dist/lib/classes.zip"));
    IRuntimeClasspathEntry jopClassesEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(jopClasses);
    jopClassesEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
    // IClasspathEntry jreEntry = JavaRuntime.getDefaultJREContainerEntry();
    List<String> classpath = new ArrayList<String>();
    classpath.add(jopToolsEntry.getMemento());
    classpath.add(jopClassesEntry.getMemento());
    // classpath.add(jreEntry.get)
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Dmgci=false");
    workingCopy.setAttributes(attributes);
    System.err.printf("> %s%n", workingCopy.toString());
    return workingCopy;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry) IVMInstall(org.eclipse.jdt.launching.IVMInstall) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Map(java.util.Map)

Example 62 with IPath

use of org.eclipse.core.runtime.IPath in project jop by jop-devel.

the class JOPizer method getToolsClasspathEntry.

private IClasspathEntry getToolsClasspathEntry() throws JavaModelException {
    IPreferenceStore prefs = JOPUIPlugin.getDefault().getPreferenceStore();
    String jopHome = prefs.getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME);
    IPath jopTools = new Path(jopHome).append(new Path("java/tools/dist/lib/jop-tools.jar"));
    IClasspathEntry[] entries = currentProject.getRawClasspath();
    for (IClasspathEntry entry : entries) {
        if (entry.getPath().equals(jopTools)) {
            return entry;
        }
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 63 with IPath

use of org.eclipse.core.runtime.IPath in project jop by jop-devel.

the class JavaDownLaunchConfigurationDelegate method jopize.

/**
     * 
     * @param configuration
     * @param mode
     * @param launch
     * @param monitor
     * @return
     * @throws CoreException
     * @throws IOException
     * @throws InterruptedException
     */
private int jopize(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException, InterruptedException {
    IPath workingDir = getAbsoluteProjectOutputPath(configuration);
    IPath jopizedFile = getJopizedFile(configuration);
    IPath jopHome = Path.fromOSString(JOPUIPlugin.getDefault().getPreferenceStore().getString(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME));
    String[] args = new String[] { "java", "-classpath", String.format("%s;%s;%s", jopHome.append("java/lib/bcel-5.1.jar"), jopHome.append("java/lib/jakarta-regexp-1.3.jar"), jopHome.append("java/tools/dist/lib/jop-tools.jar")), "com.jopdesign.build.JOPizer", "-cp", jopHome.append("java/target/dist/lib/classes.zip") + ";" + workingDir.toOSString(), "-o", jopizedFile.toOSString(), getMainTypeName(configuration) };
    Process process = DebugPlugin.exec(args, workingDir.toFile());
    IProcess p = DebugPlugin.newProcess(launch, process, "JOPizer");
    p.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, "true");
    return process.waitFor();
}
Also used : IPath(org.eclipse.core.runtime.IPath) IProcess(org.eclipse.debug.core.model.IProcess) IProcess(org.eclipse.debug.core.model.IProcess)

Example 64 with IPath

use of org.eclipse.core.runtime.IPath in project jop by jop-devel.

the class JavaDownLaunchConfigurationDelegate method simulate.

/**
     * "Hi-jacks" the Java launch and replaces main-class and parameters to run 
     * a simulation of the JOPized file
     *  
     * @param configuration
     * @param mode
     * @param launch
     * @param monitor
     * @throws CoreException
     */
public void simulate(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    IPath jopizedFile = getJopizedFile(configuration);
    Map attributes = configuration.getAttributes();
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "com.jopdesign.tools.JopSim");
    attributes.put(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, jopizedFile.toOSString());
    ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
    workingCopy.setAttributes(attributes);
    super.launch(workingCopy, mode, launch, monitor);
}
Also used : IPath(org.eclipse.core.runtime.IPath) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Map(java.util.Map)

Example 65 with IPath

use of org.eclipse.core.runtime.IPath in project jop by jop-devel.

the class JOPPropertyPage method performDefaults.

/* (non-Javadoc)
     * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performDefaults()
     */
@Override
public void performDefaults() {
    super.performDefaults();
    IProject project = getProject();
    IPath projectRoot = project.getLocation();
    IScopeContext scopeContext = new ProjectScope(project);
    Preferences projectPrefs = scopeContext.getNode(IJOPUIConstants.PLUGIN_ID);
    jopDirectoryEditor.setStringValue(projectPrefs.get(IJOPLaunchConfigurationConstants.ATTR_JOP_HOME, projectRoot.toOSString()));
    IPath defaultQuartusProjectFile = projectRoot.append("quartus").append("cycmin").append("jop").addFileExtension("qpf");
    quartusProjectFileEditor.setStringValue(projectPrefs.get(IJOPLaunchConfigurationConstants.ATTR_QUARTUS_PROJECT, defaultQuartusProjectFile.toOSString()));
}
Also used : ProjectScope(org.eclipse.core.resources.ProjectScope) IScopeContext(org.eclipse.core.runtime.preferences.IScopeContext) IPath(org.eclipse.core.runtime.IPath) Preferences(org.osgi.service.prefs.Preferences) IProject(org.eclipse.core.resources.IProject)

Aggregations

IPath (org.eclipse.core.runtime.IPath)800 Path (org.eclipse.core.runtime.Path)219 File (java.io.File)161 IFile (org.eclipse.core.resources.IFile)150 CoreException (org.eclipse.core.runtime.CoreException)135 IResource (org.eclipse.core.resources.IResource)112 IOException (java.io.IOException)100 ArrayList (java.util.ArrayList)92 IProject (org.eclipse.core.resources.IProject)85 IFolder (org.eclipse.core.resources.IFolder)80 Test (org.junit.Test)72 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)58 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)55 IStatus (org.eclipse.core.runtime.IStatus)48 InputStream (java.io.InputStream)44 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)42 Status (org.eclipse.core.runtime.Status)36 IJavaProject (org.eclipse.jdt.core.IJavaProject)36 URL (java.net.URL)33 IContainer (org.eclipse.core.resources.IContainer)33