<commit_before>package goodsbase.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import goodsbase.model.Category;
import goodsbase.model.DataLoadException;
import goodsbase.model.DataLoader;
import goodsbase.model.Warehouse;


/**Category tree widget
 * @author Daria
 */

public class CategoryTreeBuilder {		
	
	public static JTree getTree() {
		DefaultMutableTreeNode root = new DefaultMutableTreeNode();
		JTree tree;
		try {
			Set<Category> categories = Category.load();
			if(categories.size()>0) {
				buildTree(categories, root);
			} else {
				root.setUserObject("Right-click to create the first category");
			}
			
			/*pop-up messages*/
			tree = new JTree(root){<commit_msg>remove unused imports 	modified:   src/goodsbase/ui/CategoryTreeBuilder.java<commit_after>package goodsbase.ui;

import goodsbase.model.Category;
import goodsbase.model.DataLoadException;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;


/**Category tree widget
 * @author Daria
 */

public class CategoryTreeBuilder {		
	
	public static JTree getTree() {
		DefaultMutableTreeNode root = new DefaultMutableTreeNode();
		JTree tree;
		try {
			Set<Category> categories = Category.load();
			if(categories.size()>0) {
				buildTree(categories, root);
			} else {
				root.setUserObject("Right-click to create the first category");
			}
			
			/*pop-up messages*/
			tree = new JTree(root){
{'fraction_non_alphanumeric': 0.10960105217010083, 'fraction_numerical': 0.0008768084173608067, 'mean_word_length': 4.791878172588833, 'pattern_counts': {'":': 0, '<': 5, '<?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': '400624', 'n_tokens_mistral': 755, 'n_tokens_neox': 694, 'n_words': 155}