use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ErlangSearchResult method isShownInEditor.
@Override
public boolean isShownInEditor(final Match match, final IEditorPart editor) {
final ErlangSearchElement ese = (ErlangSearchElement) match.getElement();
final IFile file = ResourceUtil.getFileFromLocation(ese.getModuleName());
if (editor instanceof ErlangEditor) {
final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
final IErlModule module = erlangEditor.getModule();
if (module != null) {
if (file != null) {
return file.equals(module.getResource());
}
return ese.getModuleName().equals(module.getFilePath());
}
}
return false;
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ErlangSearchResultPage method showMatch.
@Override
protected void showMatch(final Match match, final int offset, final int length, final boolean activate) throws PartInitException {
final Object element = match.getElement();
if (element instanceof ErlangSearchElement) {
final ErlangSearchElement ese = (ErlangSearchElement) element;
final IErlModule module = ese.getModule();
final IEditorPart editor = EditorUtility.openInEditor(module);
if (offset != 0) {
if (editor instanceof ErlangEditor) {
final AbstractErlangEditor ee = (AbstractErlangEditor) editor;
ee.selectAndReveal(offset, length);
} else if (editor != null) {
showWithMarker(editor, module, offset, length);
}
}
}
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class OpenItemAction method run.
@Override
public void run() {
log.info("Open item!");
final ISelection selection = viewer.getSelection();
if (!(selection instanceof ITreeSelection)) {
final IStatus executionStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Internall error occured: bad sellection type", null);
StatusManager.getManager().handle(executionStatus, StatusManager.SHOW);
return;
}
final ITreeSelection treeSelection = (ITreeSelection) selection;
final StatsTreeObject obj = (StatsTreeObject) treeSelection.getFirstElement();
if (obj.getClass().equals(ModuleStats.class)) {
openInEditor(obj.getLabel() + ".erl");
} else if (obj.getClass().equals(FunctionStats.class)) {
final FunctionStats fs = (FunctionStats) obj;
final String moduleName = ((StatsTreeObject) fs.getParent()).getLabel();
final IEditorPart p = openInEditor(moduleName + ".erl");
if (p == null || !(p instanceof ErlangEditor)) {
return;
}
final ErlangEditor editor = (ErlangEditor) p;
IErlModule module;
try {
module = ErlangEngine.getInstance().getModel().findModule(moduleName);
final IErlFunction f = module.findFunction(new ErlangFunction(fs.getLabel(), fs.getArity()));
editor.setSelection(f);
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
} else {
// disabled
}
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ErlBreakpointAdapterFactory method getAdapter.
@Override
@Nullable
public <@Nullable T> T getAdapter(final Object adaptableObject, final Class<@Nullable T> adapterType) {
if (adaptableObject instanceof ErlangEditor) {
final AbstractErlangEditor editorPart = (AbstractErlangEditor) adaptableObject;
final IResource resource = editorPart.getEditorInput().getAdapter(IResource.class);
if (resource != null) {
final String extension = resource.getFileExtension();
if (extension != null && "erl".equals(extension)) {
return adapterType.cast(new ErlLineBreakpointAdapter());
}
}
}
return null;
}
use of org.erlide.ui.editors.erl.ErlangEditor in project erlide_eclipse by erlang.
the class ShowOutlineAction method run.
@Override
public void run() {
if (getTextEditor() instanceof ErlangEditor) {
final ErlangEditor editor = (ErlangEditor) getTextEditor();
final Shell parent = getTextEditor().getSite().getShell();
final QuickOutlinePopupDialog quickOutlinePopupDialog = new QuickOutlinePopupDialog(parent, SWT.NONE, editor, editor, editor);
quickOutlinePopupDialog.open();
}
}
Aggregations