Commit c63ec38c authored by Dumoulin Nicolas's avatar Dumoulin Nicolas
Browse files

selection listener

parent a2909d88
......@@ -60,7 +60,7 @@
<Component class="javax.swing.JTable" name="jTable">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="DefaultOutlineModel.createOutlineModel(treeModel, new OhRowModel())" type="code"/>
<Connection code="outlineModel" type="code"/>
</Property>
</Properties>
<AuxValues>
......
......@@ -25,10 +25,15 @@ package fr.cemagref.ohoui.ui.nodesandpanels;
import fr.cemagref.ohoui.reflect.DefaultObjectIntrospector;
import fr.cemagref.ohoui.reflect.IntrospectionException;
import fr.cemagref.ohoui.reflect.OhOuiContext;
import fr.cemagref.ohoui.structure.OhObject;
import fr.cemagref.ohoui.structure.OhObjectComplex;
import fr.cemagref.ohoui.ui.panels.DefaultObjectEditor;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.netbeans.swing.outline.DefaultOutlineModel;
import org.netbeans.swing.outline.Outline;
import org.netbeans.swing.outline.OutlineModel;
/**
*
......@@ -36,16 +41,28 @@ import org.netbeans.swing.outline.Outline;
*/
public class NodesAndPanelsPanel extends JPanel {
private OutlineModel outlineModel;
private OhTreeModel treeModel;
/** Creates new form NodesAndPanelsPanel */
public NodesAndPanelsPanel(Object o) throws IntrospectionException {
OhObjectComplex ohObjectComplex = DefaultObjectIntrospector.introspect("test", o, new OhOuiContext());
treeModel = new OhTreeModel(ohObjectComplex);
outlineModel = DefaultOutlineModel.createOutlineModel(treeModel, new OhRowModel());
initComponents();
Outline outline = (Outline)jTable;
Outline outline = (Outline) jTable;
outline.setRenderDataProvider(new OhDataProvider());
outline.setModel(DefaultOutlineModel.createOutlineModel(treeModel, new OhRowModel()));
outline.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
// TODO wrong index is fetched
OhObject selectedObject = (OhObject) outlineModel.getValueAt(e.getLastIndex(), 0);
System.out.println(e.getLastIndex() + " - " + outlineModel.getValueAt(e.getLastIndex(), 0));
// TODO put object editors in cache indexed by nodes (or handled object)
jScrollPaneRight.setViewportView(new DefaultObjectEditor(selectedObject).getPanel());
}
});
}
/** This method is called from within the constructor to
......@@ -65,7 +82,7 @@ public class NodesAndPanelsPanel extends JPanel {
jSplitPane1.setDividerSize(5);
jSplitPane1.setRightComponent(jScrollPaneRight);
jTable.setModel(DefaultOutlineModel.createOutlineModel(treeModel, new OhRowModel()));
jTable.setModel(outlineModel);
jScrollPaneLeft.setViewportView(jTable);
jSplitPane1.setLeftComponent(jScrollPaneLeft);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment