/** @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { try { if (!canModifyEditor()) { return; } PyEdit pyEdit = getPyEdit(); PySelection ps = new PySelection(pyEdit); try { int[] regionsToFormat = null; if (ps.getSelLength() > 0) { int startLineIndex = ps.getStartLineIndex(); int endLineIndex = ps.getEndLineIndex(); regionsToFormat = new int[endLineIndex - startLineIndex + 1]; for (int i = startLineIndex, j = 0; i <= endLineIndex; i++, j++) { regionsToFormat[j] = i; } } else { // For full-formatting, we cannot have a syntax error. if (pyEdit.hasSyntaxError(ps.getDoc())) { return; } } applyFormatAction(pyEdit, ps, regionsToFormat, true); } catch (SyntaxErrorException e) { pyEdit.getStatusLineManager().setErrorMessage(e.getMessage()); } } catch (Exception e) { beep(e); } }
/** @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { try { if (!canModifyEditor()) { return; } PyEdit pyEdit = getPyEdit(); PySelection ps = new PySelection(pyEdit); try { applyFormatAction(pyEdit, ps, false, true); } catch (SyntaxErrorException e) { pyEdit.getStatusLineManager().setErrorMessage(e.getMessage()); } } catch (Exception e) { beep(e); } }