use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class UngroupModuleparActionFromBrowser method performUngroupModulepar.
private void performUngroupModulepar() {
// 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, "UngroupModulepar");
Activator.getDefault().pauseHandlingResourceChanges();
// create refactoring
final UngroupModuleparRefactoring refactoring = new UngroupModuleparRefactoring(structSelection);
// open wizard
final UngroupModuleparWizard wiz = new UngroupModuleparWizard(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("UngroupModuleparActionFromBrowser: 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 MinimizeVisibilityActionFromBrowser method performMinimizeVisibility.
private void performMinimizeVisibility() {
// 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, "MinimizeVisibility");
Activator.getDefault().pauseHandlingResourceChanges();
// create refactoring
final MinimizeVisibilityRefactoring refactoring = new MinimizeVisibilityRefactoring(structSelection);
// open wizard
final MinimizeVisibilityWizard wiz = new MinimizeVisibilityWizard(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("MinimizeVisibilityActionFromBrowser: 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 MinimizeVisibilityActionFromEditor method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
// update AST
Utils.updateASTForProjectActiveInEditor("MinimizeVisibility");
Activator.getDefault().pauseHandlingResourceChanges();
// getting the active editor
final TTCN3Editor targetEditor = Utils.getActiveEditor();
if (targetEditor == null) {
return null;
}
// getting selected file
final IFile selectedFile = Utils.getSelectedFileInEditor("MinimizeVisibility");
if (selectedFile == null) {
return null;
}
final IStructuredSelection structSelection = new StructuredSelection(selectedFile);
final MinimizeVisibilityRefactoring refactoring = new MinimizeVisibilityRefactoring(structSelection);
// open wizard
final MinimizeVisibilityWizard wiz = new MinimizeVisibilityWizard(refactoring);
final RefactoringWizardOpenOperation operation = new RefactoringWizardOpenOperation(wiz);
try {
operation.run(targetEditor.getEditorSite().getShell(), "");
} catch (InterruptedException irex) {
// operation was cancelled
} catch (Exception e) {
ErrorReporter.logError("MinimizeVisibilityActionFromEditor: 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 OpenDeclaration method doOpenDeclaration.
private final void doOpenDeclaration() {
if (targetEditor == null || !(targetEditor instanceof TTCN3Editor)) {
return;
}
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(null);
IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
if (file == null) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(FILENOTIDENTIFIABLE);
return;
}
if (!TITANNature.hasTITANNature(file.getProject())) {
targetEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(TITANNature.NO_TITAN_FILE_NATURE_FOUND);
return;
}
if (ResourceExclusionHelper.isExcluded(file)) {
MessageDialog.openError(null, "Open Declaration does not work within excluded resources", "This module is excluded from build. To use the Open Declaration " + "feature please click on the 'Toggle exclude from build state' in the context menu of the Project Explorer. ");
return;
}
IPreferencesService prefs = Platform.getPreferencesService();
boolean reportDebugInformation = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
int offset;
if (selection instanceof TextSelection && !selection.isEmpty() && !"".equals(((TextSelection) selection).getText())) {
if (reportDebugInformation) {
TITANDebugConsole.println("text selected: " + ((TextSelection) selection).getText());
}
TextSelection tSelection = (TextSelection) selection;
offset = tSelection.getOffset() + tSelection.getLength();
} else {
offset = ((TTCN3Editor) targetEditor).getCarretOffset();
}
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
final Module module = projectSourceParser.containedModule(file);
if (module == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("The file " + file.getLocation() + "does not seem to contain a valid module.");
CompilationTimeStamp timestamp = projectSourceParser.getLastTimeChecked();
if (timestamp == null) {
TITANDebugConsole.println("The project " + file.getProject() + " was not yet analyzed semantically");
} else {
TITANDebugConsole.println("The project " + file.getProject() + " was last checked in " + projectSourceParser.getLastTimeChecked().toString());
}
}
return;
}
IdentifierFinderVisitor visitor = new IdentifierFinderVisitor(offset);
module.accept(visitor);
final Declaration decl = visitor.getReferencedDeclaration();
if (decl == null) {
if (reportDebugInformation) {
TITANDebugConsole.println("No visible elements found");
}
return;
}
selectAndRevealDeclaration(decl.getIdentifier().getLocation());
return;
}
use of org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor in project titan.EclipsePlug-ins by eclipse.
the class ToggleComment method doOperation.
@Override
protected void doOperation(final int operationCode) {
final ITextEditor editor = getTextEditor();
final Reconciler reconciler = ((TTCN3Editor) editor).getReconciler();
reconciler.allowIncrementalReconciler(false);
operationTarget.doOperation(operationCode);
reconciler.allowIncrementalReconciler(true);
}
Aggregations