List of usage examples for org.apache.wicket.extensions.ajax.markup.html AjaxEditableMultiLineLabel AjaxEditableMultiLineLabel
public AjaxEditableMultiLineLabel(final String id)
From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.metadata.template.TemplateSectionPanel.java
License:Apache License
private void setupHeadAndControlComponents(final IModel<Section> model, final List<Section> choices) { // head + control final boolean notRootSection = model.getObject().getParent() != null; head.add(new AjaxEditableLabel<String>("name") { private static final long serialVersionUID = 1L; @Override/*www . java2 s.c o m*/ protected String defaultNullLabel() { if (notRootSection) { return ResourceUtils.getString("text.template.empty.sectionName"); } else { return ResourceUtils.getString("text.template.empty.templateName"); } } }); String key; if (notRootSection) { key = "label.template.section"; } else { key = "label.template.templateName"; } head.add(new Label("sectionNameLabel", ResourceUtils.getString(key))); head.add(new AjaxEditableMultiLineLabel<String>("definition") { private static final long serialVersionUID = 1L; @Override protected String defaultNullLabel() { return ResourceUtils.getString("text.template.empty.section.definition"); } @Override protected void onConfigure() { super.onConfigure(); setVisible(viewModel.isDefinitionVisible()); } }.setVisibilityAllowed(notRootSection)); final DropDownChoice<Section> sectionList = new DropDownChoice<Section>("addSubsectionList", new Model<Section>(), choices, new ChoiceRenderer<Section>("name")); sectionList.setOutputMarkupId(true); head.add(sectionList); sectionList.add(new AjaxFormComponentUpdatingBehavior("onChange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { Section section = sectionList.getModelObject(); try { section = section.copy(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } TemplateSectionPanel.this.model.getObject().add(section); sectionList.setModelObject(null); target.add(mainContainer); } }); head.add(new AjaxLink<Void>("removeSection") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { Section section = TemplateSectionPanel.this.model.getObject(); section.getParent().removeSection(section); target.add(mainContainer); } }.setVisibilityAllowed(notRootSection)); head.add(new AjaxLink<Void>("showhideSectionContent") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { content.setVisible(!content.isVisible()); target.add(content); } }); head.add(new AjaxLink<Void>("addProperty") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { Property property = new Property( ResourceUtils.getString("text.template.empty.propertyName") + propertySuffix++, ResourceUtils.getString("text.template.empty.propertyValue")); TemplateSectionPanel.this.model.getObject().add(property); } catch (Exception e) { e.printStackTrace(); } target.add(mainContainer); } }.setVisibilityAllowed(notRootSection)); }
From source file:net.unit8.longadeseo.page.plugin.PluginListPage.java
License:Apache License
public PluginListPage() { add(new Label("pageTitle", "?")); pluginRegistryList = pluginRegistryService.findAll(); final ModalWindow window = new ModalWindow("testWindow"); window.setTitle("test"); add(window);/*ww w.j a va2 s. c o m*/ add(new ListView<PluginRegistry>("pluginRegistryList", pluginRegistryList) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<PluginRegistry> item) { final PluginRegistry pluginRegistry = item.getModelObject(); Form<PluginRegistry> pluginUpdateForm = new Form<PluginRegistry>("pluginUpdateForm", new CompoundPropertyModel<PluginRegistry>(pluginRegistry)); item.add(pluginUpdateForm); final Model<String> includes = new Model<String>( StringUtils.join(pluginRegistry.getIncludes(), "\n")); pluginUpdateForm.add(new Label("name")) .add(new AjaxEditableMultiLineLabel<PluginRegistry>("description") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }).add(new Label("pluginClass", pluginRegistry.getPluginClass().getName())) .add(new AjaxEditableMultiLineLabel<String>("pluginIncludes", includes) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistry.setIncludes(includes.getObject().split("\n")); pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }).add(new Button("deleteButton") { private static final long serialVersionUID = 1L; @Override public void onSubmit() { pluginRegistryService.delete(pluginRegistry); pluginRegistryList.remove(pluginRegistry); super.onSubmit(); } }).add(new AjaxButton("activeButton", new Model<String>(activeButtonLabel(pluginRegistry.isActive()))) { private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, Form<?> form) { pluginRegistry.setActive(!pluginRegistry.isActive()); this.setModelObject(activeButtonLabel(pluginRegistry.isActive())); pluginRegistryService.update(pluginRegistry); PluginManager pluginManager = (PluginManager) WebApplication.get() .getServletContext().getAttribute(WebdavServlet.PLUGIN_MANAGER_KEY); pluginManager.loadPlugins(); target.add(this); } }.setOutputMarkupId(true)).add(new AjaxButton("testButton") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { window.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = 1L; public Page createPage() { return new PluginTestPage(pluginRegistry); } }); window.show(target); } }); final WebMarkupContainer optionsContainer = new WebMarkupContainer("optionsContainer"); final ListView<PluginOptionEntry> options = new ListView<PluginOptionEntry>("options", pluginRegistry.getPlugin().getOptions()) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<PluginOptionEntry> item) { final PluginOptionEntry option = item.getModelObject(); item.add(new Label("name", option.getLabel())); switch (option.getFormType()) { case TEXTAREA: item.add(new AjaxEditableMultiLineLabel<PluginOptionEntry>("value", new PropertyModel<PluginOptionEntry>(option, "value")) { private static final long serialVersionUID = 1L; @Override public void onEdit(AjaxRequestTarget target) { String selector = ".codemirror:eq(" + (item.getIndex() - 1) + ") textarea"; target.appendJavaScript("CodeMirror.fromTextArea($('" + selector + "')[0], {mode: 'text/x-ruby', lineNumbers: true,indentUnit: 2,tabMode: 'shift',matchBrackets: true})" + ".on('blur', function(cm) { cm.save(); $('" + selector + "').trigger('blur') });"); super.onEdit(target); } @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistry.getPlugin().setOption(option.getName(), ValueFactoryImpl.getInstance().createValue(option.getStringValue())); pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }.add(new AttributeModifier("class", "codemirror"))); break; default: item.add(new AjaxEditableLabel<PluginOptionEntry>("value", new PropertyModel<PluginOptionEntry>(option, "value")) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target) { pluginRegistry.getPlugin().setOption(option.getName(), ValueFactoryImpl.getInstance().createValue(option.getStringValue())); pluginRegistryService.update(pluginRegistry); super.onSubmit(target); } }); break; } } }; optionsContainer.add(options); pluginUpdateForm.add(optionsContainer); } }); Form<ValueMap> form = new PluginRegistryForm("pluginRegistryForm"); add(form); }