use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class FilterAction method run.
@Override
public void run() {
if (isFilterRunning) {
MessageBox msgBox = new MessageBox(textTableView.getSite().getShell());
msgBox.setMessage("The filter is already running!");
msgBox.setText("Filter");
msgBox.open();
return;
}
isFilterRunning = true;
if (textTableView.getFilterPattern() == null) {
textTableView.setFilterPattern(new FilterPattern(new TimeInterval("", "", textTableView.getLogFileMetaData().getTimeStampFormat())));
SortedMap<String, Boolean> eventsToFilter = new TreeMap<String, Boolean>();
for (Map.Entry<String, String[]> entry : Constants.EVENT_CATEGORIES.entrySet()) {
eventsToFilter.put(entry.getKey(), true);
}
textTableView.getFilterPattern().setEventsToFilter(eventsToFilter, true, false);
}
MSCFilterDialog dialog = new MSCFilterDialog(textTableView.getSite().getShell(), textTableView.getFilterPattern());
if (dialog.open() == 0 && dialog.getChanged() && !dialog.getFilterPattern().equals(textTableView.getFilterPattern())) {
final FilterPattern tmpFilterPattern = dialog.getFilterPattern();
WorkspaceJob op = new WorkspaceJob("Filtering") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
try {
textTableView.getFilteredLogReader().runFilter(tmpFilterPattern, monitor);
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("TextTableModel.6") + e.getMessage()));
monitor.setCanceled(true);
} catch (ParseException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("TextTableModel.7") + e.getMessage()));
monitor.setCanceled(true);
}
if (monitor.isCanceled()) {
monitor.done();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
isFilterRunning = false;
textTableView.getTable().setEnabled(true);
}
});
monitor.done();
return Status.CANCEL_STATUS;
}
monitor.done();
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
textTableView.setFilterPattern(tmpFilterPattern);
textTableView.refreshTable();
isFilterRunning = false;
textTableView.getTable().setEnabled(true);
}
});
return Status.OK_STATUS;
}
};
op.setPriority(Job.LONG);
op.setSystem(false);
op.setUser(true);
op.setRule(ResourcesPlugin.getWorkspace().getRoot());
op.setProperty(IProgressConstants.ICON_PROPERTY, Activator.getImageDescriptor("titan.gif"));
textTableView.getTable().setEnabled(false);
op.schedule();
} else {
isFilterRunning = false;
}
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class LogSearchPage method getLogFilesFromResource.
private void getLogFilesFromResource(final IResource resource, final List<IFile> files) {
if (resource == null || files == null) {
return;
}
if (resource instanceof IFile) {
IFile myFile = (IFile) resource;
if (isValidLogFile(myFile) && !files.contains(myFile)) {
files.add((IFile) resource);
}
} else if (resource instanceof IContainer) {
try {
if (resource instanceof IProject) {
IProject project = (IProject) resource;
if (!project.isOpen() || project.getNature(Constants.NATURE_ID) == null) {
return;
}
}
for (IResource r : ((IContainer) resource).members()) {
getLogFilesFromResource(r, files);
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(// $NON-NLS-1$
new TechnicalException(Messages.getString("Could not collect the log files. Reason: ") + e.getMessage()));
}
}
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class LogSearchResultPage method configureTreeViewer.
@Override
protected void configureTreeViewer(final TreeViewer viewer) {
treeViewer = viewer;
contentProvider = new TreeContentProvider(this);
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(new SearchLabelProvider());
viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
try {
Object selectedElement = ((TreeSelection) event.getSelection()).getFirstElement();
if (selectedElement instanceof Match) {
showMatch((Match) selectedElement, 0, 0, true);
return;
}
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException("Could not show the selected match. Reason: " + e.getMessage()));
}
}
});
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class TextTableViewHelper method open.
/**
* Opens a TextTable view for the given log file. If the view is already open
* the record with the number recordToSelect will be selected.
* @param projectName The name of the logfile's project.
* @param projectRelativePath The project relative path of the log file
* @param recordToSelect The number of the record that will be initially selected.
* @return The newly created view or null if the view can not be opened.
*/
public static TextTableView open(final String projectName, final String projectRelativePath, final int recordToSelect) {
String secondId = projectRelativePath;
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference reference = activePage.findViewReference(Constants.TEXT_TABLE_VIEW_ID, secondId);
if (reference != null) {
try {
TextTableView view = (TextTableView) activePage.showView(Constants.TEXT_TABLE_VIEW_ID, secondId, IWorkbenchPage.VIEW_ACTIVATE);
view.setSelectedRecord(recordToSelect);
view.setFocus();
return view;
} catch (PartInitException e) {
// do nothing
}
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject(projectName);
final IFile logFile = project.getFile(projectRelativePath.substring(projectName.length() + 1));
if (!logFile.exists()) {
IViewReference[] viewReferences = activePage.getViewReferences();
ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenMSCViewMenuAction.4")));
return null;
}
try {
Object temp = logFile.getSessionProperty(Constants.EXTRACTION_RUNNING);
if (temp != null && (Boolean) temp) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(null, "View can not be opened.", "Test case extraction is already running on " + logFile.getName());
}
});
return null;
}
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new UserException(e.getMessage()));
}
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
LogFileCacheHandler.handleLogFileChange(logFile);
return null;
}
try {
TextTableView view = (TextTableView) activePage.showView(Constants.TEXT_TABLE_VIEW_ID, secondId, IWorkbenchPage.VIEW_ACTIVATE);
view.setInput(logFile, recordToSelect);
view.setFocus();
return view;
} catch (FileNotFoundException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.0") + e.getMessage()));
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.1") + e.getMessage()));
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.2") + e.getMessage()));
} catch (ClassNotFoundException e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableTestCasesViewMenuAction.2") + e.getMessage()));
}
return null;
}
use of org.eclipse.titan.log.viewer.exceptions.TechnicalException in project titan.EclipsePlug-ins by eclipse.
the class Activator method getCachedResource.
/**
* Return the resource asked for, if the resource is not found in the cache, it will be created
* @param key the resource key
* @return resource the resource
*/
public Resource getCachedResource(final RGB color) {
String key = String.valueOf(color.red) + PreferenceConstants.RGB_COLOR_SEPARATOR + String.valueOf(color.green) + PreferenceConstants.RGB_COLOR_SEPARATOR + String.valueOf(color.blue);
if (this.guiResourceCache.containsKey(key)) {
return this.guiResourceCache.get(key);
}
Resource resource = new Color(Display.getDefault(), color);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException("Resource could not be found"));
return addResource(key, resource);
}
Aggregations