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:com.netxforge.netxstudio.callflow.screens.protocols.ProtocolsTreeLabelProvider.java

License:Open Source License

private void updateColumn0(ViewerCell cell, Object element) {
    if (element instanceof Protocol) {
        Protocol protocol = (Protocol) element;
        StyledString styledString = new StyledString(indexFor(null, protocol), null);
        cell.setText(styledString.getString());
        // Image img = ResourceManager.getPluginImage(
        // "com.netxforge.netxstudio.models.edit",
        // "icons/full/obj16/Company_H.png");
        // cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    } else if (element instanceof Procedure) {
        Procedure proc = (Procedure) element;
        StyledString styledString = new StyledString(
                indexFor(ProtocolsPackage.Literals.PROTOCOL__PROCEDURES, proc), null);
        cell.setText(styledString.getString());
        cell.setStyleRanges(styledString.getStyleRanges());
    } else if (element instanceof Message) {
        Message msg = (Message) element;
        StyledString styledString = new StyledString(
                indexFor(ProtocolsPackage.Literals.PROCEDURE__MESSAGES, msg), null);
        cell.setText(styledString.getString());
        cell.setStyleRanges(styledString.getStyleRanges());
    }//ww  w  .ja  v  a2s  .  c o  m
}

From source file:com.netxforge.netxstudio.callflow.screens.protocols.ProtocolsTreeLabelProvider.java

License:Open Source License

private void updateColumn1(ViewerCell cell, Object element) {
    if (element instanceof Protocol) {
        Protocol serviceFlow = (Protocol) element;
        StyledString styledString = new StyledString(serviceFlow.getName(), null);
        cell.setText(styledString.getString());
        // Image img = ResourceManager.getPluginImage(
        // "com.netxforge.netxstudio.models.edit",
        // "icons/full/obj16/Company_H.png");
        // cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    } else if (element instanceof Procedure) {
        Procedure procedure = (Procedure) element;
        StyledString styledString = new StyledString(procedure.getName());
        cell.setStyleRanges(styledString.getStyleRanges());
        cell.setText(styledString.getString());
    } else if (element instanceof Message) {
        Message procedure = (Message) element;
        StyledString styledString = new StyledString(procedure.getName());
        cell.setStyleRanges(styledString.getStyleRanges());
        cell.setText(styledString.getString());
    }/*w  w w.  j a  v a2 s.com*/
}

From source file:com.netxforge.netxstudio.callflow.screens.protocols.ProtocolsTreeLabelProvider.java

License:Open Source License

private void updateColumn2(ViewerCell cell, Object element) {
    if (element instanceof Protocol) {
        Protocol protocol = (Protocol) element;

        if (protocol.eIsSet(ProtocolsPackage.Literals.PROTOCOL__DESCRIPTION)) {
            StyledString styledString = new StyledString(protocol.getDescription(), null);
            cell.setText(styledString.getString());
            // Image img = ResourceManager.getPluginImage(
            // "com.netxforge.netxstudio.models.edit",
            // "icons/full/obj16/Company_H.png");
            // cell.setImage(img);
            cell.setStyleRanges(styledString.getStyleRanges());
        }//w  ww  . ja v  a 2s  .c  o m
    } else if (element instanceof Message) {
        Message msg = (Message) element;

        if (msg.eIsSet(ProtocolsPackage.Literals.MESSAGE__DESCRIPTION)) {
            StyledString styledString = new StyledString(msg.getDescription());
            cell.setStyleRanges(styledString.getStyleRanges());
            cell.setText(styledString.getString());
        }
    }
}

From source file:com.netxforge.netxstudio.callflow.screens.protocols.ProtocolsTreeLabelProvider.java

License:Open Source License

private void updateColumn3(ViewerCell cell, Object element) {
    if (element instanceof Protocol) {
        Protocol protocol = (Protocol) element;

        if (protocol.eIsSet(ProtocolsPackage.Literals.PROTOCOL__OSI)) {
            OSIType osi = protocol.getOSI();

            StyledString styledString = new StyledString(osi.getLiteral(), null);
            cell.setText(styledString.getString());
            // Image img = ResourceManager.getPluginImage(
            // "com.netxforge.netxstudio.models.edit",
            // "icons/full/obj16/Company_H.png");
            // cell.setImage(img);
            cell.setStyleRanges(styledString.getStyleRanges());
        }/*from   w  w  w.  j a v  a 2s  . co m*/
    }
}

