package me.coley.recaf.ui.component.editor;

import org.controlsfx.control.PropertySheet.Item;
import org.objectweb.asm.tree.ClassNode;

import javafx.scene.Node;
import javafx.scene.control.*;
import me.coley.event.Bus;
import me.coley.recaf.event.ClassRenameEvent;
import me.coley.recaf.ui.component.*;

/**
	 * String editor that also emits a ClassRenameEvent when the enter key is
	 * pressed.
	 * 
	 * @author Matt
	 *
	 * @param <T>
	 */
	public class ClassNameEditor<T extends String> extends StagedCustomEditor<T> {
		public ClassNameEditor(Item item) {
			super(item);
		}

		@Override
		public Node getEditor() {
			ReflectiveClassNodeItem refItem = (ReflectiveClassNodeItem) item;
			ClassNode cn = refItem.getNode();
			TextField txtName = new TextField();
			txtName.setText(cn.name);
			txtName.setOnAction(e -> rename(cn, txtName));
			// This works for when focus is lost, but I'm not sure if thats user
			// friendly...
			// If you type anything in and click anywhere else (or close the
			// tab) it will
			// do the rename action.
			//@formatter:off
			/*
			txtName.focusedProperty().addListener(new ChangeListener<Boolean>() {
				@Override
				public void changed(ObservableValue<? extends Boolean> focused, Boolean oldVal, Boolean newVal) {
					if (!newVal) {
						rename(cn, txtName);
					}
				}
			});
			*/
			//@formatter:on
			return txtName;
		}

		private void rename(ClassNode node, TextField txtName) {
			String text = txtName.getText();
			if (!txtName.isDisabled() && !text.equals(node.name)) {
				Bus.post(new ClassRenameEvent(node, node.name, text));
				// use disable property to prevent-double send
				txtName.setDisable(true);
			}
		}
	}
@@ -845,520 +845,8 @@
 ));%0A
-%09%09%09// This works for when focus is lost, but I'm not sure if thats user%0A%09%09%09// friendly...%0A%09%09%09// If you type anything in and click anywhere else (or close the%0A%09%09%09// tab) it will%0A%09%09%09// do the rename action.%0A%09%09%09//@formatter:off%0A%09%09%09/*%0A%09%09%09txtName.focusedProperty().addListener(new ChangeListener%3CBoolean%3E() %7B%0A%09%09%09%09@Override%0A%09%09%09%09public void changed(ObservableValue%3C? extends Boolean%3E focused, Boolean oldVal, Boolean newVal) %7B%0A%09%09%09%09%09if (!newVal) %7B%0A%09%09%09%09%09%09rename(cn, txtName);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%09%09%09*/%0A%09%09%09//@formatter:on%0A
 %09%09%09r

Remove unused commented out code for renaming classes