Example usage for org.springframework.ide.eclipse.core.java JdtUtils getJavaProject

List of usage examples for org.springframework.ide.eclipse.core.java JdtUtils getJavaProject

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.core.java JdtUtils getJavaProject.

Prototype

public static IJavaProject getJavaProject(IResource config) 

Source Link

Usage

From source file:org.eclipse.virgo.ide.ui.editors.BundleOverviewPage.java

public void linkActivated(HyperlinkEvent e) {
    if (e.getHref().equals("dependencies")) {
        getEditor().setActivePage(BundleDependenciesPage.PAGE_ID);
    } else if (e.getHref().equals("runtime")) {
        getEditor().setActivePage(BundleRuntimePage.PAGE_ID);
    } else if (e.getHref().equals("refreshdependencies")) {
        IRunnableWithProgress op = new WorkspaceModifyOperation() {
            protected void execute(IProgressMonitor monitor) throws CoreException, InterruptedException {
                ServerClasspathContainerUpdateJob.scheduleClasspathContainerUpdateJob(
                        JdtUtils.getJavaProject(resource), BundleManifestManager.IMPORTS_CHANGED);
            }/*from w  w  w .j av a2s .c o m*/
        };
        try {
            PlatformUI.getWorkbench().getProgressService().runInUI(PDEPlugin.getActiveWorkbenchWindow(), op,
                    PDEPlugin.getWorkspace().getRoot());
        } catch (InvocationTargetException e1) {
        } catch (InterruptedException e1) {
        }
    } else if (e.getHref().equals("generate")) {
        BundlorUiPlugin.runBundlorOnProject(JdtUtils.getJavaProject(resource));
    } else if (e.getHref().equals("exportbundle")) {
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                BundleExportWizard wizard = new BundleExportWizard();
                WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
                wizard.init(PlatformUI.getWorkbench(),
                        new StructuredSelection(new Object[] { JdtUtils.getJavaProject(resource) }));
                dialog.open();
            }
        });
    }
}

From source file:org.eclipse.virgo.ide.runtime.internal.core.ServerBehaviour.java

public URL getModuleRootURL(IModule module) {
    try {/*from ww  w .  java 2 s.c  om*/
        // check pre condition; only dynamic web projects and java projects are allowed
        IProject project = module.getProject();
        if (!SpringCoreUtils.hasProjectFacet(project, FacetCorePlugin.WEB_FACET_ID)
                || !JdtUtils.isJavaProject(project)) {
            return null;
        }

        String contextPath = null;

        BundleManifest bundleManifest = BundleManifestCorePlugin.getBundleManifestManager()
                .getBundleManifest(JdtUtils.getJavaProject(project));
        if (bundleManifest != null) {
            Dictionary<String, String> manifest = bundleManifest.toDictionary();
            if (manifest != null && manifest.get(WEB_CONTEXT_PATH_MANIFEST_HEADER) != null) {
                contextPath = manifest.get(WEB_CONTEXT_PATH_MANIFEST_HEADER);
            }

        }
        if (contextPath == null) {
            contextPath = module.getName();
        }

        // TODO: CD make port configurable
        int port = 8080;
        StringBuilder urlBuilder = new StringBuilder();
        urlBuilder.append("http://localhost:");
        urlBuilder.append(port);
        urlBuilder.append("/");
        urlBuilder.append(contextPath);

        String url = urlBuilder.toString();
        if (!url.endsWith("/")) {
            urlBuilder.append("/");
        }

        return new URL(urlBuilder.toString());
    } catch (Exception e) {
        return null;
    }
}

From source file:org.eclipse.virgo.ide.jdt.internal.core.classpath.ServerClasspathContainer.java

/**
 * Adds the given project as a workspace project to the list
 * @param workspaceBundles the already existing workspace bundles
 * @param project the bundle project to add
 *//* w  w  w.  j  a v  a2 s . c  om*/
private void addWorkspaceBundle(Set<String> workspaceBundles, IProject project) {
    if (project.isAccessible() && FacetUtils.isBundleProject(project)) {
        String manifestFolder = BundleManifestUtils.locateManifestFolder(JdtUtils.getJavaProject(project));
        if (manifestFolder != null) {
            workspaceBundles.add(manifestFolder);
            manifestLocationsByProject.put(manifestFolder, JdtUtils.getJavaProject(project));
        }
    }
}