private void doEventLoop() {
    Shell splash = getSplash();
    while (fAuthenticated == false) {
      if (splash.getDisplay().readAndDispatch() == false) {
        splash.getDisplay().sleep();
      }
    }

    for (Control control : splash.getChildren()) {
      control.dispose();
    }

    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    IProduct product = Platform.getProduct();
    if (product != null) {
      progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
      messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
      foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }

    Rectangle progressRect =
        StringConverter.asRectangle(progressRectString, new Rectangle(5, 275, 445, 15));
    setProgressRect(progressRect);

    Rectangle messageRect =
        StringConverter.asRectangle(messageRectString, new Rectangle(0, 0, 0, 0));
    // new Rectangle(7, 252, 445, 20));
    setMessageRect(messageRect);

    getContent();
  }
Beispiel #2
0
  @Override
  public void init(Shell splash) {
    super.init(splash);
    String progressRectString = null;
    String messageRectString = null;
    String foregroundColorString = null;
    IProduct product = Platform.getProduct();
    if (product != null) {
      progressRectString = product.getProperty(IProductConstants.STARTUP_PROGRESS_RECT);
      messageRectString = product.getProperty(IProductConstants.STARTUP_MESSAGE_RECT);
      foregroundColorString = product.getProperty(IProductConstants.STARTUP_FOREGROUND_COLOR);
    }
    Rectangle progressRect =
        StringConverter.asRectangle(progressRectString, new Rectangle(10, 10, 300, 15));
    setProgressRect(progressRect);

    Rectangle messageRect =
        StringConverter.asRectangle(messageRectString, new Rectangle(10, 35, 300, 15));
    setMessageRect(messageRect);

    int foregroundColorInteger;
    try {
      foregroundColorInteger = Integer.parseInt(foregroundColorString, 16);
    } catch (Exception ex) {
      foregroundColorInteger = 0xD2D7FF; // off white
    }

    setForeground(
        new RGB(
            (foregroundColorInteger & 0xFF0000) >> 16,
            (foregroundColorInteger & 0xFF00) >> 8,
            foregroundColorInteger & 0xFF));
    final Point buildIdPoint = new Point(322, 190);
    getContent()
        .addPaintListener(
            new PaintListener() {

              public void paintControl(PaintEvent e) {
                // System.out
                // .println("SplashHandler.init(...).new PaintListener() {...}.paintControl()");
                e.gc.setForeground(getForeground());
                e.gc.drawText(
                    "v" + Activator.getDefault().getBundle().getHeaders().get("Bundle-Version"),
                    buildIdPoint.x,
                    buildIdPoint.y,
                    true);
              }
            });
  }
Beispiel #3
0
 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);
 }
Beispiel #4
0
  /**
   * This method hunts down the version recorded in the current product.
   *
   * @throws IOException
   */
  private void loadVersion() {
    IProduct product = Platform.getProduct();
    if (product == null || !(UDIG_PRODUCT_ID.equals(product.getId()))) {
      // chances are someone is using the SDK with their own
      // application or product.
      String message =
          "Unable to parse version from about.mappings file. Defaulting to a blank string."; //$NON-NLS-1$
      this.getLog().log(new Status(IStatus.INFO, ID, 0, message, null));
      this.version = "";
      return;
    }
    Bundle pluginBundle = product.getDefiningBundle();

    URL mappingsURL = FileLocator.find(pluginBundle, new Path(MAPPINGS_FILENAME), null);
    if (mappingsURL != null) {
      try {
        mappingsURL = FileLocator.resolve(mappingsURL);
      } catch (IOException e) {
        mappingsURL = null;
        String message =
            "Unable to find " + mappingsURL + " Defaulting to a blank string."; // $NON-NLS-1$
        this.getLog().log(new Status(IStatus.ERROR, ID, 0, message, e));
      }
    }
    PropertyResourceBundle bundle = null;
    if (mappingsURL != null) {
      InputStream is = null;
      try {
        is = mappingsURL.openStream();
        bundle = new PropertyResourceBundle(is);
      } catch (IOException e) {
        bundle = null;
        String message =
            "Unable to parse version from about.mappings file. Defaulting to a blank string."; //$NON-NLS-1$
        this.getLog().log(new Status(IStatus.ERROR, ID, 0, message, e));
      } finally {
        try {
          if (is != null) is.close();
        } catch (IOException e) {
        }
      }
    }

    if (bundle != null) {
      this.version = bundle.getString(UDIG_VERSION_KEY);
    }
  }
  @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();
    }
  }
  /** {@inheritDoc} */
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    TemplateParameter templ = (TemplateParameter) argument;
    ImplementationSettings implSettings = templ.getImplSettings();
    Implementation impl = templ.getImpl();
    SoftPkg softPkg = (SoftPkg) impl.eContainer();
    String PREFIX =
        gov.redhawk.ide.codegen.util.CodegenFileHelper.getPreferredFilePrefix(
            softPkg, implSettings);
    boolean hasSddsPort = false;
    Date date = new Date(System.currentTimeMillis());
    EList<Provides> provides =
        softPkg.getDescriptor().getComponent().getComponentFeatures().getPorts().getProvides();

    for (Provides entry : provides) {
      if (entry.getRepID().contains("BULKIO/dataSDDS")) {
        hasSddsPort = true;
      }
    }

    stringBuffer.append(TEXT_1);
    stringBuffer.append(ModelUtil.getSpdFileName(softPkg));
    stringBuffer.append(TEXT_2);
    stringBuffer.append(date.toString());

    String[] output;
    IProduct product = Platform.getProduct();
    if (product != null) {
      output = product.getProperty("aboutText").split("\n");

      stringBuffer.append(TEXT_3);
      stringBuffer.append(output[0]);
      stringBuffer.append(TEXT_4);
      stringBuffer.append(output[1]);
      stringBuffer.append(TEXT_5);
      stringBuffer.append(output[2]);
    }

    stringBuffer.append(TEXT_6);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_8);
    if (!templ.isDevice()) {
      stringBuffer.append(TEXT_9);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_10);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_11);
      stringBuffer.append(TEXT_12);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_13);
    } else {
      stringBuffer.append(TEXT_14);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_15);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_16);
      stringBuffer.append(TEXT_17);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_18);
      stringBuffer.append(TEXT_19);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_20);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_21);
      stringBuffer.append(TEXT_22);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_23);
      stringBuffer.append(TEXT_24);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_25);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_26);
      stringBuffer.append(TEXT_27);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_28);
      stringBuffer.append(TEXT_29);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_30);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_31);
      stringBuffer.append(TEXT_32);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_33);
    }
    stringBuffer.append(TEXT_34);
    stringBuffer.append(TEXT_35);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_36);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_37);
    if (hasSddsPort) {
      stringBuffer.append(TEXT_38);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_39);
      stringBuffer.append(PREFIX);
      stringBuffer.append(TEXT_40);
    }
    stringBuffer.append(TEXT_41);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_42);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_43);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_44);
    stringBuffer.append(TEXT_45);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_46);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_47);
    stringBuffer.append(TEXT_48);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_49);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_50);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_51);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_52);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_53);
    stringBuffer.append(PREFIX);
    stringBuffer.append(TEXT_54);
    stringBuffer.append(TEXT_55);
    return stringBuffer.toString();
  }
  @Override
  protected Control createDialogArea(Composite parent) {
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    // Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    parent.setBackground(background);

    Composite group = new Composite(parent, SWT.NONE);
    group.setBackground(background);
    GridLayout layout = new GridLayout(1, false);
    layout.marginHeight = 20;
    layout.marginWidth = 20;
    group.setLayout(layout);

    GridData gd;

    IProduct product = Platform.getProduct();
    String productVersion = DBeaverCore.getVersion().toString();

    Label titleLabel = new Label(group, SWT.NONE);
    titleLabel.setBackground(background);
    titleLabel.setFont(TITLE_FONT);
    titleLabel.setText(product.getProperty(PRODUCT_PROP_SUB_TITLE));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    titleLabel.setLayoutData(gd);
    titleLabel.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDoubleClick(MouseEvent e) {
            BusyIndicator.showWhile(
                getShell().getDisplay(),
                new Runnable() {
                  @Override
                  public void run() {
                    // Do not create InstallationDialog directly
                    // but execute "org.eclipse.ui.help.installationDialog" command
                    IWorkbenchWindow workbenchWindow =
                        PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                    IHandlerService service = workbenchWindow.getService(IHandlerService.class);
                    if (service != null) {
                      try {
                        service.executeCommand(
                            "org.eclipse.ui.help.installationDialog", null); // $NON-NLS-1$
                      } catch (Exception e1) {
                        // just ignore error
                      }
                    }
                  }
                });
          }
        });

    Label imageLabel = new Label(group, SWT.NONE);
    imageLabel.setBackground(background);

    gd = new GridData();
    gd.verticalAlignment = GridData.BEGINNING;
    gd.horizontalAlignment = GridData.CENTER;
    gd.grabExcessHorizontalSpace = true;
    imageLabel.setLayoutData(gd);
    imageLabel.setImage(ABOUT_IMAGE);

    Label versionLabel = new Label(group, SWT.NONE);
    versionLabel.setBackground(background);
    versionLabel.setText(CoreMessages.dialog_about_label_version + productVersion);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    versionLabel.setLayoutData(gd);

    Label authorLabel = new Label(group, SWT.NONE);
    authorLabel.setBackground(background);
    authorLabel.setText(product.getProperty(PRODUCT_PROP_COPYRIGHT));
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalAlignment = GridData.CENTER;
    authorLabel.setLayoutData(gd);

    Link siteLink =
        UIUtils.createLink(
            group,
            UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_WEBSITE)),
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                UIUtils.launchProgram(e.text);
              }
            });
    siteLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    siteLink.setLayoutData(gd);

    Link emailLink =
        UIUtils.createLink(
            group,
            UIUtils.makeAnchor(product.getProperty(PRODUCT_PROP_EMAIL)),
            new SelectionAdapter() {
              @Override
              public void widgetSelected(SelectionEvent e) {
                UIUtils.launchProgram("mailto:" + e.text); // $NON-NLS-1$
              }
            });
    emailLink.setBackground(background);
    gd = new GridData();
    gd.horizontalAlignment = GridData.CENTER;
    emailLink.setLayoutData(gd);

    return parent;
  }
  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>");
  }
  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;
  }
 /**
  * Check if JBoss Developer Studio Is Running Dynamic version of isJBDSRun Method
  *
  * @return
  */
 public static boolean isJBDSRun() {
   IProduct prod = Platform.getProduct();
   return ((prod != null) && (prod.getId().startsWith("com.jboss.jbds.")));
 }