@Override
  public void handleAction(Object context) throws ApplicationException {
    if (context == null || !(context instanceof Buchungsart)) {
      throw new ApplicationException("Keine Buchungsart ausgewählt");
    }
    try {
      Buchungsart b = (Buchungsart) context;
      if (b.isNewObject()) {
        return;
      }
      YesNoDialog d = new YesNoDialog(YesNoDialog.POSITION_CENTER);
      d.setTitle("Buchungsart löschen");
      d.setText("Wollen Sie diese Buchungsart wirklich löschen?");
      try {
        Boolean choice = (Boolean) d.open();
        if (!choice.booleanValue()) return;
      } catch (Exception e) {
        Logger.error("Fehler beim Löschen der Buchungsart", e);
        return;
      }

      b.delete();
      GUI.getStatusBar().setSuccessText("Buchungsart gelöscht.");
    } catch (RemoteException e) {
      String fehler = "Fehler beim Löschen der Buchungsart.";
      GUI.getStatusBar().setErrorText(fehler);
      Logger.error(fehler, e);
    }
  }
  /** @see de.willuhn.jameica.gui.AbstractView#bind() */
  public void bind() throws Exception {

    final UmsatzDetailControl control = getControl();

    // BUGZILLA 38 http://www.willuhn.de/bugzilla/show_bug.cgi?id=38
    Konto k = control.getUmsatz().getKonto();

    String s1 = k.getLongName();
    if (s1 == null) s1 = "";

    double d = k.getSaldo();
    String s2 = null;
    if (k.getSaldoDatum() != null)
      s2 = HBCI.DECIMALFORMAT.format(d) + " " + k.getWaehrung(); // Saldo wurde schonmal abgerufen

    if (s2 == null) GUI.getView().setTitle(i18n.tr("Buchungsdetails. {0}", s1));
    else GUI.getView().setTitle(i18n.tr("Buchungsdetails. {0}, Saldo: {1}", new String[] {s1, s2}));

    ColumnLayout columns = new ColumnLayout(getParent(), 2);
    SimpleContainer left = new SimpleContainer(columns.getComposite());

    // BUGZILLA 23 http://www.willuhn.de/bugzilla/show_bug.cgi?id=23
    left.addHeadline(i18n.tr("Gegenkonto"));
    left.addLabelPair(i18n.tr("Inhaber"), control.getEmpfaengerName());
    left.addLabelPair(i18n.tr("Kontonummer"), control.getEmpfaengerKonto());
    left.addLabelPair(i18n.tr("BLZ"), control.getEmpfaengerBLZ());

    left.addHeadline(i18n.tr("Datum und Betrag"));
    left.addLabelPair(i18n.tr("Datum"), control.getDatum());
    left.addLabelPair(i18n.tr("Valuta"), control.getValuta());
    left.addSeparator();
    left.addLabelPair(i18n.tr("Betrag"), control.getBetrag());
    left.addLabelPair(i18n.tr("Neuer Saldo"), control.getSaldo());

    SimpleContainer right = new SimpleContainer(columns.getComposite(), true);
    right.addHeadline(i18n.tr("Sonstige Informationen"));
    right.addLabelPair(i18n.tr("Art der Buchung"), control.getArt());
    right.addLabelPair(i18n.tr("Kundenreferenz"), control.getCustomerRef());
    right.addLabelPair(i18n.tr("Primanota-Kennzeichen"), control.getPrimanota());
    right.addLabelPair(i18n.tr("Geschäftsvorfall-Code"), control.getGvCode());

    right.addHeadline(i18n.tr("Notizen"));
    right.addPart(control.getKommentar());

    SimpleContainer bottom = new SimpleContainer(getParent(), true);
    bottom.addSeparator();
    bottom.addLabelPair(i18n.tr("Kategorie"), control.getUmsatzTyp());
    bottom.addHeadline(i18n.tr("Verwendungszweck"));
    bottom.addPart(control.getZweck());
    bottom.addInput(control.getZweckSwitch());

    forceSaldoUpdateforReverseBooking();
  }
Example #3
0
  /**
   * Erwartet ein Objekt vom Typ <code>Konto</code> im Context.
   *
   * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
   */
  public void handleAction(Object context) throws ApplicationException {
    I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();
    if (context == null || !(context instanceof Konto))
      throw new ApplicationException(i18n.tr("Bitte wählen Sie ein Konto aus."));

    Konto k = (Konto) context;

    try {
      if (k.isNewObject()) k.store(); // wir speichern eigenmaechtig
    } catch (RemoteException e) {
      Logger.error("error while storing konto", e);
      GUI.getStatusBar().setErrorText(i18n.tr("Fehler beim Speichern des Kontos"));
    }
    GUI.startView(de.willuhn.jameica.hbci.gui.views.UmsatzList.class, k);
  }
  /**
   * Aktualisiert die Tabelle.
   *
   * @throws RemoteException
   */
  public void handleReload() throws RemoteException {
    TablePart table = this.getTable();
    table.removeAll();

    Date tStart = (Date) getStart().getValue();
    Date tEnd = (Date) getEnd().getValue();
    if (tStart != null && tEnd != null && tStart.after(tEnd)) {
      GUI.getView().setErrorText(i18n.tr("Das Anfangsdatum muss vor dem Enddatum liegen"));
      return;
    }
    GUI.getView().setErrorText(""); // ggf. vorher angezeigten Fehler loeschen

    List<EinnahmeAusgabe> list = this.getWerte();
    for (EinnahmeAusgabe ea : list) table.addItem(ea);
  }
  @Override
  public void bind() throws Exception {
    GUI.getView().setTitle("Felddefinition");

    final FelddefinitionControl control = new FelddefinitionControl(this);

    LabelGroup group = new LabelGroup(getParent(), "Felddefinition");
    group.addLabelPair("Name", control.getName(true));
    group.addLabelPair("Label", control.getLabel());
    group.addLabelPair("Datentyp", control.getDatentyp());
    group.addLabelPair("Länge", control.getLaenge());

    ButtonArea buttons = new ButtonArea();
    buttons.addButton(
        "Hilfe",
        new DokumentationAction(),
        DokumentationUtil.FELDDEFINITIONEN,
        false,
        "help-browser.png");
    buttons.addButton("Übersicht", new FelddefinitionenAction());
    buttons.addButton(
        "speichern",
        new Action() {

          @Override
          public void handleAction(Object context) {
            control.handleStore();
          }
        },
        null,
        true,
        "document-save.png");
    buttons.paint(this.getParent());
  }
  /**
   * Als Context kann eine Sammel-Lastschrift oder eine einzelne Buchung einer Lastschrift angegeben
   * werden. Abhaengig davon wird entweder eine neue Buchung erzeugt oder die existierende
   * geoeffnet.
   *
   * @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object)
   */
  public void handleAction(Object context) throws ApplicationException {
    SammelLastBuchung u = null;

    if (context instanceof SammelLastBuchung) {
      u = (SammelLastBuchung) context;
    }
    GUI.startView(de.willuhn.jameica.hbci.gui.views.SammelLastBuchungNew.class, u);
  }
    /**
     * @see
     *     de.willuhn.jameica.messaging.MessageConsumer#handleMessage(de.willuhn.jameica.messaging.Message)
     */
    public void handleMessage(Message message) throws Exception {
      if (transfer == null) return;

      GenericObject o = ((ObjectChangedMessage) message).getObject();
      if (o == null) return;

      // View neu laden
      if (transfer.equals(o)) GUI.startView(AuslandsUeberweisungNew.this, transfer);
    }
  /** @see de.willuhn.jameica.gui.AbstractView#bind() */
  public void bind() throws Exception {
    I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

    GUI.getView().setTitle(i18n.tr("Sparquote eines Kontos"));

    de.willuhn.jameica.hbci.gui.parts.SparQuote q =
        new de.willuhn.jameica.hbci.gui.parts.SparQuote();
    q.paint(getParent());
  }
Example #9
0
  /** @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));
                    }
                  }
                });
          }
        });
  }
  /**
   * Versucht eine SEPA-Ueberweisung aus der Zwischenablage zu erstellen.
   *
   * @return die Ueberweisung, wenn eine erstellt werden konnte oder null.
   */
  public AuslandsUeberweisung getUeberweisung() {
    try {
      // BUGZILLA 336
      final Clipboard cb = new Clipboard(GUI.getDisplay());
      TextTransfer transfer = TextTransfer.getInstance();
      String text = (String) cb.getContents(transfer);

      if (text == null || text.length() == 0) return null;

      text = text.trim();

      // Fuer den Fall, dass wir Key+Value nicht nur durch Doppelpunkt sondern zusaetzlich
      // auch noch durch einen Zeilenumbruch getrennt sind, entfernen wir Zeilen-Umbrueche,
      // wenn sie auf einen Doppelpunkt folgen
      // Siehe http://www.onlinebanking-forum.de/phpBB2/viewtopic.php?p=82519#82519
      text = PT_SPLIT.matcher(text).replaceAll(":");

      StringTokenizer st = new StringTokenizer(text, System.getProperty("line.separator", "\n"));
      HashMap values = new HashMap();

      while (st.hasMoreTokens()) {
        String line = st.nextToken();
        if (line == null || line.length() <= 0) continue;

        line = line.replaceAll("\\s", " ");

        int sep = line.indexOf(":");
        if (sep == -1) continue;

        values.put(line.substring(0, sep).trim(), line.substring(sep + 1).trim());
      }

      AuslandsUeberweisung u =
          (AuslandsUeberweisung)
              Settings.getDBService().createObject(AuslandsUeberweisung.class, null);

      Iterator i = values.keySet().iterator();
      while (i.hasNext()) {
        String s = (String) i.next();
        String value = (String) values.get(s);
        if (value == null || s == null) continue;
        if (PT_BLZ.matcher(s).matches()) u.setGegenkontoBLZ(value.replaceAll(" ", ""));
        else if (PT_KONTO.matcher(s).matches()) u.setGegenkontoNummer(value.replaceAll(" ", ""));
        else if (PT_NAME.matcher(s).matches()) u.setGegenkontoName(value);
        else if (PT_ZWECK.matcher(s).matches()) u.setZweck(value);
      }
      return u;
    } catch (Throwable t) {
      Logger.debug("unable to parse clipboard data: " + t.getMessage());
    }
    return null;
  }
Example #11
0
 /**
  * Setzt den anzuzeigenden Titel.
  *
  * @param text der Titel.
  */
 public void setTitle(String text) {
   this.titleText = text;
   if (this.title != null) {
     GUI.getDisplay()
         .syncExec(
             new Runnable() {
               public void run() {
                 if (title.isDisposed()) return;
                 title.redraw();
               }
             });
   }
 }
  /** @see de.willuhn.jameica.gui.AbstractView#bind() */
  public void bind() throws Exception {
    // draw the title
    GUI.getView().setTitle(Settings.i18n().tr("Project details"));

    // instanciate controller
    final ProjectControl control = new ProjectControl(this);

    Container c = new SimpleContainer(getParent());

    // layout with 2 columns
    ColumnLayout columns = new ColumnLayout(c.getComposite(), 2);

    // left side
    Container left = new SimpleContainer(columns.getComposite());
    left.addHeadline(Settings.i18n().tr("Details"));
    left.addInput(control.getName());
    left.addInput(control.getPrice());
    left.addInput(control.getStartDate());
    left.addInput(control.getEndDate());

    // right side
    Container right = new SimpleContainer(columns.getComposite(), true);
    right.addHeadline(Settings.i18n().tr("Description"));
    right.addInput(control.getDescription());

    c.addHeadline(Settings.i18n().tr("Summary"));
    c.addInput(control.getEffortSummary());

    // add some buttons
    ButtonArea buttons = new ButtonArea();
    buttons.addButton(Settings.i18n().tr("New Task"), new TaskDetail(), control.getCurrentObject());
    buttons.addButton(
        Settings.i18n().tr("Delete"), new ProjectDelete(), control.getCurrentObject());
    buttons.addButton(
        Settings.i18n().tr("Store"),
        new Action() {
          public void handleAction(Object context) throws ApplicationException {
            control.handleStore();
          }
        },
        null,
        true); // "true" defines this button as the default button

    // Don't forget to paint the button area
    buttons.paint(getParent());

    // show task tasks in this project
    new Headline(getParent(), Settings.i18n().tr("Tasks within this project"));
    control.getTaskList().paint(getParent());
  }
  /**
   * Ueberschrieben, um das Flag fuer die Termin-Ueberweisung zu speichern.
   *
   * @see de.willuhn.jameica.hbci.gui.controller.AbstractTransferControl#handleStore()
   */
  public synchronized boolean handleStore() {
    try {
      Ueberweisung u = (Ueberweisung) getTransfer();

      Typ t = (Typ) getTyp().getValue();
      u.setTerminUeberweisung(t.termin);
      u.setUmbuchung(t.umb);
      return super.handleStore();
    } catch (RemoteException re) {
      Logger.error("error while storing ueberweisung", re);
      GUI.getStatusBar().setErrorText(i18n.tr("Fehler beim Speichern der Überweisung"));
      return false;
    }
  }
  /** @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) */
  public void handleAction(Object context) throws ApplicationException {
    I18N i18n = Application.getPluginLoader().getPlugin(HBCI.class).getResources().getI18N();

    try {
      ImportDialog d = new ImportDialog(null, AuslandsUeberweisung.class);
      d.open();
    } catch (OperationCanceledException oce) {
      Logger.info(oce.getMessage());
      return;
    } catch (ApplicationException ae) {
      throw ae;
    } catch (Exception e) {
      Logger.error("error while importing transfers", e);
      GUI.getStatusBar().setErrorText(i18n.tr("Fehler beim Importieren der SEPA-Überweisungen"));
    }
  }
Example #15
0
  /** @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) */
  public void handleAction(Object context) throws ApplicationException {
    Anlagevermoegen a = null;
    if (context != null) {
      if (context instanceof Mandant) {
        try {
          a = (Anlagevermoegen) Settings.getDBService().createObject(Anlagevermoegen.class, null);
          a.setMandant((Mandant) context);
        } catch (RemoteException e) {
          Logger.error("error while creating anlagevermoegen", e);
        }
      } else {
        a = (Anlagevermoegen) context;
      }
    }

    GUI.startView(de.willuhn.jameica.fibu.gui.views.AnlagevermoegenNeu.class, a);
  }
Example #16
0
  /** Aktualisiert die Buttons. */
  private void updateButtons() {
    if (panelButtons == null || panelButtons.isDisposed()) return;

    GUI.getDisplay()
        .syncExec(
            new Runnable() {
              public void run() {
                if (panelButtons.isDisposed()) return;

                try {
                  // Kurz ausblenden - sieht beim Aufbau sauberer aus
                  panelButtons.setVisible(false);

                  int size = buttons.size();

                  // Aktuelle Buttons disposen
                  SWTUtil.disposeChildren(panelButtons);

                  // Neues Layout basierend auf der Anzahl der Buttons anlegen
                  panelButtons.setLayout(SWTUtil.createGrid(size, false));

                  // Breite errechnen
                  Image background = SWTUtil.getImage(PanelButton.BG_DEFAULT);
                  GridData gd = (GridData) panelButtons.getLayoutData();
                  gd.widthHint = background.getBounds().width * size;

                  // Alle Buttons zeichnen - von rechts nach links
                  for (int i = size - 1; i >= 0; i--) {
                    buttons.get(i).paint(panelButtons);
                  }

                  // Das Neuberechnen des Parent fuehrt dazu, dass wir mehr Breite fuer die neuen
                  // Buttons kriegen
                  panelButtons.getParent().layout();

                  // Und wir zeichnen uns selbst neu
                  panelButtons.layout();
                } catch (Exception e) {
                  Logger.error("unable to paint panel buttons", e);
                } finally {
                  panelButtons.setVisible(true);
                }
              }
            });
  }
Example #17
0
    /**
     * @see
     *     de.willuhn.jameica.messaging.MessageConsumer#handleMessage(de.willuhn.jameica.messaging.Message)
     */
    public void handleMessage(Message message) throws Exception {
      if (message == null || !(message instanceof QueryMessage)) return;

      final Object data = ((QueryMessage) message).getData();
      if (data == null || !(data instanceof Kontenrahmen)) return;

      GUI.getDisplay()
          .asyncExec(
              new Runnable() {
                public void run() {
                  try {
                    addItem(data);
                    sort();
                  } catch (Exception e) {
                    Logger.error("error while adding new data", e);
                  }
                }
              });
    }
Example #18
0
  private void init() throws IOException {
    FileDialog fd = new FileDialog(GUI.getShell(), SWT.SAVE);
    fd.setText("Ausgabedatei wählen.");
    String path = settings.getString("lastdir", System.getProperty("user.home"));
    if (path != null && path.length() > 0) {
      fd.setFilterPath(path);
    }
    fd.setFileName(
        new Dateiname(
                "kontoauszug", "", Einstellungen.getEinstellung().getDateinamenmuster(), "PDF")
            .get());
    fd.setFilterExtensions(new String[] {"*.PDF"});

    String s = fd.open();
    if (s == null || s.length() == 0) {
      return;
    }
    if (!s.endsWith(".PDF")) {
      s = s + ".PDF";
    }
    file = new File(s);
    settings.setAttribute("lastdir", file.getParent());
  }
Example #19
0
 /** @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) */
 public void handleAction(Object context) throws ApplicationException {
   GUI.startView(de.willuhn.jameica.fibu.gui.views.AnlagevermoegenListe.class, context);
 }
 public void handleAction(Object context) {
   GUI.startView(FamilienbeitragView.class.getName(), null);
 }
Example #21
0
  /** @see de.willuhn.jameica.gui.AbstractView#bind() */
  public void bind() throws Exception {

    GUI.getView().setTitle(i18n.tr("Einstellungen"));
    final SettingsControl control = new SettingsControl(this);

    // Grund-Einstellungen
    TabGroup system = new TabGroup(getTabFolder(), i18n.tr("Grundeinstellungen"));
    system.addCheckbox(
        control.getOnlineMode(),
        i18n.tr("Dauerhafte Internetverbindung, Aufforderung zum Verbinden nicht erforderlich"));
    system.addCheckbox(
        control.getCachePin(), i18n.tr("PIN-Eingaben für die aktuelle Sitzung zwischenspeichern"));
    system.addCheckbox(
        control.getStorePin(), i18n.tr("PIN-Eingaben permanent speichern (nur bei PIN/TAN)"));
    system.addCheckbox(
        control.getDecimalGrouping(), i18n.tr("Tausender-Trennzeichen bei Geld-Beträgen anzeigen"));
    system.addCheckbox(
        control.getKontoCheck(),
        i18n.tr("Kontonummern und Bankleitzahlen mittels Prüfsumme testen"));
    system.addCheckbox(
        control.getKontoCheckExcludeAddressbook(),
        i18n.tr("Außer Bankverbindungen des Adressbuches"));
    system.addLabelPair(i18n.tr("Limit für Aufträge"), control.getUeberweisungLimit());

    // Farb-Einstellungen
    TabGroup colors = new TabGroup(getTabFolder(), i18n.tr("Farben"));
    colors.addLabelPair(i18n.tr("Textfarbe von Sollbuchungen"), control.getBuchungSollForeground());
    colors.addLabelPair(
        i18n.tr("Textfarbe von Habenbuchungen"), control.getBuchungHabenForeground());

    // Passports
    TabGroup passports = new TabGroup(getTabFolder(), i18n.tr("HBCI-Sicherheitsmedien"));
    passports.addPart(control.getPassportListe());

    ButtonArea passportButtons = new ButtonArea();
    passportButtons.addButton(
        i18n.tr("Sicherheitsmedium konfigurieren..."),
        new Action() {

          public void handleAction(Object context) throws ApplicationException {
            try {
              new PassportDetail().handleAction(control.getPassportListe().getSelection());
            } catch (RemoteException re) {
              Logger.error("unable to load passport", re);
              Application.getMessagingFactory()
                  .sendMessage(
                      new StatusBarMessage(
                          i18n.tr("Fehler beim Öffnen des Sicherheitsmediums"),
                          StatusBarMessage.TYPE_ERROR));
            }
          }
        },
        null,
        false,
        "document-properties.png");
    passports.addButtonArea(passportButtons);

    // Umsatz-Kategorien
    TabGroup umsatztypes = new TabGroup(getTabFolder(), i18n.tr("Umsatz-Kategorien"));
    control.getUmsatzTypTree().paint(umsatztypes.getComposite()); // BUGZILLA 410
    ButtonArea umsatzButtons = new ButtonArea();
    umsatzButtons.addButton(
        i18n.tr("Neue Umsatz-Kategorie..."), new UmsatzTypNew(), null, false, "text-x-generic.png");
    umsatztypes.addButtonArea(umsatzButtons);

    ButtonArea buttons = new ButtonArea();
    buttons.addButton(
        i18n.tr("Speichern"),
        new Action() {
          public void handleAction(Object context) throws ApplicationException {
            control.handleStore();
          }
        },
        null,
        true,
        "document-save.png");
    buttons.paint(getParent());

    // Mal checken, ob wir uns das zuletzt aktive Tab gemerkt haben.
    if (lastActiveTab != null) getTabFolder().setSelection(lastActiveTab.intValue());
  }
Example #22
0
  /** @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();
  }
  /** @see de.willuhn.jameica.gui.AbstractView#bind() */
  public void bind() throws Exception {
    final AuslandsUeberweisungControl control = new AuslandsUeberweisungControl(this);
    this.transfer = control.getTransfer();

    GUI.getView().setTitle(i18n.tr("SEPA-Überweisung bearbeiten"));
    GUI.getView()
        .addPanelButton(
            new PanelButton(
                "edit-select-all.png",
                new SepaExportUeberweisung(transfer),
                i18n.tr("Als SEPA-XML-Datei exportieren...")));
    GUI.getView()
        .addPanelButton(new PanelButtonPrint(new PrintSupportAuslandsUeberweisung(transfer)));

    Container cl = new SimpleContainer(getParent());
    cl.addHeadline(i18n.tr("Konto"));
    cl.addInput(control.getKontoAuswahl());

    ColumnLayout cols = new ColumnLayout(getParent(), 2);

    // Linke Seite
    {
      Container container = new SimpleContainer(cols.getComposite());
      container.addHeadline(i18n.tr("Empfänger"));
      container.addLabelPair(i18n.tr("Name"), control.getEmpfaengerName());
      container.addLabelPair(i18n.tr("IBAN"), control.getEmpfaengerKonto());
      container.addLabelPair(i18n.tr("BIC"), control.getEmpfaengerBic());
      container.addCheckbox(control.getStoreEmpfaenger(), i18n.tr("In Adressbuch übernehmen"));
    }

    // Rechte Seite
    {
      Container container = new SimpleContainer(cols.getComposite());
      container.addHeadline(i18n.tr("SEPA"));
      container.addInput(control.getEndToEndId());
      container.addHeadline(i18n.tr("Sonstige Informationen (nur Hibiscus-intern)"));
      container.addText(i18n.tr("Diese Daten werden nicht an die Bank übertragen."), true);
      container.addInput(control.getTermin());
      container.addInput(control.getReminderInterval());
    }

    Container container = new SimpleContainer(getParent());
    container.addHeadline(i18n.tr("Details"));
    container.addLabelPair(i18n.tr("Verwendungszweck"), control.getZweck());
    container.addLabelPair(i18n.tr("Betrag"), control.getBetrag());

    ButtonArea buttonArea = new ButtonArea();
    buttonArea.addButton(
        i18n.tr("Löschen"), new DBObjectDelete(), transfer, false, "user-trash-full.png");
    buttonArea.addButton(
        i18n.tr("Duplizieren..."),
        new Action() {
          public void handleAction(Object context) throws ApplicationException {
            if (control.handleStore()) // BUGZILLA 1181
            new Duplicate().handleAction(transfer);
          }
        },
        null,
        false,
        "edit-copy.png");

    Button execute =
        new Button(
            i18n.tr("Jetzt ausführen..."),
            new Action() {
              public void handleAction(Object context) throws ApplicationException {
                if (control.handleStore()) new AuslandsUeberweisungExecute().handleAction(transfer);
              }
            },
            null,
            false,
            "emblem-important.png");
    execute.setEnabled(!transfer.ausgefuehrt());

    Button store =
        new Button(
            i18n.tr("Speichern"),
            new Action() {
              public void handleAction(Object context) throws ApplicationException {
                control.handleStore();
              }
            },
            null,
            !transfer.ausgefuehrt(),
            "document-save.png");
    store.setEnabled(!transfer.ausgefuehrt());

    buttonArea.addButton(execute);
    buttonArea.addButton(store);

    buttonArea.paint(getParent());

    Application.getMessagingFactory().registerMessageConsumer(this.mc);
  }
Example #24
0
  /**
   * Importiert die Daten.
   *
   * @throws ApplicationException
   */
  private void doImport() throws ApplicationException {
    Imp imp = null;

    try {
      imp = (Imp) getImporterList().getValue();
    } catch (Exception e) {
      Logger.error("error while saving import file", e);
      throw new ApplicationException(i18n.tr("Fehler beim Starten des Imports"), e);
    }

    if (imp == null || imp.importer == null)
      throw new ApplicationException(i18n.tr("Bitte wählen Sie ein Import-Format aus"));

    Settings settings = new Settings(this.getClass());
    settings.setStoreWhenRead(true);

    FileDialog fd = new FileDialog(GUI.getShell(), SWT.OPEN);
    fd.setText(
        i18n.tr("Bitte wählen Sie die Datei aus, welche für den Import verwendet werden soll."));
    fd.setFilterNames(imp.format.getFileExtensions());

    String path = settings.getString("lastdir", System.getProperty("user.home"));
    if (path != null && path.length() > 0) fd.setFilterPath(path);

    final String s = fd.open();

    if (s == null || s.length() == 0) {
      close();
      return;
    }

    final File file = new File(s);
    if (!file.exists() || !file.isFile())
      throw new ApplicationException(i18n.tr("Datei existiert nicht oder ist nicht lesbar"));

    // Wir merken uns noch das Verzeichnis vom letzten mal
    settings.setAttribute("lastdir", file.getParent());

    // Dialog schliessen
    close();

    final Importer importer = imp.importer;
    final IOFormat format = imp.format;

    BackgroundTask t =
        new BackgroundTask() {
          public void run(ProgressMonitor monitor) throws ApplicationException {
            try {
              InputStream is = new BufferedInputStream(new FileInputStream(file));
              importer.doImport(context, format, is, monitor);
              monitor.setPercentComplete(100);
              monitor.setStatus(ProgressMonitor.STATUS_DONE);
              GUI.getStatusBar().setSuccessText(i18n.tr("Daten importiert aus {0}", s));
              GUI.getCurrentView().reload();
            } catch (ApplicationException ae) {
              monitor.setStatus(ProgressMonitor.STATUS_ERROR);
              monitor.setStatusText(ae.getMessage());
              GUI.getStatusBar().setErrorText(ae.getMessage());
              throw ae;
            } catch (Exception e) {
              monitor.setStatus(ProgressMonitor.STATUS_ERROR);
              Logger.error("error while reading objects from " + s, e);
              ApplicationException ae =
                  new ApplicationException(
                      i18n.tr("Fehler beim Importieren der Daten aus {0}", s), e);
              monitor.setStatusText(ae.getMessage());
              GUI.getStatusBar().setErrorText(ae.getMessage());
              throw ae;
            }
          }

          public void interrupt() {}

          public boolean isInterrupted() {
            return false;
          }
        };

    Application.getController().start(t);
  }
  /**
   * Aktualisiert die Tabelle der angezeigten Daten. Die Aktualisierung geschieht um einige
   * Millisekunden verzoegert, damit ggf. schnell aufeinander folgende Events gebuendelt werden.
   *
   * @param force true, wenn die Daten auch dann aktualisiert werden sollen, wenn an den
   *     Eingabe-Feldern nichts geaendert wurde.
   */
  private synchronized void handleReload(boolean force) {
    try {
      final Object konto = getKonto().getValue();
      final Date dfrom = (Date) getFrom().getValue();
      final Date dto = (Date) getTo().getValue();
      final String text = (String) getText().getValue();

      if (!force) {
        // Wenn es kein forcierter Reload ist, pruefen wir,
        // ob sich etwas geaendert hat oder Eingabe-Fehler
        // vorliegen
        if (!hasChanged()) return;

        if (dfrom != null && dto != null && dfrom.after(dto)) {
          GUI.getView().setErrorText(i18n.tr("End-Datum muss sich nach dem Start-Datum befinden"));
          return;
        }
      }

      // Fehlertext "End-Datum muss ..." ggf. wieder entfernen
      GUI.getView().setLogoText(i18n.tr("Aktualisiere Daten..."));
      GUI.startSync(
          new Runnable() // Sanduhr anzeigen
          {
            public void run() {
              try {
                // Ne, wir wurden nicht gekillt. Also machen wir uns ans Werk
                // erstmal alles entfernen.
                removeAll();

                // Liste neu laden
                GenericIterator items = getList(konto, dfrom, dto, text);
                if (items == null) return;

                items.begin();
                while (items.hasNext()) addItem(items.next());

                // Sortierung wiederherstellen
                sort();

                // Speichern der Werte aus den Filter-Feldern.
                settings.setAttribute("transferlist.filter.text", text);
              } catch (Exception e) {
                Logger.error("error while reloading table", e);
                Application.getMessagingFactory()
                    .sendMessage(
                        new StatusBarMessage(
                            i18n.tr("Fehler beim Aktualisieren der Tabelle"),
                            StatusBarMessage.TYPE_ERROR));
              } finally {
                GUI.getView().setLogoText("");
              }
            }
          });
    } catch (Exception e) {
      Logger.error("error while reloading data", e);
      Application.getMessagingFactory()
          .sendMessage(
              new StatusBarMessage(
                  i18n.tr("Fehler beim Aktualisieren der Tabelle"), StatusBarMessage.TYPE_ERROR));
    }
  }
  /** @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) */
  public void handleAction(Object context) {
    try {
      DBIterator it = Einstellungen.getDBService().createList(Mitglied.class);
      if (it.size() > 0) {
        SimpleDialog dialog = new SimpleDialog(SimpleDialog.POSITION_CENTER);
        dialog.setTitle("Fehler");
        dialog.setText("Datenbank ist nicht leer!");
        dialog.open();
        return;
      }

      // Vom System eingefügte Sätze löschen. Ansonsten gibt es duplicate keys
      it = Einstellungen.getDBService().createList(Adresstyp.class);
      while (it.hasNext()) {
        Adresstyp a = (Adresstyp) it.next();
        a.delete();
      }

    } catch (Exception e1) {
      Logger.error("Fehler: ", e1);
    }

    FileDialog fd = new FileDialog(GUI.getShell(), SWT.OPEN);
    fd.setFileName("jverein-" + new JVDateFormatJJJJMMTT().format(new Date()) + ".xml");
    fd.setFilterExtensions(new String[] {"*.xml"});
    fd.setText(JVereinPlugin.getI18n().tr("Bitte wählen Sie die Backup-Datei aus"));
    String f = fd.open();
    if (f == null || f.length() == 0) {
      return;
    }

    final File file = new File(f);
    if (!file.exists()) {
      return;
    }

    Application.getController()
        .start(
            new BackgroundTask() {

              private boolean cancel = false;

              /**
               * @see de.willuhn.jameica.system.BackgroundTask#run(de.willuhn.util.ProgressMonitor)
               */
              public void run(ProgressMonitor monitor) throws ApplicationException {
                monitor.setStatusText(JVereinPlugin.getI18n().tr("Importiere Backup"));
                Logger.info("importing backup " + file.getAbsolutePath());
                final ClassLoader loader =
                    Application.getPluginLoader()
                        .getPlugin(JVereinPlugin.class)
                        .getResources()
                        .getClassLoader();

                try {
                  EigenschaftGruppe eg =
                      (EigenschaftGruppe)
                          Einstellungen.getDBService().createObject(EigenschaftGruppe.class, "1");
                  eg.delete();
                } catch (RemoteException e1) {
                  Logger.error("EigenschaftGruppe mit id=1 kann nicht gelöscht werden", e1);
                }

                Reader reader = null;
                try {
                  InputStream is = new BufferedInputStream(new FileInputStream(file));
                  reader =
                      new XmlReader(
                          is,
                          new ObjectFactory() {

                            public GenericObject create(String type, String id, Map values)
                                throws Exception {
                              AbstractDBObject object =
                                  (AbstractDBObject)
                                      Einstellungen.getDBService()
                                          .createObject(loader.loadClass(type), null);
                              object.setID(id);
                              Iterator<?> i = values.keySet().iterator();
                              while (i.hasNext()) {
                                String name = (String) i.next();
                                object.setAttribute(name, values.get(name));
                              }
                              return object;
                            }
                          });

                  long count = 1;
                  GenericObject o = null;
                  while ((o = reader.read()) != null) {
                    try {
                      ((AbstractDBObject) o).insert();
                    } catch (Exception e) {
                      Logger.error(
                          "unable to import "
                              + o.getClass().getName()
                              + ":"
                              + o.getID()
                              + ", skipping",
                          e);
                      monitor.log(
                          JVereinPlugin.getI18n()
                              .tr(
                                  " {0} fehlerhaft: {1}, überspringe ",
                                  new String[] {BeanUtil.toString(o), e.getMessage()}));
                    }
                    if (count++ % 100 == 0) {
                      monitor.addPercentComplete(1);
                    }
                  }
                  monitor.setStatus(ProgressMonitor.STATUS_DONE);
                  monitor.setStatusText(JVereinPlugin.getI18n().tr("Backup importiert"));
                  monitor.setPercentComplete(100);
                } catch (Exception e) {
                  Logger.error("error while importing data", e);
                  throw new ApplicationException(e.getMessage());
                } finally {
                  if (reader != null) {
                    try {
                      reader.close();
                      Logger.info("backup imported");
                    } catch (Exception e) {
                      /* useless */
                    }
                  }
                }
              }

              /** @see de.willuhn.jameica.system.BackgroundTask#isInterrupted() */
              public boolean isInterrupted() {
                return this.cancel;
              }

              /** @see de.willuhn.jameica.system.BackgroundTask#interrupt() */
              public void interrupt() {
                this.cancel = true;
              }
            });
  }
Example #27
0
 /** @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) */
 public void handleAction(Object context) throws ApplicationException {
   GUI.startView(de.willuhn.jameica.gui.internal.views.Backup.class, null);
 }
Example #28
0
 private void zeigeDokument() {
   GUI.getStatusBar().setSuccessText("Kontoauszug erstellt");
   FileViewer.show(file);
 }
Example #29
0
 /**
  * Erzeugt das Text-Widget. Ist eine extra Funktion damit es zum Beispiel von TextAreaInput
  * ueberschriebn werden kann.
  *
  * @return das Text-Widget.
  */
 Text getTextWidget() {
   if (text == null) text = GUI.getStyleFactory().createText(getParent());
   return text;
 }
 /** @see de.willuhn.jameica.gui.Action#handleAction(java.lang.Object) */
 public void handleAction(Object context) throws ApplicationException {
   GUI.startView(de.willuhn.jameica.hbci.gui.views.SammelUeberweisungList.class, null);
 }