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;
}
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;
}
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();
}
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);
}
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()));
}
Aggregations