예제 #1
0
  public Splash(Display display) throws KettleException {
    log = new LogChannel(Spoon.APP_NAME);

    Rectangle displayBounds = display.getPrimaryMonitor().getBounds();

    kettle_image =
        ImageUtil.getImageAsResource(
            display,
            BasePropertyHandler.getProperty("splash_image")); // "kettle_splash.png" //$NON-NLS-1$
    kettle_icon =
        ImageUtil.getImageAsResource(
            display, BasePropertyHandler.getProperty("splash_icon")); // "spoon.ico" //$NON-NLS-1$
    exclamation_image =
        ImageUtil.getImageAsResource(
            display,
            BasePropertyHandler.getProperty(
                "exclamation_image")); // "exclamation.png" //$NON-NLS-1$

    verFont = new Font(display, "Helvetica", 11, SWT.BOLD); // $NON-NLS-1$
    licFont = new Font(display, "Helvetica", licFontSize, SWT.NORMAL); // $NON-NLS-1$
    devWarningFont = new Font(display, "Helvetica", 10, SWT.NORMAL); // $NON-NLS-1$

    versionWarningBackgroundColor = new Color(display, 255, 253, 213);
    versionWarningForegroundColor = new Color(display, 220, 177, 20);

    splash = new Shell(display, SWT.APPLICATION_MODAL);
    splash.setImage(kettle_icon);

    splash.setText(
        BaseMessages.getString(
            PKG, "SplashDialog.Title")); // "Pentaho Data Integration" //$NON-NLS-1$

    FormLayout splashLayout = new FormLayout();
    splash.setLayout(splashLayout);

    Canvas canvas = new Canvas(splash, SWT.NO_BACKGROUND);

    FormData fdCanvas = new FormData();
    fdCanvas.left = new FormAttachment(0, 0);
    fdCanvas.top = new FormAttachment(0, 0);
    fdCanvas.right = new FormAttachment(100, 0);
    fdCanvas.bottom = new FormAttachment(100, 0);
    canvas.setLayoutData(fdCanvas);

    canvas.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent e) {
            String versionText =
                BaseMessages.getString(PKG, "SplashDialog.Version")
                    + " "
                    + Const.VERSION; // $NON-NLS-1$ //$NON-NLS-2$

            StringBuilder sb = new StringBuilder();
            String line = null;

            try {
              BufferedReader reader =
                  new BufferedReader(
                      new InputStreamReader(
                          Splash.class
                              .getClassLoader()
                              .getResourceAsStream(
                                  "org/pentaho/di/ui/core/dialog/license/license.txt"))); //$NON-NLS-1$

              while ((line = reader.readLine()) != null) {
                sb.append(line + System.getProperty("line.separator")); // $NON-NLS-1$
              }
            } catch (Exception ex) {
              sb.append(""); // $NON-NLS-1$
              log.logError(
                  BaseMessages.getString(PKG, "SplashDialog.LicenseTextNotFound"),
                  ex); //$NON-NLS-1$
            }
            Calendar cal = Calendar.getInstance();
            String licenseText = String.format(sb.toString(), cal);
            e.gc.drawImage(kettle_image, 0, 0);

            // If this is a Milestone or RC release, warn the user
            if (Const.RELEASE.equals(Const.ReleaseType.MILESTONE)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.DeveloperRelease")
                      + " - "
                      + versionText; //$NON-NLS-1$ //$NON-NLS-2$
              drawVersionWarning(e);
            } else if (Const.RELEASE.equals(Const.ReleaseType.RELEASE_CANDIDATE)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.ReleaseCandidate")
                      + " - "
                      + versionText; //$NON-NLS-1$//$NON-NLS-2$
            } else if (Const.RELEASE.equals(Const.ReleaseType.PREVIEW)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.PreviewRelease")
                      + " - "
                      + versionText; //$NON-NLS-1$//$NON-NLS-2$
            } else if (Const.RELEASE.equals(Const.ReleaseType.GA)) {
              versionText =
                  BaseMessages.getString(PKG, "SplashDialog.GA")
                      + " - "
                      + versionText; //$NON-NLS-1$//$NON-NLS-2$
            }

            e.gc.setFont(verFont);
            e.gc.drawText(versionText, 290, 205, true);

            // try using the desired font size for the license text
            e.gc.setFont(licFont);

            // if the text will not fit the allowed space
            while (!willLicenseTextFit(licenseText, e.gc)) {
              licFontSize--;
              if (licFont != null) {
                licFont.dispose();
              }
              licFont = new Font(e.display, "Helvetica", licFontSize, SWT.NORMAL); // $NON-NLS-1$
              e.gc.setFont(licFont);
            }

            e.gc.drawText(licenseText, 290, 290, true);
          }
        });

    splash.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent arg0) {
            kettle_image.dispose();
            kettle_icon.dispose();
            exclamation_image.dispose();
            verFont.dispose();
            licFont.dispose();
            devWarningFont.dispose();
            versionWarningForegroundColor.dispose();
            versionWarningBackgroundColor.dispose();
          }
        });
    Rectangle bounds = kettle_image.getBounds();
    int x = (displayBounds.width - bounds.width) / 2;
    int y = (displayBounds.height - bounds.height) / 2;

    splash.setSize(bounds.width, bounds.height);
    splash.setLocation(x, y);

    splash.open();
  }
