Search in sources :

Example 6 with TTCN3Editor

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());
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 7 with TTCN3Editor

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());
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IProject(org.eclipse.core.resources.IProject) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 8 with TTCN3Editor

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;
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) IFile(org.eclipse.core.resources.IFile) RefactoringWizardOpenOperation(org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExecutionException(org.eclipse.core.commands.ExecutionException) IProject(org.eclipse.core.resources.IProject)

Example 9 with TTCN3Editor

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;
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) IFile(org.eclipse.core.resources.IFile) IdentifierFinderVisitor(org.eclipse.titan.designer.declarationsearch.IdentifierFinderVisitor) TextSelection(org.eclipse.jface.text.TextSelection) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) Declaration(org.eclipse.titan.designer.declarationsearch.Declaration) Module(org.eclipse.titan.designer.AST.Module) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) ProjectSourceParser(org.eclipse.titan.designer.parsers.ProjectSourceParser)

Example 10 with TTCN3Editor

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);
}
Also used : TTCN3Editor(org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) Reconciler(org.eclipse.titan.designer.editors.ttcn3editor.Reconciler)

Aggregations

TTCN3Editor (org.eclipse.titan.designer.editors.ttcn3editor.TTCN3Editor)24 IProject (org.eclipse.core.resources.IProject)15 IFile (org.eclipse.core.resources.IFile)14 ExecutionException (org.eclipse.core.commands.ExecutionException)13 RefactoringWizardOpenOperation (org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation)13 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 TextSelection (org.eclipse.jface.text.TextSelection)7 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)7 IEditorPart (org.eclipse.ui.IEditorPart)5 IResource (org.eclipse.core.resources.IResource)4 Module (org.eclipse.titan.designer.AST.Module)4 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)4 ISelectionService (org.eclipse.ui.ISelectionService)4 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)3 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)3 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IStatusLineManager (org.eclipse.jface.action.IStatusLineManager)2 Reconciler (org.eclipse.titan.designer.editors.ttcn3editor.Reconciler)2 HashSet (java.util.HashSet)1