/** Creates the pages of the multi-page editor. */
  protected void createPages() {
    // Here we will create the form according to
    // ContentTypeDefinition
    InfoglueEditorInput input = getInfoglueEditorInput();

    /*
     * Create the textarea editors
     */
    EditableInfoglueContent content = input.getContent();
    for (Iterator i = content.getAttributes().iterator(); i.hasNext(); ) {
      ContentTypeAttribute attribute = (ContentTypeAttribute) i.next();
      if (attribute.getInputType().equalsIgnoreCase(ContentTypeAttribute.TEXTAREA)) {
        // Here we should wait for the file to load.
        // or dump the attribute here instead of in filehelper
        createStructuredEditor(attribute);
      }
    }

    /*
     * Create the form editor
     */
    formEditor = new InfoglueFormEditor();
    try {
      int index = addPage(formEditor, input);
      setPageText(index, "Properties");

    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // setTitle(content.getName());
    setPartName(content.getName());
  }
  /** Saves the multi-page editor's document. */
  public void doSave(IProgressMonitor monitor) {
    saving = true;
    boolean dirtyflag = isDirty();
    /*
     * Save all editors
     */
    Utils.getMonitor(monitor).beginTask("Saving content to CMS", 100);

    for (int i = 0; i < getPageCount(); i++) {
      getEditor(i).doSave(monitor);
    }
    Utils.getMonitor(monitor).worked(25);
    InfoglueEditorInput input = getInfoglueEditorInput();
    input.getContent().doSave(monitor);

    try {
      InfoglueCMS.saveContentVersion(
          input.getContent().getContentVersion(), input.getContent().getConnection(), monitor);
    } catch (ConcurrentModificationException e) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "The content was updated on the server, the local version is not the latest and synchronization/update feature is still not implemented. Please close the editor and open it again to get the latest version");
    } catch (IllegalStateException e) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "The content is not in a working state, automatic working change is not yet implemented, sorry");
    } catch (InvalidVersionException e) {
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "The content you are trying to save is not the active version at the server. Someone has create a new active version, sorry");
    } catch (Exception e) {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      e.printStackTrace(pw);
      // TODO: display the stacktrace in the details.
      MessageDialog.openInformation(
          this.getActiveEditor().getSite().getShell(),
          "Unhandled situation/Unable to save",
          "We recieved the following from the server: " + e.getMessage() + "\n\n" + sw.toString());
    }

    Utils.getMonitor(monitor).worked(100);
    Utils.getMonitor(monitor).done();

    saving = false;
  }