コード例 #1
0
ファイル: View.java プロジェクト: willuhn/jameica
  /** Leert die Anzeige. Wird beim Wechsel von einem Dialog auf den naechsten aufgerufen. */
  protected void cleanContent() {
    if (content != null && !content.isDisposed()) content.dispose();

    if (scroll != null && !scroll.isDisposed()) scroll.dispose();

    if (Customizing.SETTINGS.getBoolean("application.scrollview", false)) {
      scroll = new ScrolledComposite(view, SWT.V_SCROLL | SWT.H_SCROLL);
      scroll.setLayoutData(new GridData(GridData.FILL_BOTH));
      scroll.setLayout(SWTUtil.createGrid(1, true));
      scroll.setExpandHorizontal(true);
      scroll.setExpandVertical(true);
      scroll.setMinHeight(Customizing.SETTINGS.getInt("application.scrollview.minheight", 580));

      content = new Composite(scroll, SWT.NONE);
      scroll.setContent(content);
    } else {
      content = new Composite(view, SWT.NONE);
    }

    content.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout l = new GridLayout();
    l.marginHeight = 6;
    l.marginWidth = 6;
    content.setLayout(l);

    if (this.titlePart != null) {
      this.titlePart.clearButtons();
      this.titlePart.addButton(new PanelButtonBack()); // Zurueckbutton ist immer dabei
    }

    if (notifications != null) notifications.reset();

    setTitle(null);
  }
コード例 #2
0
ファイル: Button.java プロジェクト: JackWangCUMT/jameica
  /** @see de.willuhn.jameica.gui.Part#paint(org.eclipse.swt.widgets.Composite) */
  public void paint(Composite parent) throws RemoteException {
    button = GUI.getStyleFactory().createButton(parent);
    button.setText(this.title == null ? "" : this.title);
    button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    if (this.icon != null) button.setImage(SWTUtil.getImage(this.icon));

    try {
      if (this.isDefault) parent.getShell().setDefaultButton(button);
    } catch (IllegalArgumentException ae) {
      // Kann unter MacOS wohl passieren. Siehe Mail von
      // Jan Lolling vom 22.09.2006. Mal schauen, ob wir
      // Fehlertext: "Widget has the wrong parent"
      // Wir versuchen es mal mit der Shell der GUI.
      try {
        GUI.getShell().setDefaultButton(button);
      } catch (IllegalArgumentException ae2) {
        // Geht auch nicht? Na gut, dann lassen wir es halt bleiben
        Logger.warn("unable to set default button: " + ae2.getLocalizedMessage());
      }
    }

    button.setEnabled(this.enabled);

    button.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            GUI.startSync(
                new Runnable() {
                  public void run() {
                    try {
                      action.handleAction(context);
                    } catch (ApplicationException e) {
                      Application.getMessagingFactory()
                          .sendMessage(
                              new StatusBarMessage(e.getMessage(), StatusBarMessage.TYPE_ERROR));
                    }
                  }
                });
          }
        });
  }
コード例 #3
0
  /** @see de.willuhn.jameica.gui.dialogs.PasswordDialog#paint(org.eclipse.swt.widgets.Composite) */
  protected void paint(Composite parent) throws Exception {
    Container container = new SimpleContainer(parent, true, 1);
    container.addHeadline(i18n.tr("Matrixcode"));

    MatrixCode code = new MatrixCode(this.hhduc);
    InputStream stream = new ByteArrayInputStream(code.getImage());
    Image image = SWTUtil.getImage(stream);

    // Breite des Dialogs ermitteln (+ ein paar Pixel Toleranz am Rand)
    int width = image.getBounds().width + 200;

    Label imageLabel = new Label(container.getComposite(), SWT.NONE);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalAlignment = SWT.CENTER;
    imageLabel.setLayoutData(gd);
    imageLabel.setImage(image);

    this.setSize(width, SWT.DEFAULT);

    // Hier stehen dann noch die Anweisungen von der Bank drin
    super.paint(parent);
    getShell().setMinimumSize(getShell().computeSize(width, SWT.DEFAULT));
  }
コード例 #4
0
ファイル: Button.java プロジェクト: JackWangCUMT/jameica
 /**
  * Setzt das Icon oder aendert es zur Laufzeit.
  *
  * @param icon das anzuzeigende Icon.
  */
 public void setIcon(String icon) {
   this.icon = icon;
   if (this.button != null && !this.button.isDisposed())
     button.setImage(this.icon != null ? SWTUtil.getImage(this.icon) : null);
 }
