/** * Adds a line highlight. * * @param line The line to highlight. This is zero-based. * @param color The color to highlight the line with. * @throws BadLocationException If <code>line</code> is an invalid line * number. * @see #removeLineHighlight(Object) * @see #removeAllLineHighlights() */ public Object addLineHighlight(int line, Color color) throws BadLocationException { if (lineHighlightManager==null) { lineHighlightManager = new LineHighlightManager(this); } return lineHighlightManager.addLineHighlight(line, color); }
@Test public void testGetCurrentLineHighlightTags() throws BadLocationException { Assert.assertEquals(0, lhm.getCurrentLineHighlightTags().size()); Object tag1 = lhm.addLineHighlight(0, Color.RED); Object tag2 = lhm.addLineHighlight(2, Color.BLUE); List<Object> actualTags = lhm.getCurrentLineHighlightTags(); Assert.assertEquals(2, actualTags.size()); Assert.assertEquals(tag1, actualTags.get(0)); Assert.assertEquals(tag2, actualTags.get(1)); }
@Test public void testAddLineHighlight_removeOneOfTwoOnOneLine() throws BadLocationException { Object tag1 = lhm.addLineHighlight(1, Color.BLUE); Object tag2 = lhm.addLineHighlight(1, Color.RED); Assert.assertEquals(2, lhm.getLineHighlightCount()); // We're testing a bug here with LineHighlightInfo's equals() method, // so we use a foolproof method of telling the two tags apart. lhm.removeLineHighlight(tag1); List<Object> remainingTags = lhm.getCurrentLineHighlightTags(); Assert.assertEquals(1, remainingTags.size()); Assert.assertTrue(tag2 == remainingTags.get(0)); }
@Test public void testRemoveAllHighlights() throws BadLocationException { lhm.addLineHighlight(1, Color.BLUE); lhm.addLineHighlight(1, Color.RED); Assert.assertEquals(2, lhm.getLineHighlightCount()); lhm.removeAllLineHighlights(); Assert.assertEquals(0, lhm.getLineHighlightCount()); } }
@Test public void testAddLineHighlight_happyPath() throws BadLocationException { Assert.assertEquals(0, lhm.getLineHighlightCount()); lhm.addLineHighlight(1, Color.BLUE); Assert.assertEquals(1, lhm.getLineHighlightCount()); lhm.addLineHighlight(2, Color.BLUE); Assert.assertEquals(2, lhm.getLineHighlightCount()); }
@Test public void testAddLineHighlight_twoOnSameLine() throws BadLocationException { Assert.assertEquals(0, lhm.getLineHighlightCount()); lhm.addLineHighlight(1, Color.BLUE); Assert.assertEquals(1, lhm.getLineHighlightCount()); lhm.addLineHighlight(1, Color.RED); Assert.assertEquals(2, lhm.getLineHighlightCount()); }
/** * Adds a line highlight. * * @param line The line to highlight. This is zero-based. * @param color The color to highlight the line with. * @throws BadLocationException If <code>line</code> is an invalid line * number. * @see #removeLineHighlight(Object) * @see #removeAllLineHighlights() */ public Object addLineHighlight(int line, Color color) throws BadLocationException { if (lineHighlightManager==null) { lineHighlightManager = new LineHighlightManager(this); } return lineHighlightManager.addLineHighlight(line, color); }
/** * Adds a line highlight. * * @param line The line to highlight. This is zero-based. * @param color The color to highlight the line with. * @throws BadLocationException If <code>line</code> is an invalid line * number. * @see #removeLineHighlight(Object) * @see #removeAllLineHighlights() */ public Object addLineHighlight(int line, Color color) throws BadLocationException { if (lineHighlightManager==null) { lineHighlightManager = new LineHighlightManager(this); } return lineHighlightManager.addLineHighlight(line, color); }
/** * Adds a line highlight. * * @param line The line to highlight. This is zero-based. * @param color The color to highlight the line with. * @throws BadLocationException If <code>line</code> is an invalid line * number. * @see #removeLineHighlight(Object) * @see #removeAllLineHighlights() */ public Object addLineHighlight(int line, Color color) throws BadLocationException { if (lineHighlightManager==null) { lineHighlightManager = new LineHighlightManager(this); } return lineHighlightManager.addLineHighlight(line, color); }