summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java
diff options
context:
space:
mode:
Diffstat (limited to 'projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java')
-rw-r--r--projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java248
1 files changed, 107 insertions, 141 deletions
diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java
index b304ade..6a36db3 100644
--- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java
+++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/EditController.java
@@ -28,187 +28,153 @@ import net.wotonomy.ui.swing.components.ButtonPanel;
import net.wotonomy.ui.swing.util.WindowUtilities;
/**
-* A simple editor panel with a few textfields.
-*/
-public class EditController
-{
- EODisplayGroup group;
- JDialog dialog;
-
- public EditController( EODataSource aDataSource )
- {
+ * A simple editor panel with a few textfields.
+ */
+public class EditController {
+ EODisplayGroup group;
+ JDialog dialog;
+
+ public EditController(EODataSource aDataSource) {
EditPanel editPanel = new EditPanel();
- editPanel.infoPanel.setBorder(
- BorderFactory.createCompoundBorder(
- BorderFactory.createRaisedBevelBorder(),
- BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) ) );
- editPanel.setBorder(
- BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
- ButtonPanel okPanel = new ButtonPanel(
- new String[] { "Revert", "Refault", "Refresh", "Commit" } );
- editPanel.add( okPanel, BorderLayout.SOUTH );
-
+ editPanel.infoPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
+ BorderFactory.createEmptyBorder(10, 10, 10, 10)));
+ editPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
+ ButtonPanel okPanel = new ButtonPanel(new String[] { "Revert", "Refault", "Refresh", "Commit" });
+ editPanel.add(okPanel, BorderLayout.SOUTH);
+
group = new EODisplayGroup();
- group.setDataSource( aDataSource );
- group.fetch();
+ group.setDataSource(aDataSource);
+ group.fetch();
group.selectNext();
-
+
// text associations
-
+
EOAssociation ta;
-
- ta = new TextAssociation( editPanel.firstNameField );
- ta.bindAspect( EOAssociation.ValueAspect, group, "firstName" );
+
+ ta = new TextAssociation(editPanel.firstNameField);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "firstName");
ta.establishConnection();
-
- ta = new TextAssociation( editPanel.middleNameField );
- ta.bindAspect( EOAssociation.ValueAspect, group, "middleName" );
+
+ ta = new TextAssociation(editPanel.middleNameField);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "middleName");
ta.establishConnection();
-
- ta = new TextAssociation( editPanel.lastNameField );
- ta.bindAspect( EOAssociation.ValueAspect, group, "lastName" );
+
+ ta = new TextAssociation(editPanel.lastNameField);
+ ta.bindAspect(EOAssociation.ValueAspect, group, "lastName");
ta.establishConnection();
-
+
// radio panels
-
- ta = new RadioPanelAssociation( editPanel.yearRadioPanel );
- ta.bindAspect( EOAssociation.ValueAspect, group, "createDate.year" );
-
+
+ ta = new RadioPanelAssociation(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
-
+
final EODisplayGroup detailGroup = new EODisplayGroup();
- detailGroup.setDataSource( new PropertyDataSource(
- aDataSource.editingContext(), TestObject.class ) );
-
- ta = new MasterDetailAssociation( detailGroup );
- ta.bindAspect( EOAssociation.ParentAspect, group, "childList" );
+ detailGroup.setDataSource(new PropertyDataSource(aDataSource.editingContext(), TestObject.class));
+
+ ta = new MasterDetailAssociation(detailGroup);
+ ta.bindAspect(EOAssociation.ParentAspect, group, "childList");
ta.establishConnection();
-
- ta = new ListAssociation( editPanel.list );
- ta.bindAspect( EOAssociation.TitlesAspect, detailGroup, "fullName" );
+
+ ta = new ListAssociation(editPanel.list);
+ ta.bindAspect(EOAssociation.TitlesAspect, detailGroup, "fullName");
ta.establishConnection();
-
+
// display group action associations
- AbstractButton button = (AbstractButton)
- editPanel.addPanel.getButton( "Add" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- detailGroup.insertNewObjectAtIndex( 0 );
+ AbstractButton button = (AbstractButton) editPanel.addPanel.getButton("Add");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ detailGroup.insertNewObjectAtIndex(0);
}
- } );
-
- ta = new DisplayGroupActionAssociation(
- editPanel.addPanel.getButton( "Remove" ) );
- ta.bindAspect( EOAssociation.ActionAspect, detailGroup, "deleteSelection" );
+ });
+
+ ta = new DisplayGroupActionAssociation(editPanel.addPanel.getButton("Remove"));
+ ta.bindAspect(EOAssociation.ActionAspect, detailGroup, "deleteSelection");
ta.establishConnection();
- // ok / cancel buttons
-
- button = (AbstractButton)
- okPanel.getButton( "Commit" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- group.dataSource().editingContext().saveChanges();
+ // ok / cancel buttons
+
+ button = (AbstractButton) okPanel.getButton("Commit");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ group.dataSource().editingContext().saveChanges();
}
- } );
-
- button = (AbstractButton)
- okPanel.getButton( "Refresh" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- group.dataSource().editingContext().invalidateAllObjects();
+ });
+
+ button = (AbstractButton) okPanel.getButton("Refresh");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ group.dataSource().editingContext().invalidateAllObjects();
}
- } );
-
- button = (AbstractButton)
- okPanel.getButton( "Refault" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
-/*
- Object o = group.displayedObjects().objectAtIndex( 0 );
- group.dataSource().editingContext().refaultObject(
- o,
- group.dataSource().editingContext().globalIDForObject( o ),
- group.dataSource().editingContext() );
-*/
- group.dataSource().editingContext().revert();
- group.dataSource().editingContext().refaultObjects();
+ });
+
+ button = (AbstractButton) okPanel.getButton("Refault");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ /*
+ * Object o = group.displayedObjects().objectAtIndex( 0 );
+ * group.dataSource().editingContext().refaultObject( o,
+ * group.dataSource().editingContext().globalIDForObject( o ),
+ * group.dataSource().editingContext() );
+ */
+ group.dataSource().editingContext().revert();
+ group.dataSource().editingContext().refaultObjects();
}
- } );
-
- button = (AbstractButton)
- okPanel.getButton( "Revert" );
- button.addActionListener( new ActionListener()
- {
- public void actionPerformed( ActionEvent evt )
- {
- group.dataSource().editingContext().revert();
+ });
+
+ button = (AbstractButton) okPanel.getButton("Revert");
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ group.dataSource().editingContext().revert();
}
- } );
-
+ });
+
// add mouse listener for list
-
- editPanel.list.addMouseListener( new MouseAdapter()
- {
- public void mouseClicked(MouseEvent e)
- {
- if ( e.getClickCount() == 2 )
- {
+
+ editPanel.list.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
Object item = detailGroup.selectedObject();
- if ( item != null )
- {
+ if (item != null) {
// new InspectorController( item );
-
- new EditController(
- new ChildDataSource(
- group.dataSource(), item ) );
- }
+
+ new EditController(new ChildDataSource(group.dataSource(), item));
+ }
}
}
});
-
+
// launch
-
+
dialog = new JDialog();
// add WindowListener for frame
- dialog.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
- dialog.getContentPane().add( editPanel );
- dialog.setTitle( "Edit Panel" );
+ dialog.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ dialog.getContentPane().add(editPanel);
+ dialog.setTitle("Edit Panel");
dialog.pack();
// dialog.setSize( 300, dialog.getSize().height );
- WindowUtilities.cascade( dialog );
+ WindowUtilities.cascade(dialog);
dialog.show();
- // workaround for memory issues on jdk1.2.2
- dialog.addWindowListener( new WindowAdapter()
- {
+ // workaround for memory issues on jdk1.2.2
+ dialog.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();
}
});
}
-
+
}