use of org.eclipse.core.runtime.IPath in project jop by jop-devel.
the class JavaDownLaunchConfigurationDelegate method getJopizedFile.
/**
* Returns the location of the JOPized class-file
* @param configuration
* @return
* @throws CoreException
*/
private IPath getJopizedFile(ILaunchConfiguration configuration) throws CoreException {
IPath outputPath = getAbsoluteProjectOutputPath(configuration);
IPath jopOutFile = outputPath.append(getMainTypeName(configuration)).addFileExtension("jop");
return jopOutFile;
}
use of org.eclipse.core.runtime.IPath in project jop by jop-devel.
the class JavaDownLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
if (CommonTab.isLaunchInBackground(configuration)) {
System.err.println("Launch in background");
}
try {
// JOPize
int jopizerExitValue = jopize(configuration, mode, launch, monitor);
IPath jopizedFile = getJopizedFile(configuration);
if (configuration.getAttribute(IJOPLaunchConfigurationConstants.ATTR_SIMULATE, true)) {
// configuration.getAttribute("SIMULATE", false)) {
simulate(configuration, mode, launch, monitor);
} else {
JavaDown downloader = new JavaDown();
boolean usb = useUsbDownload(configuration);
String portName = configuration.getAttribute(IJOPLaunchConfigurationConstants.ATTR_COM_PORT, "");
downloader.setCommPortId(portName);
downloader.useUSB(usb);
downloader.setJopFile(jopizedFile);
downloader.run(monitor);
}
} catch (Exception e) {
JOPUtils.abort(e.getLocalizedMessage(), e, 0);
}
}
use of org.eclipse.core.runtime.IPath in project generator by mybatis.
the class AbstractGeneratorComposite method createFileNameBrowseButtons.
private void createFileNameBrowseButtons(Composite parent) {
new Label(parent, SWT.NONE);
Composite buttonComposite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
buttonComposite.setLayout(layout);
GridData gd = new GridData(SWT.END, SWT.CENTER, false, false);
buttonComposite.setLayoutData(gd);
buttonComposite.setFont(parent.getFont());
btnBrowseWorkplace = new Button(buttonComposite, SWT.NONE);
btnBrowseWorkplace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
IResource chosenFile = chooseFileFromWorkspace();
if (chosenFile != null) {
IPath path = chosenFile.getFullPath();
//$NON-NLS-1$ //$NON-NLS-2$
txtFileName.setText("${workspace_loc:" + path.toString() + "}");
javaProjectName = GeneratorLaunchShortcut.getJavaProjectNameFromResource(chosenFile);
}
}
});
btnBrowseWorkplace.setText(Messages.FILE_PICKER_BROWSE_WORKSPACE);
btnBrowseFileSystem = new Button(buttonComposite, SWT.NONE);
btnBrowseFileSystem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chooseFileFromFileSystem();
}
});
btnBrowseFileSystem.setText(Messages.FILE_PICKER_BROWSE_FILE_SYSTEM);
}
use of org.eclipse.core.runtime.IPath in project generator by mybatis.
the class MyBatisGeneratorClasspathResolver method getGeneratorPath.
public static IPath getGeneratorPath() {
//$NON-NLS-1$
Bundle bundle = Platform.getBundle("org.mybatis.generator.core");
if (bundle == null) {
return null;
}
try {
//$NON-NLS-1$
URL devPath = bundle.getEntry("bin/");
File fullPath;
if (devPath != null) {
devPath = FileLocator.toFileURL(devPath);
fullPath = new File(devPath.toURI());
} else {
fullPath = FileLocator.getBundleFile(bundle);
}
return new Path(fullPath.getAbsolutePath());
} catch (IOException e) {
return null;
} catch (URISyntaxException e) {
return null;
}
}
use of org.eclipse.core.runtime.IPath in project generator by mybatis.
the class RunGeneratorThread method setClassLoader.
private void setClassLoader() {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IJavaProject javaProject = getJavaProject();
try {
if (javaProject != null) {
List<URL> entries = new ArrayList<URL>();
IPath path = javaProject.getOutputLocation();
IResource iResource = root.findMember(path);
path = iResource.getLocation();
path = path.addTrailingSeparator();
entries.add(path.toFile().toURI().toURL());
IClasspathEntry[] cpEntries = javaProject.getRawClasspath();
for (IClasspathEntry cpEntry : cpEntries) {
switch(cpEntry.getEntryKind()) {
case IClasspathEntry.CPE_SOURCE:
path = cpEntry.getOutputLocation();
if (path != null) {
iResource = root.findMember(path);
path = iResource.getLocation();
path = path.addTrailingSeparator();
entries.add(path.toFile().toURI().toURL());
}
break;
case IClasspathEntry.CPE_LIBRARY:
iResource = root.findMember(cpEntry.getPath());
if (iResource == null) {
// resource is not in workspace, must be an external JAR
path = cpEntry.getPath();
} else {
path = iResource.getLocation();
}
entries.add(path.toFile().toURI().toURL());
break;
}
}
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
URL[] entryArray = new URL[entries.size()];
entries.toArray(entryArray);
ClassLoader newCl = new URLClassLoader(entryArray, oldCl);
Thread.currentThread().setContextClassLoader(newCl);
oldClassLoader = oldCl;
}
} catch (Exception e) {
// ignore - something too complex is wrong
;
}
}
Aggregations