List of usage examples for org.eclipse.jface.viewers ViewerCell setStyleRanges
public void setStyleRanges(StyleRange[] styleRanges)
From source file:org.fhsolution.eclipse.plugins.csvedit.providers.CSVLabelProvider.java
License:Apache License
/** * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) *//*from www . j av a 2 s . c o m*/ @Override public void update(ViewerCell cell) { CSVRow element = (CSVRow) cell.getElement(); int index = cell.getColumnIndex(); String columnText = getColumnText(element, index); cell.setText(columnText); cell.setImage(getColumnImage(element, index)); if (searchText != null && searchText.length() > 0) { int intRangesCorrectSize[] = SearchResultStyle.getSearchTermOccurrences(searchText, columnText); List<StyleRange> styleRange = new ArrayList<StyleRange>(); for (int i = 0; i < intRangesCorrectSize.length / 2; i++) { StyleRange myStyleRange = new StyleRange(0, 0, null, searchColor); myStyleRange.start = intRangesCorrectSize[i]; myStyleRange.length = intRangesCorrectSize[++i]; styleRange.add(myStyleRange); } cell.setStyleRanges(styleRange.toArray(new StyleRange[styleRange.size()])); } else { cell.setStyleRanges(null); } super.update(cell); }
From source file:org.fusesource.ide.camel.editor.dialogs.provider.GlobalConfigElementsDialogLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); StyledString text = new StyledString(); if (element instanceof GlobalConfigCategoryItem) { GlobalConfigCategoryItem cat = (GlobalConfigCategoryItem) element; Image img = cat.getIcon(); text.append(cat.getName());/*from w ww . j a v a 2s.c om*/ cell.setImage(img); cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); } else if (element instanceof GlobalConfigElementItem) { GlobalConfigElementItem elem = (GlobalConfigElementItem) element; Image img = elem.getIcon(); text.append(elem.getName()); cell.setImage(img); cell.setText(text.toString()); cell.setStyleRanges(text.getStyleRanges()); } else { // unhandled } super.update(cell); }
From source file:org.fusesource.ide.fabric8.ui.navigator.properties.ContainerStatusLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); ContainerViewBean bean = ContainerViewBean.toContainerViewBean(element); if (bean != null) { ContainerDTO container = bean.container(); boolean managed = container.isManaged(); String image = "yellow-dot.png"; String status = bean.getStatus(); FabricPlugin.getLogger()//from w ww. j av a2 s .c o m .debug("Container: " + container.getId() + " alive: " + container.isAlive() + " managed: " + container.isManaged() + " pending: " + container.isProvisioningPending() + " complete: " + container.isProvisioningComplete() + " status: " + container.getProvisionStatus()); if (!bean.isAlive()) { image = "gray-dot.png"; } if (container.isProvisioningPending()) { //image = "pending.gif"; image = "yellow-dot.png"; managed = true; } else if (status != null) { String lowerStatus = status.toLowerCase(); if (lowerStatus.startsWith("success") || lowerStatus.length() == 0) { if (bean.isAlive()) { image = "green-dot.png"; } else { status = "stopped"; } if (lowerStatus.length() == 0 && !managed) { if (bean.isRoot()) { status = "root"; } } } else if (lowerStatus.startsWith("error")) { image = "red-dot.png"; } } if (status != null) { Styler style = null; StyledString styledString = new StyledString(status, style); /* String fileName = bean.getFileName(); if (fileName != null) { styledString.append(fileName, StyledString.COUNTER_STYLER); } */ cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } if (image != null) { cell.setImage(FabricPlugin.getDefault().getImage(image)); } } super.update(cell); }
From source file:org.fusesource.ide.fabric8.ui.view.logs.LocationLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); LogEventDTO log = (LogEventDTO) element; if (log != null) { String className = log.getClassName(); // we don't want to display ? as location if (className != null && className.trim().equals("?")) className = null;//from w ww . j a v a 2 s. c o m if (className != null) { Styler style = null; StyledString styledString = new StyledString(className, style); String fileName = log.getFileName(); if (fileName != null) { styledString.append(fileName, StyledString.COUNTER_STYLER); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } } super.update(cell); }
From source file:org.fusesource.ide.jmx.fabric8.navigator.properties.ContainerStatusLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); ContainerViewBean bean = ContainerViewBean.toContainerViewBean(element); if (bean != null) { Container container = bean.container(); boolean managed = container.isManaged(); String image = "yellow-dot.png"; String status = bean.getStatus(); Fabric8JMXPlugin.getLogger()/*from w w w. j a va 2 s.c o m*/ .debug("Container: " + container.getId() + " alive: " + container.isAlive() + " managed: " + container.isManaged() + " pending: " + container.isProvisioningPending() + " complete: " + container.isProvisioningComplete() + " status: " + container.getProvisionStatus()); if (!bean.isAlive()) { image = "gray-dot.png"; } if (container.isProvisioningPending()) { // image = "pending.gif"; image = "yellow-dot.png"; managed = true; } else if (status != null) { String lowerStatus = status.toLowerCase(); if (lowerStatus.startsWith("success") || lowerStatus.length() == 0) { if (bean.isAlive()) { image = "green-dot.png"; } else { status = "stopped"; } if (lowerStatus.length() == 0 && !managed) { if (bean.isRoot()) { status = "root"; } } } else if (lowerStatus.startsWith("error")) { image = "red-dot.png"; } } if (status != null) { Styler style = null; StyledString styledString = new StyledString(status, style); /* * String fileName = bean.getFileName(); if (fileName != null) { * styledString.append(fileName, StyledString.COUNTER_STYLER); } */ cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } if (image != null) { cell.setImage(Fabric8JMXPlugin.getDefault().getImage(image)); } } super.update(cell); }
From source file:org.fusesource.ide.jmx.fabric8.navigator.properties.LocationLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); LogEvent log = LogViewTabSection.toLogEvent(element); if (log != null) { String className = log.getClassName(); // we don't want to display ? as location if (className.trim().equals("?")) className = null;//from ww w . java2 s . c o m if (className != null) { Styler style = null; StyledString styledString = new StyledString(className, style); String fileName = log.getFileName(); if (fileName != null) { styledString.append(fileName, StyledString.COUNTER_STYLER); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } } super.update(cell); }
From source file:org.fusesource.ide.jmx.karaf.navigator.osgi.BundleStatusLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof IPropertySource) { IPropertySource bean = (IPropertySource) element; String status = null;/*from w ww . j av a2 s. c om*/ Object value = bean.getPropertyValue("State"); if (value != null) { status = value.toString(); } String image = null; if (status != null) { String lowerStatus = status.toLowerCase(); if (lowerStatus.startsWith("a")) { image = "green-dot.png"; } else if (lowerStatus.startsWith("inst")) { image = "gray-dot.png"; } else if (lowerStatus.startsWith("res")) { image = "yellow-dot.png"; } else { image = "red-dot.png"; } } if (status != null) { Styler style = null; StyledString styledString = new StyledString(status, style); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } if (image != null) { cell.setImage(KarafJMXPlugin.getDefault().getImage(image)); } } super.update(cell); }
From source file:org.goko.log.part.model.ProblemTreeLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element == null) { super.update(cell); return;// w w w. j a v a 2s.c o m } JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, HYPERLINK_COLOR); StyledString styledString = new StyledString(); if (element instanceof LogLevelNode) { LogLevelNode logNode = (LogLevelNode) element; if (targetColumn == COLUMN_DESCRIPTION) { styledString.append(logNode.getLabel()); styledString.append(" (" + CollectionUtils.size(logNode.getMessages()) + ")", StyledString.COUNTER_STYLER); cell.setImage(getImage(element)); } } else if (element instanceof ApplicativeLogEvent) { ApplicativeLogEvent event = (ApplicativeLogEvent) element; if (targetColumn == COLUMN_DESCRIPTION) { styledString.append(event.getMessage()); } else if (targetColumn == COLUMN_SOURCE) { styledString.append(event.getSource()); } else if (targetColumn == COLUMN_DATE) { DateFormat df = new SimpleDateFormat("HH:mm:ss"); styledString.append(df.format(event.getDate())); } } else { styledString.append(String.valueOf(element)); } cell.setText(styledString.getString()); cell.setStyleRanges(styledString.getStyleRanges()); super.update(cell); }
From source file:org.jboss.tools.openshift.express.internal.ui.propertytable.PropertyValueCellLabelProvider.java
License:Open Source License
private void createStyledText(IProperty property, final ViewerCell cell) { StyledString.Styler style = new StyledString.Styler() { @Override//from w ww. j av a 2 s . c o m public void applyStyles(TextStyle textStyle) { textStyle.foreground = cell.getControl().getDisplay().getSystemColor(SWT.COLOR_BLUE); textStyle.underline = true; } }; StyledString styledString = new StyledString(StringUtils.null2emptyString(property.getValue()), style); cell.setStyleRanges(styledString.getStyleRanges()); cell.setText(styledString.getString()); }
From source file:org.jboss.tools.openshift.internal.ui.portforwading.PortForwardingWizardPage.java
License:Open Source License
protected TableViewer createTable(Composite tableContainer, DataBindingContext dbc) { Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL); table.setLinesVisible(true);// w ww. j a v a2s . c o m table.setHeaderVisible(true); TableColumnLayout tableLayout = new TableColumnLayout(); tableContainer.setLayout(tableLayout); TableViewer viewer = new TableViewer(table); viewer.setContentProvider(new ArrayContentProvider()); createTableColumn("Name", 1, new CellLabelProvider() { @Override public void update(ViewerCell cell) { IPortForwardable.PortPair port = (IPortForwardable.PortPair) cell.getElement(); cell.setText(StringUtils.defaultIfBlank(port.getName(), "")); } }, viewer, tableLayout); createTableColumn("Local Port", 2, new StyledCellLabelProvider() { @Override public void update(ViewerCell cell) { IPortForwardable.PortPair port = (IPortForwardable.PortPair) cell.getElement(); int local = port.getLocalPort(); if (wizardModel.getPortForwarding() || !PortForwardingUtils.isPortInUse(local)) { cell.setText(Integer.toString(local)); cell.setStyleRanges(new StyleRange[0]); } else { String text = Integer.toString(local) + " (in use)"; StyledString styledString = new StyledString(); styledString.append(text, usedPortStyler); cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); } super.update(cell); } }, viewer, tableLayout); createTableColumn("Remote Port", 2, new CellLabelProvider() { @Override public void update(ViewerCell cell) { IPortForwardable.PortPair port = (IPortForwardable.PortPair) cell.getElement(); cell.setText(Integer.toString(port.getRemotePort())); } }, viewer, tableLayout); createTableColumn("Status", 1, new CellLabelProvider() { @Override public void update(ViewerCell cell) { final boolean started = wizardModel.getPortForwarding(); cell.setText(started ? "Started" : "Stopped"); } }, viewer, tableLayout); IObservableValue forwardablePortsModelObservable = BeanProperties .value(PortForwardingWizardModel.PROPERTY_FORWARDABLE_PORTS).observe(wizardModel); final ForwardablePortListValidator validator = new ForwardablePortListValidator( forwardablePortsModelObservable); dbc.addValidationStatusProvider(validator); viewer.setInput(wizardModel.getForwardablePorts()); // return viewer; }