package devopsdistilled.operp.client.items.panes;

import java.util.List;

import javax.inject.Inject;
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.items.models.impl.ItemTableModel;
import devopsdistilled.operp.client.items.models.observers.ItemModelObserver;
import devopsdistilled.operp.client.items.panes.controllers.ListItemPaneController;
import devopsdistilled.operp.client.items.panes.models.observers.ListItemPaneModelObserver;
import devopsdistilled.operp.server.data.entity.items.Item;

public class ListItemPane extends SubTaskPane implements
		ListItemPaneModelObserver, ItemModelObserver {

	@SuppressWarnings("unused")
	@Inject
	private ListItemPaneController controller;

	private final JPanel pane;
	private final JTable table;
	private final ItemTableModel tableModel;

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

		tableModel = new ItemTableModel();
		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 updateItems(List<Item> items) {
		tableModel.setItems(items);
	}

}

@@ -44,16 +44,86 @@
 panes;%0A%0A
+import java.awt.event.MouseAdapter;%0Aimport java.awt.event.MouseEvent;%0A
 import j
@@ -282,16 +282,90 @@
 .JTable;
+%0Aimport javax.swing.ListSelectionModel;%0Aimport javax.swing.SwingUtilities;
 %0A%0Aimport
@@ -496,30 +496,27 @@
 ent.
-items.models.impl.Item
+abstracts.libs.Bean
 Tabl
@@ -653,42 +653,31 @@
 nes.
-controllers.ListItemPaneController
+details.ItemDetailsPane
 ;%0Aim
@@ -940,86 +940,55 @@
 %0A%0A%09@
-SuppressWarnings(%22unused%22)%0A%09@Inject%0A%09private ListItemPaneController controller
+Inject%0A%09private ItemDetailsPane itemDetailsPane
 ;%0A%0A%09
@@ -1014,16 +1014,17 @@
 l pane;%0A
+%0A
 %09private
@@ -1057,18 +1057,12 @@
 ate 
-final Item
+Bean
 Tabl
@@ -1067,16 +1067,22 @@
 bleModel
+%3CItem%3E
  tableMo
@@ -1175,72 +1175,419 @@
 able
-Model
  = new 
-Item
+J
 Table
-Model();%0A%09%09table = new JTable(tableModel);%0A
+();%0A%09%09table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);%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%09Item item = tableModel.getRow(table.getSelectedRow());%0A%0A%09%09%09%09%09itemDetailsPane.show(item);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);
 %0A%09%09f
@@ -1904,23 +1904,245 @@
 odel
-.setItems(items
+ = null;%0A%09%09tableModel = new BeanTableModel%3C%3E(Item.class, items);%0A%0A%09%09for (int i = 0; i %3C tableModel.getColumnCount(); i++) %7B%0A%09%09%09tableModel.setColumnEditable(i, false);%0A%09%09%7D%0A%0A%09%09tableModel.setModelEditable(false);%0A%09%09table.setModel(tableModel
 );%0A%09

Add event for ListItemPane