Search in sources :

Example 1 with ABSEditor

use of org.absmodels.abs.plugin.editor.ABSEditor in project abstools by abstools.

the class NewModuleWizard method performFinish.

@Override
public boolean performFinish() {
    IFile resultFile = page.getResultFile();
    if (resultFile != null) {
        ABSEditor editor = UtilityFunctions.openABSEditorForFile(resultFile.getLocation(), resultFile.getProject());
        IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        // modules are always added the the end of the document
        final int off = document.getLength();
        try {
            document.replace(off, 0, insertType.getInsertionString(page.getResult()));
            final int insertOffset = insertType.getInsertOffset(page.getResult());
            WizardUtil.saveEditorAndGotoOffset(editor, insertOffset);
            return true;
        } catch (BadLocationException e) {
            MessageDialog.openError(getShell(), "Error", "Fatal error: The insertion position for the new module does not longer exist. Please save the target file and try again.");
            e.printStackTrace();
            return false;
        }
    } else {
        MessageDialog.openError(getShell(), "Error", "Fatal error: No file reference was passed by the wizard. Please try again to use the wizard and select a valid file.");
        return false;
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ABSEditor(org.absmodels.abs.plugin.editor.ABSEditor) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 2 with ABSEditor

use of org.absmodels.abs.plugin.editor.ABSEditor in project abstools by abstools.

the class NavigatorUtils method openAndHighlightEditor.

private static void openAndHighlightEditor(InternalASTNode<?> node) throws PartInitException {
    ABSEditor editorPart = openABSEditorForFile(node.getFileName(), node.getProject());
    editorPart.highlightInEditor(node, true);
}
Also used : ABSEditor(org.absmodels.abs.plugin.editor.ABSEditor)

Example 3 with ABSEditor

use of org.absmodels.abs.plugin.editor.ABSEditor in project abstools by abstools.

the class UtilityFunctions method jumpToPosition.

public static boolean jumpToPosition(IProject project, EditorPosition pos) {
    ABSEditor targeteditor = UtilityFunctions.openABSEditorForFile(pos.getPath(), project);
    if (targeteditor == null) {
        return false;
    }
    IDocument doc = targeteditor.getDocumentProvider().getDocument(targeteditor.getEditorInput());
    try {
        int startoff = doc.getLineOffset(pos.getLinestart() - 1) + pos.getColstart() - 1;
        targeteditor.getSelectionProvider().setSelection(new TextSelection(startoff, 0));
        return true;
    } catch (BadLocationException ex) {
        Activator.logException(ex);
        return false;
    }
}
Also used : TextSelection(org.eclipse.jface.text.TextSelection) ABSEditor(org.absmodels.abs.plugin.editor.ABSEditor) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 4 with ABSEditor

use of org.absmodels.abs.plugin.editor.ABSEditor in project abstools by abstools.

the class NewABSFileWizard method performFinish.

@Override
public boolean performFinish() {
    IFile file = mainPage.createNewFile();
    if (file != null) {
        try {
            ABSEditor targeteditor = (ABSEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
            insertModuleDeclaration(targeteditor);
        } catch (PartInitException e) {
            e.printStackTrace(ConsoleManager.getDefault().getPrintStream(MessageType.MESSAGE_ERROR));
        } catch (BadLocationException e) {
            e.printStackTrace(ConsoleManager.getDefault().getPrintStream(MessageType.MESSAGE_ERROR));
        }
        return true;
    } else
        return false;
}
Also used : IFile(org.eclipse.core.resources.IFile) ABSEditor(org.absmodels.abs.plugin.editor.ABSEditor) PartInitException(org.eclipse.ui.PartInitException) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 5 with ABSEditor

use of org.absmodels.abs.plugin.editor.ABSEditor in project abstools by abstools.

the class OpenTypeHierarchyDelegate method run.

@Override
public void run(IAction action) {
    if (!(editor instanceof ABSEditor)) {
        return;
    }
    ABSEditor abseditor = (ABSEditor) editor;
    TextSelection sel = (TextSelection) abseditor.getSelectionProvider().getSelection();
    TypeHierarchyView view = TypeHierarchyView.get();
    if (view == null) {
        return;
    }
    InternalASTNode<?> node = getNodeUnderCursor(abseditor, sel);
    view.setNode(node);
    view.bringToTop();
}
Also used : TextSelection(org.eclipse.jface.text.TextSelection) ABSEditor(org.absmodels.abs.plugin.editor.ABSEditor)

Aggregations

ABSEditor (org.absmodels.abs.plugin.editor.ABSEditor)5 BadLocationException (org.eclipse.jface.text.BadLocationException)3 IFile (org.eclipse.core.resources.IFile)2 IDocument (org.eclipse.jface.text.IDocument)2 TextSelection (org.eclipse.jface.text.TextSelection)2 PartInitException (org.eclipse.ui.PartInitException)1