private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    final IModel<Boolean> editable =
        new LoadableModel<Boolean>(false) {

          @Override
          protected Boolean load() {
            return !isEditing();
          }
        };
    mainForm.add(
        new AjaxCheckBox(ID_EDIT, editable) {

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            editPerformed(target, editable.getObject());
          }
        });
    AceEditor editor =
        new AceEditor(ID_ACE_EDITOR, new PropertyModel<String>(model, ObjectViewDto.F_XML));
    editor.setReadonly(
        new LoadableModel<Boolean>(false) {

          @Override
          protected Boolean load() {
            return isEditing();
          }
        });
    mainForm.add(editor);

    initButtons(mainForm);
  }
Пример #2
0
  private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);

    ImportOptionsPanel importOptions = new ImportOptionsPanel(ID_IMPORT_OPTIONS, model);
    mainForm.add(importOptions);

    final WebMarkupContainer input = new WebMarkupContainer(ID_INPUT);
    input.setOutputMarkupId(true);
    mainForm.add(input);

    final WebMarkupContainer buttonBar = new WebMarkupContainer(ID_BUTTON_BAR);
    buttonBar.setOutputMarkupId(true);
    mainForm.add(buttonBar);

    final IModel<Integer> groupModel = new Model<Integer>(INPUT_FILE);
    RadioGroup importRadioGroup = new RadioGroup(ID_IMPORT_RADIO_GROUP, groupModel);
    importRadioGroup.add(
        new AjaxFormChoiceComponentUpdatingBehavior() {

          @Override
          protected void onUpdate(AjaxRequestTarget target) {
            target.add(input);
            target.add(buttonBar);
          }
        });
    mainForm.add(importRadioGroup);

    Radio fileRadio = new Radio(ID_FILE_RADIO, new Model(INPUT_FILE), importRadioGroup);
    importRadioGroup.add(fileRadio);

    Radio xmlRadio = new Radio(ID_XML_RADIO, new Model(INPUT_XML), importRadioGroup);
    importRadioGroup.add(xmlRadio);

    WebMarkupContainer inputAce = new WebMarkupContainer(ID_INPUT_ACE);
    addVisibileForInputType(inputAce, INPUT_XML, groupModel);
    input.add(inputAce);

    AceEditor aceEditor = new AceEditor(ID_ACE_EDITOR, xmlEditorModel);
    aceEditor.setOutputMarkupId(true);
    inputAce.add(aceEditor);

    WebMarkupContainer inputFileLabel = new WebMarkupContainer(ID_INPUT_FILE_LABEL);
    addVisibileForInputType(inputFileLabel, INPUT_FILE, groupModel);
    input.add(inputFileLabel);

    WebMarkupContainer inputFile = new WebMarkupContainer(ID_INPUT_FILE);
    addVisibileForInputType(inputFile, INPUT_FILE, groupModel);
    input.add(inputFile);

    FileUploadField fileInput = new FileUploadField(ID_FILE_INPUT);
    inputFile.add(fileInput);

    initButtons(buttonBar, groupModel);
  }
Пример #3
0
  private void initPanelLayout(int minSize) {
    Label title = new Label(ID_TITLE, this.title);
    add(title);

    AceEditor editor = new AceEditor(ID_EDITOR, getModel());
    editor.setReadonly(false);
    if (minSize > 0) {
      editor.setMinSize(minSize);
    }
    add(editor);
  }
  private void editPerformed(AjaxRequestTarget target, boolean editable) {
    AceEditor editor = (AceEditor) get(createComponentPath(ID_MAIN_FORM, ID_ACE_EDITOR));

    editor.setReadonly(!editable);
    editor.refreshReadonly(target);
  }