Search in sources :

Example 86 with CoreException

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) AbstractProposalSorter(org.eclipse.jdt.ui.text.java.AbstractProposalSorter) PerformanceStats(org.eclipse.core.runtime.PerformanceStats) CoreException(org.eclipse.core.runtime.CoreException) InvalidRegistryObjectException(org.eclipse.core.runtime.InvalidRegistryObjectException)

Example 87 with CoreException

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;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) File(java.io.File)

Example 88 with CoreException

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);
    }
}
Also used : JavaDown(com.jopdesign.jopeclipse.internal.core.JavaDown) IPath(org.eclipse.core.runtime.IPath) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException)

Example 89 with CoreException

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();
    }
}
Also used : Status(org.eclipse.core.runtime.Status) AntRunner(org.eclipse.ant.core.AntRunner) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) File(java.io.File)

Example 90 with CoreException

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;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException) IProject(org.eclipse.core.resources.IProject)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)987 IStatus (org.eclipse.core.runtime.IStatus)264 Status (org.eclipse.core.runtime.Status)240 IFile (org.eclipse.core.resources.IFile)176 IOException (java.io.IOException)174 IProject (org.eclipse.core.resources.IProject)133 IResource (org.eclipse.core.resources.IResource)132 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)128 IPath (org.eclipse.core.runtime.IPath)126 ArrayList (java.util.ArrayList)125 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)100 File (java.io.File)95 InvocationTargetException (java.lang.reflect.InvocationTargetException)95 InputStream (java.io.InputStream)76 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)67 Path (org.eclipse.core.runtime.Path)61 ByteArrayInputStream (java.io.ByteArrayInputStream)54 IWorkspace (org.eclipse.core.resources.IWorkspace)53 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)52 IFileStore (org.eclipse.core.filesystem.IFileStore)51