Skip to content
Snippets Groups Projects
Commit cf897f10 authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Fixed NPE errors

parent 6c68cf13
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</parent> </parent>
<artifactId>workbooks</artifactId> <artifactId>workbooks</artifactId>
<version>3.4.11</version> <version>3.4.12</version>
<packaging>jar</packaging> <packaging>jar</packaging>
......
package plugins.adufour.vars.gui.swing; package plugins.adufour.vars.gui.swing;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
...@@ -109,7 +110,7 @@ public class WorkbookEditor extends SwingVarEditor<Workbook> ...@@ -109,7 +110,7 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
private JTabbedPane tabs; private JTabbedPane tabs;
private final HashMap<Sheet, JXTable> tables = new HashMap<Sheet, JXTable>(); private final HashMap<Sheet, JXTable> tables = new HashMap<Sheet, JXTable>();
private final HashMap<Sheet, JXTable> headers = new HashMap<Sheet, JXTable>(); private final HashMap<Sheet, JXTable> headers = new HashMap<Sheet, JXTable>();
// cached workbook to avoid reference of old book being leaked by GUI // cached workbook to avoid reference of old book being leaked by GUI
private Workbook book; private Workbook book;
...@@ -231,7 +232,8 @@ public class WorkbookEditor extends SwingVarEditor<Workbook> ...@@ -231,7 +232,8 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
/** /**
* Sets whether the open button should be visible * Sets whether the open button should be visible
* *
* @param visible visible state * @param visible
* visible state
*/ */
public void setOpenButtonVisible(boolean visible) public void setOpenButtonVisible(boolean visible)
{ {
...@@ -241,7 +243,8 @@ public class WorkbookEditor extends SwingVarEditor<Workbook> ...@@ -241,7 +243,8 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
/** /**
* Sets whether the table editor is read-only, and therefore rejects user input * Sets whether the table editor is read-only, and therefore rejects user input
* *
* @param readOnly read only state * @param readOnly
* read only state
*/ */
public void setReadOnly(boolean readOnly) public void setReadOnly(boolean readOnly)
{ {
...@@ -972,7 +975,9 @@ public class WorkbookEditor extends SwingVarEditor<Workbook> ...@@ -972,7 +975,9 @@ public class WorkbookEditor extends SwingVarEditor<Workbook>
Component component = super.getTableCellRendererComponent(theTable, value, isSelected, hasFocus, Component component = super.getTableCellRendererComponent(theTable, value, isSelected, hasFocus,
theRow, theColumn); theRow, theColumn);
component.setBackground(icySheet.getFillColor(theRow, theColumn)); Color fillColor = icySheet.getFillColor(theRow, theColumn);
if (fillColor != null)
component.setBackground(fillColor);
return component; return component;
} }
......
...@@ -222,17 +222,23 @@ public class IcySpreadSheet ...@@ -222,17 +222,23 @@ public class IcySpreadSheet
if (color instanceof HSSFColor) if (color instanceof HSSFColor)
{ {
short[] rgb = ((HSSFColor) color).getTriplet(); short[] rgb = ((HSSFColor) color).getTriplet();
if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0) if ((rgb != null) && (rgb.length >= 3))
{ {
return new Color(rgb[0], rgb[1], rgb[2]); if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
{
return new Color(rgb[0], rgb[1], rgb[2]);
}
} }
} }
else if (color instanceof XSSFColor) else if (color instanceof XSSFColor)
{ {
byte[] rgb = ((XSSFColor) color).getRGB(); byte[] rgb = ((XSSFColor) color).getRGB();
if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0) if ((rgb != null) && (rgb.length >= 3))
{ {
return new Color(rgb[0] & 0xff, rgb[1] & 0xff, rgb[2] & 0xff); if (rgb[0] != 0 || rgb[1] != 0 || rgb[2] != 0)
{
return new Color(rgb[0] & 0xff, rgb[1] & 0xff, rgb[2] & 0xff);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment