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;
}
}
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);
}
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;
}
}
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;
}
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();
}
Aggregations