/** 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());
  }
  private IEditorPart getEditorForAttribute(ContentTypeAttribute attribute) throws CoreException {
    IEditorPart editor = null;
    boolean enableComponentPropertiesEditor = false;
    Integer stateId = getInfoglueEditorInput().getContent().getContentVersion().getStateId();
    final boolean isWorkingState =
        (stateId == null
            || ContentVersionVO.WORKING_STATE.equals(
                getInfoglueEditorInput().getContent().getContentVersion().getStateId()));

    try {
      enableComponentPropertiesEditor =
          Boolean.parseBoolean(
              attribute
                  .getContentTypeAttribute("enableComponentPropertiesEditor")
                  .getContentTypeAttributeParameterValue()
                  .getValue("label"));
    } catch (Exception e) {
    }

    System.out.println("Getting editor for attribute: " + attribute.getName());
    System.out.println("enableComponentPropertiesEditor=" + enableComponentPropertiesEditor);
    System.out.println("-----------------------------------");

    editor =
        new StructuredTextEditor() {
          @Override
          public boolean isDirty() {
            // TODO Auto-generated method stub
            return super.isDirty();
          }

          @Override
          public void doSave(IProgressMonitor progressMonitor) {

            super.doSave(progressMonitor);
            String document = getDocumentProvider().getDocument(getEditorInput()).get();
            getAttributeEditorInput().getAttribute().setValue(document);
          }

          @Override
          public boolean isEditable() {
            return isWorkingState;
          }

          private AttributeEditorInput getAttributeEditorInput() {
            return (AttributeEditorInput) getEditorInput();
          }
        };
    return editor;
  }
  public void createStructuredEditor(ContentTypeAttribute attribute) {
    IEditorPart editor = null;

    try {
      editor = getEditorForAttribute(attribute);
      int index =
          addPage(
              editor,
              new AttributeEditorInput(
                  attribute, getInfoglueEditorInput().getContent().getConnection()));
      setPageText(index, attribute.getName());
    } catch (PartInitException e) {
    } catch (CoreException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }