Example usage for org.eclipse.jdt.core IType getCorrespondingResource

List of usage examples for org.eclipse.jdt.core IType getCorrespondingResource

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IType getCorrespondingResource.

Prototype

IResource getCorrespondingResource() throws JavaModelException;

Source Link

Document

Returns the resource that corresponds directly to this element, or null if there is no resource that corresponds to this element.

Usage

From source file:org.codehaus.groovy.eclipse.refactoring.test.DebugUtils.java

License:Open Source License

public static void dumpIType(String msg, IType type) {
    System.out.println("DUMPING IType:" + msg); //$NON-NLS-1$
    System.out.println("exists:" + type.exists()); //$NON-NLS-1$
    try {/* w w w. j  a va2s  . c om*/
        System.out.println("correspondingResource:" + type.getCorrespondingResource()); //$NON-NLS-1$
        System.out.println("underResource:" + type.getUnderlyingResource()); //$NON-NLS-1$
        System.out.println("source:\n" + type.getSource()); //$NON-NLS-1$

        //System.out.println("cu.orig.under" + type.getCompilationUnit().getOriginalElement().getUnderlyingResource());
        System.out.println("cu:" + type.getCompilationUnit().getSource()); //$NON-NLS-1$
    } catch (JavaModelException e) {
        System.out.println("JavaModelException: " + e.getMessage()); //$NON-NLS-1$
    }

}

From source file:org.eclipse.jst.ws.internal.consumption.ui.widgets.object.JavaBeanSelectionWidget.java

License:Open Source License

private void handleBrowseClasses() {
    Shell shell = parent_.getShell();//w w w .  j a  v a  2 s.co m
    IType itype = DialogUtils.browseClassesAsIType(shell,
            ResourcesPlugin.getWorkspace().getRoot().getProjects(), new ProgressMonitorDialog(shell));
    if (itype != null) {
        beanClassText_.setText(itype.getFullyQualifiedName());
        try {
            IResource res = itype.getCorrespondingResource();
            if (res != null) {
                serverProject_ = res.getProject();
                IVirtualComponent comp = ResourceUtils.getComponentOf(res);
                if (comp != null) {
                    serverComponentName_ = comp.getName();
                }
            } else {
                serverProject_ = null;
                serverComponentName_ = null;
            }
        } catch (JavaModelException jme) {
            serverProject_ = null;
            serverComponentName_ = null;
        }
    }
}