org.eclipse.swt.custom.StyleRange Java Examples
The following examples show how to use
org.eclipse.swt.custom.StyleRange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PyInformationPresenter.java From Pydev with Eclipse Public License 1.0 | 6 votes |
protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) { int yoursStart = offset; int yoursEnd = offset + insertLength - 1; yoursEnd = Math.max(yoursStart, yoursEnd); Iterator<StyleRange> e = presentation.getAllStyleRangeIterator(); while (e.hasNext()) { StyleRange range = e.next(); int myStart = range.start; int myEnd = range.start + range.length - 1; myEnd = Math.max(myStart, myEnd); if (myEnd < yoursStart) { continue; } if (myStart < yoursStart) { range.length += insertLength; } else { range.start += insertLength; } } }
Example #2
Source File: AbstractHighlightingTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void testHighlighting(StyledText styledText, String text, int fontStyle, int foregroundR, int foregroundG, int foregroundB, int backgroundR, int backgroundG, int backgroundB) { Color expectedForegroundColor = new Color(null, foregroundR, foregroundG, foregroundB); Color expectedBackgroundColor = new Color(null, backgroundR, backgroundG, backgroundB); String content = styledText.getText(); int offset = getStartPosition(content, text); assertNotEquals("Cannot locate '" + text + "' in " + content, -1, offset); for (int i = 0; i < text.length(); i++) { int currentPosition = offset + i; String character = styledText.getTextRange(currentPosition, 1); StyleRange styleRange = styledText.getStyleRangeAtOffset(currentPosition); if (isRelevant(character)) { assertFontStyle(styleRange, character, fontStyle); assertForegroundColor(styleRange, character, expectedForegroundColor); assertBackgroundColor(styleRange, character, expectedBackgroundColor); } } }
Example #3
Source File: StyledTextWithoutVerticalBar.java From Pydev with Eclipse Public License 1.0 | 6 votes |
@Override public void replaceStyleRanges(int start, int length, StyleRange[] styles) { checkWidget(); if (isListening(ST.LineGetStyle)) { return; } if (styles == null) { SWT.error(SWT.ERROR_NULL_ARGUMENT); } RangesInfo rangesInfo = createRanges(styles, this.getCharCount()); int[] newRanges = rangesInfo.newRanges; styles = rangesInfo.styles; try { setStyleRanges(start, length, newRanges, styles); } catch (Exception e) { Log.log(e); } }
Example #4
Source File: ChatLine.java From saros with GNU General Public License v2.0 | 6 votes |
private void addHyperLinkListener(final StyledText text) { text.addListener( SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { try { int offset = text.getOffsetAtLocation(new Point(event.x, event.y)); StyleRange style = text.getStyleRangeAtOffset(offset); if (style != null && style.underline && style.underlineStyle == SWT.UNDERLINE_LINK) { String url = (String) style.data; SWTUtils.openInternalBrowser(url, url); } } catch (IllegalArgumentException e) { // no character under event.x, event.y } } }); }
Example #5
Source File: AbstractAttributesColorer.java From JAADAS with GNU General Public License v3.0 | 6 votes |
protected void changeStyles(){ final StyleRange [] srs = new StyleRange[styleList.size()]; styleList.toArray(srs); getDisplay().asyncExec(new Runnable(){ public void run(){ for (int i = 0; i < srs.length; i++){ try{ //System.out.println("Style Range: "+srs[i]); getViewer().getTextWidget().setStyleRange(srs[i]); } catch(Exception e){ System.out.println("Seting Style Range Ex: "+e.getMessage()); } } }; }); }
Example #6
Source File: AnnotationExpansionControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void resetViewerBackground(StyleRange[] oldRanges) { if (oldRanges == null) return; if (fInput == null) return; StyledText text= fInput.fViewer.getTextWidget(); if (text == null || text.isDisposed()) return; // set the ranges one by one for (int i= 0; i < oldRanges.length; i++) { text.setStyleRange(oldRanges[i]); } }
Example #7
Source File: BufferDialog.java From e4macs with Eclipse Public License 1.0 | 6 votes |
private Control createBufferTip(Composite parent, IEditorReference ref) { Composite result = new Composite(parent, SWT.NO_FOCUS); Color bg = parent.getBackground(); result.setBackground(bg); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; result.setLayout(gridLayout); StyledText name = new StyledText(result, SWT.READ_ONLY | SWT.HIDE_SELECTION); // italics results in slightly clipped text unless extended String text = ref.getTitleToolTip() + ' '; name.setText(text); name.setBackground(bg); name.setCaret(null); StyleRange styleIt = new StyleRange(0, text.length(), null, bg); styleIt.fontStyle = SWT.ITALIC; name.setStyleRange(styleIt); return result; }
Example #8
Source File: StyleRanges.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public List<StyleRange> getRanges(String expression) { final List<StyleRange> ranges = Lists.newArrayList(); DocumentEvent event = new DocumentEvent(); event.fDocument = new DummyDocument(expression); DocumentTokenSource tokenSource = tokenSourceProvider.get(); tokenSource.updateStructure(event); Iterator<ILexerTokenRegion> iterator = tokenSource.getTokenInfos().iterator(); while (iterator.hasNext()) { ILexerTokenRegion next = iterator.next(); TextAttribute attribute = attributeProvider.getAttribute(tokenTypeMapper.getId(next.getLexerTokenType())); StyleRange range = new StyleRange(next.getOffset(), next.getLength(), attribute.getForeground(), attribute.getBackground()); range.font = attribute.getFont(); range.fontStyle = attribute.getStyle(); ranges.add(range); } return merge(ranges); }
Example #9
Source File: TLCUIHelperTest.java From tlaplus with MIT License | 6 votes |
@Test public void testTLAandPCalLocations() { final String text = // PCal "Failure of assertion at line " + line + ", column " + beginColumn + ".\n" + // TLA "4. Line " + line+ ", column " + beginColumn + " to line " + line + ", column " + endColumn + " in " + module; final List<StyleRange> ranges = TLCUIHelper.setTLCLocationHyperlinks(text); // check if we get expected amount of locations Assert.assertEquals(2, ranges.size()); // check each location individually for (final StyleRange range : ranges) { if (range.data instanceof Location) { final Location location = (Location) range.data; Assert.assertEquals(module, location.source()); Assert.assertEquals(line, location.beginLine()); Assert.assertEquals(beginColumn, location.beginColumn()); // ignore end line and endColumn here as the PCal matcher does // not know and hence set this information. } } }
Example #10
Source File: XViewerStyledTextLabelProvider.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString styledString = getStyledText(element, cell.getColumnIndex()); String newText = styledString.toString(); StyleRange[] oldStyleRanges = cell.getStyleRanges(); StyleRange[] newStyleRanges = isOwnerDrawEnabled() ? styledString.getStyleRanges() : null; if (!Arrays.equals(oldStyleRanges, newStyleRanges)) { cell.setStyleRanges(newStyleRanges); } cell.setText(newText); cell.setImage(getColumnImage(element, cell.getColumnIndex())); cell.setFont(getFont(element, cell.getColumnIndex())); cell.setForeground(getForeground(element, cell.getColumnIndex())); cell.setBackground(getBackground(element, cell.getColumnIndex())); // no super call required. changes on item will trigger the refresh. }
Example #11
Source File: UrlFormatRule.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public Format execute( String value ) { Format format = new Format(); Matcher matcher = parse( value ); List<StyleRange> styleRanges = new ArrayList<>(); while ( matcher.find() ) { StyleRange styleRange = new StyleRange(); styleRange.start = value.indexOf( matcher.group( 0 ) ); styleRange.length = matcher.group( 1 ).length(); styleRange.data = matcher.group( 2 ); styleRange.underlineStyle = SWT.UNDERLINE_LINK; styleRange.underline = true; styleRanges.add( styleRange ); value = value.replace( matcher.group( LINK_TEXT ), matcher.group( LINK_URL ) ); } format.setStyleRanges( styleRanges ); format.setText( value ); return format; }
Example #12
Source File: PyInformationPresenterTest.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public void testStyleRanges() throws Exception { PyInformationPresenter presenter = new PyInformationPresenter(); TextPresentation presentation = new TextPresentation(); String str = "@foo: <pydev_link link=\"itemPointer\">link</pydev_link> <pydev_hint_bold>bold</pydev_hint_bold>"; Reader reader = presenter.createReader(str, presentation); String handled = StringUtils.readAll(reader); assertEquals("@foo: link bold", handled); Iterator<StyleRange> it = presentation.getAllStyleRangeIterator(); ArrayList<String> tagsReplaced = new ArrayList<String>(); ArrayList<String> expected = new ArrayList<String>(); expected.add("<pydev_link link=\"itemPointer\">"); expected.add("<pydev_hint_bold>"); while (it.hasNext()) { PyStyleRange next = (PyStyleRange) it.next(); tagsReplaced.add(next.tagReplaced); } assertEquals(expected, tagsReplaced); }
Example #13
Source File: CoverageInformationItem.java From tlaplus with MIT License | 6 votes |
public void style(final TextPresentation textPresentation, final Color c, final Representation rep) { if (!isRoot()) { final StyleRange rs = new StyleRange(); rs.start = region.getOffset(); rs.length = region.getLength(); rs.background = c; if ((rep == Representation.STATES_DISTINCT || rep == Representation.STATES) && !(this instanceof ActionInformationItem)) { rs.background = JFaceResources.getColorRegistry().get(ModuleCoverageInformation.GRAY); rs.borderStyle = SWT.NONE; rs.borderColor = null; } else if (rep != Representation.COST && rep.getValue(this, Grouping.INDIVIDUAL) == 0L) { rs.background = null; rs.borderStyle = SWT.BORDER_SOLID; rs.borderColor = JFaceResources.getColorRegistry().get(ModuleCoverageInformation.RED); } active = false; textPresentation.replaceStyleRange(addStlye(rs)); } for (CoverageInformationItem child : childs) { child.style(textPresentation, c, rep); } }
Example #14
Source File: DamageRepairer.java From LogViewer with Eclipse Public License 2.0 | 6 votes |
/** * Adds style information to the given text presentation. * * @param presentation the text presentation to be extended * @param offset the offset of the range to be styled * @param length the length of the range to be styled * @param attr the attribute describing the style of the range to be styled * @param wholeLine the boolean switch to declare that the whole line should be colored */ private void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr, boolean wholeLine) { if (attr != null) { int style= attr.getStyle(); int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); if(wholeLine) { try { int line = document.getLineOfOffset(offset); int start = document.getLineOffset(line); length = document.getLineLength(line); offset = start; } catch (BadLocationException e) { } } StyleRange styleRange = new StyleRange(offset,length,attr.getForeground(),attr.getBackground(),fontStyle); styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline = (style & TextAttribute.UNDERLINE) != 0; presentation.addStyleRange(styleRange); } }
Example #15
Source File: HsMultiCellEditor.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void highlightedTerms(List<String> terms) { if (!isValid()) { return; } StyledText styledText = cellEditor.viewer.getTextWidget(); String text = styledText.getText(); char[] source = text.toCharArray(); List<StyleRange> ranges = new ArrayList<StyleRange>(); TextStyle style = new TextStyle(cellEditor.getSegmentViewer().getTextWidget().getFont(), null, ColorConfigBean.getInstance().getHighlightedTermColor()); for (String term : terms) { ranges.addAll(calculateTermsStyleRange(source, term.toCharArray(), style)); } for (StyleRange range : ranges) { styledText.setStyleRange(range); } }
Example #16
Source File: HsMultiCellEditor.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 刷新拼写检查中错误单词的样式 * @param ranges */ public void refreshErrorWordsStyle(List<StyleRange> ranges){ StyledText styledText = cellEditor.viewer.getTextWidget(); List<StyleRange> oldRangeList = new ArrayList<StyleRange>(); for(StyleRange oldRange : styledText.getStyleRanges()){ if (oldRange.underlineStyle != SWT.UNDERLINE_ERROR) { oldRangeList.add(oldRange); } } styledText.setStyleRange(null); styledText.setStyleRanges(oldRangeList.toArray(new StyleRange[oldRangeList.size()])); if (ranges != null) { for (StyleRange range : ranges) { styledText.setStyleRange(range); } } }
Example #17
Source File: PyCodeFormatterPage.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private void updateLabelExampleNow(FormatStd formatStd) { String str = "" + " \n" + " \n" + " \n" + " \n" + "class Example(object): \n" + " \n" + " def Call(self, param1=None): \n" + " '''docstring''' \n" + " return param1 + 10 * 10 \n" + " \n" + " \n" + " \n" + " def Call2(self): #Comment \n" + " #Comment \n" + " return self.Call(param1=10)" + ""; Tuple<String, StyleRange[]> result = formatAndStyleRangeHelper.formatAndGetStyleRanges(formatStd, str, PyDevUiPrefs.getChainedPrefStore(), true); labelExample.setText(result.o1); labelExample.setStyleRanges(result.o2); }
Example #18
Source File: ModulaSearchLabelProvider.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
protected StyleRange prepareStyleRange(StyleRange styleRange, boolean applyColors) { if (!applyColors && styleRange.background != null) { styleRange= super.prepareStyleRange(styleRange, applyColors); styleRange.borderStyle= SWT.BORDER_DOT; return styleRange; } return super.prepareStyleRange(styleRange, applyColors); }
Example #19
Source File: CmdPanelOutput.java From Rel with Apache License 2.0 | 5 votes |
private void outputPlain(String s, Color color) { StyleRange styleRange = new StyleRange(); styleRange.start = styledText.getCharCount(); styleRange.length = s.length(); styleRange.fontStyle = SWT.NORMAL; styleRange.foreground = color; styledText.append(s); styledText.setStyleRange(styleRange); }
Example #20
Source File: AbstractSyntaxColoringTest.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Checks if the two given {@link StyleRange}s are equal, with respect to start, length, font, style, and colors. Underlines are ignored. * * @param styleRangeA * the first {@link StyleRange} * @param styleRangeB * the second {@link StyleRange} * @return {@code true} if the given {@link StyleRange}s are equal, {@code false} otherwise */ @SuppressWarnings("PMD.CompareObjectsWithEquals") public static boolean areEqualStyleRanges(final StyleRange styleRangeA, final StyleRange styleRangeB) { if (styleRangeA == styleRangeB) { return true; } boolean result = styleRangeA != null && styleRangeB != null; result &= styleRangeA.start == styleRangeB.start; result &= styleRangeA.length == styleRangeB.length; result &= styleRangeA.fontStyle == styleRangeB.fontStyle; result &= areEqualTextStyles(styleRangeA, styleRangeB); return result; }
Example #21
Source File: TexSourceViewerConfiguration.java From texlipse with Eclipse Public License 1.0 | 5 votes |
private void boldRange(int start, int length, TextPresentation presentation, boolean doItalic) { // We have found a tag and create a new style range int fontStyle = doItalic ? (SWT.BOLD | SWT.ITALIC) : SWT.BOLD; StyleRange range = new StyleRange(start, length, null, null, fontStyle); // Add this style range to the presentation presentation.addStyleRange(range); }
Example #22
Source File: XStyledString.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
public void append(XStyledString ss) { int shift = sb.length(); for (StyleRange sr : ss.getStyleRanges()) { sr.start += shift; srarr.add(sr); } sb.append(ss.getText()); }
Example #23
Source File: PyCompletionPresentationUpdater.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private StyleRange createStyleRange(ITextViewer viewer, int initialOffset, int len) { StyledText text = viewer.getTextWidget(); if (text == null || text.isDisposed()) { return null; } int widgetCaret = text.getCaretOffset(); int modelCaret = 0; if (viewer instanceof ITextViewerExtension5) { ITextViewerExtension5 extension = (ITextViewerExtension5) viewer; modelCaret = extension.widgetOffset2ModelOffset(widgetCaret); } else { IRegion visibleRegion = viewer.getVisibleRegion(); modelCaret = widgetCaret + visibleRegion.getOffset(); } if (modelCaret >= initialOffset + len) { return null; } int length = initialOffset + len - modelCaret; Color foreground = getForegroundColor(); Color background = getBackgroundColor(); return new StyleRange(modelCaret, length, foreground, background); }
Example #24
Source File: TMXValidatorDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private void cleanCharacters() { FileDialog fd = new FileDialog(getShell(), SWT.OPEN); String[] extensions = { "*.tmx", "*.*" }; //$NON-NLS-1$ //$NON-NLS-2$ fd.setFilterExtensions(extensions); String[] names = { Messages.getString("dialog.TMXValidatorDialog.names1"), Messages.getString("dialog.TMXValidatorDialog.names2") }; fd.setFilterNames(names); String name = fd.open(); if (name != null) { red = Display.getDefault().getSystemColor(SWT.COLOR_RED); styledText.setText(""); styledText.append(Messages.getString("dialog.TMXValidatorDialog.styledText1")); getShell().setCursor(cursorWait); try { } catch (Exception e) { LOGGER.error("", e); String errorTip = e.getMessage(); if (errorTip == null) { errorTip = MessageFormat.format(Messages.getString("dialog.TMXValidatorDialog.msg1"), name); } StyleRange range = new StyleRange(styledText.getText().length(), errorTip.length(), red, null); styledText.append(errorTip); styledText.setStyleRange(range); } styledText.append(Messages.getString("dialog.TMXValidatorDialog.styledText2")); getShell().setCursor(cursorArrow); } }
Example #25
Source File: StyledTextWithoutVerticalBarTest.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public void testWrongRanges1() { StyleRange[] styles = new StyleRange[] { new StyleRange(0, 2, null, null), new StyleRange(0, 3, null, null), new StyleRange(5, 5, null, null), }; RangesInfo rangesInfo = StyledTextWithoutVerticalBar.createRanges(styles, 10); int[] ranges = rangesInfo.newRanges; Assert.assertArrayEquals(new int[] { 0, 2, 2, 1, 5, 5 }, ranges); assertEquals(3, rangesInfo.styles.length); }
Example #26
Source File: DiffAttributeEditor.java From git-appraise-eclipse with Eclipse Public License 1.0 | 5 votes |
/** * Starts a new {@link StyleRange} given a specific line type. */ private StyleRange initDiffStyleRangeForLineType(DiffLineType lineType, int startTextOffset) { ColorRegistry reg = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); StyleRange range = new StyleRange(); range.start = startTextOffset; switch (lineType) { case ADD: range.foreground = reg.get(THEME_DiffAddForegroundColor); range.background = reg.get(THEME_DiffAddBackgroundColor); break; case REMOVE: range.foreground = reg.get(THEME_DiffRemoveForegroundColor); range.background = reg.get(THEME_DiffRemoveBackgroundColor); break; case HUNK: range.foreground = reg.get(THEME_DiffHunkForegroundColor); range.background = reg.get(THEME_DiffHunkBackgroundColor); break; case HEADLINE: range.foreground = reg.get(THEME_DiffHeadlineForegroundColor); range.background = reg.get(THEME_DiffHeadlineBackgroundColor); FontRegistry fontReg = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry(); range.font = fontReg.get(THEME_DiffHeadlineFont); break; default: break; } return range; }
Example #27
Source File: SyntaxHighlighter.java From RepDev with GNU General Public License v3.0 | 5 votes |
public void lineGetStyle(LineStyleEvent event) { ArrayList<Token> ltokens = parser.getLtokens(); ArrayList<StyleRange> ranges = new ArrayList<StyleRange>(); int line = txt.getLineAtOffset(event.lineOffset); int ftoken; for (ftoken = 0; ftoken < ltokens.size(); ftoken++) if (ltokens.get(ftoken).getEnd() >= event.lineOffset) break; int ltoken = ltokens.size(); if (line + 1 < txt.getLineCount()) { int pos = txt.getOffsetAtLine(line + 1); for (ltoken = ftoken; ltoken < ltokens.size(); ltoken++) if (ltokens.get(ltoken).getStart() > pos) break; } for (int i = ftoken; i < ltoken; i++){ StyleRange range = getStyle(ltokens.get(i)); ranges.add(range); //If we are a backgroudn highlighted token, and a CODE SNIPPET one, then connect the highlighting over whitespace between tokens if( ltokens.get(i).getBackgroundReason() == SpecialBackgroundReason.CODE_SNIPPET ) if( i + 1 < ltoken && ltokens.get(i+1).getBackgroundReason() == SpecialBackgroundReason.CODE_SNIPPET && ltokens.get(i+1).getSnippetVar() == ltokens.get(i).getSnippetVar()) ranges.add(new StyleRange(ltokens.get(i).getEnd(),ltokens.get(i+1).getStart()-ltokens.get(i).getEnd(),null,ltokens.get(i).getSpecialBackground())); } StyleRange[] rangesArray = new StyleRange[ranges.size()]; event.styles = ranges.toArray(rangesArray); }
Example #28
Source File: TextAreaAppender.java From Flashtool with GNU General Public License v3.0 | 5 votes |
/** * This method is where the appender does the work. * * @param event Log event with log data */ @Override public void append(LogEvent event) { readLock.lock(); String message = new String(getLayout().toByteArray(event)); Level l = event.getLevel(); if (styledText!=null) { StyleRange styleRange = new StyleRange(); if (l==Level.ERROR) { styleRange.length = message.length(); styleRange.fontStyle = SWT.NORMAL; styleRange.foreground = cred; } else if (l==Level.WARN) { styleRange.length = message.length(); styleRange.fontStyle = SWT.NORMAL; styleRange.foreground = cblue; } else { styleRange.length = message.length(); styleRange.fontStyle = SWT.NORMAL; styleRange.foreground = cblack; } Display.getDefault().asyncExec(new Runnable() { public void run() { // Append formatted message to textarea. styleRange.start = styledText.getCharCount(); styledText.append(message); styledText.setStyleRange(styleRange); styledText.setSelection(styledText.getCharCount()); } }); } readLock.unlock(); }
Example #29
Source File: StyledTextWithoutVerticalBarTest.java From Pydev with Eclipse Public License 1.0 | 5 votes |
public void testCreateRanges() { StyleRange[] styles = new StyleRange[] { new StyleRange(0, 2, null, null), new StyleRange(2, 3, null, null), new StyleRange(5, 5, null, null), }; RangesInfo rangesInfo = StyledTextWithoutVerticalBar.createRanges(styles, 10); int[] ranges = rangesInfo.newRanges; Assert.assertArrayEquals(new int[] { 0, 2, 2, 3, 5, 5 }, ranges); assertEquals(3, rangesInfo.styles.length); rangesInfo = StyledTextWithoutVerticalBar.createRanges(styles, 3); ranges = rangesInfo.newRanges; Assert.assertArrayEquals(new int[] { 0, 2, 2, 1 }, ranges); assertEquals(2, rangesInfo.styles.length); rangesInfo = StyledTextWithoutVerticalBar.createRanges(styles, 2); ranges = rangesInfo.newRanges; Assert.assertArrayEquals(new int[] { 0, 2 }, ranges); assertEquals(1, rangesInfo.styles.length); rangesInfo = StyledTextWithoutVerticalBar.createRanges(styles, 1); ranges = rangesInfo.newRanges; Assert.assertArrayEquals(new int[] { 0, 1 }, ranges); assertEquals(1, rangesInfo.styles.length); assertEquals(0, rangesInfo.styles[0].start); assertEquals(1, rangesInfo.styles[0].length); }
Example #30
Source File: HsMultiCellEditor.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 根据传入的相关参数获取错误单词的样式 robert 2013-01-22 * @param style * @param start * @param length * @return */ private StyleRange getErrorWordRange(TextStyle style, int start, int length){ StyleRange range = new StyleRange(style); range.start = start; range.length = length; range.underline = true; range.underlineStyle = SWT.UNDERLINE_ERROR; range.underlineColor = ColorConfigBean.getInstance().getErrorWordColor(); return range; }