protected Application() throws Exception {
    UIUtil.runUITaskNow(
        new Runnable() {
          public void run() {
            Thread.currentThread()
                .setUncaughtExceptionHandler(
                    new UncaughtExceptionHandler() {
                      public void uncaughtException(Thread thread, Throwable exception) {
                        Application.getInstance()
                            .showUnhandledErrorDialog(
                                LanguageBundle.getString("general.errors.uncaughtexception.title"),
                                LanguageBundle.getString(
                                    "general.errors.uncaughtexception.message"),
                                exception);
                      }
                    });
          }
        });

    String applicationClassName = "";
    switch (Platform.getOS()) {
      case MAC:
        applicationClassName = Registry.getProperty("application_classname_osx");
        break;
      case WIN:
        applicationClassName = Registry.getProperty("application_classname_windows");
        break;
      case NIX:
        applicationClassName = Registry.getProperty("application_classname_linux");
        break;
    }
    platformApplication = (IApplication) Class.forName(applicationClassName).newInstance();

    UIUtil.setUpLAF();

    resourceEditActions.put(ResourceType.SNU, new EditSnuAction());
    resourceEditActions.put(ResourceType.VIDEO, new EditVideoAction());
    resourceEditActions.put(ResourceType.IMAGE, new EditImageAction());
    resourceEditActions.put(ResourceType.TEXT, new EditTextAction());
    resourceEditActions.put(ResourceType.SOUND, new EditSoundAction());
    resourceEditActions.put(ResourceType.INTERFACE, new EditInterfaceAction());
    resourceEditActions.put(ResourceType.PROJECT, new ProjectEditAction());

    undoManager = new UndoManager();
    undoManager.setLimit(999);

    UIManager.put("AbstractUndoableEdit.undoText", "");
    UIManager.put("AbstractUndoableEdit.redoText", "");
  }
  /** add an undoableEdit to the manager */
  public synchronized boolean addEdit(UndoableEdit anEdit) {
    System.out.println("appel à addEdit : " + anEdit);
    //        System.out.println("addEdit .. " + (anEdit != null ? anEdit.getClass() : "") );
    //        System.out.println("\tisInProgress ? " + this.isInProgress());
    //        System.out.println("\tgroup mode   ? " + this.groupActivated);
    //
    //        System.out.println("affichage de edits : ");
    //        for (int i = 0; i < this.edits.size(); i++)
    //            System.out.println("\t" + this.edits.elementAt(i).getClass());

    if (!this.isInProgress()) return false;

    System.out.println("groupActivated : " + this.groupActivated);

    if (this.groupActivated) {
      if (!(this.editToBeUndone() instanceof UndoManager)) {
        System.out.println("\teditToBeUndone is NOT NOT an UndoManager");
        UndoManager newManager = new UndoManager();
        newManager.setLimit(this.limit); // attention, la limite peut poser de graves problemes
        // super.addEdit(newManager);
        this.edits.add(newManager);

        indexOfNextAdd = edits.size();
        System.out.println("\tindexOfNextAdd : " + indexOfNextAdd);
      }

      if (this.editToBeUndone() instanceof UndoManager) {
        System.out.println("\teditToBeUndone is an UndoManager");
        ((UndoManager) this.editToBeUndone()).addEdit(anEdit);
        //                System.out.println("\tindexOfNextAdd : " + indexOfNextAdd);

        //        System.out.println("gaga affichage de edits : ");
        //        for (int i = 0; i < this.edits.size(); i++)
        //            System.out.println("\t" + this.edits.elementAt(i).getClass());

        return true;
      } else {
        //                System.out.println("\teditToBeUndone is NOT an UndoManager");

        if (this.edits.size() > 0) {
          System.out.println("\ta");
          ((UndoManager) this.edits.elementAt(this.edits.size() - 1)).addEdit(anEdit);
        } else {
          System.out.println("\tb");
          this.edits.add(anEdit);
        }
        return true;
      }
      // throw new RuntimeException("gros probleme dans l'undoManager"); }
    } else {
      System.out.println("\tajout simple");
      boolean retVal;

      // Trim from the indexOfNextAdd to the end, as we'll
      // never reach these edits once the new one is added.
      trimEdits(indexOfNextAdd, edits.size() - 1);

      ///////////////
      if (!this.isInProgress()) {
        return false;
      } else {
        UndoableEdit last = lastEdit();

        // If this is the first subedit received, just add it.
        // Otherwise, give the last one a chance to absorb the new
        // one.  If it won't, give the new one a chance to absorb
        // the last one.

        System.out.println("\t\tlast : " + (last == null ? "null" : last.getClass()));
        if (last == null) {
          System.out.println("\t\taddElement");
          edits.addElement(anEdit);
        } else // if (last instanceof UndoManager)//!last.addEdit(anEdit) || )
        {
          System.out.println("\t\ti");
          if (anEdit.replaceEdit(last)) {
            edits.removeElementAt(edits.size() - 1);
            System.out.println("\t\tj");
          }
          System.out.println(
              "il ajoute quand meme ce connard !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
          edits.addElement(anEdit);
        }

        retVal = true;
      }
      ///////////////

      if (this.isInProgress()) {
        retVal = true;
      }

      // Maybe super added this edit, maybe it didn't (perhaps
      // an in progress compound edit took it instead. Or perhaps
      // this UndoManager is no longer in progress). So make sure
      // the indexOfNextAdd is pointed at the right place.
      indexOfNextAdd = edits.size();

      System.out.println("indexofNextAdd : " + indexOfNextAdd);

      // Enforce the limit
      trimForLimit();

      return retVal;
    }
  }