Search in sources :

Example 6 with ErlModelException

use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.

the class SimpleCodeInspectionHandler method createErlModuleList.

private ArrayList<IErlElement> createErlModuleList(final OtpErlangList modList) {
    final ArrayList<IErlElement> modules = new ArrayList<>();
    for (int i = 0; i < modList.arity(); ++i) {
        IErlModule m;
        try {
            m = extractModule(modList.elementAt(i));
            modules.add(m);
        } catch (final ErlModelException e) {
        }
    }
    return modules;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 7 with ErlModelException

use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.

the class DebuggerTraceView method gotoModuleLine.

// @Override
// public void createPartControl(final Composite parent) {
// viewer = new TreeViewer(new Tree(parent, SWT.H_SCROLL | SWT.V_SCROLL
// | SWT.MULTI | SWT.FULL_SELECTION));
// setViewer(viewer);
// super.createPartControl(parent);
// // parent.setLayout(new FillLayout());
// 
// viewer.getTree().setLinesVisible(true);
// viewer.setUseHashlookup(true);
// 
// createColumns();
// 
// viewer.setContentProvider(getContentProvider());
// viewer.setLabelProvider(new ColumnLabelProvider());
// getSite().setSelectionProvider(viewer);
// 
// viewer.setInput(this);
// DebugPlugin.getDefault().addDebugEventListener(this);
// 
// // viewer.getTree().addTreeListener(new TreeAdapter() {
// // @Override
// // public void treeCollapsed(final TreeEvent e) {
// // removeExpandedCategory((MarkerCategory) e.item.getData());
// // }
// //
// // @Override
// // public void treeExpanded(final TreeEvent e) {
// // addExpandedCategory((MarkerCategory) e.item.getData());
// // }
// // });
// 
// // // Set help on the view itself
// // viewer.getControl().addHelpListener(new HelpListener() {
// // public void helpRequested(HelpEvent e) {
// // Object provider = getAdapter(IContextProvider.class);
// // if (provider == null) {
// // return;
// // }
// //
// // IContext context = ((IContextProvider) provider)
// // .getContext(viewer.getControl());
// // PlatformUI.getWorkbench().getHelpSystem().displayHelp(context);
// // }
// //
// // });
// 
// viewer.getTree().addSelectionListener(new SelectionAdapter() {
// @Override
// public void widgetSelected(final SelectionEvent e) {
// final Object o = getSelectedInTree();
// final String msg = o == null ? "" : o.toString(); //$NON-NLS-1$
// getViewSite().getActionBars().getStatusLineManager()
// .setMessage(msg);
// 
// }
// });
// 
// viewer.getTree().addMouseListener(new MouseListener() {
// 
// public void mouseDoubleClick(final MouseEvent e) {
// final Object o = getSelectedInTree();
// if (o instanceof OtpErlangTuple) {
// final OtpErlangTuple t = (OtpErlangTuple) o;
// final OtpErlangTuple t2 = (OtpErlangTuple) t.elementAt(1);
// final OtpErlangTuple ieval = (OtpErlangTuple) t2
// .elementAt(0);
// final OtpErlangAtom mod = (OtpErlangAtom) ieval
// .elementAt(3);
// final String module = mod.atomValue();
// final OtpErlangLong lin = (OtpErlangLong) ieval
// .elementAt(2);
// try {
// final int line = lin.intValue();
// gotoModuleLine(module, line);
// } catch (final OtpErlangRangeException e1) {
// }
// 
// }
// }
// 
// public void mouseDown(final MouseEvent e) {
// }
// 
// public void mouseUp(final MouseEvent e) {
// }
// 
// });
// // PlatformUI.getWorkbench().getWorkingSetManager()
// // .addPropertyChangeListener(getWorkingSetListener());
// 
// // registerContextMenu();
// // initDragAndDrop();
// 
// }
protected void gotoModuleLine(final String moduleName, final int line) {
    final IWorkbenchWindow window = ErlideUIPlugin.getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    final IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    IEditorPart part = null;
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    IErlModule module;
    try {
        module = model.findModule(moduleName);
    } catch (final ErlModelException e) {
        ErlLogger.error(e);
        return;
    }
    IEditorInput input = null;
    input = EditorUtility.getEditorInput(module);
    if (input != null) {
        final String editorId = EditorUtility.getEditorID(input, module);
        if (editorId != null) {
            try {
                part = page.openEditor(input, editorId);
            } catch (final PartInitException e) {
                ErlideUIPlugin.errorDialog(window.getShell(), "Go to File", "Exception occurred", // 
                e);
            }
        }
    }
    if (part instanceof ErlangEditor) {
        part.setFocus();
        final ErlangEditor ee = (ErlangEditor) part;
        final IDocument d = ee.getDocument();
        int lineStart;
        int lineLength;
        try {
            lineStart = d.getLineOffset(line - 1);
            lineLength = d.getLineLength(line - 1);
            EditorUtility.revealInEditor(ee, lineStart, lineLength - 1);
        } catch (final BadLocationException e) {
            ErlLogger.error(e);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) IEditorPart(org.eclipse.ui.IEditorPart) ErlModelException(org.erlide.engine.model.ErlModelException) IErlModule(org.erlide.engine.model.root.IErlModule) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument) BadLocationException(org.eclipse.jface.text.BadLocationException) ErlangEditor(org.erlide.ui.editors.erl.ErlangEditor)

Example 8 with ErlModelException

use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.

the class DialyzerPreferencePage method doLinkActivated.

void doLinkActivated(final Link widget) {
    if (isProjectPreferencePage()) {
        openWorkspacePreferences(null);
    } else {
        final List<IProject> erlProjects = new ArrayList<>();
        final Set<IProject> projectsWithSpecifics = new HashSet<>();
        final IErlModel model = ErlangEngine.getInstance().getModel();
        try {
            for (final IErlProject ep : model.getErlangProjects()) {
                final IProject p = ep.getWorkspaceProject();
                if (hasProjectSpecificOptions(p)) {
                    projectsWithSpecifics.add(p);
                }
                erlProjects.add(p);
            }
        } catch (final ErlModelException e) {
        }
        final ProjectSelectionDialog dialog = new ProjectSelectionDialog(getShell(), erlProjects, projectsWithSpecifics);
        if (dialog.open() == Window.OK) {
            final IProject res = (IProject) dialog.getFirstResult();
            openProjectProperties(res);
        }
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList) ProjectSelectionDialog(org.erlide.ui.prefs.ProjectSelectionDialog) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Example 9 with ErlModelException

use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.

the class CoverMainTab method createControl.

@Override
public void createControl(final Composite parent) {
    final ScrolledComposite scrolled = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    final Composite comp = new Composite(scrolled, SWT.NONE);
    scrolled.setContent(comp);
    scrolled.setExpandVertical(true);
    scrolled.setExpandHorizontal(true);
    scrolled.setMinSize(760, 300);
    setControl(scrolled);
    final GridLayout mainLayout = new GridLayout();
    mainLayout.numColumns = 3;
    mainLayout.verticalSpacing = 15;
    mainLayout.horizontalSpacing = 20;
    mainLayout.marginHeight = 15;
    mainLayout.marginHeight = 15;
    comp.setLayout(mainLayout);
    final GridData gData = new GridData();
    gData.horizontalAlignment = GridData.FILL;
    gData.horizontalSpan = 3;
    singleRadio = new Button(comp, SWT.RADIO);
    singleRadio.setText("Run tests for a single module");
    singleRadio.setLayoutData(gData);
    singleRadio.addSelectionListener(radioSelectionListener);
    createModuleGroup(comp);
    allRadio = new Button(comp, SWT.RADIO);
    allRadio.setText("Run all tests in specific project");
    allRadio.setLayoutData(gData);
    allRadio.addSelectionListener(radioSelectionListener);
    createAllTestsGroup(comp);
    final Label testLabel = new Label(comp, SWT.NONE);
    testLabel.setText("Testing framework: ");
    testCombo = new Combo(comp, SWT.NONE);
    testCombo.setItems(new String[] { FrameworkType.EUNIT.getRepr() });
    testCombo.addModifyListener(basicModifyListener);
    Collection<IErlProject> projects;
    try {
        projects = ErlangEngine.getInstance().getModel().getErlangProjects();
        final List<String> ps = new ArrayList<>();
        for (final IErlProject p : projects) {
            ps.add(p.getName());
        }
    } catch (final ErlModelException e) {
        ErlLogger.warn(e);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ErlModelException(org.erlide.engine.model.ErlModelException) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 10 with ErlModelException

use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.

the class CoverMainTab method createProjectArray.

private Object[] createProjectArray() {
    Object[] array;
    try {
        final List<ProjectElement> res = new LinkedList<>();
        final Collection<IErlProject> projects = ErlangEngine.getInstance().getModel().getErlangProjects();
        for (final IErlProject p : projects) {
            final ProjectElement elem = new ProjectElement(p.getName(), PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT).createImage());
            res.add(elem);
        }
        array = res.toArray();
    } catch (final ErlModelException e) {
        array = new Object[0];
        ErlLogger.error(e);
    }
    return array;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ErlModelException(org.erlide.engine.model.ErlModelException) ProjectElement(org.erlide.cover.ui.launch.helpers.ProjectElement) LinkedList(java.util.LinkedList)

Aggregations

ErlModelException (org.erlide.engine.model.ErlModelException)45 IErlElement (org.erlide.engine.model.IErlElement)21 IErlModule (org.erlide.engine.model.root.IErlModule)21 IErlModel (org.erlide.engine.model.root.IErlModel)9 IErlProject (org.erlide.engine.model.root.IErlProject)9 ArrayList (java.util.ArrayList)8 IOpenable (org.erlide.engine.model.root.IOpenable)7 CoreException (org.eclipse.core.runtime.CoreException)6 IProject (org.eclipse.core.resources.IProject)5 IResource (org.eclipse.core.resources.IResource)5 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)4 IFile (org.eclipse.core.resources.IFile)4 IParent (org.erlide.engine.model.IParent)4 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)4 IErlFunctionClause (org.erlide.engine.model.erlang.IErlFunctionClause)4 Composite (org.eclipse.swt.widgets.Composite)3 ErlangEditor (org.erlide.ui.editors.erl.ErlangEditor)3 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)2 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2