コード例 #5
0
ファイル: TitlePart.java プロジェクト: blackfoxoh/jameica
  /** @see de.willuhn.jameica.gui.Part#paint(org.eclipse.swt.widgets.Composite) */
  public void paint(Composite parent) {
    if (myParent != null) return;

    // BUGZILLA 286 Wenn die Ueberschriftengroesse hoeher als die Bild-Groesse ist, dann strecken
    Image image = SWTUtil.getImage("panelbar.png");
    int imageHeight = image.getBounds().height;
    int fontHeight =
        Font.getHeight(FONT)
            + (2 * TITLE_OFFSET_Y); // Abstand oben und unten brauchen wir auch etwas
    int height = fontHeight > imageHeight ? fontHeight : imageHeight;

    ///////////////////////////////
    // Eigenes Parent, damit wir ein GridLayout verwenden koennen
    myParent = new Composite(parent, this.border ? SWT.BORDER : SWT.NONE);
    myParent.setLayout(SWTUtil.createGrid(1, false));
    myParent.setLayoutData(new GridData(GridData.FILL_BOTH));
    //
    ///////////////////////////////

    ///////////////////////////////
    // Titelleiste
    Composite head = new Composite(myParent, SWT.NONE);
    head.setLayout(SWTUtil.createGrid(2, false));
    {
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.heightHint = height;
      head.setLayoutData(gd);
    }

    //
    ///////////////////////////////

    ///////////////////////////////
    // Der Titel selbst
    title = SWTUtil.getCanvas(head, image, SWT.TOP | SWT.BOTTOM);
    title.setBackground(GUI.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    title.setLayout(SWTUtil.createGrid(1, false));
    {
      GridData gd = new GridData(GridData.FILL_HORIZONTAL);
      gd.heightHint = height;
      title.setLayoutData(gd);
    }
    title.addListener(
        SWT.Paint,
        new Listener() {
          public void handleEvent(Event event) {
            GC gc = event.gc;
            gc.setFont(FONT.getSWTFont());
            // kein Hintergrund hinter dem Text malen
            // Ist zumindest unter Linux nicht noetig. Windows und OSX muesste man mal noch testen
            gc.setBackground(GUI.getDisplay().getSystemColor(SWT.TRANSPARENT));
            // gc.setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_BLACK)); // Siehe Mail von
            // Hermann vom 29.03.2012
            gc.drawText(titleText == null ? "" : titleText, TITLE_OFFSET_X, TITLE_OFFSET_Y, true);
          }
        });
    //
    ///////////////////////////////

    ///////////////////////////////
    // Bereich fuer die Buttons
    this.panelButtons = new Composite(head, SWT.NONE);
    {
      GridData gd = new GridData();
      gd.heightHint = height;
      gd.widthHint = 0; // Erstmal ohne Breitenangabe - gibts erst, wenn wirklich Buttons da sind
      this.panelButtons.setLayoutData(gd);
    }
    //
    ///////////////////////////////

    ///////////////////////////////
    // Separator
    Label sep = new Label(myParent, SWT.SEPARATOR | SWT.HORIZONTAL);
    sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    //
    ///////////////////////////////

    // Einmal initial die Buttons zeichnen
    updateButtons();
  }
コード例 #6
0
ファイル: View.java プロジェクト: willuhn/jameica
  /** Initialisiert das Layout der View. */
  private void init() {
    sash = new SashForm(parent, SWT.VERTICAL);
    sash.setLayoutData(new GridData(GridData.FILL_BOTH));
    sash.setLayout(SWTUtil.createGrid(1, true));

    view = new Composite(sash, SWT.BORDER);
    view.setLayoutData(new GridData(GridData.FILL_BOTH));
    view.setLayout(SWTUtil.createGrid(1, true));

    snapin = new Composite(sash, SWT.BORDER);
    snapin.setLayoutData(new GridData(GridData.FILL_BOTH));
    snapin.setLayout(SWTUtil.createGrid(1, true));
    sash.setMaximizedControl(view);

    if (!Customizing.SETTINGS.getBoolean("application.view.hidelogo", false)) {
      ////////////////////////////////////////////////////////////////////////////
      //
      final Image logo =
          SWTUtil.getImage(Customizing.SETTINGS.getString("application.view.logo", "panel.png"));
      final Rectangle imageSize = logo.getBounds();
      logoBg = SWTUtil.getCanvas(view, logo, SWT.TOP | SWT.RIGHT);
      RGB bg =
          Customizing.SETTINGS.getRGB(
              "application.view.background",
              GUI.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB());
      logoBg.setBackground(new org.eclipse.swt.graphics.Color(GUI.getDisplay(), bg));
      logoBg.setLayout(SWTUtil.createGrid(1, false));

      logoBg.addListener(
          SWT.Paint,
          new Listener() {
            public void handleEvent(Event event) {
              GC gc = event.gc;
              Rectangle size = logoBg.getBounds();
              gc.fillRectangle(size);
              gc.drawImage(logo, size.width - imageSize.width, 0);
              gc.setFont(Font.SMALL.getSWTFont());

              // kein Hintergrund hinter dem Text malen
              // Ist zumindest unter Linux nicht noetig. Windows und OSX muesste man mal noch testen
              gc.setBackground(GUI.getDisplay().getSystemColor(SWT.TRANSPARENT));
              gc.setForeground(GUI.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
              gc.setAlpha(150);
              gc.drawText(logotext == null ? "" : logotext, 8, 10, true);
            }
          });

      Label sep = new Label(view, SWT.SEPARATOR | SWT.HORIZONTAL);
      sep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      ////////////////////////////////////////////////////////////////////////////
    }

    if (!Customizing.SETTINGS.getBoolean("application.view.hidepanel", false)) {
      ////////////////////////////////////////////////////////////////////////////
      //
      Composite comp = new Composite(view, SWT.NONE);
      comp.setLayout(SWTUtil.createGrid(1, false));
      comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      this.titlePart = new TitlePart(title, false);
      this.titlePart.paint(comp);
    }

    if (!Customizing.SETTINGS.getBoolean("application.view.hidemessages", false)) {
      ////////////////////////////////////////////////////////////////////////////
      //
      try {
        notifications = new NotificationPanel();
        notifications.paint(view);
      } catch (Exception e) {
        Logger.error("unable to paint notification panel", e);
      }
      ////////////////////////////////////////////////////////////////////////////
    }
  }