diff --git a/.classpath b/.classpath
index 6c06bcb..f84f380 100644
--- a/.classpath
+++ b/.classpath
@@ -1,9 +1,25 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/buildGlumBin.jardesc b/buildGlumBin.jardesc
index 42edf92..a108912 100644
--- a/buildGlumBin.jardesc
+++ b/buildGlumBin.jardesc
@@ -4,15 +4,8 @@
-
-
-
-
-
-
-
diff --git a/buildGlumSrc.jardesc b/buildGlumSrc.jardesc
index 5659700..1fe7e90 100644
--- a/buildGlumSrc.jardesc
+++ b/buildGlumSrc.jardesc
@@ -4,15 +4,7 @@
-
-
-
-
-
-
-
-
diff --git a/lib/guava-12.0-sources.jar b/lib/guava-12.0-sources.jar
deleted file mode 100644
index f6e0301..0000000
Binary files a/lib/guava-12.0-sources.jar and /dev/null differ
diff --git a/lib/guava-12.0.jar b/lib/guava-12.0.jar
deleted file mode 100644
index fefd6b2..0000000
Binary files a/lib/guava-12.0.jar and /dev/null differ
diff --git a/lib/guava-18.0-sources.jar b/lib/guava-18.0-sources.jar
new file mode 100644
index 0000000..d97cc50
Binary files /dev/null and b/lib/guava-18.0-sources.jar differ
diff --git a/lib/guava-18.0.jar b/lib/guava-18.0.jar
new file mode 100644
index 0000000..8f89e49
Binary files /dev/null and b/lib/guava-18.0.jar differ
diff --git a/src/Manifest.txt b/src/Manifest.txt
deleted file mode 100644
index fcb7d37..0000000
--- a/src/Manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: lib/guava-12.0.jar lib/miglayout-3.7.2-sources.jar
diff --git a/src/glum/gui/GuiUtil.java b/src/glum/gui/GuiUtil.java
index 6158c85..35e17a9 100644
--- a/src/glum/gui/GuiUtil.java
+++ b/src/glum/gui/GuiUtil.java
@@ -1,16 +1,16 @@
package glum.gui;
-import glum.gui.icon.IconUtil;
-import glum.reflect.Function;
-import glum.reflect.FunctionRunnable;
-
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.Collection;
+
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.event.ChangeListener;
+import glum.gui.icon.IconUtil;
+import glum.reflect.Function;
+
public class GuiUtil
{
/**
@@ -144,12 +144,12 @@ public class GuiUtil
/**
* Creates a JComboBox with the specified settings
*/
- public static JComboBox createJComboBox(ActionListener aListener, Font aFont, Object... itemArr)
+ public static JComboBox createJComboBox(ActionListener aListener, Font aFont, Collection aItemL)
{
- JComboBox tmpBox;
+ JComboBox tmpBox;
- tmpBox = new JComboBox();
- for (Object aItem : itemArr)
+ tmpBox = new JComboBox();
+ for (G1 aItem : aItemL)
tmpBox.addItem(aItem);
if (aFont != null)
@@ -209,7 +209,7 @@ public class GuiUtil
/**
* Utility method for creating a visual thin divider
- *
+ *
* Typically added to MigLayout (or like manager) with: add(aComp, "growx,h 4!,span,wrap");
*/
public static JPanel createDivider()
@@ -652,7 +652,7 @@ public class GuiUtil
/**
* Utility method that checks to ensure the current thread is running on the ATW thread. If it is NOT then the
- * specified function will be posted so that it is called on the AWT thread. If it is running on the AWT thread then
+ * specified Runnable will be posted so that it is called on the AWT thread. If it is running on the AWT thread then
* nothing will happen and this method will return false.
*
* Typically this utility method is called at the start of a function to ensure it is on the AWT thread, and if not
@@ -665,6 +665,7 @@ public class GuiUtil
* public void actionPerformed(aEvent)
* {
* // Ensure this method is run on the AWT thread
+ * Runnable tmpRunnable = ()-> actionPerformed(aEvent);
* if (redispatchOnAwtIfNeeded(this, "actionPerformed", aEvent) = true)
* return;
*
@@ -672,16 +673,13 @@ public class GuiUtil
* }
*
*/
- public static boolean redispatchOnAwtIfNeeded(Object aObj, String methodName, Object... aArgArr)
+ public static boolean redispatchOnAwtIfNeeded(Runnable aRunnable)
{
- FunctionRunnable aFunctionRunnable;
-
// Do nothing if this is the AWT thread
if (SwingUtilities.isEventDispatchThread() == true)
return false;
- aFunctionRunnable = new FunctionRunnable(aObj, methodName, aArgArr);
- SwingUtilities.invokeLater(aFunctionRunnable);
+ SwingUtilities.invokeLater(aRunnable);
return true;
}
diff --git a/src/glum/gui/component/GComboBox.java b/src/glum/gui/component/GComboBox.java
index 4c2581c..4682a0e 100644
--- a/src/glum/gui/component/GComboBox.java
+++ b/src/glum/gui/component/GComboBox.java
@@ -18,7 +18,7 @@ public class GComboBox extends JComboBox
setModel(itemModel);
}
- public GComboBox(ActionListener aListener, ListCellRenderer aRenderer)
+ public GComboBox(ActionListener aListener, ListCellRenderer super G1> aRenderer)
{
this();
@@ -158,7 +158,7 @@ public class GComboBox extends JComboBox
for (ActionListener aListener : listenerArr)
addActionListener(aListener);
}
-
+
// Note you cannot do the below as internal methods within JComboBox make calls to
// the methods below.
// @Override
diff --git a/src/glum/gui/component/GList.java b/src/glum/gui/component/GList.java
index 34416ed..fbe2491 100644
--- a/src/glum/gui/component/GList.java
+++ b/src/glum/gui/component/GList.java
@@ -20,9 +20,9 @@ import com.google.common.collect.Lists;
public class GList extends JComponent implements GenericCodes, ListSelectionListener
{
// Gui vars
- private JList refList;
+ private JList refList;
private GListModel refModel;
-
+
// State vars
private ActionListener refActionListener;
private ListSelectionListener refListSelectionListener;
@@ -31,36 +31,36 @@ public class GList extends JComponent implements GenericCodes, ListSelection
{
refActionListener = null;
refListSelectionListener = null;
-
- refModel = new GListModel(aItemList);
- refList = new JList(refModel);
+
+ refModel = new GListModel<>(aItemList);
+ refList = new JList<>(refModel);
buildGui(aListener);
}
-
- public GList(Object aListener, G1... aItemArr)
- {
- refActionListener = null;
- refListSelectionListener = null;
-
- refModel = new GListModel(aItemArr);
- refList = new JList(refModel);
- buildGui(aListener);
- }
-
+
+// public GList(Object aListener, G1... aItemArr)
+// {
+// refActionListener = null;
+// refListSelectionListener = null;
+//
+// refModel = new GListModel(aItemArr);
+// refList = new JList<>(refModel);
+// buildGui(aListener);
+// }
+//
/**
* Returns the (first) selected item
*/
public G1 getSelectedItem()
{
int selectedIndex;
-
+
selectedIndex = refList.getSelectedIndex();
if (selectedIndex == -1)
return null;
-
+
return refModel.getElementAt(selectedIndex);
}
-
+
/**
* Returns all of the selected items
*/
@@ -68,17 +68,17 @@ public class GList extends JComponent implements GenericCodes, ListSelection
{
ArrayList retList;
int[] indexArr;
-
+
indexArr = refList.getSelectedIndices();
-
+
retList = Lists.newArrayList();
for (int aIndex : indexArr)
retList.add(refModel.getElementAt(aIndex));
-
+
retList.trimToSize();
return retList;
}
-
+
/**
* Replaces all of the items in the list with aItemList.
*/
@@ -88,7 +88,7 @@ public class GList extends JComponent implements GenericCodes, ListSelection
refList.setModel(new GListModel(aItemList));
refList.addListSelectionListener(this);
}
-
+
/**
* Sets aItem as the selected item.
*/
@@ -106,13 +106,13 @@ public class GList extends JComponent implements GenericCodes, ListSelection
{
int[] idArr;
int c1;
-
+
// Ensure we are executed only on the proper thread
if (SwingUtilities.isEventDispatchThread() == false)
throw new RuntimeException("GList.selectItems() not executed on the AWT event dispatch thread.");
-
+
refList.removeListSelectionListener(this);
-
+
c1 = 0;
idArr = new int[aItemList.size()];
for (G1 aItem : aItemList)
@@ -122,10 +122,10 @@ public class GList extends JComponent implements GenericCodes, ListSelection
}
refList.setSelectedIndices(idArr);
-
+
refList.addListSelectionListener(this);
}
-
+
@Override
public void setEnabled(boolean aBool)
{
@@ -137,7 +137,7 @@ public class GList extends JComponent implements GenericCodes, ListSelection
{
if (refListSelectionListener != null)
refListSelectionListener.valueChanged(new ListSelectionEvent(this, aEvent.getFirstIndex(), aEvent.getLastIndex(), aEvent.getValueIsAdjusting()));
-
+
if (refActionListener != null)
refActionListener.actionPerformed(new ActionEvent(this, ID_UPDATE, "update"));
}
@@ -151,9 +151,9 @@ public class GList extends JComponent implements GenericCodes, ListSelection
refActionListener = (ActionListener)aListener;
if (aListener instanceof ListSelectionListener)
refListSelectionListener = (ListSelectionListener)aListener;
-
+
setLayout(new BorderLayout());
add(refList);
}
-
+
}
diff --git a/src/glum/gui/component/model/GComboBoxModel.java b/src/glum/gui/component/model/GComboBoxModel.java
index e9558b7..a35352e 100644
--- a/src/glum/gui/component/model/GComboBoxModel.java
+++ b/src/glum/gui/component/model/GComboBoxModel.java
@@ -5,7 +5,7 @@ import javax.swing.ComboBoxModel;
import com.google.common.collect.Lists;
-public class GComboBoxModel extends GListModel implements ComboBoxModel
+public class GComboBoxModel extends GListModel implements ComboBoxModel
{
protected G1 chosenItem;
@@ -13,11 +13,11 @@ public class GComboBoxModel extends GListModel implements ComboBoxModel
{
this(Lists.newArrayList(aItemArr));
}
-
+
public GComboBoxModel(Collection aItemList)
{
super(aItemList);
-
+
chosenItem = null;
if (itemList.size() > 0)
chosenItem = itemList.get(0);
@@ -28,20 +28,20 @@ public class GComboBoxModel extends GListModel implements ComboBoxModel
{
if (chosenItem == null)
chosenItem = aItem;
-
+
super.addItem(aItem);
}
-
+
@Override
public void removeItem(G1 aItem)
{
super.removeItem(aItem);
-
+
chosenItem = null;
if (itemList.size() > 0)
chosenItem = itemList.get(0);
}
-
+
/**
* Note aItem must be of the Generified type
*/
diff --git a/src/glum/gui/component/model/GListModel.java b/src/glum/gui/component/model/GListModel.java
index 420e81b..9a44ee9 100644
--- a/src/glum/gui/component/model/GListModel.java
+++ b/src/glum/gui/component/model/GListModel.java
@@ -11,7 +11,7 @@ import com.google.common.collect.Lists;
/**
* Generified mutable ListModel
*/
-public class GListModel extends AbstractListModel
+public class GListModel extends AbstractListModel
{
protected List itemList;
@@ -20,11 +20,11 @@ public class GListModel extends AbstractListModel
itemList = Lists.newArrayList(aItemList);
}
- public GListModel(G1... aItemArr)
- {
- itemList = Lists.newArrayList(aItemArr);
- }
-
+// public GListModel(G1... aItemArr)
+// {
+// itemList = Lists.newArrayList(aItemArr);
+// }
+//
/**
* Adds aItem to this model
*/
diff --git a/src/glum/gui/dock/PrimDockFactory.java b/src/glum/gui/dock/PrimDockFactory.java
index 434c942..2be01d8 100644
--- a/src/glum/gui/dock/PrimDockFactory.java
+++ b/src/glum/gui/dock/PrimDockFactory.java
@@ -170,7 +170,7 @@ public class PrimDockFactory implements DockFactory maxVal)
throw new BadLocationException("Out of numerical range.", offs);
- else if (aVal < minVal)
+ else if (aVal < minVal && resultStr.length() >= ("" + maxVal).length())
throw new BadLocationException("Out of numerical range.", offs);
// Insert the string
diff --git a/src/glum/gui/panel/ColorInputPanel.java b/src/glum/gui/panel/ColorInputPanel.java
index 55767b5..d6313c1 100644
--- a/src/glum/gui/panel/ColorInputPanel.java
+++ b/src/glum/gui/panel/ColorInputPanel.java
@@ -1,19 +1,20 @@
package glum.gui.panel;
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
+import glum.gui.component.GNumberField;
+import glum.unit.*;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
import javax.swing.*;
-import javax.swing.event.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
import net.miginfocom.swing.MigLayout;
-import glum.gui.component.GNumberField;
-import glum.unit.ConstUnitProvider;
-import glum.unit.NumberUnit;
-import glum.unit.UnitProvider;
-
-public class ColorInputPanel extends JPanel implements ActionListener, ChangeListener
+public class ColorInputPanel extends GPanel implements ActionListener, ChangeListener
{
// Constants
private static final Font miniFont = new Font("Serif", Font.PLAIN, 10);
@@ -24,54 +25,22 @@ public class ColorInputPanel extends JPanel implements ActionListener, ChangeLis
private JSlider redS, greenS, blueS;
private GNumberField redNF, greenNF, blueNF;
- // State vars
- private Collection myActionListeners;
-
/**
* Constructor
*/
public ColorInputPanel(boolean isHorizontal, boolean showTF)
{
- super();
-
- // Init internal vars
- myActionListeners = new LinkedHashSet();
-
// Build the gui areas
buildGuiArea(isHorizontal, showTF);
// Set in the default color
- setColor(Color.BLACK);
- }
-
- /**
- * addActionListener
- */
- public synchronized void addActionListener(ActionListener aActionListener)
- {
- // Insanity check
- if (aActionListener == null)
- return;
-
- myActionListeners.add(aActionListener);
- }
-
- /**
- * removeActionListener
- */
- public synchronized void removeActionListener(ActionListener aActionListener)
- {
- // Insanity check
- if (aActionListener == null)
- return;
-
- myActionListeners.remove(aActionListener);
+ setColorConfig(Color.BLACK);
}
/**
* Returns the selected color
*/
- public Color getColor()
+ public Color getColorConfig()
{
int redVal, greenVal, blueVal;
@@ -82,9 +51,9 @@ public class ColorInputPanel extends JPanel implements ActionListener, ChangeLis
}
/**
- * Sets in the current selected color
+ * Sets in the current selected color.
*/
- public void setColor(Color aColor)
+ public void setColorConfig(Color aColor)
{
// Insanity check
if (aColor == null)
@@ -103,7 +72,7 @@ public class ColorInputPanel extends JPanel implements ActionListener, ChangeLis
updateGui(source);
// Notify the listeners
- fireActionEvent(false);
+ notifyListeners(source, ID_UPDATE);
}
@Override
@@ -138,9 +107,9 @@ public class ColorInputPanel extends JPanel implements ActionListener, ChangeLis
// Fire off an event only if not being updated
aSlider = (JSlider)source;
if (aSlider.getValueIsAdjusting() == false)
- fireActionEvent(false);
+ notifyListeners(source, ID_UPDATE);
else
- fireActionEvent(true);
+ notifyListeners(source, ID_UPDATING);
}
}
@@ -244,33 +213,6 @@ public class ColorInputPanel extends JPanel implements ActionListener, ChangeLis
return aPanel;
}
- /**
- * Notifies all listeners of color change
- */
- private void fireActionEvent(boolean isChanging)
- {
- Collection currListeners;
- ActionEvent aEvent;
-
- // Get a copy of the current set of listeners
- synchronized(this)
- {
- currListeners = new LinkedHashSet(myActionListeners);
- }
-
- // Construct the event
- if (isChanging == false)
- aEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Color changed.");
- else
- aEvent = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Color changing.");
-
- // Notify our listeners
- for (ActionListener aListener : currListeners)
- {
- aListener.actionPerformed(aEvent);
- }
- }
-
/**
* Syncs the GUI to match aColor
*/
diff --git a/src/glum/gui/panel/GPanel.java b/src/glum/gui/panel/GPanel.java
index bd3804e..bccb60f 100644
--- a/src/glum/gui/panel/GPanel.java
+++ b/src/glum/gui/panel/GPanel.java
@@ -4,47 +4,68 @@ import glum.gui.panel.generic.GenericCodes;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.List;
+import java.util.*;
import javax.swing.JPanel;
-import com.google.common.collect.Lists;
-
+/**
+ * JPanel that supports registration of ActionListeners. Derived classes will be responsible for determining when an ActionEvent should be fired.
+ */
public class GPanel extends JPanel implements GenericCodes
{
// State vars
- protected List myListeners;
+ protected Set myListeners;
public GPanel()
{
super();
-
- myListeners = Lists.newLinkedList();
+
+ myListeners = new LinkedHashSet<>();
}
-
+
/**
* Add an ActionListener to this GPanel
*/
- public void addActionListener(ActionListener aListener)
+ public synchronized void addActionListener(ActionListener aListener)
{
+ // Insanity check
+ if (aListener == null)
+ throw new RuntimeException("Listener should not be null.");
+
myListeners.add(aListener);
}
/**
* Remove an ActionListener to this GPanel
*/
- public void removeActionListener(ActionListener aListener)
+ public synchronized void removeActionListener(ActionListener aListener)
{
myListeners.remove(aListener);
}
-
+
/**
* Send out notification to all of the ActionListeners
*/
public void notifyListeners(Object aSource, int aId, String aCommand)
{
- for (ActionListener aListener : myListeners)
+ Set tmpListeners;
+
+ // Get a copy of the current set of listeners
+ synchronized (this)
+ {
+ tmpListeners = new LinkedHashSet<>(myListeners);
+ }
+
+ // Notify our listeners
+ for (ActionListener aListener : tmpListeners)
aListener.actionPerformed(new ActionEvent(aSource, aId, aCommand));
}
-
+
+ /**
+ * Send out notification to all of the ActionListeners
+ */
+ public void notifyListeners(Object aSource, int aId)
+ {
+ notifyListeners(aSource, aId, "");
+ }
}
diff --git a/src/glum/gui/panel/generic/GenericCodes.java b/src/glum/gui/panel/generic/GenericCodes.java
index 56a47de..32daa92 100644
--- a/src/glum/gui/panel/generic/GenericCodes.java
+++ b/src/glum/gui/panel/generic/GenericCodes.java
@@ -4,8 +4,10 @@ public interface GenericCodes
{
// Constants
public static final int ID_UNDEFINED = 0;
- public static final int ID_UPDATE = 10;
- public static final int ID_ACCEPT = 11;
- public static final int ID_CANCEL = 12;
-
+
+ public static final int ID_ACCEPT = 10;
+ public static final int ID_CANCEL = 11;
+
+ public static final int ID_UPDATE = 20;
+ public static final int ID_UPDATING = 21;
}
diff --git a/src/glum/gui/panel/itemList/SearchBoxRenderer.java b/src/glum/gui/panel/itemList/SearchBoxRenderer.java
index 944903b..9334c7d 100644
--- a/src/glum/gui/panel/itemList/SearchBoxRenderer.java
+++ b/src/glum/gui/panel/itemList/SearchBoxRenderer.java
@@ -15,7 +15,7 @@ public class SearchBoxRenderer extends DefaultListCellRenderer
}
@Override
- public Component getListCellRendererComponent(JList list, Object aObj, int index, boolean isSelected, boolean hasFocus)
+ public Component getListCellRendererComponent(JList> list, Object aObj, int index, boolean isSelected, boolean hasFocus)
{
JLabel retL;
String aStr;
diff --git a/src/glum/gui/panel/itemList/query/QueryComposer.java b/src/glum/gui/panel/itemList/query/QueryComposer.java
index 9e9a332..a9d6dfa 100644
--- a/src/glum/gui/panel/itemList/query/QueryComposer.java
+++ b/src/glum/gui/panel/itemList/query/QueryComposer.java
@@ -1,11 +1,13 @@
package glum.gui.panel.itemList.query;
import java.util.*;
-import javax.swing.*;
-import javax.swing.table.*;
+
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
import com.google.common.base.Preconditions;
-import com.google.common.collect.*;
import glum.unit.UnitProvider;
@@ -14,24 +16,24 @@ public class QueryComposer>
// State vars
protected ArrayList itemList;
// protected Map itemMap;
-
+
public QueryComposer()
{
- itemList = Lists.newArrayList();
+ itemList = new ArrayList<>();
// itemMap = Maps.newLinkedHashMap();
}
-
+
/**
- * Return the QueryAttribute located at aIndex
- */
+ * Return the QueryAttribute located at aIndex
+ */
public QueryAttribute get(int aIndex)
{
return itemList.get(aIndex);
}
-
+
/**
- * Return the QueryAttribute associated with aRefKey
- */
+ * Return the QueryAttribute associated with aRefKey
+ */
public QueryAttribute getItem(G1 aRefKey)
{
for (QueryAttribute aItem : itemList)
@@ -39,49 +41,35 @@ public class QueryComposer>
if (aItem.refKey == aRefKey)
return aItem;
}
-
+
return null;
}
-
+
/**
- * Returns a listing of all the QueryAttributes that were composed
- */
+ * Returns a listing of all the QueryAttributes that were composed
+ */
public Collection getItems()
{
- return Lists.newArrayList(itemList);
+ return new ArrayList<>(itemList);
}
-
+
/**
- * Returns a listing of the items found in the keyArr
- */
- public Collection getItems(G1... keyArr)
+ * Returns a listing of the items found between sIndex, eIndex (inclusive)
+ */
+ public Collection getItemsFrom(int sIndex, int eIndex)
{
List rList;
-
- rList = Lists.newArrayListWithCapacity(keyArr.length);
- for (G1 aEnum : keyArr)
- rList.add(getItem(aEnum));
-
+
+ rList = new ArrayList<>((eIndex - sIndex) + 1);
+ for (int c1 = sIndex; c1 <= eIndex; c1++)
+ rList.add(itemList.get(c1));
+
return rList;
}
/**
- * Returns a listing of the items found between sIndex, eIndex (inclusive)
- */
- public Collection getItemsFrom(int sIndex, int eIndex)
- {
- List rList;
-
- rList = Lists.newArrayListWithCapacity((eIndex - sIndex) + 1);
- for (int c1 = sIndex; c1 <= eIndex; c1++)
- rList.add(itemList.get(c1));
-
- return rList;
- }
-
- /**
- * Returns a listing of the items found between sKey, eKey (inclusive)
- */
+ * Returns a listing of the items found between sKey, eKey (inclusive)
+ */
public Collection getItemsFrom(G1 sKey, G1 eKey)
{
int sIndex, eIndex;
@@ -95,7 +83,7 @@ public class QueryComposer>
if (itemList.get(c1).refKey == eKey)
eIndex = c1;
}
-
+
// Insanity checks
if (sIndex == -1)
throw new RuntimeException("Failure. Key is not in composer: sKey: " + sKey);
@@ -103,21 +91,21 @@ public class QueryComposer>
throw new RuntimeException("Failure. Key is not in composer: eKey: " + eKey);
if (sIndex > eIndex)
throw new RuntimeException("Failure: eKey: (" + eKey + ") appears before for sKey: (" + sKey + ")");
-
+
return getItemsFrom(sIndex, eIndex);
}
-
+
/**
- * Returns the num of items in the composition
- */
+ * Returns the num of items in the composition
+ */
public int size()
{
return itemList.size();
}
-
+
/**
- * Method to add a QueryAttribute to this container
- */
+ * Method to add a QueryAttribute to this container
+ */
public QueryAttribute addAttribute(G1 aRefKey, UnitProvider aUnitProvider, String aName, String maxValue)
{
return addAttribute(aRefKey, aUnitProvider, aName, maxValue, true);
@@ -126,7 +114,7 @@ public class QueryComposer>
public QueryAttribute addAttribute(G1 aRefKey, UnitProvider aUnitProvider, String aName, String maxValue, boolean isVisible)
{
QueryAttribute aAttribute;
-
+
// Insanity check
Preconditions.checkNotNull(aUnitProvider);
@@ -143,12 +131,12 @@ public class QueryComposer>
public QueryAttribute addAttribute(G1 aRefKey, Class> aClass, String aName, String maxValue, boolean isVisible)
{
int maxSize;
-
+
// Compute the maxSize
maxSize = Integer.MAX_VALUE;
if (maxValue != null)
maxSize = computeStringWidth(maxValue) + 15;
-
+
return addAttribute(aRefKey, aClass, aName, maxSize, isVisible);
}
@@ -161,12 +149,12 @@ public class QueryComposer>
{
QueryAttribute aAttribute;
int defaultSize, minSize, maxSize;
-
+
// Get the defaultSize
defaultSize = 15;
if (aLabel != null)
defaultSize = computeStringWidth(aLabel);
-
+
minSize = 15;
maxSize = aMaxSize;
if (defaultSize < minSize)
@@ -177,7 +165,7 @@ public class QueryComposer>
// Set the defaultSize to be maxSize (unless it is ~infinite)
if (maxSize != Integer.MAX_VALUE)
defaultSize = maxSize;
-
+
// Form the attribute
aAttribute = new QueryAttribute(itemList.size());
aAttribute.refKey = aRefKey;
@@ -227,10 +215,10 @@ public class QueryComposer>
itemList.add(aAttribute);
return aAttribute;
}
-
+
/**
- * Method to set in a custom Editor for the QueryAttribute associated with aRefKey
- */
+ * Method to set in a custom Editor for the QueryAttribute associated with aRefKey
+ */
public void setEditor(G1 aRefKey, TableCellEditor aEditor)
{
for (QueryAttribute aItem : itemList)
@@ -241,13 +229,13 @@ public class QueryComposer>
return;
}
}
-
+
throw new RuntimeException("No item found with the key:" + aRefKey);
}
/**
- * Method to set in a custom Renderer for the QueryAttribute associated with aRefKey
- */
+ * Method to set in a custom Renderer for the QueryAttribute associated with aRefKey
+ */
public void setRenderer(G1 aRefKey, TableCellRenderer aRenderer)
{
for (QueryAttribute aItem : itemList)
@@ -258,20 +246,20 @@ public class QueryComposer>
return;
}
}
-
+
throw new RuntimeException("No item found with the key:" + aRefKey);
}
-
+
/**
- * Utility method to compute the width of a string with the standard font
- */
+ * Utility method to compute the width of a string with the standard font
+ */
protected int computeStringWidth(String aStr)
{
JLabel tmpL;
-
+
tmpL = new JLabel(aStr);
tmpL.setFont((new JTextField()).getFont());
-
+
return tmpL.getPreferredSize().width + 5;
}
diff --git a/src/glum/gui/panel/task/BaseTaskPanel.java b/src/glum/gui/panel/task/BaseTaskPanel.java
index ec78b9a..81df0d8 100644
--- a/src/glum/gui/panel/task/BaseTaskPanel.java
+++ b/src/glum/gui/panel/task/BaseTaskPanel.java
@@ -1,21 +1,17 @@
package glum.gui.panel.task;
-import glum.gui.component.GLabel;
-import glum.gui.panel.GlassPanel;
-import glum.reflect.FunctionRunnable;
-import glum.task.Task;
-import glum.util.WallTimer;
-
import java.awt.Component;
import java.awt.Font;
-import javax.swing.JLabel;
-import javax.swing.JTextArea;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
+
+import glum.gui.component.GLabel;
+import glum.gui.panel.GlassPanel;
+import glum.task.Task;
+import glum.util.WallTimer;
/**
- * Abstract TaskPanel that handles all of the state vars used to maintain
- * the Task interface.
+ * Abstract TaskPanel that handles all of the state vars used to maintain the Task interface.
*/
public abstract class BaseTaskPanel extends GlassPanel implements Task
{
@@ -28,17 +24,17 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
protected long oldTimeMs;
protected long refreshRateMs;
protected int maxLC;
-
+
// Gui vars
protected JLabel titleL;
- protected GLabel progressL, timerL;
+ protected GLabel progressL, timerL;
protected GLabel statusL;
protected JTextArea infoTA;
-
+
public BaseTaskPanel(Component aParent)
{
super(aParent);
-
+
isActive = true;
infoMsgFrag = null;
mProgress = 0;
@@ -48,7 +44,7 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
refreshRateMs = 47;
maxLC = -1;
}
-
+
/**
* Method to set the font of the infoTA
*/
@@ -65,15 +61,16 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
{
maxLC = aMaxLC;
}
-
+
@Override
public void abort()
{
mTimer.stop();
isActive = false;
- SwingUtilities.invokeLater(new FunctionRunnable(this, "updateGui"));
+ Runnable tmpRunnable = () -> updateGui();
+ SwingUtilities.invokeLater(tmpRunnable);
}
-
+
@Override
public void infoAppend(String aMsg)
{
@@ -115,30 +112,32 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
mStatus = "";
mTimer.start();
oldTimeMs = Long.MIN_VALUE;
-
+
// Clear out all the text in the infoTA
if (infoTA != null)
infoTA.setText("");
-
- SwingUtilities.invokeLater(new FunctionRunnable(this, "updateGui"));
+
+ Runnable tmpRunnable = () -> updateGui();
+ SwingUtilities.invokeLater(tmpRunnable);
}
@Override
public void setProgress(double aProgress)
{
mProgress = aProgress;
-
+
// Bail if it is not time to update our UI
if (isTimeForUpdate() == false && aProgress < 1.0)
return;
-
- SwingUtilities.invokeLater(new FunctionRunnable(this, "updateGui"));
+
+ Runnable tmpRunnable = () -> updateGui();
+ SwingUtilities.invokeLater(tmpRunnable);
}
@Override
public void setProgress(int currVal, int maxVal)
{
- setProgress((currVal + 0.0)/ maxVal);
+ setProgress((currVal + 0.0) / maxVal);
}
@Override
@@ -164,12 +163,13 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
public void setStatus(String aMsg)
{
mStatus = aMsg;
-
+
// Bail if it is not time to update our UI
if (isTimeForUpdate() == false)
return;
-
- SwingUtilities.invokeLater(new FunctionRunnable(this, "updateGui"));
+
+ Runnable tmpRunnable = () -> updateGui();
+ SwingUtilities.invokeLater(tmpRunnable);
}
@Override
@@ -177,11 +177,10 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
{
return isActive;
}
-
+
/**
- * Utility method that checks the update rate and returns true if the task
- * UI can be updated. Note this method keeps track of the timer vars to
- * honor refreshRateMs
+ * Utility method that checks the update rate and returns true if the task UI can be updated. Note this method keeps
+ * track of the timer vars to honor refreshRateMs
*/
protected boolean isTimeForUpdate()
{
@@ -194,11 +193,11 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
totalTimeMs = currTimeMs - oldTimeMs;
if (totalTimeMs < refreshRateMs && totalTimeMs > 0)
return false;
-
+
oldTimeMs = currTimeMs;
- return true;
- }
-
+ return true;
+ }
+
/**
* Utility method that does the actual updating of the previous info text with aMsg
*/
@@ -218,11 +217,11 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
start = end = 0;
try
{
- end = infoTA.getLineEndOffset(infoTA.getLineCount()-1);
+ end = infoTA.getLineEndOffset(infoTA.getLineCount() - 1);
start = end - infoMsgFrag.length();
infoTA.replaceRange(aMsg, start, end);
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
System.out.println("infoMsgFrag:" + infoMsgFrag.length() + " start: " + start + " end:" + end);
throw new RuntimeException(aExp);
@@ -232,7 +231,7 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
else
{
infoTA.append(aMsg);
-
+
// Trim the buffer if we exceed our maxLC
if (maxLC > 0)
{
@@ -246,7 +245,7 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
end = infoTA.getLineEndOffset(currLC - maxLC);
infoTA.replaceRange("", start, end);
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
System.out.println("currLC:" + currLC + " maxLC:" + maxLC + " start: " + start + " end:" + end);
throw new RuntimeException(aExp);
@@ -257,14 +256,14 @@ public abstract class BaseTaskPanel extends GlassPanel implements Task
// Save off the new dynamic message fragment
infoMsgFrag = aMsg;
-
+
// timerL.setValue(mTimer.getTotal());
// SwingUtilities.invokeLater(new FunctionRunnable(timerL, "updateGui"));
// Update our internal time
oldTimeMs = System.nanoTime() / 1000000;
}
-
+
/**
* Utility method to update the GUI
*/
diff --git a/src/glum/gui/unit/TimeZoneCellRenderer.java b/src/glum/gui/unit/TimeZoneCellRenderer.java
index fcd7837..6a3dc75 100644
--- a/src/glum/gui/unit/TimeZoneCellRenderer.java
+++ b/src/glum/gui/unit/TimeZoneCellRenderer.java
@@ -15,7 +15,7 @@ public class TimeZoneCellRenderer extends DefaultListCellRenderer
}
@Override
- public Component getListCellRendererComponent(JList list, Object aObj, int index, boolean isSelected, boolean hasFocus)
+ public Component getListCellRendererComponent(JList> list, Object aObj, int index, boolean isSelected, boolean hasFocus)
{
JLabel retL;
String aStr;
diff --git a/src/glum/gui/unit/UnitConfigurationDialog.java b/src/glum/gui/unit/UnitConfigurationDialog.java
index 7d5e698..178f317 100644
--- a/src/glum/gui/unit/UnitConfigurationDialog.java
+++ b/src/glum/gui/unit/UnitConfigurationDialog.java
@@ -1,27 +1,24 @@
package glum.gui.unit;
-import java.awt.*;
-import java.awt.event.*;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.*;
-import javax.swing.event.*;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
import javax.swing.table.*;
-import net.miginfocom.swing.MigLayout;
-
import glum.gui.FocusUtil;
import glum.gui.GuiUtil;
import glum.gui.action.ClickAction;
import glum.gui.panel.CardPanel;
-import glum.gui.panel.itemList.BasicItemHandler;
-import glum.gui.panel.itemList.ItemHandler;
-import glum.gui.panel.itemList.ItemListPanel;
-import glum.gui.panel.itemList.StaticItemProcessor;
+import glum.gui.panel.itemList.*;
import glum.gui.panel.itemList.query.QueryComposer;
-import glum.reflect.FunctionRunnable;
import glum.unit.UnitListener;
import glum.unit.UnitProvider;
+import net.miginfocom.swing.MigLayout;
public class UnitConfigurationDialog extends JDialog implements ActionListener, ListSelectionListener, UnitListener
{
@@ -34,16 +31,16 @@ public class UnitConfigurationDialog extends JDialog implements ActionListener,
// State vars
private StaticItemProcessor itemProcessor;
- public UnitConfigurationDialog(JFrame parentFrame)
+ public UnitConfigurationDialog(JFrame aParentFrame)
{
// Make sure we call the parent
- super(parentFrame);
+ super(aParentFrame);
// Set the characteristics for this dialog
setTitle("Edit Unit");
setDefaultCloseOperation(HIDE_ON_CLOSE);
- setLocationRelativeTo(parentFrame);
+ setLocationRelativeTo(aParentFrame);
setModal(false);
// Build the actual GUI
@@ -109,11 +106,11 @@ public class UnitConfigurationDialog extends JDialog implements ActionListener,
}
@Override
- public void actionPerformed(ActionEvent e)
+ public void actionPerformed(ActionEvent aEvent)
{
Object source;
- source = e.getSource();
+ source = aEvent.getSource();
if (source == closeB)
{
setVisible(false);
@@ -210,10 +207,12 @@ public class UnitConfigurationDialog extends JDialog implements ActionListener,
editorPanel.setMaximumSize(new Dimension(5000, aDim.height));
// Hack to get the editorPanel resize properly. Not sure why invalidate(), validate() do not work
int aHeight = getHeight();
- SwingUtilities.invokeLater(new FunctionRunnable(this, "setSize", getWidth(), aHeight - 1));
- SwingUtilities.invokeLater(new FunctionRunnable(this, "setSize", getWidth(), aHeight));
-// SwingUtilities.invokeLater(new FunctionRunnable(editorPanel, "invalidate"));
-// SwingUtilities.invokeLater(new FunctionRunnable(editorPanel, "validate"));
+ Runnable tmpRunnable1 = () -> setSize(getWidth(), aHeight - 1);
+ Runnable tmpRunnable2 = () -> setSize(getWidth(), aHeight);
+ SwingUtilities.invokeLater(tmpRunnable1);
+ SwingUtilities.invokeLater(tmpRunnable2);
+// Runnable tmpRunnable1 = () -> editorPanel.invalidate();
+// Runnable tmpRunnable2 = () -> editorPanel.validate();
// invalidate();
// validate();
}
@@ -257,7 +256,8 @@ public class UnitConfigurationDialog extends JDialog implements ActionListener,
*/
enum Lookup
{
- Key, Value,
+ Key,
+ Value,
};
public class UnitProviderHandler extends BasicItemHandler
@@ -268,25 +268,25 @@ public class UnitConfigurationDialog extends JDialog implements ActionListener,
}
@Override
- public Object getColumnValue(UnitProvider aItem, int colNum)
+ public Object getColumnValue(UnitProvider aItem, int aColNum)
{
Enum> refKey;
// Insanity check
- if (colNum < 0 && colNum >= fullAttributeList.size())
+ if (aColNum < 0 && aColNum >= fullAttributeList.size())
return null;
- refKey = fullAttributeList.get(colNum).refKey;
+ refKey = fullAttributeList.get(aColNum).refKey;
switch ((Lookup)refKey)
{
case Key:
- return aItem.getDisplayName();
+ return aItem.getDisplayName();
case Value:
- return aItem.getConfigName();
+ return aItem.getConfigName();
default:
- break;
+ break;
}
return null;
diff --git a/src/glum/gui/unit/UnitLabelRenderer.java b/src/glum/gui/unit/UnitLabelRenderer.java
index 83eca8e..b566e3f 100644
--- a/src/glum/gui/unit/UnitLabelRenderer.java
+++ b/src/glum/gui/unit/UnitLabelRenderer.java
@@ -13,7 +13,7 @@ public class UnitLabelRenderer extends DefaultListCellRenderer
}
@Override
- public Component getListCellRendererComponent(JList list, Object aObj, int index, boolean isSelected, boolean hasFocus)
+ public Component getListCellRendererComponent(JList> list, Object aObj, int index, boolean isSelected, boolean hasFocus)
{
JLabel retL;
String aStr;
diff --git a/src/glum/io/IoUtil.java b/src/glum/io/IoUtil.java
index 6d93b62..169fe8e 100644
--- a/src/glum/io/IoUtil.java
+++ b/src/glum/io/IoUtil.java
@@ -7,10 +7,9 @@ import glum.zio.ZoutStream;
import java.io.*;
import java.net.*;
import java.nio.channels.Channel;
+import java.util.Base64;
import java.util.Map;
-import javax.xml.bind.DatatypeConverter;
-
import com.google.common.collect.Maps;
public class IoUtil
@@ -20,18 +19,18 @@ public class IoUtil
*/
public static URL createURL(String aUrlStr)
{
- URL aURL;
+ URL retURL;
try
{
- aURL = new URL(aUrlStr);
+ retURL = new URL(aUrlStr);
}
- catch (MalformedURLException e)
+ catch(MalformedURLException e)
{
- aURL = null;
+ retURL = null;
}
- return aURL;
+ return retURL;
}
/**
@@ -55,7 +54,7 @@ public class IoUtil
{
aChannel.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -73,7 +72,7 @@ public class IoUtil
{
aStream.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -91,7 +90,7 @@ public class IoUtil
{
aStream.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -109,7 +108,7 @@ public class IoUtil
{
aReader.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -127,7 +126,7 @@ public class IoUtil
{
aWriter.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -146,7 +145,7 @@ public class IoUtil
{
aStream.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -164,7 +163,7 @@ public class IoUtil
{
aStream.close();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aExp.printStackTrace();
}
@@ -176,26 +175,20 @@ public class IoUtil
*/
public static boolean copyUrlToFile(Task aTask, URL aUrl, File aFile, Map aPropertyMap)
{
- URLConnection aConnection;
- InputStream inStream;
- OutputStream outStream;
- byte[] byteArr;
- int numBytes;
-
// Ensure we have a valid aTask
if (aTask == null)
aTask = new ConsoleTask();
// Allocate space for the byte buffer
- byteArr = new byte[10000];
+ byte[] byteArr = new byte[10000];
// Perform the actual copying
- inStream = null;
- outStream = null;
+ InputStream inStream = null;
+ OutputStream outStream = null;
try
{
// Open the src stream (with a 30 sec connect timeout)
- aConnection = aUrl.openConnection();
+ URLConnection aConnection = aUrl.openConnection();
aConnection.setConnectTimeout(30 * 1000);
aConnection.setReadTimeout(90 * 1000);
@@ -213,13 +206,13 @@ public class IoUtil
outStream = new FileOutputStream(aFile);
// Copy the bytes from the instream to the outstream
- numBytes = 0;
+ int numBytes = 0;
while (numBytes != -1)
{
numBytes = inStream.read(byteArr);
if (numBytes > 0)
outStream.write(byteArr, 0, numBytes);
-
+
// Bail if aTask is aborted
if (aTask.isActive() == false)
{
@@ -228,7 +221,7 @@ public class IoUtil
}
}
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
aTask.infoAppendln("Exception:" + aExp);
aTask.infoAppendln(" URL:" + aUrl);
@@ -268,13 +261,10 @@ public class IoUtil
*/
public static boolean copyUrlToFile(Task aTask, URL aUrl, File aFile, String aUsername, String aPassword)
{
- Map plainMap;
- String authStr;
+ String authStr = aUsername + ":" + aPassword;
+ authStr = Base64.getEncoder().encodeToString(authStr.getBytes());
- authStr = aUsername + ":" + aPassword;
- authStr = DatatypeConverter.printBase64Binary(authStr.getBytes());
-
- plainMap = Maps.newHashMap();
+ Map plainMap = Maps.newHashMap();
plainMap.put("Authorization", "Basic " + authStr);
return copyUrlToFile(aTask, aUrl, aFile, plainMap);
@@ -294,20 +284,19 @@ public class IoUtil
*/
public static boolean copyFileToFile(File aFile1, File aFile2)
{
- URL aUrl;
-
+ URL tmpUrl;
try
{
- aUrl = aFile1.toURI().toURL();
+ tmpUrl = aFile1.toURI().toURL();
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
System.out.println("Exception:" + aExp);
aExp.printStackTrace();
return false;
}
- return copyUrlToFile(aUrl, aFile2);
+ return copyUrlToFile(tmpUrl, aFile2);
}
/**
@@ -344,16 +333,13 @@ public class IoUtil
*/
public static String readString(DataInputStream aStream) throws IOException
{
- byte[] data;
- int size;
-
- size = aStream.readShort() & 0x00FFFF;
+ int size = aStream.readShort() & 0x00FFFF;
if (size == 0x00FFFF)
return null;
if (size == 0)
return "";
- data = new byte[size];
+ byte[] data = new byte[size];
aStream.readFully(data);
return new String(data, "UTF-8");
}
@@ -363,9 +349,6 @@ public class IoUtil
*/
public static void writeString(DataOutputStream aStream, String aStr) throws IOException
{
- byte[] data;
- int size;
-
// Null strings are handled in special fashion
if (aStr == null)
{
@@ -380,8 +363,8 @@ public class IoUtil
return;
}
- data = aStr.getBytes("UTF-8");
- size = data.length;
+ byte[] data = aStr.getBytes("UTF-8");
+ int size = data.length;
// Ensure the string size is less than 0x00FFFF
if (size >= 0x00FFFF)
@@ -397,18 +380,17 @@ public class IoUtil
*/
public static short sizeOnDisk(String aStr)
{
- byte[] data;
- int size;
-
if (aStr == null || aStr.equals("") == true)
return 2;
+ byte[] data;
+ int size;
try
{
data = aStr.getBytes("UTF-8");
size = data.length;
}
- catch (Exception aExp)
+ catch(Exception aExp)
{
throw new RuntimeException("UTF-8 Transform error.", aExp);
}
diff --git a/src/glum/logic/LogicChunkEngine.java b/src/glum/logic/LogicChunkEngine.java
index 3e75776..14613f4 100644
--- a/src/glum/logic/LogicChunkEngine.java
+++ b/src/glum/logic/LogicChunkEngine.java
@@ -21,7 +21,7 @@ public class LogicChunkEngine implements ActionListener
private JMenuBar menuBar;
private Map