Example usage for org.eclipse.jface.viewers ViewerCell setStyleRanges

List of usage examples for org.eclipse.jface.viewers ViewerCell setStyleRanges

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ViewerCell setStyleRanges.

Prototype

public void setStyleRanges(StyleRange[] styleRanges) 

Source Link

Document

Set the style ranges to be applied on the text label Note: Requires StyledCellLabelProvider with owner draw enabled.

Usage

From source file:org.bonitasoft.studio.actors.ui.section.StyledFilterLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof ActorFilter) {
        ActorFilter filter = (ActorFilter) cell.getElement();
        ConnectorDefinition def = defStore.getDefinition(filter.getDefinitionId(),
                filter.getDefinitionVersion());
        StyledString styledString = new StyledString();

        styledString.append(getText(filter), null);
        styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
        String connectorType = filter.getDefinitionId() + " (" + filter.getDefinitionVersion() + ")";
        styledString.append(connectorType, StyledString.DECORATIONS_STYLER);
        if (filter.getEvent() != null && !filter.getEvent().isEmpty()) {
            styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
            styledString.append(filter.getEvent(), StyledString.COUNTER_STYLER);
        }//www.  java  2 s. com
        if (def == null) {
            styledString.setStyle(0, styledString.length(),
                    new org.eclipse.jface.viewers.StyledString.Styler() {

                        @Override
                        public void applyStyles(TextStyle textStyle) {
                            textStyle.strikeout = true;
                        }
                    });
            styledString.append(" ");
            styledString.append(Messages.bind(Messages.filterDefinitionNotFound,
                    filter.getDefinitionId() + " (" + filter.getDefinitionVersion() + ")"));
        }

        cell.setText(styledString.getString());
        cell.setImage(getImage(filter));
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}

From source file:org.bonitasoft.studio.actors.ui.wizard.page.OrganizationLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    String orgaName = getText(cell.getElement());
    String activeOrganization = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore()
            .getString(ActorsPreferenceConstants.DEFAULT_ORGANIZATION);
    StyledString styledString = new StyledString();
    styledString.append(orgaName, null);
    if (orgaName.equals(activeOrganization)) {
        styledString.append("  (" + Messages.active + ")", boldgreen);
    }/*from ww  w.  ja  v  a2 s.  co m*/
    cell.setText(styledString.getString());
    cell.setImage(null);
    cell.setStyleRanges(styledString.getStyleRanges());
}

From source file:org.bonitasoft.studio.businessobject.ui.BusinessObjectDataStyledLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    super.update(cell);
    if (cell.getElement() instanceof BusinessObjectData) {
        final BusinessObjectData data = (BusinessObjectData) cell.getElement();
        if (!businessObjectDefinitionExists(data)) {
            final StyledString styledString = createStrikethroughStyle(cell.getText(), data.getClassName());
            cell.setText(styledString.getString());
            cell.setStyleRanges(styledString.getStyleRanges());
        }/*w  w w. jav a2 s . co  m*/
    }
}

From source file:org.bonitasoft.studio.common.jface.DataStyledTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof Data) {
        Data d = (Data) cell.getElement();
        StyledString styledString = new StyledString();

        String decoration = " -- " + getTypeLabel(d);
        if (d.isTransient()) {
            styledString.append(d.getName(), italicGrey);
        } else {// w  w w .  j av a  2s. c  om
            styledString.append(d.getName(), null);
        }
        styledString.append(decoration, StyledString.DECORATIONS_STYLER);
        if (d.getDefaultValue() != null && d.getDefaultValue().getName() != null
                && !d.getDefaultValue().getName().isEmpty()) {
            String content = d.getDefaultValue().getName();
            content = Messages.defaultValue + ": " + content.replaceAll("\n", " ");
            styledString.append(" -- ", StyledString.DECORATIONS_STYLER);
            styledString.append(content, StyledString.QUALIFIER_STYLER);
        }

        cell.setText(styledString.getString());
        cell.setImage(getImage(d));
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}

From source file:org.bonitasoft.studio.common.refactoring.DiffTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    StyledString styledString = new StyledString();

    DiffNode node = (DiffNode) cell.getElement();
    if (node.getLeft() != null) {
        styledString.append(getText(cell.getElement()), boldgreen);
    } else {//from www. j a  v a2 s  .  c o m
        styledString.append(getText(cell.getElement()));
    }
    cell.setText(styledString.getString());
    cell.setImage(getImage(cell.getElement()));
    cell.setStyleRanges(styledString.getStyleRanges());

}

From source file:org.bonitasoft.studio.connectors.ui.provider.DatabaseDriversLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof String) {
        String s = (String) cell.getElement();
        StyledString styledString = new StyledString();
        styledString.append(s, null);/*www .j a  v  a 2s.c o  m*/
        if (s.equals(defaultDriver)) {
            styledString.append(" (Active)", boldgreen);
        }
        cell.setText(styledString.getString());
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}

From source file:org.bonitasoft.studio.connectors.ui.provider.StyledConnectorLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof Connector) {
        Connector connector = (Connector) cell.getElement();
        ConnectorDefinition def = connectorDefStore.getDefinition(connector.getDefinitionId(),
                connector.getDefinitionVersion(), definitions);
        if (def == null) {
            def = connectorDefStore.getDefinition(connector.getDefinitionId(),
                    connector.getDefinitionVersion());
        }//from w ww  .j av  a 2  s. com
        StyledString styledString = new StyledString();

        styledString.append(getText(connector), null);
        styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
        String connectorType = connector.getDefinitionId() + " (" + connector.getDefinitionVersion() + ")";
        styledString.append(connectorType, StyledString.DECORATIONS_STYLER);
        EObject parent = connector.eContainer();
        if (!(parent instanceof Expression) && !(parent instanceof Form)
                && !(parent instanceof SubmitFormButton)) {
            if (connector.getEvent() != null && !connector.getEvent().isEmpty()) {
                styledString.append(" -- ", StyledString.QUALIFIER_STYLER);
                styledString.append(connector.getEvent(), StyledString.COUNTER_STYLER);
            }
        }
        if (def == null) {
            styledString.setStyle(0, styledString.length(),
                    new org.eclipse.jface.viewers.StyledString.Styler() {

                        @Override
                        public void applyStyles(TextStyle textStyle) {
                            textStyle.strikeout = true;
                        }
                    });
            styledString.append(" ");
            styledString.append(Messages.bind(Messages.connectorDefinitionNotFound,
                    connector.getDefinitionId() + " (" + connector.getDefinitionVersion() + ")"));
        }

        cell.setText(styledString.getString());
        cell.setImage(getImage(connector));
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}

From source file:org.bonitasoft.studio.contract.ui.expression.ContractInputLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    super.update(cell);
    final ContractInput element = (ContractInput) cell.getElement();
    final StyledString styledString = getStyledString(element);
    cell.setText(styledString.toString());
    cell.setStyleRanges(styledString.getStyleRanges());
    cell.setImage(getImage(element));/*from   ww w. java2 s  .c  o m*/
}

From source file:org.bonitasoft.studio.diagram.custom.wizard.DiagramLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof DiagramFileStore) {
        DiagramFileStore filseStore = (DiagramFileStore) cell.getElement();
        StyledString styledString = new StyledString();

        styledString.append(fileStoreLabelProvider.getText(filseStore), null);
        if (filseStore.getMigrationReport() != null) {
            styledString.append(" -- ", StyledString.DECORATIONS_STYLER);
            styledString.append(Messages.migrationOngoing, StyledString.COUNTER_STYLER);
        }/* w  w w.ja v  a 2 s .com*/

        cell.setText(styledString.getString());
        cell.setImage(fileStoreLabelProvider.getImage(filseStore));
        cell.setStyleRanges(styledString.getStyleRanges());
    }
    super.update(cell);
}

From source file:org.bonitasoft.studio.parameters.property.section.provider.ParameterStyledLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof Parameter) {
        Parameter p = (Parameter) cell.getElement();
        StyledString styledString = new StyledString();

        String decoration = " -- " + typeProvider.getText(p);
        styledString.append(p.getName(), null);

        styledString.append(decoration, StyledString.DECORATIONS_STYLER);
        cell.setText(styledString.getString());
        cell.setImage(getImage(p));/*from   w ww . j av a  2 s  .  c  o m*/
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}