Search in sources :

Example 6 with AbstractErlangEditor

use of org.erlide.ui.editors.erl.AbstractErlangEditor in project erlide_eclipse by erlang.

the class ErlangNodeLaunchShortcut method launch.

@Override
public void launch(final IEditorPart editor, final String mode) {
    ErlLogger.debug("** Launch :: " + editor.getTitle());
    if (editor instanceof AbstractErlangEditor) {
        final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
        final IErlProject project = erlangEditor.getProject();
        if (project != null) {
            try {
                doLaunch(mode, Lists.newArrayList(project));
            } catch (final CoreException e) {
                final IWorkbench workbench = PlatformUI.getWorkbench();
                final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
                MessageDialog.openError(shell, "Error", e.getStatus().getMessage());
            }
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IWorkbench(org.eclipse.ui.IWorkbench) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 7 with AbstractErlangEditor

use of org.erlide.ui.editors.erl.AbstractErlangEditor in project erlide_eclipse by erlang.

the class ErlangSearchPage method tryErlangTextSelection.

public SearchPatternData tryErlangTextSelection(final SearchPatternData initData0, final IEditorPart activePart) throws ErlModelException {
    final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) activePart;
    final IErlModule module = erlangEditor.getModule();
    SearchPatternData initData = initData0;
    if (module != null) {
        final ISelection ssel = erlangEditor.getSite().getSelectionProvider().getSelection();
        final ITextSelection textSel = (ITextSelection) ssel;
        final int offset = textSel.getOffset();
        OpenResult res;
        try {
            res = ErlangEngine.getInstance().getOpenService().open(module.getScannerName(), offset, ErlangEngine.getInstance().getModelUtilService().getImportsAsList(module), "", ErlangEngine.getInstance().getModel().getPathVars());
        } catch (final RpcException e) {
            res = null;
        }
        ErlLogger.debug("searchPage(open) " + res);
        initData = determineInitValuesFrom(module, offset, res);
    }
    return initData;
}
Also used : OpenResult(org.erlide.engine.services.search.OpenResult) RpcException(org.erlide.runtime.rpc.RpcException) IErlModule(org.erlide.engine.model.root.IErlModule) ISelection(org.eclipse.jface.viewers.ISelection) ITextSelection(org.eclipse.jface.text.ITextSelection) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 8 with AbstractErlangEditor

use of org.erlide.ui.editors.erl.AbstractErlangEditor 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;
}
Also used : IFile(org.eclipse.core.resources.IFile) IErlModule(org.erlide.engine.model.root.IErlModule) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 9 with AbstractErlangEditor

use of org.erlide.ui.editors.erl.AbstractErlangEditor 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);
            }
        }
    }
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) IEditorPart(org.eclipse.ui.IEditorPart) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor)

Example 10 with AbstractErlangEditor

use of org.erlide.ui.editors.erl.AbstractErlangEditor 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;
}
Also used : IResource(org.eclipse.core.resources.IResource) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) AbstractErlangEditor(org.erlide.ui.editors.erl.AbstractErlangEditor) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

AbstractErlangEditor (org.erlide.ui.editors.erl.AbstractErlangEditor)13 IErlModule (org.erlide.engine.model.root.IErlModule)8 IErlProject (org.erlide.engine.model.root.IErlProject)4 ErlangEditor (org.erlide.ui.editors.erl.ErlangEditor)4 IEditorPart (org.eclipse.ui.IEditorPart)3 IErlElement (org.erlide.engine.model.IErlElement)3 OpenResult (org.erlide.engine.services.search.OpenResult)3 IFile (org.eclipse.core.resources.IFile)2 IProject (org.eclipse.core.resources.IProject)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 ITextSelection (org.eclipse.jface.text.ITextSelection)2 IOtpRpc (org.erlide.runtime.rpc.IOtpRpc)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 ITypedRegion (org.eclipse.jface.text.ITypedRegion)1 TextSelection (org.eclipse.jface.text.TextSelection)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1