Skip to content
Snippets Groups Projects
Commit 044ca9fa authored by Raphael GIRARDOT's avatar Raphael GIRARDOT
Browse files

- code readapted to changes in ProjectUtilities

- Prefer using constants to new Strings
- Prefer using named threads
parent ea69c1be
Branches
No related tags found
1 merge request!3code readapted to changes in ProjectUtilities
......@@ -47,7 +47,7 @@ import fr.soleil.bensikin.actions.BensikinAction;
import fr.soleil.bensikin.containers.context.ContextDetailPrintPanel;
import fr.soleil.bensikin.options.Options;
import fr.soleil.bensikin.options.sub.PrintOptions;
import fr.soleil.lib.project.awt.print.ComponentPrinter;
import fr.soleil.lib.project.swing.print.ComponentPrinter;
/**
* An action that prints the current snapshot comparison's table to a printer.
......
......@@ -51,7 +51,7 @@ import fr.soleil.bensikin.components.snapshot.detail.SnapshotCompareTable;
import fr.soleil.bensikin.models.SnapshotCompareTablePrintModel;
import fr.soleil.bensikin.options.Options;
import fr.soleil.bensikin.options.sub.PrintOptions;
import fr.soleil.lib.project.awt.print.ComponentPrinter;
import fr.soleil.lib.project.swing.print.ComponentPrinter;
/**
* An action that prints the current snapshot comparison's table to a printer.
......
......@@ -44,7 +44,7 @@ import fr.soleil.bensikin.actions.BensikinAction;
import fr.soleil.bensikin.containers.snapshot.SnapshotDetailPrintPanel;
import fr.soleil.bensikin.options.Options;
import fr.soleil.bensikin.options.sub.PrintOptions;
import fr.soleil.lib.project.awt.print.ComponentPrinter;
import fr.soleil.lib.project.swing.print.ComponentPrinter;
/**
* An action that prints the current snapshot comparison's table to a printer.
......
......@@ -73,6 +73,7 @@ import fr.soleil.archiving.snap.api.tools.SnapAttributeExtract;
import fr.soleil.bensikin.options.Options;
import fr.soleil.bensikin.options.sub.SnapshotOptions;
import fr.soleil.bensikin.xml.BensikinXMLLine;
import fr.soleil.lib.project.ObjectUtils;
/**
* Represents an attribute attached to a snapshot. A SnapshotAttribute belongs
......@@ -161,7 +162,7 @@ public class SnapshotAttribute {
dataType = _dataType;
dataFormat = _format;
permit = _writable;
displayFormat = "";
displayFormat = ObjectUtils.EMPTY_STRING;
SnapshotAttributeReadValue _readValue = null;
SnapshotAttributeWriteValue _writeValue = null;
......@@ -260,13 +261,16 @@ public class SnapshotAttribute {
final String[] readst = (String[]) getValue(val, 0);
_readValue = new SnapshotAttributeReadValue(_format, _dataType, readst, nullRead);
} catch (final ClassCastException cce) {
_readValue = new SnapshotAttributeReadValue(_format, _dataType, new String[0], null);
_readValue = new SnapshotAttributeReadValue(_format, _dataType, new String[0],
null);
}
try {
final String[] writest = (String[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writest, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writest,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new String[0], null);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new String[0],
null);
}
break;
case TangoConst.Tango_DEV_BOOLEAN:
......@@ -274,13 +278,16 @@ public class SnapshotAttribute {
final boolean[] readb = (boolean[]) getValue(val, 0);
_readValue = new SnapshotAttributeReadValue(_format, _dataType, readb, nullRead);
} catch (final ClassCastException cce) {
_readValue = new SnapshotAttributeReadValue(_format, _dataType, new boolean[0], null);
_readValue = new SnapshotAttributeReadValue(_format, _dataType, new boolean[0],
null);
}
try {
final boolean[] writeb = (boolean[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writeb, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writeb,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new boolean[0], null);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new boolean[0],
null);
}
break;
case TangoConst.Tango_DEV_CHAR:
......@@ -293,9 +300,11 @@ public class SnapshotAttribute {
}
try {
final byte[] writec = (byte[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writec, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writec,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new byte[0], null);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new byte[0],
null);
}
break;
case TangoConst.Tango_DEV_LONG:
......@@ -308,7 +317,8 @@ public class SnapshotAttribute {
}
try {
final int[] writel = (int[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writel, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writel,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new int[0], null);
}
......@@ -323,9 +333,11 @@ public class SnapshotAttribute {
}
try {
final short[] writes = (short[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writes, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writes,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new short[0], null);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new short[0],
null);
}
break;
case TangoConst.Tango_DEV_FLOAT:
......@@ -337,9 +349,11 @@ public class SnapshotAttribute {
}
try {
final float[] writef = (float[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writef, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writef,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new float[0], null);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new float[0],
null);
}
break;
case TangoConst.Tango_DEV_DOUBLE:
......@@ -347,13 +361,16 @@ public class SnapshotAttribute {
final double[] readd = (double[]) getValue(val, 0);
_readValue = new SnapshotAttributeReadValue(_format, _dataType, readd, nullRead);
} catch (final ClassCastException cce) {
_readValue = new SnapshotAttributeReadValue(_format, _dataType, new double[0], null);
_readValue = new SnapshotAttributeReadValue(_format, _dataType, new double[0],
null);
}
try {
final double[] writed = (double[]) getValue(val, 1);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writed, nullWrite);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, writed,
nullWrite);
} catch (final ClassCastException cce) {
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new double[0], null);
_writeValue = new SnapshotAttributeWriteValue(_format, _dataType, new double[0],
null);
}
break;
default: // nothing to do
......@@ -406,7 +423,8 @@ public class SnapshotAttribute {
if (_readValue != null) {
readValue = _readValue;
} else {
readValue = new SnapshotAttributeReadValue(SnapshotAttributeValue.NOT_APPLICABLE_DATA_FORMAT, 0, null, null);
readValue = new SnapshotAttributeReadValue(SnapshotAttributeValue.NOT_APPLICABLE_DATA_FORMAT, 0, null,
null);
}
if (_writeValue != null) {
......@@ -442,16 +460,16 @@ public class SnapshotAttribute {
public SnapshotAttribute(final String name, final SnapshotAttributes attrs) {
setAttributeCompleteName(name);
snapshotAttributes = attrs;
displayFormat = "";
displayFormat = ObjectUtils.EMPTY_STRING;
updateDisplayFormat();
}
/**
* Sets the displa format, reading it from Tango. Uses a Thread to avoid
* Sets the display format, reading it from Tango. Uses a Thread to avoid
* freezing
*/
public void updateDisplayFormat() {
new Thread() {
new Thread("SnapshotAttribute.updateDisplayFormat()") {
@Override
public void run() {
try {
......@@ -459,7 +477,7 @@ public class SnapshotAttribute {
proxy = new AttributeProxy(attributeCompleteName);
displayFormat = proxy.get_info().format;
} catch (final Exception e) {
displayFormat = "";
displayFormat = ObjectUtils.EMPTY_STRING;
} finally {
if (readValue != null) {
readValue.setDisplayFormat(displayFormat);
......@@ -481,7 +499,7 @@ public class SnapshotAttribute {
*
* @return The result conversion
*/
SnapAttributeExtract toSnapAttributeExtrac() {
public SnapAttributeExtract toSnapAttributeExtrac() {
final AttributeLight snapAttributeLight = new AttributeLight();
snapAttributeLight.setAttributeCompleteName(attributeCompleteName);
......@@ -619,10 +637,12 @@ public class SnapshotAttribute {
*/
@Override
public String toString() {
String ret = "";
String ret = ObjectUtils.EMPTY_STRING;
final BensikinXMLLine openingLine = new BensikinXMLLine(SnapshotAttribute.XML_TAG, BensikinXMLLine.OPENING_TAG_CATEGORY);
final BensikinXMLLine closingLine = new BensikinXMLLine(SnapshotAttribute.XML_TAG, BensikinXMLLine.CLOSING_TAG_CATEGORY);
final BensikinXMLLine openingLine = new BensikinXMLLine(SnapshotAttribute.XML_TAG,
BensikinXMLLine.OPENING_TAG_CATEGORY);
final BensikinXMLLine closingLine = new BensikinXMLLine(SnapshotAttribute.XML_TAG,
BensikinXMLLine.CLOSING_TAG_CATEGORY);
openingLine.setAttribute(SnapshotAttribute.ID_PROPERTY_XML_TAG, String.valueOf(attributeId));
openingLine.setAttribute(SnapshotAttribute.DATA_TYPE_PROPERTY_XML_TAG, String.valueOf(dataType));
......@@ -921,7 +941,8 @@ public class SnapshotAttribute {
}
}
final SnapshotAttributeWriteAbsValue snapshotWriteAbsValue = new SnapshotAttributeWriteAbsValue(
writeValue.getDataFormat(), writeValue.getDataType(), writeAbsScalarValue, writeValue.getNullElements());
writeValue.getDataFormat(), writeValue.getDataType(), writeAbsScalarValue,
writeValue.getNullElements());
return snapshotWriteAbsValue;
}
......@@ -964,7 +985,7 @@ public class SnapshotAttribute {
* @return
*/
public String toUserFriendlyString() {
String ret = "";
String ret = ObjectUtils.EMPTY_STRING;
final Options options = Options.getInstance();
final SnapshotOptions snapshotOptions = options.getSnapshotOptions();
final String separator = snapshotOptions.getCSVSeparator();
......
......@@ -47,6 +47,7 @@ import java.util.Map;
import fr.soleil.archiving.gui.tools.GUIUtilities;
import fr.soleil.archiving.snap.api.tools.SnapAttributeExtract;
import fr.soleil.lib.project.ObjectUtils;
/**
* A group of snapshot attributes, rattached to a snapshot.
......@@ -162,7 +163,7 @@ public class SnapshotAttributes {
*
* @return An ArrayList of SnapAttributeExtract objects.
*/
ArrayList<SnapAttributeExtract> toArrayList() {
public ArrayList<SnapAttributeExtract> toArrayList() {
if (snapshotAttributes == null) {
// System.out.println("snapshotAttributes null !!!!");
return null;
......@@ -204,7 +205,7 @@ public class SnapshotAttributes {
*/
@Override
public String toString() {
String ret = "";
String ret = ObjectUtils.EMPTY_STRING;
if (this.snapshotAttributes != null) {
for (int i = 0; i < this.snapshotAttributes.length; i++) {
......@@ -307,7 +308,7 @@ public class SnapshotAttributes {
* @return
*/
public String toUserFriendlyString() {
String ret = "";
String ret = ObjectUtils.EMPTY_STRING;
if (this.snapshotAttributes != null) {
for (int i = 0; i < this.snapshotAttributes.length; i++) {
......
......@@ -38,7 +38,7 @@ import fr.soleil.archiving.common.api.exception.ArchivingException;
import fr.soleil.bensikin.containers.sub.dialogs.options.OptionsPrintTab;
import fr.soleil.bensikin.options.PushPullOptionBook;
import fr.soleil.bensikin.options.ReadWriteOptionBook;
import fr.soleil.lib.project.awt.print.ComponentPrinter;
import fr.soleil.lib.project.swing.print.ComponentPrinter;
/**
* The print options of the application.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment