Search in sources :

Example 6 with AceEditor

use of com.evolveum.midpoint.web.component.AceEditor in project midpoint by Evolveum.

the class DefinitionXmlPanel method initLayout.

protected void initLayout() {
    AceEditor editor = new AceEditor(ID_ACE_EDITOR, new PropertyModel<String>(getModel(), CertDefinitionDto.F_XML));
    //TODO for now it is only readonly
    editor.setReadonly(true);
    add(editor);
}
Also used : AceEditor(com.evolveum.midpoint.web.component.AceEditor)

Example 7 with AceEditor

use of com.evolveum.midpoint.web.component.AceEditor in project midpoint by Evolveum.

the class PageBulkAction method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    CheckBox async = new CheckBox(ID_ASYNC, new PropertyModel<Boolean>(model, BulkActionDto.F_ASYNC));
    mainForm.add(async);
    AceEditor editor = new AceEditor(ID_EDITOR, new PropertyModel<String>(model, BulkActionDto.F_SCRIPT));
    mainForm.add(editor);
    AjaxSubmitButton start = new AjaxSubmitButton(ID_START, createStringResource("PageBulkAction.button.start")) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            startPerformed(target);
        }
    };
    mainForm.add(start);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(org.apache.wicket.markup.html.form.Form) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AceEditor(com.evolveum.midpoint.web.component.AceEditor)

Example 8 with AceEditor

use of com.evolveum.midpoint.web.component.AceEditor in project midpoint by Evolveum.

the class PageDebugView method addOrReplaceEditor.

private void addOrReplaceEditor() {
    editor = new AceEditor("aceEditor", new PropertyModel<String>(model, ObjectViewDto.F_XML));
    editor.setModeForDataLanguage(dataLanguage);
    editor.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    mainForm.addOrReplace(editor);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PropertyModel(org.apache.wicket.model.PropertyModel) AceEditor(com.evolveum.midpoint.web.component.AceEditor)

Example 9 with AceEditor

use of com.evolveum.midpoint.web.component.AceEditor in project midpoint by Evolveum.

the class PageEvaluateMapping method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_MAIN_FORM);
    add(mainForm);
    AceEditor editorMapping = new AceEditor(ID_EDITOR_MAPPING, new PropertyModel<String>(model, ExecuteMappingDto.F_MAPPING));
    editorMapping.setHeight(400);
    editorMapping.setResizeToMaxHeight(false);
    mainForm.add(editorMapping);
    AceEditor editorRequest = new AceEditor(ID_EDITOR_REQUEST, new PropertyModel<String>(model, ExecuteMappingDto.F_REQUEST));
    editorRequest.setHeight(430);
    editorRequest.setResizeToMaxHeight(false);
    mainForm.add(editorRequest);
    AjaxSubmitButton evaluateMapping = new AjaxSubmitButton(ID_EXECUTE, createStringResource("PageEvaluateMapping.button.evaluateMapping")) {

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            executeMappingPerformed(target);
        }
    };
    mainForm.add(evaluateMapping);
    final DropDownChoice<String> sampleChoice = new DropDownChoice<>(ID_MAPPING_SAMPLE, Model.of(""), new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            return SAMPLES;
        }
    }, new StringResourceChoiceRenderer("PageEvaluateMapping.sample"));
    sampleChoice.setNullValid(true);
    sampleChoice.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            String sampleName = sampleChoice.getModelObject();
            if (StringUtils.isEmpty(sampleName)) {
                return;
            }
            model.getObject().setMapping(readResource(SAMPLES_DIR + "/" + sampleName + ".map.xml.data"));
            model.getObject().setRequest(readResource(SAMPLES_DIR + "/" + sampleName + ".req.xml.data"));
            model.getObject().setResultText("");
            target.add(PageEvaluateMapping.this);
        }

        private String readResource(String name) {
            InputStream is = PageEvaluateMapping.class.getResourceAsStream(name);
            if (is != null) {
                try {
                    return IOUtils.toString(is, "UTF-8");
                } catch (IOException e) {
                    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't read sample from resource {}", e, name);
                } finally {
                    IOUtils.closeQuietly(is);
                }
            } else {
                LOGGER.warn("Resource {} containing sample couldn't be found", name);
            }
            return null;
        }
    });
    mainForm.add(sampleChoice);
    AceEditor resultText = new AceEditor(ID_RESULT_TEXT, new PropertyModel<String>(model, ExecuteMappingDto.F_RESULT_TEXT));
    resultText.setReadonly(true);
    resultText.setHeight(300);
    resultText.setResizeToMaxHeight(false);
    resultText.setMode(null);
    mainForm.add(resultText);
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) StringResourceChoiceRenderer(com.evolveum.midpoint.web.util.StringResourceChoiceRenderer) Form(org.apache.wicket.markup.html.form.Form) InputStream(java.io.InputStream) AceEditor(com.evolveum.midpoint.web.component.AceEditor) IOException(java.io.IOException) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) List(java.util.List)

Example 10 with AceEditor

use of com.evolveum.midpoint.web.component.AceEditor in project midpoint by Evolveum.

the class PageImportObject method initLayout.

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);
}
Also used : RadioGroup(org.apache.wicket.markup.html.form.RadioGroup) Form(org.apache.wicket.markup.html.form.Form) Radio(org.apache.wicket.markup.html.form.Radio) AceEditor(com.evolveum.midpoint.web.component.AceEditor) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) FileUploadField(org.apache.wicket.markup.html.form.upload.FileUploadField) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ImportOptionsPanel(com.evolveum.midpoint.web.page.admin.configuration.component.ImportOptionsPanel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) AjaxFormChoiceComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior)

Aggregations

AceEditor (com.evolveum.midpoint.web.component.AceEditor)16 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)9 Form (org.apache.wicket.markup.html.form.Form)8 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 Label (org.apache.wicket.markup.html.basic.Label)5 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)3 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)2 StringResourceChoiceRenderer (com.evolveum.midpoint.web.util.StringResourceChoiceRenderer)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 List (java.util.List)2 AjaxFormChoiceComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior)2 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)2 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)2 AjaxSubmitLink (org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink)2 Radio (org.apache.wicket.markup.html.form.Radio)2 RadioGroup (org.apache.wicket.markup.html.form.RadioGroup)2