use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.
the class LogConverter method setCols.
/**
* Set the columns to write in the converted string
*
* @param columns A vector of LogField representing the field to
* write in the converted string
* @param additionlData <code>true</code> if the additional data must be
* appended in the last position of the converted string
*
* @see colIndexVector
*/
public void setCols(Collection<LogField> columns, boolean additionlData) {
if ((columns == null || columns.isEmpty()) && !additionlData) {
throw new IllegalArgumentException("The columns can't be null nor empty");
}
StringBuilder cols = new StringBuilder();
for (LogField f : columns) {
cols.append(f.id);
}
if (additionlData) {
cols.append(ADDITIONAL_DATA_ID);
}
setCols(cols.toString());
}
use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.
the class DetailedLogTable method setupContent.
/**
* Fill the table with the fields of the given log.
*
* @param log The log whose content is shown in the table
*/
public void setupContent(ILogEntry log) {
if (log == null) {
setEmptyContent();
return;
}
// The number of rows in the table is given by the number of fields
// of each LogEntry plus the number of the "data" elements for the selected log
Vector<ILogEntry.AdditionalData> additionalData = log.getAdditionalData();
rowsNum = LogField.values().length;
if (additionalData != null) {
rowsNum += additionalData.size();
}
if (rowsNum > 0) {
nameValue = new String[rowsNum][2];
for (int i = 0; i < LogField.values().length; i++) {
LogField field = LogField.values()[i];
nameValue[i][0] = "<HTML><B>" + field.getName() + "</B>";
Object obj = log.getField(field);
if (obj != null) {
if (field == LogField.ENTRYTYPE) {
nameValue[i][1] = obj.toString();
dataModel.logType = (LogTypeHelper) obj;
} else if (field == LogField.TIMESTAMP) {
SimpleDateFormat df = new IsoDateFormat();
Date dt = new Date((Long) obj);
StringBuffer dateSB = new StringBuffer();
java.text.FieldPosition pos = new java.text.FieldPosition(0);
df.format(dt, dateSB, pos);
nameValue[i][1] = dateSB.toString();
} else {
nameValue[i][1] = obj.toString();
}
} else {
nameValue[i][1] = "";
}
}
for (int i = LogField.values().length; i < rowsNum; i++) {
nameValue[i][0] = "<HTML><B>Additional</B> <I>" + additionalData.get(i - LogField.values().length).name + "</I>";
String temp = (String) additionalData.get(i - LogField.values().length).value;
nameValue[i][1] = temp;
}
dataModel.fireTableDataChanged();
}
}
use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.
the class LogEntryTest method testGetField.
public void testGetField() {
//Object getField(int fieldIndex)
Object actualField = null;
String curFieldDesc = null;
Object expectedField = "maciHeartbeatController.cpp";
LogField fileField = LogField.FILE;
actualField = log.getField(LogField.FILE);
assertEquals("The two logs are not equal.", expectedField, actualField);
}
use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.
the class LogEntryTest method testGetFieldClass.
public void testGetFieldClass(String currentFieldDesc) {
//Class getFieldClass(int fieldIndex)
Class actualFieldClass = null;
Class curFieldClass = null;
String curFieldDesc = null;
currentFieldDesc = "File";
Class expectedFieldClass = String.class;
for (LogField f : LogField.values()) {
curFieldDesc = f.getName();
// can be anything: timstamp, entrytype, field
if (curFieldDesc.equals(currentFieldDesc))
curFieldClass = f.getClass();
// gets the class of the "File" which is String
}
assertEquals("The two logs are not equal.", expectedFieldClass, actualFieldClass);
}
use of com.cosylab.logging.engine.log.LogField in project ACS by ACS-Community.
the class LogEntryTable method showFieldChooser.
/**
* Displays the field chooser dialog.
* <p>
* Creation date: (1/2/2002 23:20:27)
*/
public void showFieldChooser() {
String[] fieldNames = new String[LogField.values().length];
int t = 0;
for (LogField f : LogField.values()) {
fieldNames[t++] = f.getName();
}
boolean[] fieldVisible = getVisibleColumns(true);
if (fieldChooser == null) {
fieldChooser = new FieldChooserDialog(loggingClient);
}
fieldChooser.setupFields(fieldNames, fieldVisible);
fieldChooser.setVisible(true);
if (fieldChooser.getModalResult() == DialogExitAction.CANCEL) {
return;
}
boolean[] newFields = fieldChooser.getFields();
for (int i = 0; i < LogField.values().length; i++) {
if (newFields[i] != fieldVisible[i]) {
if (newFields[i])
showColumn(i + 1);
else
hideColumn(i + 1);
}
}
}
Aggregations