summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-05-20 17:58:16 -0400
commit40a9d99496e098562f090fb7ffce9e749011b131 (patch)
tree437df24d65470582e943e494a52db8ed65a881ae /projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java
parentff072dfe782f6f22123cd4ba050828d35c0d0fbd (diff)
Formatting pass
Diffstat (limited to 'projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java')
-rw-r--r--projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java372
1 files changed, 158 insertions, 214 deletions
diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java
index d61d8ff..c5f596b 100644
--- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java
+++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TreeController.java
@@ -27,259 +27,203 @@ import net.wotonomy.ui.swing.util.ObjectInspector;
import net.wotonomy.ui.swing.util.WindowUtilities;
/**
-* A simple editor panel with a few textfields.
-*/
-public class TreeController implements ActionListener
-{
- final EODisplayGroup group;
- final EODisplayGroup titlesGroup;
- final EODisplayGroup detailGroup;
- final EOEditingContext editingContext;
-
- public TreeController( EODataSource aDataSource )
- {
- titlesGroup = new EODisplayGroup();
- group = new EODisplayGroup();
- detailGroup = new EODisplayGroup();
- titlesGroup.setDataSource( aDataSource );
- editingContext = aDataSource.editingContext();
- init();
- }
-
- public TreeController( EOEditingContext aContext,
- EODisplayGroup aTitlesGroup, EODisplayGroup aChildGroup )
- {
- titlesGroup = aTitlesGroup;
- group = aChildGroup;
- detailGroup = new EODisplayGroup();
- editingContext = aContext;
- init();
- }
-
- public void init()
- {
+ * A simple editor panel with a few textfields.
+ */
+public class TreeController implements ActionListener {
+ final EODisplayGroup group;
+ final EODisplayGroup titlesGroup;
+ final EODisplayGroup detailGroup;
+ final EOEditingContext editingContext;
+
+ public TreeController(EODataSource aDataSource) {
+ titlesGroup = new EODisplayGroup();
+ group = new EODisplayGroup();
+ detailGroup = new EODisplayGroup();
+ titlesGroup.setDataSource(aDataSource);
+ editingContext = aDataSource.editingContext();
+ init();
+ }
+
+ public TreeController(EOEditingContext aContext, EODisplayGroup aTitlesGroup, EODisplayGroup aChildGroup) {
+ titlesGroup = aTitlesGroup;
+ group = aChildGroup;
+ detailGroup = new EODisplayGroup();
+ editingContext = aContext;
+ init();
+ }
+
+ public void init() {
final TreePanel treePanel = new TreePanel();
- treePanel.panel.setBorder(
- BorderFactory.createCompoundBorder(
- BorderFactory.createRaisedBevelBorder(),
- BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) ) );
- treePanel.setBorder(
- BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
- ButtonPanel okPanel = new ButtonPanel(
- new String[] { "Refresh", "Commit" } );
- treePanel.add( okPanel, BorderLayout.SOUTH );
-/*
-
- // set up renderer
- IconCellRenderer iconRenderer = new IconCellRenderer()
- {
- private Icon icon = UIManager.getIcon("FileChooser.homeFolderIcon");
- public Icon getIconForContext(
- JComponent container, Object value,
- int row, int col,
- boolean isSelected, boolean hasFocus,
- boolean isExpanded, boolean isLeaf )
- {
- return icon;
- }
- };
- treePanel.tree.setCellRenderer( iconRenderer );
-
- // enable icon clicking
- treePanel.tree.setCellEditor( iconRenderer );
- iconRenderer.addActionListener( this );
-*/
-
- treePanel.tree.setEditable( true );
-
- // set up display groups
-
- titlesGroup.fetch();
+ treePanel.panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
+ BorderFactory.createEmptyBorder(10, 10, 10, 10)));
+ treePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ ButtonPanel okPanel = new ButtonPanel(new String[] { "Refresh", "Commit" });
+ treePanel.add(okPanel, BorderLayout.SOUTH);
+ /*
+ *
+ * // set up renderer IconCellRenderer iconRenderer = new IconCellRenderer() {
+ * private Icon icon = UIManager.getIcon("FileChooser.homeFolderIcon"); public
+ * Icon getIconForContext( JComponent container, Object value, int row, int col,
+ * boolean isSelected, boolean hasFocus, boolean isExpanded, boolean isLeaf ) {
+ * return icon; } }; treePanel.tree.setCellRenderer( iconRenderer );
+ *
+ * // enable icon clicking treePanel.tree.setCellEditor( iconRenderer );
+ * iconRenderer.addActionListener( this );
+ */
+
+ treePanel.tree.setEditable(true);
+
+ // set up display groups
+
+ titlesGroup.fetch();
// text associations
EOAssociation ta;
-
- ta = new TreeAssociation( treePanel.tree, "People" );
- ta.bindAspect( EOAssociation.TitlesAspect, titlesGroup, "fullName" );
- ta.bindAspect( EOAssociation.ChildrenAspect, group, "childList" );
- ta.bindAspect( EOAssociation.IsLeafAspect, titlesGroup, "childCount" );
+
+ ta = new TreeAssociation(treePanel.tree, "People");
+ ta.bindAspect(EOAssociation.TitlesAspect, titlesGroup, "fullName");
+ ta.bindAspect(EOAssociation.ChildrenAspect, group, "childList");
+ ta.bindAspect(EOAssociation.IsLeafAspect, titlesGroup, "childCount");
// ta.bindAspect( EOAssociation.IsLeafAspect, null, "false" );
ta.establishConnection();
- treePanel.tree.setEditable( true );
-
- ta = new TextAssociation( treePanel.editPanel.firstNameField );
- ta.bindAspect( EOAssociation.ValueAspect, group, "firstName" );
+ treePanel.tree.setEditable(true);
+
+ ta = new TextAssociation(treePanel.editPanel.firstNameField);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "firstName");
ta.establishConnection();
-
- ta = new TextAssociation( treePanel.editPanel.middleNameField );
- ta.bindAspect( EOAssociation.ValueAspect, group, "middleName" );
+
+ ta = new TextAssociation(treePanel.editPanel.middleNameField);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "middleName");
ta.establishConnection();
-
- ta = new TextAssociation( treePanel.editPanel.lastNameField );
- ta.bindAspect( EOAssociation.ValueAspect, group, "lastName" );
+
+ ta = new TextAssociation(treePanel.editPanel.lastNameField);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "lastName");
ta.establishConnection();
- ta = new RadioPanelAssociation( treePanel.editPanel.yearRadioPanel );
- ta.bindAspect( EOAssociation.ValueAspect, group, "createDate.year" );
-
+ ta = new RadioPanelAssociation(treePanel.editPanel.yearRadioPanel);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "createDate.year");
+
EODisplayGroup yearTitles = new EODisplayGroup();
- yearTitles.setObjectArray( new NSArray(
- new Object[] { "1999", "2000", "2001" } ) );
- ta.bindAspect( EOAssociation.TitlesAspect, yearTitles, "" );
-
+ yearTitles.setObjectArray(new NSArray(new Object[] { "1999", "2000", "2001" }));
+ ta.bindAspect(EOAssociation.TitlesAspect, yearTitles, "");
+
EODisplayGroup yearObjects = new EODisplayGroup();
- yearObjects.setObjectArray( new NSArray(
- new Object[] { new Integer( 99 ), new Integer( 100 ), new Integer( 101 ) } ) );
- ta.bindAspect( EOAssociation.ObjectsAspect, yearObjects, "" );
-
+ yearObjects.setObjectArray(new NSArray(new Object[] { new Integer(99), new Integer(100), new Integer(101) }));
+ ta.bindAspect(EOAssociation.ObjectsAspect, yearObjects, "");
+
ta.establishConnection();
// detail group
-
- ta = new MasterDetailAssociation( detailGroup );
- ta.bindAspect( EOAssociation.ParentAspect, group, "childList" );
+
+ ta = new MasterDetailAssociation(detailGroup);
+ ta.bindAspect(EOAssociation.ParentAspect, group, "childList");
ta.establishConnection();
-
- ta = new ListAssociation( treePanel.editPanel.list );
- ta.bindAspect( EOAssociation.TitlesAspect, detailGroup, "fullName" );
+
+ ta = new ListAssociation(treePanel.editPanel.list);
+ ta.bindAspect(EOAssociation.TitlesAspect, detailGroup, "fullName");
ta.establishConnection();
-
+
// display group action associations
- AbstractButton addButton = (AbstractButton)
- treePanel.editPanel.addPanel.getButton( "Add" );
- addButton.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- Object testObject = new TestObject();
- editingContext.insertObject( testObject );
- detailGroup.insertObjectAtIndex( testObject, 0 );
+ AbstractButton addButton = (AbstractButton) treePanel.editPanel.addPanel.getButton("Add");
+ addButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ Object testObject = new TestObject();
+ editingContext.insertObject(testObject);
+ detailGroup.insertObjectAtIndex(testObject, 0);
}
- } );
-
- AbstractButton removeButton = (AbstractButton)
- treePanel.editPanel.addPanel.getButton( "Remove" );
- removeButton.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- if ( detailGroup.selectedObject() != null )
- detailGroup.deleteSelection();
+ });
+
+ AbstractButton removeButton = (AbstractButton) treePanel.editPanel.addPanel.getButton("Remove");
+ removeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ if (detailGroup.selectedObject() != null)
+ detailGroup.deleteSelection();
}
- } );
-
- // ok / cancel buttons
-
- AbstractButton button;
-
- button = (AbstractButton)
- okPanel.getButton( "Commit" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- editingContext.saveChanges();
+ });
+
+ // ok / cancel buttons
+
+ AbstractButton button;
+
+ button = (AbstractButton) okPanel.getButton("Commit");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ editingContext.saveChanges();
}
- } );
-
- button = (AbstractButton)
- okPanel.getButton( "Refresh" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- editingContext.revert();
+ });
+
+ button = (AbstractButton) okPanel.getButton("Refresh");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ editingContext.revert();
// editingContext.invalidateAllObjects();
}
- } );
-
-
-/*
- AbstractButton refreshButton = (AbstractButton)
- treePanel.editPanel.addPanel.getButton( "Refresh" );
- refreshButton.addActionListener( new ActionListener()
- {
- int count = 0;
- public void actionPerformed( ActionEvent evt )
- {
- EODisplayGroup displayGroup = (EODisplayGroup)
- treePanel.tree.getSelectionPath().getLastPathComponent();
-// displayGroup.insertObjectAtIndex( new TestObject(), 0 );
-// displayGroup.deleteObjectAtIndex( 0 );
- List sortOrderings = new LinkedList();
- if ( count++ % 2 == 0 )
- {
- sortOrderings.add( new EOSortOrdering(
- "lastName", EOSortOrdering.CompareAscending ) );
- }
- else
- {
- sortOrderings.add( new EOSortOrdering(
- "lastName", EOSortOrdering.CompareDescending ) );
- }
- displayGroup.setSortOrderings( sortOrderings );
- displayGroup.updateDisplayedObjects();
- }
- } );
-*/
-/*
- ta = new DisplayGroupActionAssociation(
- treePanel.editPanel.addPanel.getButton( "Remove" ) );
- ta.bindAspect( EOAssociation.ActionAspect, detailGroup, "deleteSelection" );
- ta.establishConnection();
-
- ta = new DisplayGroupActionAssociation(
- treePanel.editPanel.addPanel.getButton( "Refresh" ) );
- ta.bindAspect( EOAssociation.ActionAspect, group, "updateDisplayedObjects" );
- ta.establishConnection();
-*/
+ });
+
+ /*
+ * AbstractButton refreshButton = (AbstractButton)
+ * treePanel.editPanel.addPanel.getButton( "Refresh" );
+ * refreshButton.addActionListener( new ActionListener() { int count = 0; public
+ * void actionPerformed( ActionEvent evt ) { EODisplayGroup displayGroup =
+ * (EODisplayGroup) treePanel.tree.getSelectionPath().getLastPathComponent(); //
+ * displayGroup.insertObjectAtIndex( new TestObject(), 0 ); //
+ * displayGroup.deleteObjectAtIndex( 0 ); List sortOrderings = new LinkedList();
+ * if ( count++ % 2 == 0 ) { sortOrderings.add( new EOSortOrdering( "lastName",
+ * EOSortOrdering.CompareAscending ) ); } else { sortOrderings.add( new
+ * EOSortOrdering( "lastName", EOSortOrdering.CompareDescending ) ); }
+ * displayGroup.setSortOrderings( sortOrderings );
+ * displayGroup.updateDisplayedObjects(); } } );
+ */
+ /*
+ * ta = new DisplayGroupActionAssociation(
+ * treePanel.editPanel.addPanel.getButton( "Remove" ) ); ta.bindAspect(
+ * EOAssociation.ActionAspect, detailGroup, "deleteSelection" );
+ * ta.establishConnection();
+ *
+ * ta = new DisplayGroupActionAssociation(
+ * treePanel.editPanel.addPanel.getButton( "Refresh" ) ); ta.bindAspect(
+ * EOAssociation.ActionAspect, group, "updateDisplayedObjects" );
+ * ta.establishConnection();
+ */
// add mouse listener for list
-
- treePanel.editPanel.list.addMouseListener( new MouseAdapter()
- {
- public void mouseClicked(MouseEvent e)
- {
- if ( e.getClickCount() == 2 )
- {
+
+ treePanel.editPanel.list.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
Object item = detailGroup.selectedObject();
- if ( item != null )
- {
- new InspectorController( item );
- }
+ if (item != null) {
+ new InspectorController(item);
+ }
}
}
});
// launch
-
+
JDialog d = new JDialog();
- d.getContentPane().add( treePanel );
- d.setTitle( "Tree Panel" );
+ d.getContentPane().add(treePanel);
+ d.setTitle("Tree Panel");
d.pack();
- WindowUtilities.cascade( d );
+ WindowUtilities.cascade(d);
d.show();
- // workaround for memory issues on jdk1.2.2
- d.addWindowListener( new WindowAdapter()
- {
+ // workaround for memory issues on jdk1.2.2
+ d.addWindowListener(new WindowAdapter() {
// exit on close
- public void windowClosing(WindowEvent e)
- {
- ((JDialog)e.getWindow()).getContentPane().removeAll();
+ public void windowClosing(WindowEvent e) {
+ ((JDialog) e.getWindow()).getContentPane().removeAll();
}
});
}
-
- public void actionPerformed( ActionEvent evt )
- {
- Object item = group.selectedObject();
- if ( item != null )
- {
+
+ public void actionPerformed(ActionEvent evt) {
+ Object item = group.selectedObject();
+ if (item != null) {
// new InspectorController( item );
- new ObjectInspector( item );
- }
- }
-
+ new ObjectInspector(item);
+ }
+ }
+
}