Example usage for org.eclipse.jdt.core JavaModelException printStackTrace

List of usage examples for org.eclipse.jdt.core JavaModelException printStackTrace

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaModelException printStackTrace.

Prototype

@Override
public void printStackTrace(PrintWriter output) 

Source Link

Document

Prints this exception's stack trace to the given print writer.

Usage

From source file:com.idega.eclipse.ejbwizards.BeanCreator.java

License:Open Source License

protected BeanCreator(IResource resource, boolean isLegacyOrSessionBean) {
    this.isLegacyEntity = isLegacyOrSessionBean;
    this.isSessionBean = isLegacyOrSessionBean;

    String resourceName = resource.getName();

    IJavaElement javaElement = JavaCore.create(resource);
    if (javaElement instanceof ICompilationUnit) {
        String typeName = resourceName.substring(0, resourceName.indexOf(".java"));
        ICompilationUnit compilationUnit = (ICompilationUnit) javaElement;
        fillImportMap(compilationUnit);/*from  ww w  .j  av a2 s.  co  m*/
        this.type = compilationUnit.getType(typeName);
    }

    Map map = javaElement.getJavaProject().getOptions(false);
    if (map != null) {
        String value = (String) map.get("org.eclipse.jdt.core.compiler.compliance");
        if (value != null) {
            float version = Float.parseFloat(value);
            if (version > 1.4) {
                this.isJDK1_5 = true;
            }
        }
    }

    try {
        generateCode();
    } catch (JavaModelException jme) {
        jme.printStackTrace(System.err);
    }
}

From source file:com.jstar.eclipse.services.Utils.java

License:BSD License

private void makeImportReady(final JavaFile selectedFile, final String importLine) throws IOException {
    final IPath sourcePath = new Path(StringUtils.replace(importLine, ".", File.separator));

    try {/*ww  w.j a va2  s.  c o  m*/
        final IJavaElement element = selectedFile.getJavaProject().getProject()
                .findElement(sourcePath.addFileExtension("java"));

        if (element == null) {
            throw new NullPointerException("Could not import class: " + importLine
                    + ". Please check if it is written in the correct way, e.g. java.lang.Object");
        }

        final IResource resource = element.getResource();

        if (resource == null) {
            checkFiles(selectedFile, sourcePath, importLine);
            return;
        }

        if (resource != null && resource instanceof IFile) {
            final boolean specInSource = JavaFilePersistentProperties.isSpecInSourceFile(resource);

            if (specInSource) {
                final IFile file = (IFile) resource;
                checkGeneratedFiles(file, selectedFile, sourcePath, importLine);
                makeImportsReady(new JavaFile(file));
            } else {
                checkFiles(selectedFile, sourcePath, importLine);
            }

            return;
        }

        throw new RuntimeException("Could not import class: " + importLine
                + ". Please check if it is written in the correct way, e.g. java.lang.Object");

    } catch (JavaModelException jme) {
        jme.printStackTrace(ConsoleService.getInstance().getConsoleStream());
    }

}

From source file:com.windowtester.eclipse.ui.convert.WTAPIUsage.java

License:Open Source License

private Collection<String> collectReferencedPlugins(PrintWriter writer) {
    Collection<String> pluginIds = new HashSet<String>();
    try {//  w ww  .j  a  v  a 2s.  c  o m
        for (IJavaProject proj : projects)
            for (IClasspathEntry entry : proj.getRawClasspath())
                collectPluginsReferencedByClasspathEntry(writer, pluginIds, proj, entry);
    } catch (JavaModelException e) {
        writer.println();
        e.printStackTrace(writer);
    } catch (IOException e) {
        writer.println();
        e.printStackTrace(writer);
    }
    return pluginIds;
}