From source file:com.netxforge.netxstudio.callflow.screens.protocols.ProtocolsTreeLabelProvider.java

License:Open Source License

private void updateColumn4(ViewerCell cell, Object element) {
    if (element instanceof Protocol) {
        Protocol protocol = (Protocol) element;

        if (protocol.eIsSet(ProtocolsPackage.Literals.PROTOCOL__SPECIFICATION)) {
            String specification = protocol.getSpecification();

            StyledString styledString = new StyledString(specification, null);
            cell.setText(styledString.getString());
            // Image img = ResourceManager.getPluginImage(
            // "com.netxforge.netxstudio.models.edit",
            // "icons/full/obj16/Company_H.png");
            // cell.setImage(img);
            cell.setStyleRanges(styledString.getStyleRanges());
        }/*from  w  ww.j  a  va  2 s  . c  o  m*/
    }
}

From source file:com.netxforge.netxstudio.screens.ch9.ObjectExpressions.java

License:Open Source License

private void bindExpressionSelector(EMFDataBindingContext bindingContext) {

    List<EReference> expressionEReferences = StudioUtils.expressionEReferences(primaryContextObject);
    for (EReference eref : expressionEReferences) {
        expressionEntries.put(eref.getName(), eref);
    }/*from  www  . j a  va 2  s .  c om*/

    // set the content provider and label provider for the listviewer.
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setLabelProvider(new StyledCellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            Object element = cell.getElement();
            EReference eReference = expressionEntries.get(element);
            Expression exp = (Expression) primaryContextObject.eGet(eReference);

            // Strip some words from the ref name.
            String refName = (String) element;
            String replaceAll = refName.replaceAll("(Expression|Ref)", "");
            StyledString styledString = new StyledString((String) replaceAll);

            if (exp == null) {
                styledString.append(" (not set)", StyledString.COUNTER_STYLER);
            }

            cell.setText(styledString.getString());
            cell.setStyleRanges(styledString.getStyleRanges());

            super.update(cell);
        }
    });

    tableViewer.setInput(expressionEntries.keySet().toArray());

}

From source file:com.netxforge.netxstudio.screens.f1.support.MonitoringTreeLabelProvider.java

License:Open Source License

private void processColumn0(ViewerCell cell) {
    Object element = cell.getElement();

    if (element instanceof Operator) {
        Operator o = (Operator) element;

        StyledString styledString = new StyledString(
                o.eIsSet(GenericsPackage.Literals.COMPANY__NAME) ? o.getName() : "?", null);
        // String decoration = " (" + tt.getFunctions() + " Functions)"
        // + " (" + tt.getEquipments() + " Equipments)";
        // styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Company_H.png");
        cell.setImage(img);/*  w  w  w  . j a va 2s .c om*/
        cell.setStyleRanges(styledString.getStyleRanges());

    } else if (element instanceof RFSService) {

        RFSService nt = (RFSService) element;

        StyledString styledString = new StyledString(nt.getServiceName() != null ? nt.getServiceName() : "?",
                null);
        // String decoration = " (" + tt.getFunctions() + " Functions)"
        // + " (" + tt.getEquipments() + " Equipments)";
        // styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Service_H.png");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    } else if (element instanceof NetXResource) {
        NetXResource res = (NetXResource) element;
        StyledString styledString = new StyledString(res.getShortName() != null ? res.getShortName() : "?",
                null);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/NetXResource_H.gif");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());

    } else if (element instanceof MetricValueRange) {

        MetricValueRange mvr = (MetricValueRange) element;
        int size = mvr.getMetricValues().size();

        Tuple interval = NonModelUtils.interval(mvr.getIntervalHint());
        StyledString styledString = new StyledString(
                interval.getKey() + " : " + mvr.getKindHint() + " : (" + new Integer(size).toString() + ")");
        cell.setText(styledString.getString());
        cell.setStyleRanges(styledString.getStyleRanges());

    } else {

        networkTreeLabelProvider.update(cell);
    }
}

