Search in sources :

Example 91 with IServer

use of org.eclipse.wst.server.core.IServer in project mdw-designer by CenturyLinkCloud.

the class JavaSourcePathComputer method computeSourceContainers.

@Override
public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
    IRuntimeClasspathEntry[] unresolvedEntries = JavaRuntime.computeUnresolvedSourceLookupPath(configuration);
    List<ISourceContainer> sourcefolderList = new ArrayList<ISourceContainer>();
    IServer server = ServerUtil.getServer(configuration);
    List<IJavaProject> javaProjectList = new ArrayList<IJavaProject>();
    if (server == null) {
        String projectName = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
        if (projectName != null) {
            WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(projectName);
            if (workflowProject != null)
                javaProjectList.add(workflowProject.getJavaProject());
        }
    } else {
        IModule[] modules = server.getModules();
        addProjectsFromModules(sourcefolderList, modules, javaProjectList, server, monitor);
    }
    IRuntimeClasspathEntry[] projectEntries = new IRuntimeClasspathEntry[javaProjectList.size()];
    for (int i = 0; i < javaProjectList.size(); i++) projectEntries[i] = JavaRuntime.newDefaultProjectClasspathEntry(javaProjectList.get(i));
    IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[projectEntries.length + unresolvedEntries.length];
    System.arraycopy(unresolvedEntries, 0, entries, 0, unresolvedEntries.length);
    System.arraycopy(projectEntries, 0, entries, unresolvedEntries.length, projectEntries.length);
    IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
    ISourceContainer[] javaSourceContainers = JavaRuntime.getSourceContainers(resolved);
    if (!sourcefolderList.isEmpty()) {
        ISourceContainer[] combinedSourceContainers = new ISourceContainer[javaSourceContainers.length + sourcefolderList.size()];
        sourcefolderList.toArray(combinedSourceContainers);
        System.arraycopy(javaSourceContainers, 0, combinedSourceContainers, sourcefolderList.size(), javaSourceContainers.length);
        javaSourceContainers = combinedSourceContainers;
    }
    return javaSourceContainers;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IRuntimeClasspathEntry(org.eclipse.jdt.launching.IRuntimeClasspathEntry) IJavaProject(org.eclipse.jdt.core.IJavaProject) ISourceContainer(org.eclipse.debug.core.sourcelookup.ISourceContainer)

Example 92 with IServer

use of org.eclipse.wst.server.core.IServer in project mdw-designer by CenturyLinkCloud.

the class ServerRunnerLaunchConfiguration method launch.

public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    IServer server = ServerUtil.getServer(configuration);
    if (server == null) {
        showError("Launch configuration could not find server", "Server Launch", null);
        return;
    }
    ServiceMixServerBehavior serverBehave = null;
    if (server.getServerType().getId().startsWith(ServiceMixServer.ID_PREFIX))
        serverBehave = (ServiceMixServerBehavior) server.loadAdapter(ServiceMixServerBehavior.class, null);
    else if (server.getServerType().getId().startsWith(FuseServer.ID_PREFIX))
        serverBehave = (FuseServerBehavior) server.loadAdapter(FuseServerBehavior.class, null);
    if (serverBehave == null) {
        showError("ServerBehaviorDelagate could not be loaded", "Server Launch", null);
        return;
    }
    if (!"true".equals(configuration.getAttribute("STOP", "false")))
        serverBehave.start(mode.equals(ILaunchManager.DEBUG_MODE), monitor);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ServiceMixServerBehavior(com.centurylink.mdw.plugin.server.ServiceMixServerBehavior)

Example 93 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class AbstractOpenInBrowserHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection sel = HandlerUtil.getCurrentSelection(event);
    JcrNode node = SelectionUtils.getFirst(sel, JcrNode.class);
    if (node == null) {
        return null;
    }
    Shell shell = HandlerUtil.getActiveShell(event);
    IModule module = ServerUtil.getModule(node.getProject());
    if (module == null) {
        MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
        return null;
    }
    IServer[] servers = ServerUtil.getServersByModule(module, new NullProgressMonitor());
    if (servers == null || servers.length == 0) {
        MessageDialog.openWarning(shell, "Cannot open browser", "Not configured for any server");
        return null;
    }
    IServer server = servers[0];
    URL url;
    try {
        url = getUrlToOpen(node, server);
    } catch (MalformedURLException e) {
        StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Url is invalid", e), StatusManager.SHOW);
        return null;
    }
    try {
        IWorkbenchBrowserSupport browserSupport = HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench().getBrowserSupport();
        browserSupport.createBrowser("org.apache.sling.ide.openOnServer").openURL(url);
    } catch (PartInitException e) {
        StatusManager.getManager().handle(new Status(Status.WARNING, Activator.PLUGIN_ID, "Failed creating browser instance", e), StatusManager.SHOW | StatusManager.LOG);
    }
    return null;
}
Also used : Status(org.eclipse.core.runtime.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Shell(org.eclipse.swt.widgets.Shell) IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) MalformedURLException(java.net.MalformedURLException) JcrNode(org.apache.sling.ide.eclipse.ui.nav.model.JcrNode) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchBrowserSupport(org.eclipse.ui.browser.IWorkbenchBrowserSupport) PartInitException(org.eclipse.ui.PartInitException) URL(java.net.URL)

Example 94 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class ServerUtil method getAllServers.

private static Set<IServer> getAllServers(IProject project) {
    IModule module = org.eclipse.wst.server.core.ServerUtil.getModule(project);
    if (module == null) {
        // is what we need to create a RepositoryInfo
        return null;
    }
    Set<IServer> result = new HashSet<>();
    IServer defaultServer = ServerCore.getDefaultServer(module);
    if (defaultServer != null) {
        result.add(defaultServer);
    }
    IServer[] allServers = ServerCore.getServers();
    for (int i = 0; i < allServers.length; i++) {
        IServer aServer = allServers[i];
        IModule[] allModules = aServer.getModules();
        for (int j = 0; j < allModules.length; j++) {
            IModule aMoudle = allModules[j];
            if (aMoudle.equals(module)) {
                result.add(aServer);
                break;
            }
        }
    }
    return result;
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IServer(org.eclipse.wst.server.core.IServer) HashSet(java.util.HashSet)

Example 95 with IServer

use of org.eclipse.wst.server.core.IServer in project sling by apache.

the class SelectionUtils method getServersLinkedToProject.

public static List<IServer> getServersLinkedToProject(IProject project, IProgressMonitor monitor) {
    if (project == null) {
        return Collections.emptyList();
    }
    List<IServer> servers = new ArrayList<>();
    IModule[] modules = ServerUtil.getModules(project);
    for (IServer server : ServerCore.getServers()) {
        for (IModule module : modules) {
            if (ServerUtil.containsModule(server, module, monitor)) {
                servers.add(server);
            }
        }
    }
    return servers;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IModule(org.eclipse.wst.server.core.IModule) ArrayList(java.util.ArrayList)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8