<commit_before>package de.fau.cs.mad.gamekobold.template_generator;

import de.fau.cs.mad.gamekobold.*;
import de.fau.cs.mad.gamekobold.character.CharacterEditActivity;
import de.fau.cs.mad.gamekobold.jackson.AbstractTable;
import de.fau.cs.mad.gamekobold.jackson.ContainerTable;
import de.fau.cs.mad.gamekobold.jackson.MatrixTable;
import de.fau.cs.mad.gamekobold.jackson.Table;
import de.fau.cs.mad.gamekobold.matrix.MatrixFragment;
import de.fau.cs.mad.gamekobold.template_generator.FolderElementData.element_type;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.graphics.drawable.Drawable;
//import android.support.v4.app.Fragment;
//import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class FolderFragment extends GeneralFragment {
	/*
	 * JACKSON START
	 */
	public ContainerTable jacksonTable;
	/*
	 * JACKSON END
	 */
	
	View view;
	public ListView lView;
	public ArrayList<FolderElementData> allData;
	
	Button buttonAdd;
	View mainView;
	public FolderElementAdapter dataAdapter;
	AlertDialog dialogCreateElement;
	View dialogViewCreateElement;
    boolean editable = true;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        editable = (getActivity() instanceof CharacterEditActivity? false:true);
		Log.d("FolderFragment","onCreate; editable set to: " + editable);
        // nullcheck needed for jackson inflation. creates allData before onCreate is called
        if(allData == null) {
        	allData = new ArrayList<FolderElementData>();
        }
        // nullcheck needed for jackson inflation. creates dataAdapter before onCreate is called
        if(dataAdapter == null) {
        	dataAdapter = new FolderElementAdapter((SlideoutNavigationActivity)getActivity(), editable, R.layout.template_listview_row, allData);
            /*
             * JACKSON START
             */
            dataAdapter.jacksonTable = jacksonTable;
            /*
             * JACKSON END
             */
        }
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(SlideoutNavigationActivity.theActiveActivity);
        LayoutInflater inflater = SlideoutNavigationActivity.theActiveActivity.getLayoutInflater();
        dialogViewCreateElement = inflater.inflate(R.layout.alertdialog_template_generator_add_new_element, null);
        final EditText nameInput = (EditText) dialogViewCreateElement.findViewById(R.id.enter_name_of_element);
        nameInput.setSingleLine();
        alertDialogBuilder.setView(dialogViewCreateElement);
        alertDialogBuilder.setCancelable(true);
        ImageButton createTable = (ImageButton) dialogViewCreateElement.findViewById(R.id.create_table);<commit_msg>set FolderFragment as not editable if it deals with CharacterPlayActivity<commit_after>package de.fau.cs.mad.gamekobold.template_generator;

import de.fau.cs.mad.gamekobold.*;
import de.fau.cs.mad.gamekobold.character.CharacterEditActivity;
import de.fau.cs.mad.gamekobold.game.CharacterPlayActivity;
import de.fau.cs.mad.gamekobold.jackson.AbstractTable;
import de.fau.cs.mad.gamekobold.jackson.ContainerTable;
import de.fau.cs.mad.gamekobold.jackson.MatrixTable;
import de.fau.cs.mad.gamekobold.jackson.Table;
import de.fau.cs.mad.gamekobold.matrix.MatrixFragment;
import de.fau.cs.mad.gamekobold.template_generator.FolderElementData.element_type;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.graphics.drawable.Drawable;
//import android.support.v4.app.Fragment;
//import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class FolderFragment extends GeneralFragment {
	/*
	 * JACKSON START
	 */
	public ContainerTable jacksonTable;
	/*
	 * JACKSON END
	 */
	
	View view;
	public ListView lView;
	public ArrayList<FolderElementData> allData;
	
	Button buttonAdd;
	View mainView;
	public FolderElementAdapter dataAdapter;
	AlertDialog dialogCreateElement;
	View dialogViewCreateElement;
    boolean editable = true;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        editable = (getActivity() instanceof CharacterEditActivity || getActivity() instanceof CharacterPlayActivity? false:true);
		Log.d("FolderFragment","onCreate; editable set to: " + editable);
        // nullcheck needed for jackson inflation. creates allData before onCreate is called
        if(allData == null) {
        	allData = new ArrayList<FolderElementData>();
        }
        // nullcheck needed for jackson inflation. creates dataAdapter before onCreate is called
        if(dataAdapter == null) {
        	dataAdapter = new FolderElementAdapter((SlideoutNavigationActivity)getActivity(), editable, R.layout.template_listview_row, allData);
            /*
             * JACKSON START
             */
            dataAdapter.jacksonTable = jacksonTable;
            /*
             * JACKSON END
             */
        }
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(SlideoutNavigationActivity.theActiveActivity);
        LayoutInflater inflater = SlideoutNavigationActivity.theActiveActivity.getLayoutInflater();
        dialogViewCreateElement = inflater.inflate(R.layout.alertdialog_template_generator_add_new_element, null);
        final EditText nameInput = (EditText) dialogViewCreateElement.findViewById(R.id.enter_name_of_element);
        nameInput.setSingleLine();
        alertDialogBuilder.setView(dialogViewCreateElement);
        alertDialogBuilder.setCancelable(true);
        ImageButton createTable = (ImageButton) dialogViewCreateElement.findViewById(R.id.create_table);
{'fraction_non_alphanumeric': 0.08927473878303627, 'fraction_numerical': 0.0006146281499692685, 'mean_word_length': 4.190590111642743, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4441968', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1800, 'n_words': 351}