use of org.eclipse.wst.server.core.util.HttpLaunchable in project webtools.servertools by eclipse.
the class GenericServerLaunchableAdapterDelegate method prepareHttpLaunchable.
/**
* @param moduleObject
* @param delegate
* @return object
*/
private Object prepareHttpLaunchable(IModuleArtifact moduleObject, ServerDelegate delegate) {
try {
URL url = ((IURLProvider) delegate).getModuleRootURL(moduleObject.getModule());
// $NON-NLS-1$
Trace.trace("root: " + url);
if (moduleObject instanceof Servlet) {
Servlet servlet = (Servlet) moduleObject;
if (servlet.getAlias() != null) {
String path = servlet.getAlias();
if (// $NON-NLS-1$
path.startsWith("/"))
path = path.substring(1);
url = new URL(url, path);
} else
// $NON-NLS-1$
url = new URL(url, "servlet/" + servlet.getServletClassName());
} else if (moduleObject instanceof WebResource) {
WebResource resource = (WebResource) moduleObject;
String path = resource.getPath().toString();
// $NON-NLS-1$
Trace.trace("path: " + path);
if (// $NON-NLS-1$
path != null && path.startsWith("/") && path.length() > 0)
path = path.substring(1);
if (path != null && path.length() > 0)
url = new URL(url, path);
}
return new HttpLaunchable(url);
} catch (Exception e) {
// $NON-NLS-1$
Trace.trace("Error getting URL for " + moduleObject, e);
return null;
}
}
use of org.eclipse.wst.server.core.util.HttpLaunchable in project webtools.servertools by eclipse.
the class PreviewLaunchableAdapterDelegate method getLaunchable.
/*
* @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
*/
public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
if (server == null || moduleArtifact == null)
return null;
PreviewServer server2 = (PreviewServer) server.loadAdapter(PreviewServer.class, null);
if (server2 == null)
return null;
try {
URL url = server2.getModuleRootURL(moduleArtifact.getModule());
if (moduleArtifact instanceof WebResource) {
WebResource resource = (WebResource) moduleArtifact;
String path = resource.getPath().toString();
if (path.startsWith("/"))
path = path.substring(1);
url = new URL(url.toExternalForm() + "/" + path);
}
return new HttpLaunchable(url);
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
}
return null;
}
use of org.eclipse.wst.server.core.util.HttpLaunchable in project webtools.servertools by eclipse.
the class PreviewLaunchableAdapterDelegate method getLaunchable.
/*
* @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
*/
public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
if (server == null || moduleArtifact == null)
return null;
PreviewServer server2 = (PreviewServer) server.loadAdapter(PreviewServer.class, null);
if (server2 == null)
return null;
try {
URL url = server2.getModuleRootURL(moduleArtifact.getModule());
if (moduleArtifact instanceof WebResource) {
WebResource resource = (WebResource) moduleArtifact;
String path = resource.getPath().toString();
if (path.startsWith("/"))
path = path.substring(1);
url = new URL(url.toExternalForm() + "/" + path);
}
return new HttpLaunchable(url);
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
}
return null;
}
use of org.eclipse.wst.server.core.util.HttpLaunchable in project webtools.servertools by eclipse.
the class WebLaunchableClient method launch.
/*
* @see ClientDelegate#launch(ILaunchable)
*/
public IStatus launch(IServer server, Object launchable, String launchMode, ILaunch launch) {
HttpLaunchable http = (HttpLaunchable) launchable;
try {
IWorkbenchBrowserSupport browserSupport = ServerUIPlugin.getInstance().getWorkbench().getBrowserSupport();
IWebBrowser browser = browserSupport.createBrowser(IWorkbenchBrowserSupport.LOCATION_BAR | IWorkbenchBrowserSupport.NAVIGATION_BAR, null, null, null);
browser.openURL(http.getURL());
return Status.OK_STATUS;
} catch (Exception e) {
if (Trace.SEVERE) {
Trace.trace(Trace.STRING_SEVERE, "Error opening browser", e);
}
return new Status(IStatus.ERROR, ServerUIPlugin.PLUGIN_ID, e.getMessage(), e);
}
}
use of org.eclipse.wst.server.core.util.HttpLaunchable in project webtools.servertools by eclipse.
the class HttpLaunchableAdapterDelegate method getLaunchable.
/*
* @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
*/
public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
if (server == null || moduleArtifact == null)
return null;
HttpServer server2 = (HttpServer) server.loadAdapter(HttpServer.class, null);
if (server2 == null)
return null;
try {
URL url = server2.getModuleRootURL(moduleArtifact.getModule());
if (moduleArtifact instanceof WebResource) {
WebResource resource = (WebResource) moduleArtifact;
String path = resource.getPath().toString();
if (path.startsWith("/"))
path = path.substring(1);
url = new URL(url.toExternalForm() + "/" + path);
}
return new HttpLaunchable(url);
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
}
return null;
}
Aggregations