package devopsdistilled.operp.client.items.panes;

import java.util.List;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import net.miginfocom.swing.MigLayout;
import devopsdistilled.operp.client.abstracts.SubTaskPane;
import devopsdistilled.operp.client.abstracts.libs.BeanTableModel;
import devopsdistilled.operp.client.items.models.observers.CategoryModelObserver;
import devopsdistilled.operp.client.items.panes.models.observers.ListCategoryPaneModelObserver;
import devopsdistilled.operp.server.data.entity.items.Category;

public class ListCategoryPane extends SubTaskPane implements
		ListCategoryPaneModelObserver, CategoryModelObserver {

	private final JPanel pane;

	private final JTable table;
	BeanTableModel<Category> tableModel;

	public ListCategoryPane() {
		pane = new JPanel(new MigLayout("debug, fill"));

		tableModel = new BeanTableModel<>(Category.class);
		table = new JTable(tableModel);

		final JScrollPane scrollPane = new JScrollPane(table,
				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		pane.add(scrollPane, "grow");
	}

	@Override
	public JComponent getPane() {
		return pane;
	}

	@Override
	public void updateCategories(List<Category> categories) {
		if (tableModel.getRowCount() != 0) {
			int lastRow = tableModel.getRowCount() - 1;
			tableModel.removeRowRange(0, lastRow);
		}

		tableModel.insertRows(0, categories);
	}
}

@@ -60,19 +60,117 @@
 ava.
-util.List;%0A
+awt.event.MouseAdapter;%0Aimport java.awt.event.MouseEvent;%0Aimport java.util.List;%0A%0Aimport javax.inject.Inject;
 %0Aimp
@@ -282,16 +282,90 @@
 .JTable;
+%0Aimport javax.swing.ListSelectionModel;%0Aimport javax.swing.SwingUtilities;
 %0A%0Aimport
@@ -597,32 +597,109 @@
 yModelObserver;%0A
+import devopsdistilled.operp.client.items.panes.details.CategoryDetailsPane;%0A
 import devopsdis
@@ -962,16 +962,76 @@
 rver %7B%0A%0A
+%09@Inject%0A%09private CategoryDetailsPane categoryDetailsPane;%0A%0A
 %09private
@@ -1286,16 +1286,436 @@
 eModel);
+%0A%09%09table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);%0A%0A%09%09table.addMouseListener(new MouseAdapter() %7B%0A%09%09%09@Override%0A%09%09%09public void mousePressed(MouseEvent e) %7B%0A%09%09%09%09if (SwingUtilities.isLeftMouseButton(e)%0A%09%09%09%09%09%09&& e.getClickCount() == 2%0A%09%09%09%09%09%09&& table.getSelectedRow() != -1) %7B%0A%0A%09%09%09%09%09Category category = tableModel.getRow(table%0A%09%09%09%09%09%09%09.getSelectedRow());%0A%0A%09%09%09%09%09categoryDetailsPane.show(category);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);
 %0A%0A%09%09fina

Bring DetailsPane upon double click