use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class ContextLoggingActionFromBrowser method performContextLogging.
private void performContextLogging() {
// find selection
if (!(selection instanceof IStructuredSelection)) {
return;
}
final IStructuredSelection structSelection = (IStructuredSelection) selection;
final Set<IProject> projsToUpdate = Utils.findAllProjectsInSelection(structSelection);
// update AST before refactoring
Utils.updateASTBeforeRefactoring(projsToUpdate, "ContextLogging");
Activator.getDefault().pauseHandlingResourceChanges();
// create refactoring
final ContextLoggingRefactoring refactoring = new ContextLoggingRefactoring(structSelection, null);
// open wizard
final ContextLoggingWizard wiz = new ContextLoggingWizard(refactoring);
final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
// getting the active editor
final TTCN3Editor targetEditor = Utils.getActiveEditor();
try {
operation.run(targetEditor == null ? null : targetEditor.getEditorSite().getShell(), "");
} catch (InterruptedException irex) {
// operation was cancelled
} catch (Exception e) {
ErrorReporter.logError("ContextLoggingActionFromBrowser: Error while performing refactoring change! ");
ErrorReporter.logExceptionStackTrace(e);
}
Activator.getDefault().resumeHandlingResourceChanges();
// update AST after refactoring
Utils.updateASTAfterRefactoring(wiz, refactoring.getAffectedObjects(), refactoring.getName());
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class ContextLoggingActionFromEditor method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
// update AST
Utils.updateASTForProjectActiveInEditor("ContextLogging");
Activator.getDefault().pauseHandlingResourceChanges();
// getting the active editor
final TTCN3Editor targetEditor = Utils.getActiveEditor();
if (targetEditor == null) {
return null;
}
// getting status line manager
statusLineManager = targetEditor.getEditorSite().getActionBars().getStatusLineManager();
// getting selected file
final IFile selectedFile = Utils.getSelectedFileInEditor("MinimizeVisibility");
if (selectedFile == null) {
return null;
}
// getting selection
final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
final ISelection sel = selectionService.getSelection();
if (sel == null) {
setStatusLineMsg(ERR_MSG_NO_SELECTION, statusLineManager);
return null;
} else if (!(sel instanceof TextSelection)) {
ErrorReporter.logError("ContextLoggingActionFromEditor:" + " selection is not a TextSelection");
return null;
}
selection = (TextSelection) sel;
//
ContextLoggingRefactoring refactoring;
if (selection.getLength() == 0) {
final IStructuredSelection ssel = new StructuredSelection(new Object[] { selectedFile });
refactoring = new ContextLoggingRefactoring(ssel, null);
} else {
refactoring = new ContextLoggingRefactoring(selectedFile, selection, null);
}
// open wizard
final ContextLoggingWizard wiz = new ContextLoggingWizard(refactoring);
final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
try {
operation.run(targetEditor.getEditorSite().getShell(), "");
} catch (InterruptedException irex) {
// operation was cancelled
} catch (Exception e) {
ErrorReporter.logError("ContextLoggingActionFromEditor: Error while performing refactoring change! ");
ErrorReporter.logExceptionStackTrace(e);
}
// update AST again
Activator.getDefault().resumeHandlingResourceChanges();
final IProject project = selectedFile.getProject();
GlobalParser.getProjectSourceParser(project).reportOutdating(selectedFile);
GlobalParser.getProjectSourceParser(project).analyzeAll();
return null;
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class MinimizeScopeActionFromBrowser method performMinimizeScope.
private void performMinimizeScope() {
// getting the active editor
final TTCN3Editor targetEditor = Utils.getActiveEditor();
// find selection
if (!(selection instanceof IStructuredSelection)) {
return;
}
final IStructuredSelection structSelection = (IStructuredSelection) selection;
final Set<IProject> projsToUpdate = Utils.findAllProjectsInSelection(structSelection);
// update AST before refactoring
Utils.updateASTBeforeRefactoring(projsToUpdate, "MinimizeScope");
Activator.getDefault().pauseHandlingResourceChanges();
// create refactoring
final MinimizeScopeRefactoring refactoring = new MinimizeScopeRefactoring(structSelection, null);
// open wizard
final MinimizeScopeWizard wiz = new MinimizeScopeWizard(refactoring);
final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
try {
operation.run(targetEditor == null ? null : targetEditor.getEditorSite().getShell(), "");
} catch (InterruptedException irex) {
// operation was cancelled
} catch (Exception e) {
ErrorReporter.logError("MinimizeScopeActionFromBrowser: Error while performing refactoring change! ");
ErrorReporter.logExceptionStackTrace(e);
}
Activator.getDefault().resumeHandlingResourceChanges();
// update AST after refactoring
Utils.updateASTAfterRefactoring(wiz, refactoring.getAffectedObjects(), refactoring.getName());
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class MinimizeScopeActionFromEditor method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
// update AST
Utils.updateASTForProjectActiveInEditor("MinimizeScope");
Activator.getDefault().pauseHandlingResourceChanges();
// getting the active editor
final TTCN3Editor targetEditor = Utils.getActiveEditor();
if (targetEditor == null) {
return null;
}
// get selected definition
selection = findSelection();
if (selection == null) {
return null;
}
final IResource selectedRes = selection.getLocation().getFile();
if (!(selectedRes instanceof IFile)) {
ErrorReporter.logError("MinimizeScopeActionFromEditor.execute(): Selected resource `" + selectedRes.getName() + "' is not a file.");
return null;
}
final IFile selectedFile = (IFile) selectedRes;
//
final MinimizeScopeRefactoring refactoring = new MinimizeScopeRefactoring(selection, null);
// open wizard
final MinimizeScopeWizard wiz = new MinimizeScopeWizard(refactoring);
final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
try {
operation.run(targetEditor.getEditorSite().getShell(), "");
} catch (InterruptedException irex) {
// operation was cancelled
} catch (Exception e) {
ErrorReporter.logError("MinimizeScopeActionFromEditor: Error while performing refactoring change! ");
ErrorReporter.logExceptionStackTrace(e);
}
// update AST again
Activator.getDefault().resumeHandlingResourceChanges();
final IProject project = selectedFile.getProject();
GlobalParser.getProjectSourceParser(project).reportOutdating(selectedFile);
GlobalParser.getProjectSourceParser(project).analyzeAll();
return null;
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class MinimizeScopeActionFromEditor method findSelection.
private Definition findSelection() {
// getting the active editor
final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
TTCN3Editor targetEditor;
if (editor == null || !(editor instanceof TTCN3Editor)) {
return null;
} else {
targetEditor = (TTCN3Editor) editor;
}
final IStatusLineManager statusLineManager = targetEditor.getEditorSite().getActionBars().getStatusLineManager();
// getting current selection
final ISelectionService selectionService = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
final TextSelection textSelection = extractSelection(selectionService.getSelection());
// iterating through part of the module
final IResource selectedRes = extractResource(targetEditor);
if (!(selectedRes instanceof IFile)) {
ErrorReporter.logError("SelectionFinder.findSelection(): Selected resource `" + selectedRes.getName() + "' is not a file.");
return null;
}
final IFile selectedFile = (IFile) selectedRes;
final ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(selectedFile.getProject());
final Module selectedModule = projectSourceParser.containedModule(selectedFile);
// getting current selection nodes
final int selectionOffset = textSelection.getOffset() + textSelection.getLength();
final SelectionFinderVisitor selVisitor = new SelectionFinderVisitor(selectionOffset);
selectedModule.accept(selVisitor);
final Definition selectedDef = selVisitor.getSelection();
if (selectedDef == null) {
ErrorReporter.logWarning("SelectionFinder.findSelection(): Visitor did not find a definition in the selection.");
statusLineManager.setErrorMessage(ERR_MSG_NO_SELECTION);
return null;
}
return selectedDef;
}
Aggregations