From source file:com.netxforge.netxstudio.screens.f1.support.MonitoringTreeLabelProvider.java

License:Open Source License

private void processRagColumns(ViewerCell cell) {
    Object element = cell.getElement();

    if (element instanceof EObject) {

        // For node, we need to present the nodetype summary.
        if (element instanceof Node) {
            if (((EObject) element).eIsSet(OperatorsPackage.Literals.NODE__NODE_TYPE)) {
                element = ((Node) element).getNodeType();
            }//from  ww  w  . ja  v  a  2  s.c  om
        }

        if (!MonitoringStateModel.isAdapted((EObject) element)) {
            // We let our screen deal with calling the monitoring state
            // model.
            // System.out.println(" No monitor for: " + element);
        } else {
            IMonitoringSummary summary = MonitoringStateModel.getAdapted((EObject) element);

            StyledString styledString = backGroundAndStyleForRag(cell, summary);
            cell.setText(styledString.getString());
            cell.setStyleRanges(styledString.getStyleRanges());
        }
    }
}

From source file:com.netxforge.netxstudio.screens.f1.support.RFSServiceTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {

    Object element = cell.getElement();

    if (element instanceof Operator) {
        Operator o = (Operator) element;

        StyledString styledString = new StyledString(
                o.eIsSet(GenericsPackage.Literals.COMPANY__NAME) ? o.getName() : "?", null);
        // String decoration = " (" + tt.getFunctions() + " Functions)"
        // + " (" + tt.getEquipments() + " Equipments)";
        // styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Company_H.png");
        cell.setImage(img);//w ww. j av  a 2s. c  o  m
        cell.setStyleRanges(styledString.getStyleRanges());

    }
    if (element instanceof RFSService) {

        RFSService nt = (RFSService) element;

        StyledString styledString = new StyledString(nt.getServiceName() != null ? nt.getServiceName() : "?",
                null);
        // String decoration = " (" + tt.getFunctions() + " Functions)"
        // + " (" + tt.getEquipments() + " Equipments)";
        // styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Service_H.png");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}

From source file:com.netxforge.netxstudio.screens.f2.support.NodeTypeTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {

    Object element = cell.getElement();

    if (element instanceof NodeType) {

        NodeType nt = (NodeType) element;

        StyledString styledString = new StyledString(nt.getName() != null ? nt.getName() : "?", null);

        if (!MonitoringStateModel.isAdapted(nt)) {
            stateModel.summary(new LabelProviderCallBack(), nt,
                    MonitoringStateModel.MONITOR_COMPUTATION_REPETITIVE_MODE);
        } else {//from w  w w . ja v  a 2s .c  om
            NodeTypeSummary summary = (NodeTypeSummary) MonitoringStateModel.getAdapted(nt);

            String decoration = " (" + summary.getFunctionCountAsString() + " Functions)" + " ("
                    + summary.getEquipmentCountAsString() + " Equipments)";

            styledString.append(decoration, StyledString.COUNTER_STYLER);
        }

        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Node_H.png");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());

    }

    if (element instanceof Function) {
        Function fc = (Function) element;

        StyledString styledString = new StyledString(fc.getName() != null ? fc.getName() : "?", null);
        String decoration = " (" + fc.getResourceRefs().size() + " Resources)";
        styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Function_H.png");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    }
    if (element instanceof Equipment) {

        Equipment eq = (Equipment) element;
        StyledString styledString = new StyledString(
                eq.getEquipmentCode() != null ? eq.getEquipmentCode() : "?", null);
        String decoration = " (" + eq.getResourceRefs().size() + " Resources)";
        styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Equipment_H.png");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    }

    if (element instanceof NetXResource) {

        NetXResource eq = (NetXResource) element;
        StyledString styledString = new StyledString(eq.getShortName() != null ? eq.getShortName() : "?", null);
        // String decoration = " (" + eq.getResources().size() +
        // " Resources)";
        // styledString.append(decoration, StyledString.COUNTER_STYLER);
        cell.setText(styledString.getString());
        Image img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                "icons/full/obj16/Resource_H.gif");
        cell.setImage(img);
        cell.setStyleRanges(styledString.getStyleRanges());
    }
}