use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class WranglerUtils method notifyErlide.
/**
* Notifies Erlide about the changed files.
*
* @param changedFiles
* changed files
*/
public static void notifyErlide(final List<ChangedFile> changedFiles) {
final IErlModel model = ErlangEngine.getInstance().getModel();
for (final ChangedFile f : changedFiles) {
IFile file;
try {
file = WranglerUtils.getFileFromPath(f.getNewPath());
final IErlElement element = model.findElement(file);
final IErlModule m = (IErlModule) element;
m.resourceChanged(null);
final IEditorPart editor = GlobalParameters.getEditor();
if (editor instanceof ErlangEditor) {
((ErlangEditor) editor).resetAndCacheScannerAndParser();
}
model.notifyChange(m);
} catch (final Exception e) {
ErlLogger.error(e);
}
}
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ExpandCollapseAllHandler method execute.
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (!(activeEditor instanceof ErlangEditor)) {
return null;
}
final ErlangEditor editor = (ErlangEditor) activeEditor;
final boolean collapse = "collapse".equals(event.getParameter("org.erlide.ui.commands.expandCollapseParameter"));
final boolean comments = "comments".equals(event.getParameter("org.erlide.ui.commands.foldWhatParameter"));
editor.expandCollapseFunctionsOrComments(collapse, comments);
return null;
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class DefaultErlangFoldingStructureProvider method install.
@Override
public void install(final ITextEditor editor, final ProjectionViewer viewer) {
if (editor instanceof ErlangEditor) {
fFirstTimeInitialCollapse = true;
fEditor = editor;
fViewer = viewer;
fViewer.addProjectionListener(this);
final IErlModel mdl = ErlangEngine.getInstance().getModel();
mdl.addModelChangeListener(this);
}
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class EditorUtility method getAllErlangEditors.
public static Collection<IEditorPart> getAllErlangEditors() {
final List<IEditorPart> result = Lists.newArrayList();
final IWorkbench workbench = ErlideUIPlugin.getDefault().getWorkbench();
for (final IWorkbenchWindow i : workbench.getWorkbenchWindows()) {
for (final IWorkbenchPage j : i.getPages()) {
for (final IEditorReference editorReference : j.getEditorReferences()) {
final IEditorPart editorPart = editorReference.getEditor(false);
if (editorPart instanceof ErlangEditor) {
result.add(editorPart);
}
}
}
}
return result;
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ConvertMultiStringQuickFix method appliesAt.
@Override
public boolean appliesAt(final IQuickAssistInvocationContext invocationContext) {
final ISourceViewer viewer = invocationContext.getSourceViewer();
final IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (!(editorPart instanceof ErlangEditor)) {
return false;
}
final ErlangEditor editor = (ErlangEditor) editorPart;
if (editor.getViewer() != viewer) {
return false;
}
final IErlModule module = editor.getModule();
final int offset = invocationContext.getOffset();
final ErlToken token = module.getScanner().getTokenAt(offset);
if (token == null || token.getKind() != ErlToken.KIND_STRING) {
return false;
}
final IDocument doc = viewer.getDocument();
String text;
try {
text = doc.get(token.getOffset(), token.getLength());
if (text.contains("\n")) {
return true;
}
} catch (final BadLocationException e) {
}
return false;
}
Aggregations