protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { try { ResourceBundle rb = SootPlugin.getDefault().getResourceBundle(); if (editor instanceof JimpleEditor){ return new SootAttributeJimpleSelectAction(rb, null, editor, rulerInfo); } else { return new SootAttributeJavaSelectAction(rb, null, editor, rulerInfo); } } catch (Exception e){ System.out.println("exception: "+e.getMessage()); } return null; }
/** * Gets the {@link List} of {@link IMarker} for the current line. * * @return the {@link List} of {@link IMarker} */ private List<IMarker> getMarkersForCurrentLine() { final List<IMarker> res = new ArrayList<IMarker>(); final IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getActiveEditor(); if (activeEditor instanceof ITextEditor) { final IVerticalRulerInfo rulerInfo = (IVerticalRulerInfo)activeEditor.getAdapter( IVerticalRulerInfo.class); // TODO check if the last right click has been done on the ruler final IResource resource = getResource(activeEditor); if (resource != null) { res.addAll(getMarkers((ITextEditor)activeEditor, rulerInfo)); } } return res; }
/** * Gets the {@link List} of {@link IMarker} for the current line of the given {@link ITextEditor}. * * @param editor * the {@link ITextEditor} * @param rulerInfo * the {@link IVerticalRulerInfo} * @return the {@link List} of {@link IMarker} for the current line of the given {@link ITextEditor} */ protected List<IMarker> getMarkers(final ITextEditor editor, final IVerticalRulerInfo rulerInfo) { final List<IMarker> res = new ArrayList<IMarker>(); final IDocument document = (IDocument)editor.getDocumentProvider().getDocument(editor .getEditorInput()); if (document != null) { final AbstractMarkerAnnotationModel model = getAnnotationModel(editor); if (model != null) { final int activeLine = rulerInfo.getLineOfLastMouseButtonActivity(); res.addAll(getMarkers(document, model, activeLine)); } } return res; }
@Override public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) { ITextEditor editor = (ITextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); IVerticalRulerInfo rulerInfo = editor.getAdapter(IVerticalRulerInfo.class); try { List<IMarker> markers = getMarkers(editor, rulerInfo); additions.addContributionItem(new ReviewMarkerMenuContribution(editor, markers), null); if (!markers.isEmpty()) { additions.addContributionItem(new Separator(), null); } } catch (CoreException e) { AppraiseUiPlugin.logError("Error creating marker context menus", e); } }
/** * @return an action that can be run to create a breakpoint in the given line */ public PyBreakpointRulerAction createAddBreakPointAction(final int line) { PyBreakpointRulerAction ret = new PyBreakpointRulerAction(debugEditor, new IVerticalRulerInfo() { @Override public int getLineOfLastMouseButtonActivity() { return line; } @Override public Control getControl() { throw new RuntimeException("Not Implemented"); } @Override public int getWidth() { throw new RuntimeException("Not Implemented"); } @Override public int toDocumentLineNumber(int y_coordinate) { throw new RuntimeException("Not Implemented"); } }); ret.update(); return ret; }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); IFileEditorInput input = (IFileEditorInput) part.getEditorInput(); IFile file = input.getFile(); if (part instanceof ITextEditor) { final ITextEditor editor = (ITextEditor) part; IVerticalRulerInfo ruleInfo = editor.getAdapter(IVerticalRulerInfo.class); IDocumentProvider provider = editor.getDocumentProvider(); IDocument document = provider.getDocument(editor.getEditorInput()); int lineNumber = ruleInfo.getLineOfLastMouseButtonActivity(); String className = file.getName().substring(0, file.getName().lastIndexOf('.')); HashMap<VFUnit, VFMethod> resultantUnit = getSelectedUnit(className, document, lineNumber); List<VFNode> unit = new ArrayList<>(); if (resultantUnit.size() > 0) { if (event.getCommand().getId().equals("JavaHandler.NavigateToJimple")) { NavigationHandler handler = new NavigationHandler(); handler.highlightJimpleSource(new ArrayList<>(resultantUnit.keySet())); } else { for (VFUnit vfUnit : resultantUnit.keySet()) { unit.add(new VFNode(vfUnit, 0)); } try { ServiceUtil.getService(DataModel.class).filterGraph(unit, true, true, null); } catch (Exception e) { e.printStackTrace(); } } } // call graph highlighting code here } else { logger.error("Editor not a Text Editor"); } return null; }
private List<IMarker> getMarkers(ITextEditor editor, IVerticalRulerInfo rulerInfo) throws CoreException { List<IMarker> clickedOnMarkers = new ArrayList<IMarker>(); for (IMarker marker : getAllMarkers(editor)) { if (markerHasBeenClicked(marker, rulerInfo)) { clickedOnMarkers.add(marker); } } return clickedOnMarkers; }
public JavaSelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler) { super(bundle, prefix, editor, ruler); fBundle= bundle; fTextEditor= editor; fAnnotationPreferenceLookup= EditorsUI.getAnnotationPreferenceLookup(); fStore= JavaPlugin.getDefault().getCombinedPreferenceStore(); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.JAVA_SELECT_MARKER_RULER_ACTION); }
public PyBreakpointRulerAction(ITextEditor editor, IVerticalRulerInfo ruler) { setInfo(ruler); setTextEditor(editor); setText("Breakpoint &Properties..."); fAddLabel = "Add Breakpoint"; fRemoveLabel = "Remove Breakpoint"; }
private int getLineNumber() throws BadLocationException { IVerticalRulerInfo ruleInfo = getTextEditor().getAdapter(IVerticalRulerInfo.class); int lineNumber = ruleInfo.getLineOfLastMouseButtonActivity(); int actualLineNumber = lineNumber + 1; return actualLineNumber; }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new UnitBreakpointPropertiesAction(editor, rulerInfo); }
/** * Creates the action to enable/disable breakpoints */ public UnitBreakpointPropertiesAction(ITextEditor editor, IVerticalRulerInfo info) { super(editor, info); setText("Unit Breakpoint Properties"); }
public SootAttributeJavaSelectAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo rulerInfo) { super(bundle, prefix, editor, rulerInfo); }
public SootAttributeJimpleSelectAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo rulerInfo) { super(bundle, prefix, editor, rulerInfo); }
public XtextMarkerRulerAction(ResourceBundle bundle, String prefix, XtextEditor editor, IVerticalRulerInfo ruler) { super(bundle, prefix, editor, ruler); this.textEditor = editor;// can't access private super field this.ruler = ruler; }
private boolean markerHasBeenClicked(IMarker marker, IVerticalRulerInfo rulerInfo) { return (marker.getAttribute(IMarker.LINE_NUMBER, 0)) == (rulerInfo.getLineOfLastMouseButtonActivity() + 1); }
public JsBreakpointPropertiesRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { super(editor, rulerInfo); setText(Messages.JsBreakpointPropertiesRulerAction_ItemLabel); }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new JsBreakpointPropertiesRulerAction(editor, rulerInfo); }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new JavaSelectAnnotationRulerAction(JavaEditorMessages.getBundleForConstructedKeys(), "JavaSelectAnnotationRulerAction.", editor, rulerInfo); //$NON-NLS-1$ }
protected IVerticalRulerInfo getInfo() { return fInfo; }
protected void setInfo(IVerticalRulerInfo info) { fInfo = info; }
public PythonBreakpointPropertiesRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { setInfo(rulerInfo); setTextEditor(editor); setText("Breakpoint &Properties..."); }
public EnableDisableBreakpointRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { fInfo = rulerInfo; fTextEditor = editor; }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new EnableDisableBreakpointRulerAction(editor, rulerInfo); }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new PythonBreakpointPropertiesRulerAction(editor, rulerInfo); }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new PyBreakpointRulerAction(editor, rulerInfo); }
ToggleBreakpointSilentAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { super(editor, rulerInfo); }
@Override protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { return new ToggleBreakpointSilentAction(editor, rulerInfo); }