예제 #2
0
  private void init() throws KettleException {
    this.lineStyle = ELineStyle.SOLID;
    this.lineWidth = 1;
    this.alpha = 255;

    this.background = new Color(255, 255, 255);
    this.black = new Color(0, 0, 0);
    this.red = new Color(255, 0, 0);
    this.yellow = new Color(255, 255, 0);
    this.orange = new Color(255, 165, 0);
    this.green = new Color(0, 255, 0);
    this.blue = new Color(0, 0, 255);
    this.magenta = new Color(255, 0, 255);
    this.gray = new Color(128, 128, 128);
    this.lightGray = new Color(200, 200, 200);
    this.darkGray = new Color(80, 80, 80);

    imageLocked = getImageIcon(BasePropertyHandler.getProperty("Locked_image"));
    imageStepError = getImageIcon(BasePropertyHandler.getProperty("StepErrorLines_image"));
    imageEdit = getImageIcon(BasePropertyHandler.getProperty("Edit_image"));
    imageContextMenu = getImageIcon(BasePropertyHandler.getProperty("ContextMenu_image"));
    imageTrue = getImageIcon(BasePropertyHandler.getProperty("True_image"));
    imageFalse = getImageIcon(BasePropertyHandler.getProperty("False_image"));
    imageErrorHop = getImageIcon(BasePropertyHandler.getProperty("ErrorHop_image"));
    imageInfoHop = getImageIcon(BasePropertyHandler.getProperty("InfoHop_image"));
    imageHopTarget = getImageIcon(BasePropertyHandler.getProperty("HopTarget_image"));
    imageHopInput = getImageIcon(BasePropertyHandler.getProperty("HopInput_image"));
    imageHopOutput = getImageIcon(BasePropertyHandler.getProperty("HopOutput_image"));
    imageArrow = getImageIcon(BasePropertyHandler.getProperty("ArrowIcon_image"));
    imageCopyHop = getImageIcon(BasePropertyHandler.getProperty("CopyHop_image"));
    imageLoadBalance = getImageIcon(BasePropertyHandler.getProperty("LoadBalance_image"));
    imageCheckpoint = getImageIcon(BasePropertyHandler.getProperty("CheckeredFlag_image"));
    imageParallelHop = getImageIcon(BasePropertyHandler.getProperty("ParallelHop_image"));
    imageUnconditionalHop = getImageIcon(BasePropertyHandler.getProperty("UnconditionalHop_image"));
    imageStart = getImageIcon(BasePropertyHandler.getProperty("STR_image"));
    imageDummy = getImageIcon(BasePropertyHandler.getProperty("DUM_image"));
    imageBusy = getImageIcon(BasePropertyHandler.getProperty("Busy_image"));
    imageInject = getImageIcon(BasePropertyHandler.getProperty("Inject_image"));

    fontGraph = new Font("FreeSans", Font.PLAIN, 10);
    fontNote = new Font("FreeSans", Font.PLAIN, 10);
    fontSmall = new Font("FreeSans", Font.PLAIN, 8);

    gc.setFont(fontGraph);

    gc.setColor(background);
    gc.fillRect(0, 0, area.x, area.y);
  }