List of usage examples for org.eclipse.jface.viewers ViewerRow getText
public abstract String getText(int columnIndex);
From source file:org.netxms.ui.eclipse.perfview.widgets.TableValue.java
License:Open Source License
/** * @param viewerRow/*from ww w . ja va 2 s. c o m*/ * @return */ private String buildInstanceString(ViewerRow viewerRow) { StringBuilder instance = new StringBuilder(); boolean first = true; for (int i = 0; i < currentData.getColumnCount(); i++) { TableColumnDefinition cd = currentData.getColumnDefinition(i); if (cd.isInstanceColumn()) { if (!first) instance.append("~~~"); //$NON-NLS-1$ instance.append(viewerRow.getText(i)); first = false; } } return instance.toString(); }
From source file:rabbit.ui.internal.viewers.TreePathDurationLabelProviderTest.java
License:Apache License
private ViewerCell newCell(int columnIndex, Object element) throws Exception { final String[] text = new String[1]; final Color[] background = new Color[1]; final Color[] foreground = new Color[1]; ViewerRow row = mock(ViewerRow.class); given(row.getBackground(columnIndex)).willAnswer(new Answer<Color>() { @Override//from w w w. j a v a 2 s .com public Color answer(InvocationOnMock invocation) throws Throwable { return background[0]; } }); given(row.getForeground(columnIndex)).willAnswer(new Answer<Color>() { @Override public Color answer(InvocationOnMock invocation) throws Throwable { return foreground[0]; } }); given(row.getText(columnIndex)).willAnswer(new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { return text[0]; } }); given(row.getTreePath()).willReturn(new TreePath(new Object[] { element })); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { background[0] = (Color) invocation.getArguments()[1]; return null; } }).when(row).setBackground(eq(columnIndex), Mockito.<Color>any()); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { foreground[0] = (Color) invocation.getArguments()[1]; return null; } }).when(row).setForeground(eq(columnIndex), Mockito.<Color>any()); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { text[0] = (String) invocation.getArguments()[1]; return null; } }).when(row).setText(eq(columnIndex), Mockito.anyString()); Constructor<ViewerCell> constructor = ViewerCell.class.getDeclaredConstructor(ViewerRow.class, int.class, Object.class); constructor.setAccessible(true); return constructor.newInstance(row, columnIndex, element); }