Search in sources :

Example 31 with ILogEntry

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);
        }
    }
}
Also used : SingleLogSelectionListener(com.cosylab.logging.viewcoordination.ViewCoordinator.SingleLogSelectionListener) ILogEntry(com.cosylab.logging.engine.log.ILogEntry)

Example 32 with ILogEntry

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);
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) LogEntryTable(alma.acs.logging.table.LogEntryTable)

Example 33 with ILogEntry

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);
        }
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) FileFilter(javax.swing.filechooser.FileFilter) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) File(java.io.File)

Example 34 with ILogEntry

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());
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry)

Example 35 with ILogEntry

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);
    }
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry)

Aggregations

ILogEntry (com.cosylab.logging.engine.log.ILogEntry)85 Vector (java.util.Vector)15 ACSLogParser (alma.acs.logging.engine.parser.ACSLogParser)11 Date (java.util.Date)11 IsoDateFormat (alma.acs.util.IsoDateFormat)9 LogCacheException (com.cosylab.logging.client.cache.LogCacheException)9 AdditionalData (com.cosylab.logging.engine.log.ILogEntry.AdditionalData)9 SimpleDateFormat (java.text.SimpleDateFormat)9 FieldPosition (java.text.FieldPosition)8 LogTypeHelper (com.cosylab.logging.engine.log.LogTypeHelper)7 LogEntry (com.cosylab.logging.engine.log.LogEntry)6 ParserTypes (alma.acs.logging.engine.parser.ACSLogParserFactory.ParserTypes)5 LogBufferedFileCache (com.cosylab.logging.client.cache.LogBufferedFileCache)5 LogFileCache (com.cosylab.logging.client.cache.LogFileCache)5 Random (java.util.Random)5 IOHelper (alma.acs.logging.engine.io.IOHelper)4 LogCache (com.cosylab.logging.client.cache.LogCache)4 IOException (java.io.IOException)4 ILogMap (com.cosylab.logging.client.cache.ILogMap)3 LogField (com.cosylab.logging.engine.log.LogField)3