From 02bc52037e9ccccca672d6156d9c325c74fe28b3 Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 1 Jul 2024 17:27:48 -0400 Subject: Update a whole bunch of things Yeah... not a great commit message. t.b.h, I could maybe've split the commit into more parts; but that would be quite a lot off effort and would have a pretty decent chance of at least one of the commits leaving the repository in a non-working state. For the future, will want to try and commit more often so there aren't these mega-commits where it's just "a whole bunch of stuff changed" --- .../main/java/net/wotonomy/test/DataObjectStore.java | 12 ++++++++++++ .../src/main/java/net/wotonomy/test/Test.java | 18 ++++++++---------- .../main/java/net/wotonomy/test/TestController.java | 2 ++ .../main/java/net/wotonomy/test/TestObjectStore.java | 12 ++++++++++++ .../src/main/java/net/wotonomy/test/TestPanel.java | 10 +++++----- 5 files changed, 39 insertions(+), 15 deletions(-) (limited to 'projects/net.wotonomy.test/src/main/java/net/wotonomy') diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/DataObjectStore.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/DataObjectStore.java index ac5ee44..a65e2d5 100644 --- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/DataObjectStore.java +++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/DataObjectStore.java @@ -39,6 +39,7 @@ public class DataObjectStore extends EOObjectStore { /** * This implementation returns an appropriately configured array fault. */ + @Override public NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationship, EOEditingContext aContext) { return new ArrayFault(aGlobalID, aRelationship, aContext); } @@ -46,6 +47,7 @@ public class DataObjectStore extends EOObjectStore { /** * This implementation returns the actual object for the specified id. */ + @Override public Object faultForGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) { System.out.println("DataObjectStore.faultForGlobalID: * reading object * : " + aGlobalID); Object result = soup.getObjectByKey(((DataKeyID) aGlobalID).getKey()); @@ -66,6 +68,7 @@ public class DataObjectStore extends EOObjectStore { * values from the specified dictionary. The fault should belong to the * specified editing context. */ + @Override public Object faultForRawRow(Map aDictionary, String anEntityName, EOEditingContext aContext) { // TODO: faults are not yet supported throw new WotonomyException("Faults are not yet supported."); @@ -76,6 +79,7 @@ public class DataObjectStore extends EOObjectStore { * values appropriate for the specified id. The object should belong to the * specified editing context. This method is called to populate faults. */ + @Override public void initializeObject(Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext) { if (aGlobalID.isTemporary()) { // TODO: this should never happen, but it does now until we get @@ -100,6 +104,7 @@ public class DataObjectStore extends EOObjectStore { * Remove all values from all objects in memory, turning them into faults, and * posts a notification that all objects have been invalidated. */ + @Override public void invalidateAllObjects() { // does nothing except post notification @@ -111,6 +116,7 @@ public class DataObjectStore extends EOObjectStore { * Removes values with the specified ids from memory, turning them into faults, * and posts a notification that those objects have been invalidated. */ + @Override public void invalidateObjectsWithGlobalIDs(List aList) { // does nothing } @@ -118,6 +124,7 @@ public class DataObjectStore extends EOObjectStore { /** * Returns false because locking is not permitted. */ + @Override public boolean isObjectLockedWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) { return false; } @@ -125,6 +132,7 @@ public class DataObjectStore extends EOObjectStore { /** * Does nothing because locking is not permitted. */ + @Override public void lockObjectWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) { // does nothing } @@ -137,6 +145,7 @@ public class DataObjectStore extends EOObjectStore { * key must produce a result of type Collection for the source object or an * exception is thrown. */ + @Override public NSArray objectsForSourceGlobalID(EOGlobalID aGlobalID, String aRelationship, EOEditingContext aContext) { System.out.println("DataObjectStore.objectsForSourceGlobalID: * reading object * : " + aGlobalID); Object object = soup.getObjectByKey(((DataKeyID) aGlobalID).getKey()); @@ -176,6 +185,7 @@ public class DataObjectStore extends EOObjectStore { * If any object is already registered in the specified context, it is not * refetched and that object should be used in the array. */ + @Override public NSArray objectsWithFetchSpecification(EOFetchSpecification aFetchSpec, EOEditingContext aContext) { // TODO: fetch specs are not yet supported @@ -202,6 +212,7 @@ public class DataObjectStore extends EOObjectStore { * Removes all values from the specified object, converting it into a fault for * the specified id. New or deleted objects should not be refaulted. */ + @Override public void refaultObject(Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext) { // TODO: faults are not yet supported // just re-initialize the object @@ -211,6 +222,7 @@ public class DataObjectStore extends EOObjectStore { /** * Writes all changes in the specified editing context to the respository. */ + @Override public void saveChangesInEditingContext(EOEditingContext aContext) { Object o; DataKeyID id; diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/Test.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/Test.java index 5b4533d..d262aad 100644 --- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/Test.java +++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/Test.java @@ -1,8 +1,6 @@ package net.wotonomy.test; import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; @@ -31,7 +29,7 @@ public class Test { // system l&f try { // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); - UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); +// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); // UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception e) { @@ -66,11 +64,7 @@ public class Test { menu.add("New"); menuItem = new JMenuItem("Save"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); - menuItem.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - controller.displayGroup.dataSource().editingContext().saveChanges(); - } - }); + menuItem.addActionListener(evt -> controller.displayGroup.dataSource().editingContext().saveChanges()); menu.add(menuItem); menu.add("Close"); @@ -84,12 +78,16 @@ public class Test { frame.getContentPane().add(testPanel, BorderLayout.CENTER); frame.setTitle("Test Frame"); - frame.setBounds(50, 50, 750, 500); - frame.show(); // comment out this to avoid memory leak from jdk1.2.2 bug + + frame.pack(); + frame.setSize(640, 480); + + frame.setVisible(true); // comment out this to avoid memory leak from jdk1.2.2 bug // add WindowListener for frame frame.addWindowListener(new WindowAdapter() { // exit on close + @Override public void windowClosing(WindowEvent e) { System.exit(0); } diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestController.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestController.java index 83fe97c..c91739c 100644 --- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestController.java +++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestController.java @@ -73,8 +73,10 @@ public class TestController implements ActionListener { column = new TableColumn(); column.setHeaderValue("First"); IconCellRenderer iconRenderer = new IconCellRenderer() { + private static final long serialVersionUID = 6287856165157518684L; private Icon icon = UIManager.getIcon("FileChooser.homeFolderIcon"); + @Override public Icon getIconForContext(JComponent container, Object value, int row, int col, boolean isSelected, boolean hasFocus, boolean isExpanded, boolean isLeaf) { return icon; diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestObjectStore.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestObjectStore.java index 316fcf7..cbd16fa 100644 --- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestObjectStore.java +++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestObjectStore.java @@ -34,6 +34,7 @@ public class TestObjectStore extends EOObjectStore { /** * This implementation simply returns objectsWithSourceGlobalID. */ + @Override public NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, String aRelationship, EOEditingContext aContext) { return objectsForSourceGlobalID(aGlobalID, aRelationship, aContext); } @@ -41,6 +42,7 @@ public class TestObjectStore extends EOObjectStore { /** * This implementation returns the actual object for the specified id. */ + @Override public Object faultForGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) { System.out.println("TestObjectStore: * reading object * : " + aGlobalID); return soup.getObjectByKey(((DataKeyID) aGlobalID).getKey()); @@ -51,6 +53,7 @@ public class TestObjectStore extends EOObjectStore { * values from the specified dictionary. The fault should belong to the * specified editing context. */ + @Override public Object faultForRawRow(Map aDictionary, String anEntityName, EOEditingContext aContext) { // TODO: faults are not yet supported throw new WotonomyException("Faults are not yet supported."); @@ -61,6 +64,7 @@ public class TestObjectStore extends EOObjectStore { * values appropriate for the specified id. The object should belong to the * specified editing context. This method is called to populate faults. */ + @Override public void initializeObject(Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext) { System.out.println("TestObjectStore: * reading object * : " + aGlobalID); Object original = soup.getObjectByKey(((DataKeyID) aGlobalID).getKey()); @@ -73,6 +77,7 @@ public class TestObjectStore extends EOObjectStore { * Remove all values from all objects in memory, turning them into faults, and * posts a notification that all objects have been invalidated. */ + @Override public void invalidateAllObjects() { // does nothing } @@ -81,6 +86,7 @@ public class TestObjectStore extends EOObjectStore { * Removes values with the specified ids from memory, turning them into faults, * and posts a notification that those objects have been invalidated. */ + @Override public void invalidateObjectsWithGlobalIDs(List aList) { // does nothing } @@ -88,6 +94,7 @@ public class TestObjectStore extends EOObjectStore { /** * Returns false because locking is not permitted. */ + @Override public boolean isObjectLockedWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) { return false; } @@ -95,6 +102,7 @@ public class TestObjectStore extends EOObjectStore { /** * Does nothing because locking is not permitted. */ + @Override public void lockObjectWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext) { // does nothing } @@ -104,6 +112,7 @@ public class TestObjectStore extends EOObjectStore { * for the specified property relationship. Faults are not allowed in the array. * All objects should belong to the specified editing context. */ + @Override public NSArray objectsForSourceGlobalID(EOGlobalID aGlobalID, String aRelationship, EOEditingContext aContext) { // TODO: relationships are not yet supported throw new WotonomyException("Relationships are not yet supported."); @@ -116,6 +125,7 @@ public class TestObjectStore extends EOObjectStore { * the specified context, it is not refetched and that object should be used in * the array. */ + @Override public NSArray objectsWithFetchSpecification(EOFetchSpecification aFetchSpec, EOEditingContext aContext) { // TODO: fetch specs are not yet supported @@ -144,6 +154,7 @@ public class TestObjectStore extends EOObjectStore { * Removes all values from the specified object, converting it into a fault for * the specified id. New or deleted objects should not be refaulted. */ + @Override public void refaultObject(Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext) { // TODO: faults are not yet supported // just re-initialize the object @@ -153,6 +164,7 @@ public class TestObjectStore extends EOObjectStore { /** * Writes all changes in the specified editing context to the respository. */ + @Override public void saveChangesInEditingContext(EOEditingContext aContext) { Object o; DataKeyID id; diff --git a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestPanel.java b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestPanel.java index 78eedb6..a85593e 100644 --- a/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestPanel.java +++ b/projects/net.wotonomy.test/src/main/java/net/wotonomy/test/TestPanel.java @@ -66,13 +66,13 @@ public class TestPanel extends JPanel { infoPanel.addRow("Name", new Component[] { firstNameField, middleNameField, lastNameField, checkbox }); // date comboboxen - Vector datesList = new Vector(); + Vector datesList = new Vector<>(); for (int i = 1; i < 32; i++) - datesList.add(new Integer(i)); - dateBox = new JComboBox(datesList); + datesList.add(Integer.valueOf(i)); + dateBox = new JComboBox<>(datesList); dateBox.setEditable(true); - monthBox = new JComboBox(); - yearBox = new JComboBox(); + monthBox = new JComboBox<>(); + yearBox = new JComboBox<>(); infoPanel.addRow("Create Date", dateBox, monthBox, yearBox); // year slider -- cgit v1.2.3