Java Code Examples for org.eclipse.wst.server.core.IServer#getModules()

The following examples show how to use org.eclipse.wst.server.core.IServer#getModules() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GwtFacetUtils.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Get the modules added in the server.
 * 
 * @return
 */
public static IModule[] getModules(IServer server) {
  // Multi-module project
  IModule[] modules = server.getChildModules(server.getModules(), new NullProgressMonitor());
  if (modules == null || modules.length == 0) { // does it have multi-modules?
    // So it doesn't have multi-modules, lets use the root as the module.
    modules = server.getModules();
  }

  // Just in case
  if (modules == null || modules.length == 0) {
    GwtWtpPlugin.logMessage(
        "Could not find GWT Faceted project from the Server runtime. Add a GWT Facet to the server modules.");
    return null;
  }

  return modules;
}
 
Example 2
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private void addServerUrlsToDevModeView(ILaunch launch) {
  IServer server = getServerFromLaunchConfig(launch);
  if (server == null) {
    logMessage("posiblyLaunchGwtSuperDevModeCodeServer: No WTP server found.");
    return;
  }

  IModule[] modules = server.getModules();
  if (modules == null || modules.length == 0) {
    return;
  }

  IModule rootMod = modules[0];
  if (rootMod == null) {
    return;
  }

  // First clear the previous urls, before adding new ones
  launchUrls.clear();

  String url = getServerUrl(server, rootMod);
  if (url != null) {
    launchUrls.add(url);
  }
}
 
Example 3
Source File: LocalAppEngineServerBehaviour.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
protected void publishFinish(IProgressMonitor monitor) throws CoreException {
  boolean allPublished = true;
  IServer server = getServer();
  IModule[] modules = server.getModules();
  for (IModule module : modules) {
    if (server.getModulePublishState(new IModule[] {module}) != IServer.PUBLISH_STATE_NONE) {
      allPublished = false;
    }
  }
  if (allPublished) {
    setServerPublishState(IServer.PUBLISH_STATE_NONE);
  }
}
 
Example 4
Source File: ModuleUtils.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/** Find the module with the given App Engine Service ID. */
public static IModule findService(IServer server, String serviceId) {
  Preconditions.checkNotNull(server);
  Preconditions.checkNotNull(serviceId);
  for (IModule module : server.getModules()) {
    if (serviceId.equals(getServiceId(module))) {
      return module;
    }
  }
  return null;
}
 
Example 5
Source File: ModuleUtils.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the set of all referenced modules, including child modules. This returns the unique
 * modules, and doesn't return the module paths. Required as neither
 * {@code Server#getAllModules()} nor the module-visiting method {@code #visit()} are exposed on
 * {@link IServer}, and {@code ServerBehaviourDelegate#getAllModules()} is protected.
 */
public static IModule[] getAllModules(IServer server) {
  Set<IModule> modules = new LinkedHashSet<>();
  for (IModule module : server.getModules()) {
    modules.add(module);
    addChildModules(server, new IModule[] {module}, modules);
  }
  return modules.toArray(new IModule[modules.size()]);
}
 
Example 6
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return all the modules on the server, including child modules.
 */
private List<IModule[]> getAllModules(IServer server) {
  List<IModule[]> modules = new ArrayList<>();
  // todo: add grandchildren
  for (IModule root : server.getModules()) {
    modules.add(new IModule[] {root});
    for (IModule child : server.getChildModules(new IModule[] {root}, null)) {
      modules.add(new IModule[] {root, child});
    }
  }
  return modules;
}