@Override
  public Object start(IApplicationContext applicationContext) throws Exception {
    // set the display name before the Display is
    // created to ensure the app name is used in any
    // platform menus, etc. See
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=329456#c14
    IProduct product = Platform.getProduct();
    if (product != null && product.getName() != null) {
      Display.setAppName(product.getName());
    }
    Display display = getApplicationDisplay();
    Location instanceLocation = null;
    try {
      E4Workbench workbench = createE4Workbench(applicationContext, display);

      instanceLocation = (Location) workbench.getContext().get(E4Workbench.INSTANCE_LOCATION);
      Shell shell = display.getActiveShell();
      if (shell == null) {
        shell = new Shell();
        // place it off so it's not visible
        shell.setLocation(0, 10000);
      }
      if (!checkInstanceLocation(instanceLocation, shell, workbench.getContext())) return EXIT_OK;

      // Create and run the UI (if any)
      workbench.createAndRunUI(workbench.getApplication());

      saveModel();
      workbench.close();

      if (workbench.isRestart()) {
        return EXIT_RESTART;
      }

      return EXIT_OK;
    } finally {
      if (display != null) display.dispose();
      if (instanceLocation != null) instanceLocation.release();
    }
  }
예제 #2
0
파일: UIUtils.java 프로젝트: ralic/dbeaver
 public static void updateMainWindowTitle(IWorkbenchWindow window) {
   IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
   IProduct product = Platform.getProduct();
   String title = product == null ? "Unknown" : product.getName(); // $NON-NLS-1$
   if (activeProject != null) {
     title += " - " + activeProject.getName(); // $NON-NLS-1$
   }
   IWorkbenchPage activePage = window.getActivePage();
   if (activePage != null) {
     IEditorPart activeEditor = activePage.getActiveEditor();
     if (activeEditor != null) {
       title += " - [ " + activeEditor.getTitle() + " ]";
     }
   }
   window.getShell().setText(title);
 }
예제 #3
0
  private void doHtmlResponse(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String errorMsg = "";

    /* run garbage collection for better estimation of current memory usage */
    String doGc = req.getParameter("gc");
    if (StringUtility.hasText(doGc)) {
      System.gc();
      errorMsg = "<font color='blue'> System.gc() triggered.</font>";
    }

    List<List<String>> result = getDiagnosticItems();

    IDiagnostic[] diagnosticServices = DiagnosticFactory.getDiagnosticProviders();
    for (IDiagnostic diagnosticService : diagnosticServices) {
      if (CollectionUtility.hasElements(diagnosticService.getPossibleActions())) {
        diagnosticService.addSubmitButtonsHTML(result);
      }
    }
    DiagnosticFactory.addDiagnosticItemToList(
        result, "System.gc()", "", "<input type='checkbox' name='gc' value='yes'/>");

    String diagnosticHTML = getDiagnosticItemsHTML(result);

    String title = "unknown";
    Version version = Version.emptyVersion;
    IProduct product = Platform.getProduct();
    if (product != null) {
      title = product.getName();
      version =
          Version.parseVersion("" + product.getDefiningBundle().getHeaders().get("Bundle-Version"));
    }

    resp.setContentType("text/html");
    ServletOutputStream out = resp.getOutputStream();
    out.println("<html>");
    out.println("<head>");
    out.println("<title>" + title + "</title>");
    out.println("<style>");
    out.println("body {font-family: sans-serif; font-size: 12; background-color : #F6F6F6;}");
    out.println("a,a:VISITED {color: #6666ff;text-decoration: none;}");
    out.println("table {font-size: 12; empty-cells: show;}");
    out.println(
        "th {text-align: left;vertical-align: top; padding-left: 2; background-color : #cccccc;}");
    out.println("td {text-align: left;vertical-align: top; padding-left: 2;}");
    out.println("p {margin-top: 4; margin-bottom: 4; padding-top: 4; padding-bottom: 4;}");
    out.println("dt {font-weight: bold;}");
    out.println("dd {margin-left: 20px; margin-bottom: 3px;}");
    out.println(".copyright {font-size: 10;}");
    out.println("</style>");
    out.println("<script type=\"text/javascript\">");
    out.println("function toggle_visibility(id) {");
    out.println("   var el = document.getElementById(id);");
    out.println("   el.style.display = (el.style.display != 'none' ? 'none' : 'block');");
    out.println("}");
    out.println("</script>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h3>" + title + " " + version + "</h3>");
    out.println(
        "<form method='POST' action='"
            + StringUtility.join("?", req.getRequestURL().toString(), req.getQueryString())
            + "'>");
    out.print(diagnosticHTML);
    out.println("<p><input type='submit' value='submit'/></p>");
    out.println("</form>");
    out.print(errorMsg);
    out.println("<p class=\"copyright\">&copy; " + OfficialVersion.COPYRIGHT + "</p>");
    out.println("</body>");
    out.println("</html>");
  }
