public String getText(Object element) {
    if (element instanceof ModuleServer) {
      ModuleServer ms = (ModuleServer) element;
      if (ms.module == null) return "";
      return ms.getModuleDisplayName();
    }

    if (element instanceof IServer) {
      IServer server = (IServer) element;
      return notNull(server.getName());
    }

    if (element == ServerContentProvider.INITIALIZING) return Messages.viewInitializing;

    if (element instanceof IWorkspaceRoot) {
      return Platform.getResourceString(ServerUIPlugin.getInstance().getBundle(), "%viewServers");
    }

    return "";
  }
  private String getUrl() throws CoreException {
    String urlString = null;
    IServer server = getServer();
    if (server != null && server.getServerState() == IServer.STATE_STARTED) {
      // When a module is selected, behave as you would during run-on-server for project-level
      // selection
      ModuleServer ms = getModuleServer();
      if (ms != null) {
        // Go through the wtp framework to find the proper launchable adapter for the project
        JBTCustomHttpLaunchable launchable = getCustomLaunchable(server, ms.getModule());
        // IF its one we provide, return its url directly
        if (launchable != null) {
          return (launchable).getURL().toString();
        }

        // Otherwise, do the magic we did in the past to try our best to come up with a url
        IModule[] mss = ms.getModule();
        IModule m = getWebModule(mss);
        if (m != null) {
          IServer s = getServer();
          Object o = s.loadAdapter(IURLProvider.class, null);
          if (o instanceof IURLProvider) {
            URL url = ((IURLProvider) o).getModuleRootURL(m);
            if (url != null) {
              urlString = url.toString();
            }
          }
        }
      } else {
        // When no module is selected,use welcome page url
        ServerExtendedProperties props =
            (ServerExtendedProperties)
                server.loadAdapter(ServerExtendedProperties.class, new NullProgressMonitor());
        if (props != null) urlString = props.getWelcomePageUrl();
      }
    }
    return urlString;
  }