use of org.eclipse.core.runtime.CoreException in project che by eclipse.
the class ProposalSorterHandle method sortProposals.
/**
* Safely computes completion proposals through the described extension. If the extension throws
* an exception or otherwise does not adhere to the contract described in
* {@link AbstractProposalSorter}, the list is returned as is.
*
* @param context the invocation context passed on to the extension
* @param proposals the list of computed completion proposals to be sorted (element type:
* {@link ICompletionProposal}), must be writable
*/
public void sortProposals(ContentAssistInvocationContext context, List<ICompletionProposal> proposals) {
IStatus status;
try {
AbstractProposalSorter sorter = getSorter();
PerformanceStats stats = startMeter(SORT, sorter);
sorter.beginSorting(context);
Collections.sort(proposals, sorter);
sorter.endSorting();
status = stopMeter(stats, SORT);
// valid result
if (status == null)
return;
status = createAPIViolationStatus(SORT);
} catch (InvalidRegistryObjectException x) {
status = createExceptionStatus(x);
} catch (CoreException x) {
status = createExceptionStatus(x);
} catch (RuntimeException x) {
status = createExceptionStatus(x);
}
JavaPlugin.log(status);
return;
}
use of org.eclipse.core.runtime.CoreException in project jop by jop-devel.
the class JOPMainTab method validateOutputDirectory.
/**
* @return
*/
private boolean validateOutputDirectory() {
String dir = fJOPizedOutputText.getText().trim();
if (dir.length() == 0) {
setErrorMessage(null);
setMessage("Output location can not be empty");
return false;
}
String expandedDir = null;
try {
expandedDir = VariableManagerUtils.resolveValue(dir);
if (expandedDir == null) {
// A variable needs to be resolved at run-time
return true;
}
} catch (CoreException e) {
setErrorMessage(e.getStatus().getMessage());
return false;
}
File file = new File(expandedDir);
if (!file.exists()) {
// The file does not exist.
setErrorMessage("Location_does_not_exist");
return false;
}
if (!file.isDirectory()) {
setErrorMessage("Location_specified_is_not_a_directory_20");
return false;
}
return true;
}
use of org.eclipse.core.runtime.CoreException 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.CoreException in project generator by mybatis.
the class GeneratorLaunchConfigurationDelegate method launch.
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
AntRunner antRunner = new AntRunner();
String buildFile;
try {
buildFile = generateAntScript(configuration);
} catch (IOException e) {
Status status = new Status(Status.ERROR, Activator.PLUGIN_ID, Messages.LAUNCH_ERROR_ERROR_GENERATING_ANT_FILE, e);
throw new CoreException(status);
}
antRunner.setBuildFileLocation(buildFile);
//$NON-NLS-1$
antRunner.addBuildLogger("org.mybatis.generator.eclipse.ui.ant.GeneratorBuildLogger");
modifyAntClasspathIfNecessary(configuration, antRunner);
if (ILaunchManager.DEBUG_MODE.equals(mode)) {
antRunner.setMessageOutputLevel(Project.MSG_DEBUG);
//$NON-NLS-1$
antRunner.setArguments("-debug");
} else {
antRunner.setMessageOutputLevel(Project.MSG_WARN);
}
antRunner.run(monitor);
if (LauncherUtils.getBooleanOrFalse(configuration, GeneratorLaunchConstants.ATTR_SQL_SCRIPT_SECURE_CREDENTIALS)) {
File file = new File(buildFile);
file.delete();
}
}
use of org.eclipse.core.runtime.CoreException in project generator by mybatis.
the class GeneratorLaunchShortcut method getJavaProjectNameFromResource.
/**
* This will return null if there isn't a JavaProject associated with this
* resource.
*
* @param resource
* @return the JavaProject name if there is one
*/
public static String getJavaProjectNameFromResource(IResource resource) {
String name = null;
IProject project = resource.getProject();
try {
if (project != null && project.exists() && project.hasNature(JavaCore.NATURE_ID)) {
// add the JavaProject name to the launch - this will add it to the
// classpath of the launch automatically
IJavaProject javaProject = JavaCore.create(project);
name = javaProject.getElementName();
}
} catch (CoreException e) {
// just ignore it - no ultimate harm done if we can't find the Java project
}
return name;
}
Aggregations