예제 #4
0
  private List<List<String>> getDiagnosticItems() {
    List<List<String>> result = new ArrayList<List<String>>();

    /* system information from JVM */
    ArrayList<String> infos = getSystemInformation();
    DiagnosticFactory.addDiagnosticItemToList(result, "Server", "", DiagnosticFactory.STATUS_TITLE);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Runtime Environment", infos.get(0), DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Application Directory", infos.get(1), DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result,
        "JVM Memory Status",
        "Max: "
            + infos.get(2)
            + ", Reserved: "
            + infos.get(3)
            + ", Currently Used: "
            + infos.get(4),
        DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "JVM Locale", infos.get(11), DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Operating System", infos.get(6), DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Architecture", infos.get(5), DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "#CPUs available to JVM", infos.get(12), DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result,
        "OS Country / Timezone",
        infos.get(9) + " / " + infos.get(10),
        DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result,
        "Host Address / Name",
        infos.get(13) + " / " + infos.get(14),
        DiagnosticFactory.STATUS_INFO);

    IDiagnostic[] diagnosticServices = DiagnosticFactory.getDiagnosticProviders();
    for (IDiagnostic diagnosticService : diagnosticServices) {
      diagnosticService.addDiagnosticItemToList(result);
    }

    // system properties
    List<String> properties = new ArrayList<String>();
    for (Object property : System.getProperties().keySet()) {
      properties.add(property + "");
    }
    Collections.sort(properties);
    String sysprops = "";
    sysprops +=
        "<a href=\"#\" onClick=\"javascript:toggle_visibility('sysprops'); return false;\">(show / hide)</a>";
    sysprops +=
        "<div id=\"sysprops\" style=\"width:600px; margin: 0px; padding: 0px; display: none; word-wrap: break-word;\">";
    sysprops += "<dl>";
    for (String property : properties) {
      sysprops += "<dt>" + property + ":</b></dt><dd>" + System.getProperty(property) + "</dd>";
    }
    sysprops += "</dl>";
    sysprops += "</div>";
    DiagnosticFactory.addDiagnosticItemToList(
        result, "System properties", sysprops, DiagnosticFactory.STATUS_INFO);

    // environment
    List<String> envKeys = new ArrayList<String>();
    for (String envKey : System.getenv().keySet()) {
      envKeys.add(envKey);
    }
    Collections.sort(envKeys);
    String envList = "";
    envList +=
        "<a href=\"#\" onClick=\"javascript:toggle_visibility('env'); return false;\">(show / hide)</a>";
    envList +=
        "<div id=\"env\" style=\"width:600px; margin: 0px; padding: 0px; display: none; word-wrap: break-word;\">";
    envList += "<dl>";
    for (String envKey : envKeys) {
      envList += "<dt>" + envKey + ":</b></dt><dd>" + System.getenv(envKey) + "</dd>";
    }
    envList += "</dl>";
    envList += "</div>";
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Environment variables", envList, DiagnosticFactory.STATUS_INFO);

    DiagnosticFactory.addDiagnosticItemToList(
        result, "Version", "", DiagnosticFactory.STATUS_TITLE);
    Version v = Version.emptyVersion;
    IProduct product = Platform.getProduct();
    String productId = "n/a";
    String productName = "n/a";
    String application = "n/a";
    String definingBundle = "n/a";
    if (product != null) {
      productId = product.getId();
      productName = product.getName();
      application = product.getApplication();
      definingBundle = product.getDefiningBundle().getSymbolicName();
      v = Version.parseVersion("" + product.getDefiningBundle().getHeaders().get("Bundle-Version"));
    }
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Product ID", productId, DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Product Name", productName, DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Application", application, DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Defining Bundle", definingBundle, DiagnosticFactory.STATUS_INFO);
    DiagnosticFactory.addDiagnosticItemToList(
        result, "Defining Bundle Version", v.toString(), DiagnosticFactory.STATUS_INFO);

    DiagnosticFactory.addDiagnosticItemToList(
        result, "Change values", "", DiagnosticFactory.STATUS_TITLE);
    return result;
  }