<commit_before>package ro.nextreports.server.web.analysis.feature.select;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBoxMultipleChoice;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

import ro.nextreports.server.domain.Analysis;
import ro.nextreports.server.web.analysis.util.DatabaseUtil;
import ro.nextreports.server.web.common.form.FormContentPanel;
import ro.nextreports.server.web.common.form.FormPanel;

public class ColumnsPanel extends FormContentPanel<Analysis> {
	
	private List<String> choices;
	public ArrayList<String> columns = new ArrayList<String>();
	private ColumnsOrderBehavior orderBehavior;
		
	public ColumnsPanel(IModel<Analysis> model) {		
		super(FormPanel.CONTENT_ID);
		
		//System.out.println("@@@@@ " + model.getObject());
		
		setRenderBodyOnly(false);
		setOutputMarkupId(true);
	 
		columns = model.getObject().getSelectedColumns();
		choices = new LinkedList<String>();				
		choices.addAll(model.getObject().getColumns());
		
		add(new Label("info", new StringResourceModel("ColumnsPanel.info", null, null)));
		
		final CheckBoxMultipleChoice<String> listChoice = new CheckBoxMultipleChoice<String>("columns", new PropertyModel(this, "columns"), choices,
				new ChoiceRenderer<String>() {
					@Override
					public Object getDisplayValue(String fullColumnName) {
						return DatabaseUtil.getColumnAlias(fullColumnName);
					}								
		});
		listChoice.setOutputMarkupId(true);
		// add class to allow for changing layout from vertical to horizontal
		listChoice.setPrefix("<li class=\"analysisChoice\">");
		listChoice.setSuffix("</li>"); 
	    add(listChoice);		
	    
	    
	    add(new AjaxLink<Analysis>("selectAll") {						
			@Override
			public void onClick(AjaxRequestTarget target) {
				columns = new ArrayList<String>(choices);
				//System.out.println("*** select all = " + choices);				
				target.add(listChoice);
			}
	    });	
	    
	    add(new AjaxLink<Analysis>("selectNone") {						
			@Override
			public void onClick(AjaxRequestTarget target) {
				columns = new ArrayList<String>();								
				target.add(listChoice);
			}
	    });	
	    
	    add(orderBehavior = new ColumnsOrderBehavior() {
	        @Override
	        public void onResponse(int oldIndex, int newIndex, AjaxRequestTarget target) {	            
	            moveElement(choices, oldIndex, newIndex);
	            target.add(ColumnsPanel.this);
	        }
	    });
	}
	
	public List<String> getColumns() {
		return columns;
	}

	public void setColumns(ArrayList<String> columns) {
		this.columns = columns;
	}
	
	public List<String> getChoices() {
		return choices;
	}
	
	@Override<commit_msg>selectAll and selectNone deactivate columns drag and drop<commit_after>package ro.nextreports.server.web.analysis.feature.select;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBoxMultipleChoice;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.StringResourceModel;

import ro.nextreports.server.domain.Analysis;
import ro.nextreports.server.web.analysis.util.DatabaseUtil;
import ro.nextreports.server.web.common.form.FormContentPanel;
import ro.nextreports.server.web.common.form.FormPanel;

public class ColumnsPanel extends FormContentPanel<Analysis> {
	
	private List<String> choices;
	public ArrayList<String> columns = new ArrayList<String>();
	private ColumnsOrderBehavior orderBehavior;
		
	public ColumnsPanel(IModel<Analysis> model) {		
		super(FormPanel.CONTENT_ID);
		
		//System.out.println("@@@@@ " + model.getObject());
		
		setRenderBodyOnly(false);
		setOutputMarkupId(true);
	 
		columns = model.getObject().getSelectedColumns();
		choices = new LinkedList<String>();				
		choices.addAll(model.getObject().getColumns());
		
		add(new Label("info", new StringResourceModel("ColumnsPanel.info", null, null)));
		
		final CheckBoxMultipleChoice<String> listChoice = new CheckBoxMultipleChoice<String>("columns", new PropertyModel(this, "columns"), choices,
				new ChoiceRenderer<String>() {
					@Override
					public Object getDisplayValue(String fullColumnName) {
						return DatabaseUtil.getColumnAlias(fullColumnName);
					}								
		});
		listChoice.setOutputMarkupId(true);
		// add class to allow for changing layout from vertical to horizontal
		listChoice.setPrefix("<li class=\"analysisChoice\">");
		listChoice.setSuffix("</li>"); 
	    add(listChoice);		
	    
	    
	    add(new AjaxLink<Analysis>("selectAll") {						
			@Override
			public void onClick(AjaxRequestTarget target) {
				columns = new ArrayList<String>(choices);				
				target.add(ColumnsPanel.this);
			}
	    });	
	    
	    add(new AjaxLink<Analysis>("selectNone") {						
			@Override
			public void onClick(AjaxRequestTarget target) {
				columns = new ArrayList<String>();								
				target.add(ColumnsPanel.this);
			}
	    });	
	    
	    add(orderBehavior = new ColumnsOrderBehavior() {
	        @Override
	        public void onResponse(int oldIndex, int newIndex, AjaxRequestTarget target) {	            
	            moveElement(choices, oldIndex, newIndex);
	            target.add(ColumnsPanel.this);
	        }
	    });
	}
	
	public List<String> getColumns() {
		return columns;
	}

	public void setColumns(ArrayList<String> columns) {
		this.columns = columns;
	}
	
	public List<String> getChoices() {
		return choices;
	}
	
	@Override
{'fraction_non_alphanumeric': 0.11717624459740676, 'fraction_numerical': 0.0, 'mean_word_length': 4.018473895582329, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '18130', 'n_tokens_mistral': 2103, 'n_tokens_neox': 1819, 'n_words': 332}