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) {
}
}
Aggregations