<commit_before>package marubinotto.piggydb.ui.page.common;

import static marubinotto.util.CollectionUtils.set;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;

import java.util.List;
import java.util.Map;

import marubinotto.piggydb.model.Fragment;
import marubinotto.piggydb.model.FragmentsOptions.SortOption;
import marubinotto.piggydb.model.ModelUtils;
import marubinotto.piggydb.model.Tag;
import marubinotto.piggydb.model.enums.FragmentField;
import marubinotto.piggydb.model.exception.DuplicateException;
import marubinotto.piggydb.model.exception.NoSuchEntityException;
import marubinotto.piggydb.ui.page.control.form.PublicFieldForm;
import marubinotto.piggydb.ui.page.model.SelectedFragments;
import marubinotto.piggydb.ui.page.partial.AbstractFragments;
import marubinotto.util.message.CodedException;
import marubinotto.util.procedure.Procedure;
import net.sf.click.Context;
import net.sf.click.control.HiddenField;

import org.apache.commons.lang.StringUtils;

public abstract class AbstractFragmentsPage extends AbstractBorderPage {

	public AbstractFragmentsPage() {
	}
	
	protected String getAtomUrl() {
		return null;
	}
	
	protected String getDefaultAtomUrl() {
		return StringUtils.replace(getFullPageUrl(), ".htm", ".atom");
	}


	//
	// Model
	//
	
	public static final String MK_ATOM_URL = "atomUrl";

	public static final String MK_HIGHLIGHTED_FRAGMENT = "highlightedFragment";
	private static final String SK_HIGHLIGHTED_FRAGMENT = "highlightedFragment";

	public Boolean fragmentOperations = true;
	public List<FragmentField> fragmentFields = FragmentField.getEnumList();

	public Integer fragmentsViewScale;
	public Integer fragmentsViewOrderBy;
	public Boolean fragmentsViewAscending;

	@Override
	protected void setModels() throws Exception {
		super.setModels();
		
		String atomUrl = getAtomUrl();
		if (atomUrl != null) addModel(MK_ATOM_URL, atomUrl);

		importBottomJs("js/piggydb-fragments.js", true);
		importBottomJs("js/piggydb.widget.QuickEdit.js", true);
		importBottomJs("js/piggydb.widget.ContentToggle.js", true);
		importBottomJs("js/piggydb.widget.FragmentTree.js", true);
		importBottomJs("js/piggydb.widget.FragmentsView.js", true);

		if (showsSelectedFragments()) setSelectedFragments();
		setHighlightedFragment();

		this.fragmentsViewScale = (Integer) getContext().getSessionAttribute(
			AbstractFragments.SK_SCALE);
		if (this.fragmentsViewScale == null)
			this.fragmentsViewScale = getWarSetting().getDefaultFragmentsViewScale();

		setFragmentsViewSortOption();
	}

	protected boolean showsSelectedFragments() {
		return true;
	}

	public void highlightFragment(Long id) {
		getContext().setFlashAttribute(SK_HIGHLIGHTED_FRAGMENT, id);
	}

	public static void highlightFragment(Long id, Context context) {
		context.setFlashAttribute(SK_HIGHLIGHTED_FRAGMENT, id);
	}<commit_msg>deleted an import of js/piggydb-fragments.js<commit_after>package marubinotto.piggydb.ui.page.common;

import static marubinotto.util.CollectionUtils.set;
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;

import java.util.List;
import java.util.Map;

import marubinotto.piggydb.model.Fragment;
import marubinotto.piggydb.model.FragmentsOptions.SortOption;
import marubinotto.piggydb.model.ModelUtils;
import marubinotto.piggydb.model.Tag;
import marubinotto.piggydb.model.enums.FragmentField;
import marubinotto.piggydb.model.exception.DuplicateException;
import marubinotto.piggydb.model.exception.NoSuchEntityException;
import marubinotto.piggydb.ui.page.control.form.PublicFieldForm;
import marubinotto.piggydb.ui.page.model.SelectedFragments;
import marubinotto.piggydb.ui.page.partial.AbstractFragments;
import marubinotto.util.message.CodedException;
import marubinotto.util.procedure.Procedure;
import net.sf.click.Context;
import net.sf.click.control.HiddenField;

import org.apache.commons.lang.StringUtils;

public abstract class AbstractFragmentsPage extends AbstractBorderPage {

	public AbstractFragmentsPage() {
	}
	
	protected String getAtomUrl() {
		return null;
	}
	
	protected String getDefaultAtomUrl() {
		return StringUtils.replace(getFullPageUrl(), ".htm", ".atom");
	}


	//
	// Model
	//
	
	public static final String MK_ATOM_URL = "atomUrl";

	public static final String MK_HIGHLIGHTED_FRAGMENT = "highlightedFragment";
	private static final String SK_HIGHLIGHTED_FRAGMENT = "highlightedFragment";

	public Boolean fragmentOperations = true;
	public List<FragmentField> fragmentFields = FragmentField.getEnumList();

	public Integer fragmentsViewScale;
	public Integer fragmentsViewOrderBy;
	public Boolean fragmentsViewAscending;

	@Override
	protected void setModels() throws Exception {
		super.setModels();
		
		String atomUrl = getAtomUrl();
		if (atomUrl != null) addModel(MK_ATOM_URL, atomUrl);

		importBottomJs("js/piggydb.widget.QuickEdit.js", true);
		importBottomJs("js/piggydb.widget.ContentToggle.js", true);
		importBottomJs("js/piggydb.widget.FragmentTree.js", true);
		importBottomJs("js/piggydb.widget.FragmentsView.js", true);

		if (showsSelectedFragments()) setSelectedFragments();
		setHighlightedFragment();

		this.fragmentsViewScale = (Integer) getContext().getSessionAttribute(
			AbstractFragments.SK_SCALE);
		if (this.fragmentsViewScale == null)
			this.fragmentsViewScale = getWarSetting().getDefaultFragmentsViewScale();

		setFragmentsViewSortOption();
	}

	protected boolean showsSelectedFragments() {
		return true;
	}

	public void highlightFragment(Long id) {
		getContext().setFlashAttribute(SK_HIGHLIGHTED_FRAGMENT, id);
	}

	public static void highlightFragment(Long id, Context context) {
		context.setFlashAttribute(SK_HIGHLIGHTED_FRAGMENT, id);
	}
{'fraction_non_alphanumeric': 0.10048342541436464, 'fraction_numerical': 0.0, 'mean_word_length': 6.2322097378277155, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1118534', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1830, 'n_words': 322}