All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.ydn.wicket.wicketconsole.HistoryItemPanel Maven / Gradle / Ivy

There is a newer version: 1.3
Show newest version
package ru.ydn.wicket.wicketconsole;

import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.panel.GenericPanel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.util.string.Strings;

import ru.ydn.wicket.wicketconsole.behavior.HideIfObjectIsEmptyBehavior;

public class HistoryItemPanel extends GenericPanel
{
	private Component script;
	private Component engine;
	
	public HistoryItemPanel(String id, IModel model,final Component inpitField,final Component engineSelect)
	{
		super(id, model instanceof CompoundPropertyModel?model:new CompoundPropertyModel(model));
		add(engine = new MultiLineLabel("engine").add(HideIfObjectIsEmptyBehavior.INSTANCE));
		add(script = new MultiLineLabel("script").add(HideIfObjectIsEmptyBehavior.INSTANCE));
		add(new AjaxLink("reuse"){
			@Override
			public void onClick(AjaxRequestTarget target) {
				inpitField.setDefaultModelObject(script.getDefaultModelObject());
				engineSelect.setDefaultModelObject(engine.getDefaultModelObject());
				target.add(engineSelect);
				target.add(inpitField);
			}
		});
	}
	
	@Override
	protected void onInitialize() {
		super.onInitialize();
		
		ScriptResult historyItem =  getModelObject();
		ScriptResultRendererManager renderer =  ScriptResultRendererManager.INSTANCE;
		add(new MultiLineLabel("out").add(HideIfObjectIsEmptyBehavior.INSTANCE));
		add(new MultiLineLabel("error").add(HideIfObjectIsEmptyBehavior.INSTANCE));
		add(renderer.render("result",historyItem.getResultModel()));

	}
	

	@Override
	protected void onComponentTag(ComponentTag tag) {
		super.onComponentTag(tag);
		tag.append("class", "wc-item", " ");
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy