use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class TextTableView method refreshTable.
/**
* Refreshes the visible part of the table
*/
void refreshTable() {
table.setItemCount(filteredLogReader.size());
table.setTopIndex(0);
table.setSelection(0);
int topIndex = 0;
int visibleItems = TextTableView.this.table.getClientArea().height / TextTableView.this.table.getItemHeight();
int startPos = topIndex + visibleItems + TextTableView.CACHE_SIZE;
if (startPos >= filteredLogReader.size()) {
startPos = filteredLogReader.size() - 1;
}
if (clearingThread != null) {
clearingThread.stop();
}
clearingThread = new ClearingRunnable(topIndex, visibleItems);
Display.getDefault().asyncExec(clearingThread);
try {
cachedLogReader.cacheRecords(topIndex, startPos);
for (int rowIndex = topIndex; rowIndex <= startPos; ++rowIndex) {
final TableItem item = table.getItem(rowIndex);
LogRecord record = getLogRecordAtRow(rowIndex);
setTableItem(item, record);
}
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("TextTableModel.6") + e.getMessage()));
} catch (ParseException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("TextTableModel.7") + e.getMessage()));
}
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class LogSearchPage method readConfiguration.
private void readConfiguration() {
IDialogSettings settings = getDialogSettings();
int historySize;
try {
historySize = settings.getInt("historySize");
} catch (NumberFormatException e) {
historySize = HISTORY_SIZE;
}
try {
for (int i = 0; i < historySize; ++i) {
IDialogSettings histSettings = settings.getSection("history" + i);
if (histSettings != null) {
SearchPattern data = SearchPattern.create(histSettings);
if (data != null) {
previousSearchPatterns.add(data);
}
}
}
} catch (NumberFormatException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("Could not read the configuration of the page. Reason: ") + e.getMessage()));
}
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class LogSearchResultPage method openTextTableView.
private TextTableView openTextTableView(final IFile logFile, final int recordToSelect) {
try {
TextTableView part = (TextTableView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString(), IWorkbenchPage.VIEW_VISIBLE);
part.setInput(logFile, recordToSelect);
return part;
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.5") + e.getMessage()));
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.6") + e.getMessage()));
} catch (ClassNotFoundException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.7") + e.getMessage()));
}
return null;
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class ImportExportUtils method exportToXml.
protected static void exportToXml(String pageID, Map<String, String[]> settings, boolean useIndentation, OutputStream stream) throws TechnicalException {
try {
Document document = createDocument(pageID);
Element root = document.getDocumentElement();
root.setAttribute(VERSION_ATTRIBUTE_KEY, CURRENT_LV_VERSION);
// Add all keys/values
SortedMap<String, String[]> sortedMap = new TreeMap<String, String[]>(settings);
for (Map.Entry<String, String[]> entry : sortedMap.entrySet()) {
String currentKey = entry.getKey();
String[] values = entry.getValue();
Element parent = document.createElement(currentKey);
if (useIndentation) {
root.appendChild(document.createTextNode(NEW_LINE + PARENT_INDENTATION));
}
root.appendChild(parent);
for (int i = 0; i < values.length; i++) {
addStringElement(useIndentation, document, parent, values[i]);
addNewLineIfLast(document, parent, values, i);
}
}
// if last parent
if (useIndentation) {
root.appendChild(document.createTextNode(NEW_LINE));
}
writeDocument(stream, document);
} catch (ParserConfigurationException e) {
throw new TechnicalException(e);
} catch (TransformerException e) {
throw new TechnicalException(e);
}
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class LogFileCacheHandler method processLogFile.
/**
* Processes the given LogFile if it has changed. The property file, index file, and log record index file will be created.
* Does nothing if the log file has not changed, or test case extraction is already running on the file.
* @param logFile The log file
* @param pMonitor Progress monitor.
* @param quietMode If false, the error messages will be displayed to the user.
* @return true if the processing was successful, false otherwise
*/
public static boolean processLogFile(final IFile logFile, final IProgressMonitor pMonitor, final boolean quietMode) {
IProgressMonitor monitor = pMonitor == null ? new NullProgressMonitor() : pMonitor;
if (!logFile.exists()) {
if (!quietMode) {
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException("The log file does not exist: " + logFile.getName()));
}
return false;
}
try {
Object temp = logFile.getSessionProperty(Constants.EXTRACTION_RUNNING);
if (temp != null && (Boolean) temp) {
if (!quietMode) {
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException("Test case extraction is running on the given logfile: " + logFile.getName()));
}
return false;
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
return false;
}
if (!LogFileCacheHandler.hasLogFileChanged(logFile)) {
return true;
}
try {
logFile.setSessionProperty(Constants.EXTRACTION_RUNNING, true);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
return false;
}
final LogFileHandler logFileHandler = new LogFileHandler(logFile);
try {
LogFileMetaData logFileMetaData = logFileHandler.autoDetect();
final TestCaseExtractor testCaseExtractor = new TestCaseExtractor();
testCaseExtractor.extractTestCasesFromLogFile(logFileMetaData, monitor);
if (monitor.isCanceled()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.findView("org.eclipse.ui.navigator.ProjectExplorer");
if (view instanceof CommonNavigator) {
CommonNavigator navigator = (CommonNavigator) view;
navigator.getCommonViewer().update(logFile, null);
navigator.getCommonViewer().collapseToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
}
}
});
return false;
}
fillCache(logFile, logFileMetaData, testCaseExtractor.getTestCases(), testCaseExtractor.getLogRecordIndexes());
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart view = activePage.findView("org.eclipse.ui.navigator.ProjectExplorer");
if (view instanceof CommonNavigator) {
CommonNavigator navigator = (CommonNavigator) view;
navigator.getCommonViewer().refresh(logFile, true);
navigator.getCommonViewer().expandToLevel(logFile, AbstractTreeViewer.ALL_LEVELS);
}
}
});
if (testCaseExtractor.failedDuringExtraction()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(null, Messages.getString("OpenTextTableProjectsViewMenuAction.8"), Messages.getString("OpenTextTableProjectsViewMenuAction.9"));
}
});
return false;
}
} catch (IOException e) {
if (!quietMode) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(// $NON-NLS-1$
new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.2") + e.getMessage()));
}
return false;
} catch (TechnicalException e) {
// invalid file format
if (!quietMode) {
MessageDialog.openError(Display.getDefault().getActiveShell(), "Invalid log file", e.getMessage());
}
return false;
} finally {
try {
logFile.setSessionProperty(Constants.EXTRACTION_RUNNING, false);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
return true;
}
Aggregations