<commit_before>package hr.fer.zemris.vhdllab.applets.schema2.gui.toolbars.selectcomponent;

import hr.fer.zemris.vhdllab.applets.schema2.enums.ECanvasState;
import hr.fer.zemris.vhdllab.applets.schema2.enums.EPropertyChange;
import hr.fer.zemris.vhdllab.applets.schema2.gui.SchemaMainPanel;
import hr.fer.zemris.vhdllab.applets.schema2.gui.canvas.CanvasToolbarLocalGUIController;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ILocalGuiController;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ISchemaComponent;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ISchemaController;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ISchemaInfo;
import hr.fer.zemris.vhdllab.applets.schema2.misc.Caseless;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class TabbedCTAddToolbar extends JTabbedPane implements
		PropertyChangeListener, ListSelectionListener {
	private static final long serialVersionUID = 2973973513115634524L;

	/**
	 * Debug/retail mode
	 */
	public static final boolean DEBUG_MODE = true;

	/**
	 * Schema controller
	 */
	private ISchemaController schemaController = null;

	/**
	 * Local controller za komunikaciju medju toolbarima
	 */
	private ILocalGuiController localController;

	/**
	 * Prvi ListBox
	 */
	private JList firstListBox = null;

	public TabbedCTAddToolbar(ISchemaController schemaController,
			ILocalGuiController localController) {
		super();

		if (schemaController == null) {
			throw new NullPointerException("Schema controller cannot be null!");
		}

		if (localController == null) {
			throw new NullPointerException(
					"Local GUI controller cannot be null!");
		}
		this.schemaController = schemaController;
		this.localController = localController;

		initToolbar();
	}

	/**
	 * 
	 */
	private void initToolbar() {
		setLayout(new BorderLayout());

		placePanel();
	}

	/**
	 * Stavlja stvoreni JTabbedPanel na toolbar
	 */
	private void placePanel() {
		// JTabbedPane tabbedPane = createTabbedPane();
		faceLiftTabbedPane(this);

		JPanel firstPanel = new JPanel(new GridLayout(1, 1));
		JPanel secondPanel = new JPanel(new GridLayout(1, 1));
		firstPanel.add(new JLabel("First panel", JLabel.CENTER));
		secondPanel.add(new JLabel("Second panel", JLabel.CENTER));

		this.add("Prvi panel", firstPanel);
		this.add("Drugi panel", secondPanel);

		// add(tabbedPane, BorderLayout.CENTER);
	}

	/**
	 * Uredjuje izgled JTabbedPane-a
	 * 
	 * @param tabbedPane
	 */
	private void faceLiftTabbedPane(JTabbedPane tabbedPane) {
		tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
	}

	/**
	 * Stvara JTabbedPane na temelju postojecih komponenti
	 * 
	 * @return JTabbedPane komponenti koje su razvrstane po kategorijama
	 */
	private JTabbedPane createTabbedPane() {
		// kategorija<->listboxmodel
		Map<String, DefaultListModel> categoryModel = createListModelByCategory();
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);

		for (Map.Entry<String, DefaultListModel> categoty : categoryModel
				.entrySet()) {
			JPanel pane = crateListBoxPane(categoty.getValue());

			// tabbedPane.add(categoty.getKey(), pane);
		}

		return tabbedPane;
	}

	private JPanel crateListBoxPane(DefaultListModel value) {
		JPanel pane = new JPanel(new BorderLayout());
		JList listBox = new JList(value);

		faceLiftListBox(listBox);
		listBox.addListSelectionListener(this);
		pane.add(listBox, BorderLayout.CENTER);

		if (firstListBox == null)
			firstListBox = listBox;

		return pane;
	}

	private void faceLiftListBox(JList listBox) {
		listBox.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		listBox.setLayoutOrientation(JList.VERTICAL);
	}

	private void refreshToolbar() {
		firstListBox = null;<commit_msg>popravljno (privremeno) ovo čudo sa JTabbedPane<commit_after>package hr.fer.zemris.vhdllab.applets.schema2.gui.toolbars.selectcomponent;

import hr.fer.zemris.vhdllab.applets.schema2.enums.ECanvasState;
import hr.fer.zemris.vhdllab.applets.schema2.enums.EPropertyChange;
import hr.fer.zemris.vhdllab.applets.schema2.gui.canvas.CanvasToolbarLocalGUIController;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ILocalGuiController;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ISchemaComponent;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ISchemaController;
import hr.fer.zemris.vhdllab.applets.schema2.interfaces.ISchemaInfo;
import hr.fer.zemris.vhdllab.applets.schema2.misc.Caseless;

import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.LinkedHashMap;
import java.util.Map;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class TabbedCTAddToolbar extends JPanel implements
		PropertyChangeListener, ListSelectionListener {
	private static final long serialVersionUID = 2973973513115634524L;

	/**
	 * Debug/retail mode
	 */
	public static final boolean DEBUG_MODE = true;

	/**
	 * Schema controller
	 */
	private ISchemaController schemaController = null;

	/**
	 * Local controller za komunikaciju medju toolbarima
	 */
	private ILocalGuiController localController;

	/**
	 * Prvi ListBox
	 */
	private JList firstListBox = null;

	public TabbedCTAddToolbar(ISchemaController schemaController,
			ILocalGuiController localController) {
		super();

		if (schemaController == null) {
			throw new NullPointerException("Schema controller cannot be null!");
		}

		if (localController == null) {
			throw new NullPointerException(
					"Local GUI controller cannot be null!");
		}
		this.schemaController = schemaController;
		this.localController = localController;

		initToolbar();
	}

	/**
	 * 
	 */
	private void initToolbar() {
		setLayout(new BorderLayout());

		placePanel();
	}

	/**
	 * Stavlja stvoreni JTabbedPanel na toolbar
	 */
	private void placePanel() {
		JTabbedPane tabbedPane = createTabbedPane();
		faceLiftTabbedPane(tabbedPane);

		add(tabbedPane, BorderLayout.CENTER);
	}

	/**
	 * Uredjuje izgled JTabbedPane-a
	 * 
	 * @param tabbedPane
	 */
	private void faceLiftTabbedPane(JTabbedPane tabbedPane) {
		tabbedPane.setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
	}

	/**
	 * Stvara JTabbedPane na temelju postojecih komponenti
	 * 
	 * @return JTabbedPane komponenti koje su razvrstane po kategorijama
	 */
	private JTabbedPane createTabbedPane() {
		// kategorija<->listboxmodel
		Map<String, DefaultListModel> categoryModel = createListModelByCategory();
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);

		for (Map.Entry<String, DefaultListModel> categoty : categoryModel
				.entrySet()) {
			JPanel pane = crateListBoxPane(categoty.getValue());

			tabbedPane.addTab(categoty.getKey(), pane);
		}

		return tabbedPane;
	}

	private JPanel crateListBoxPane(DefaultListModel value) {
		JPanel pane = new JPanel(new BorderLayout());
		JList listBox = new JList(value);

		faceLiftListBox(listBox);
		listBox.addListSelectionListener(this);
		pane.add(listBox, BorderLayout.CENTER);

		if (firstListBox == null)
			firstListBox = listBox;

		return pane;
	}

	private void faceLiftListBox(JList listBox) {
		listBox.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		listBox.setLayoutOrientation(JList.VERTICAL);
	}

	private void refreshToolbar() {
		firstListBox = null;
{'fraction_non_alphanumeric': 0.10063371356147022, 'fraction_numerical': 0.007731305449936629, 'mean_word_length': 5.098145285935085, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2021847', 'n_tokens_mistral': 2788, 'n_tokens_neox': 2591, 'n_words': 484}