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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations