public void newEntity(String template) {
   this.preview.closePreview();
   this.originalElement = null;
   this.editedEntity =
       CustomElementCompiler.getInstance().genEntityFromTemplate(template, this.errorhandler);
   if (this.editedEntity != null)
     this.codepane.setText(((CustomElement) this.editedEntity).getCode());
   else {
     this.codepane.setText("");
     this.editedEntity = new ErrorOccurred();
   }
   this.editedEntity.setState(
       "// Modify the text below and"
           + Constants.newline
           + "// observe the element preview."
           + Constants.newline
           + Constants.newline
           + "Hello, World! "
           + Constants.newline
           + "Enjoy UMLet!");
   this.editedEntity.setBounds(20, 20, 200, 200);
   this.updatePreview(editedEntity);
   this.getPreviewHandler().getDrawPanel().getSelector().select(editedEntity);
   this.setChanged(false);
   this.start();
 }
 public void saveEntity() {
   Entity e = CustomElementCompiler.getInstance().genEntity(this.codepane.getText(), errorhandler);
   this.editedEntity = e;
   if (e == null) e = new ErrorOccurred();
   else this.updatePreview(e); // update preview panel to set the entities bounds...
   this.updateElement(e);
   this.setChanged(false);
 }
 // runs compilation every 1 seconds and updates gui/errors...
 protected void runCompilation() {
   if (!this.compilation_running
       && !keypressed) // prevent 2 compilations to run at the same time (if compilation takes more
   // then 1sec)
   {
     this.compilation_running = true;
     String txt = this.codepane.getText();
     if (!txt.equals(this.old_text)) {
       this.setChanged(true);
       this.errorhandler.clearErrors();
       this.old_text = txt;
       CustomElement e = CustomElementCompiler.getInstance().genEntity(txt, errorhandler);
       if (e != null) {
         this.editedEntity = e;
         this.panel.setCustomElementSaveable(true);
         this.updatePreview(e);
       } else {
         this.panel.setCustomElementSaveable(false);
       }
     }
     this.compilation_running = false;
   }
   keypressed = false;
 }