use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LogEntryTable method changeSelection.
/**
* Override the method in <code>JTable</code> to catch the change of selection operated
* by the user and update the detailed log info accordingly.
*
* @see <code>JTable.changeSelection(int rowIndex, int columnIndex, boolean toggle,boolean extend)</code>
*/
@Override
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
super.changeSelection(rowIndex, columnIndex, toggle, extend);
// to avoid concurrency issues
SingleLogSelectionListener listenerCopy = listener;
if (rowIndex != -1 && !toggle && !extend) {
LogTableDataModel model = (LogTableDataModel) getModel();
ILogEntry log = model.getVisibleLogEntry(convertRowIndexToModel(rowIndex));
loggingClient.setLogDetailContent(log);
selecteViewdRow = rowIndex;
selecteModelRow = convertRowIndexToModel(rowIndex);
selecteLogKey = ((LogTableDataModel) getModel()).getLogKey(selecteModelRow);
if (listenerCopy != null && log != null) {
listenerCopy.notifyLogSelected(log);
}
} else {
// Multiple line selection etc all mean 'deselection' for our SingleLogSelectionListener
if (listenerCopy != null) {
listenerCopy.notifyLogSelected(null);
}
}
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class LoggingClient method showDetailedLogInfo.
/**
* Show a detailed view of the selected log in the right panel
*/
public void showDetailedLogInfo() {
try {
LogEntryTable jt = getLogEntryTable();
int selectedRow = jt.getSelectedRow();
// no row selected
if (selectedRow == -1) {
detailedLogTable.setupContent(null);
} else {
// a row is selected
ILogEntry log = jt.getLCModel().getVisibleLogEntry(selectedRow);
detailedLogTable.setupContent(log);
}
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class TablePopupMenu method saveSelectedLogs.
/**
* Save the selected logs into a file in the passed format.
*
* @param converter The converter to desired format
* @param fileIcon The icon of the file type
*/
private void saveSelectedLogs(LogConverter converter, ImageIcon fileIcon, String extension) {
if (converter == null) {
throw new IllegalArgumentException("The converter can't be null");
}
if (extension == null || extension.isEmpty()) {
throw new IllegalArgumentException("Invalid file extension");
}
converter.setCols(buildFields());
// Build the text to save in the file
StringBuilder strBuffer = new StringBuilder();
if (!selectionModel.isSelectionEmpty()) {
for (int i = selectionModel.getMinSelectionIndex(); i <= selectionModel.getMaxSelectionIndex(); i++) {
if (!selectionModel.isSelectedIndex(i)) {
continue;
} else {
ILogEntry log = model.getVisibleLogEntry(sorter.convertRowIndexToModel(i));
strBuffer.append(converter.convert(log));
}
}
if (strBuffer.length() == 0) {
// Nothing to save
return;
}
}
FileFilter fileFilter = new FileNameExtensionFilter("File " + extension, extension);
CustomFileChooser fc = new CustomFileChooser(fileIcon, fileFilter);
fc.addChoosableFileFilter(fileFilter);
if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
// If not present, add the xml extension
if (!file.getAbsolutePath().toLowerCase().endsWith("." + extension)) {
file = new File(file.getAbsolutePath() + "." + extension);
}
FileOutputStream outFStream = null;
try {
outFStream = new FileOutputStream(file);
} catch (FileNotFoundException fnfe) {
JOptionPane.showMessageDialog(null, "Error creating " + file.getAbsolutePath() + ":\n" + fnfe.getMessage(), "Error saving logs", JOptionPane.ERROR_MESSAGE);
return;
}
try {
outFStream.write(strBuffer.toString().getBytes());
outFStream.flush();
outFStream.close();
} catch (IOException ioe) {
JOptionPane.showMessageDialog(null, "Error saving " + file.getAbsolutePath() + ":\n" + ioe.getMessage(), "Error saving logs", JOptionPane.ERROR_MESSAGE);
}
}
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class TablePopupMenu method copyToClipboard.
private void copyToClipboard(LogConverter converter) {
if (converter == null) {
throw new IllegalArgumentException("Invalid null converter");
}
converter.setCols(buildFields());
// Build the text to copy in the clipboard
if (!selectionModel.isSelectionEmpty()) {
StringBuffer strBuffer = new StringBuffer();
for (int i = selectionModel.getMinSelectionIndex(); i <= selectionModel.getMaxSelectionIndex(); i++) {
if (!selectionModel.isSelectedIndex(i)) {
continue;
} else {
ILogEntry log = model.getVisibleLogEntry(table.convertRowIndexToModel(i));
strBuffer.append(converter.convert(log));
}
}
// Copy the text to the clipboard
textTransfer.setClipboardContents(strBuffer.toString());
}
}
use of com.cosylab.logging.engine.log.ILogEntry in project ACS by ACS-Community.
the class CacheTest method testGet.
/**
* Get all the logs in cache to check the get method
*
* @throws Exception
*/
public void testGet() throws Exception {
ILogEntry log;
for (int t = 0; t < cache.getSize(); t++) {
log = cache.getLog(0);
assertNotNull("Error getting the log " + t, log);
}
}
Aggregations