Search in sources :

Example 1 with PopupListSelector

use of ca.mcgill.sable.soot.ui.PopupListSelector in project soot by Sable.

the class SootAttributeSelectAction method run.

public void run() {
    // need to get list of texts
    IAnnotationModel model = getEditor().getDocumentProvider().getAnnotationModel(getEditor().getEditorInput());
    if (model instanceof AbstractMarkerAnnotationModel) {
        setModel((AbstractMarkerAnnotationModel) model);
    }
    int markerLine = getRulerInfo().getLineOfLastMouseButtonActivity();
    IResource rec = getResource(getEditor());
    try {
        IMarker[] markers = rec.findMarkers("ca.mcgill.sable.soot.sootattributemarker", true, IResource.DEPTH_INFINITE);
        for (int i = 0; i < markers.length; i++) {
            if (getModel().getMarkerPosition(markers[i]) == null)
                continue;
            setLineNumber(getDocument().getLineOfOffset(getModel().getMarkerPosition(markers[i]).getOffset()));
            if (getLineNumber() == markerLine) {
                ArrayList links = getMarkerLinks();
                Iterator lit = links.iterator();
                String[] list = getMarkerLabels(links);
                if ((list == null) || (list.length == 0)) {
                // show no links
                } else {
                    IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getWorkbenchWindow();
                    PopupListSelector popup = new PopupListSelector(window.getShell());
                    popup.setItems(list);
                    int listWidth = getListWidth(list);
                    if (getEditor() instanceof JimpleEditor) {
                        int topIndex = ((JimpleEditor) getEditor()).getViewer().getTopIndex();
                        Rectangle rect = new Rectangle(320, (getLineNumber() + 1 - topIndex), listWidth, 45);
                        popup.open(rect);
                    } else {
                        int topIndex = ((ITextViewer) ((AbstractTextEditor) getEditor()).getAdapter(ITextOperationTarget.class)).getTopIndex();
                        int pos = getModel().getMarkerPosition(markers[i]).getOffset();
                        pos = pos / getLineNumber();
                        Rectangle rect = new Rectangle(320, getLineNumber() + 1 - topIndex, listWidth, 45);
                        popup.open(rect);
                    }
                    handleSelection(popup.getSelected(), links);
                }
            }
        }
    } catch (CoreException e) {
    } catch (BadLocationException e1) {
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) PopupListSelector(ca.mcgill.sable.soot.ui.PopupListSelector) ArrayList(java.util.ArrayList) Rectangle(org.eclipse.swt.graphics.Rectangle) JimpleEditor(ca.mcgill.sable.soot.editors.JimpleEditor) Iterator(java.util.Iterator)

Aggregations

JimpleEditor (ca.mcgill.sable.soot.editors.JimpleEditor)1 PopupListSelector (ca.mcgill.sable.soot.ui.PopupListSelector)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1