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

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

Introduction

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

Prototype

public void setImage(Image image) 

Source Link

Document

Set the Image for the cell.

Usage

From source file:com.netxforge.netxstudio.screens.f3.support.NetworkTreeLabelProvider.java

License:Open Source License

private void updateColumn1(ViewerCell cell, Object element) {

    StyledString styledString = new StyledString();
    // Styler expressionColorStyle = StyledString.createColorRegistryStyler(
    // EXPRESSION_COLOR_STYLER, null);
    Image img = null;//from  ww  w. j a  v a  2s  .c  om
    if (element instanceof Component) {
        Component c = (Component) element;
        if (c.eIsSet(LibraryPackage.Literals.COMPONENT__CAPACITY_EXPRESSION_REF)) {
            // styledString.append(" C ", expressionColorStyle);
            // cell.setText(styledString.getString());
            img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                    "icons/full/obj16/Expression_H.png");
            cell.setImage(img);
            cell.setStyleRanges(styledString.getStyleRanges());
        } else {
            cell.setImage(null);
        }
    }

}

From source file:com.netxforge.netxstudio.screens.f3.support.NetworkTreeLabelProvider.java

License:Open Source License

private void updateColumn2(ViewerCell cell, Object element) {

    StyledString styledString = new StyledString();
    // Styler expressionColorStyle = StyledString.createColorRegistryStyler(
    // EXPRESSION_COLOR_STYLER, null);
    Image img = null;/*w w  w  .  java 2 s . c  o m*/

    if (element instanceof Component) {
        Component c = (Component) element;

        if (c.eIsSet(LibraryPackage.Literals.COMPONENT__UTILIZATION_EXPRESSION_REF)) {
            // styledString.append(" ,U ", expressionColorStyle);
            // cell.setText(styledString.getString());
            img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                    "icons/full/obj16/Expression_H.png");
            cell.setImage(img);
            cell.setStyleRanges(styledString.getStyleRanges());
        } else {
            cell.setImage(null);
        }
    }
}

From source file:com.netxforge.netxstudio.screens.f3.support.NetworkTreeLabelProvider.java

License:Open Source License

private void updateColumn0(ViewerCell cell, Object element) {
    if (element instanceof Operator) {

        Operator operator = (Operator) element;

        StyledString styledString = new StyledString(operator.getName() != null ? operator.getName() : "?",
                null);//  w ww. ja va  2 s  . co  m
        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());
    }

    if (element instanceof Network) {

        Network network = (Network) element;

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

    if (element instanceof Node) {

        Node node = (Node) element;

        StyledString styledString = new StyledString(node.getNodeID() != null ? node.getNodeID() : "?", null);
        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 Component) {

        Component c = (Component) element;
        StyledString styledString = new StyledString();

        Styler lifecycleColorStyler = StyledString.createColorRegistryStyler(LIFECYCLE_COLOR_STYLER, null);
        int lifeCycleState = StudioUtils.lifecycleState(c.getLifecycle());

        styledString.append(StudioUtils.componentName(c), null);

        if (element instanceof Function) {
            cell.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                    "icons/full/obj16/Function_H.png"));
        }
        if (element instanceof Equipment) {
            cell.setImage(ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                    "icons/full/obj16/Equipment_H.png"));

        }

        Styler metricColorStyler = StyledString.createColorRegistryStyler(METRIC_COLOR_STYLER, null);

        // Add Resources info.
        if (!c.getResourceRefs().isEmpty()) {
            String decoration = " (" + c.getResourceRefs().size() + " Res.)";
            styledString.append(decoration, StyledString.COUNTER_STYLER);
        }

        // Add Metrics info.
        if (!c.getMetricRefs().isEmpty()) {
            String decoration = " (" + c.getMetricRefs().size() + " Metrics)";
            styledString.append(decoration, metricColorStyler);
        }

        // Add Life Cycle info.
        if (lifeCycleState != StudioUtils.LIFECYCLE_NOTSET) {
            String decoration = " (" + StudioUtils.lifecycleText(lifeCycleState) + ")";
            styledString.append(decoration, lifecycleColorStyler);
        }

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

    }

    if (element instanceof Relationship) {

        Styler xColorStyler = StyledString.createColorRegistryStyler(REL_NOTCONNECTED_COLOR_STYLER, null);

        Relationship rel = (Relationship) element;
        StyledString styledString = new StyledString(rel.getName() != null ? rel.getName() : "?", null);

        StringBuffer decoration = new StringBuffer();
        decoration.append(" (");
        if (rel.getNodeID1Ref() != null) {
            decoration.append(rel.getNodeID1Ref().getNodeID());
            styledString.append(decoration.toString(), StyledString.COUNTER_STYLER);
        } else {
            styledString.append(decoration.toString(), StyledString.COUNTER_STYLER);
            styledString.append(" x", xColorStyler);
        }

        decoration = new StringBuffer();
        decoration.append(" <--> ");

        if (rel.getNodeID2Ref() != null) {
            decoration.append(rel.getNodeID2Ref().getNodeID());
            styledString.append(decoration.toString(), StyledString.COUNTER_STYLER);
        } else {
            styledString.append(decoration.toString(), StyledString.COUNTER_STYLER);
            styledString.append("x", xColorStyler);

        }
        decoration = new StringBuffer();
        decoration.append(" )");

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

        cell.setText(styledString.getString());

        Image img;
        if (element instanceof FunctionRelationship) {
            img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                    "icons/full/obj16/FunctionRelationship_H.png");
            cell.setImage(img);
        }
        if (element instanceof EquipmentRelationship) {
            img = ResourceManager.getPluginImage("com.netxforge.netxstudio.models.edit",
                    "icons/full/obj16/EquipmentRelationship_H.png");
            cell.setImage(img);
        }

        cell.setStyleRanges(styledString.getStyleRanges());
    }
}

From source file:com.nextep.designer.sqlclient.ui.jface.SQLResultLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    final Object elt = cell.getElement();
    final int colIndex = cell.getColumnIndex();
    final String text = getColumnText(elt, colIndex);
    cell.setText(text);//w  w  w  .j  av  a2s.  c o  m
    final Image img = getColumnImage(elt, colIndex);
    cell.setImage(img);
    final Color background = getBackground(elt, colIndex);
    cell.setBackground(background);
}

From source file:com.puppetlabs.geppetto.pp.dsl.ui.editor.findrefs.ReferenceSearchResultLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    Object o = cell.getElement();
    StyledString st = getStyledText(o);//from   w ww . j  a v a 2s . c  om
    if (st == null)
        st = new StyledString("<cell with null element>");
    cell.setText(st.toString());
    cell.setStyleRanges(st.getStyleRanges());
    cell.setImage(getImage(o));
}

From source file:com.reprezen.swagedit.core.editor.outline.OutlineStyledLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();

    if (element instanceof AbstractNode) {
        StyledString styledString = getStyledString((AbstractNode) element);

        cell.setText(styledString.toString());
        cell.setStyleRanges(styledString.getStyleRanges());
        cell.setImage(getImage(getIcon((AbstractNode) element)));
    }//from www  .  j a v a 2  s . c  o  m
}

From source file:com.siteview.mde.internal.runtime.registry.RegistryBrowserLabelProvider.java

License:Open Source License

public void update(ViewerCell cell) {
    StyledString string = getStyledText(cell.getElement());
    cell.setText(string.getString());/*ww w  . j ava2 s.  co m*/
    cell.setStyleRanges(string.getStyleRanges());
    cell.setImage(getImage(cell.getElement()));
    super.update(cell);
}

From source file:com.siteview.mde.internal.ui.shared.target.StyledBundleLabelProvider.java

License:Open Source License

public void update(ViewerCell cell) {
    Object element = cell.getElement();
    StyledString styledString = getStyledString(element);
    cell.setText(styledString.toString());
    cell.setStyleRanges(styledString.getStyleRanges());
    cell.setImage(getImage(element));
    super.update(cell);
}

From source file:com.vectrace.MercurialEclipse.ui.AbstractHighlightableTable.java

License:Open Source License

public AbstractHighlightableTable(Composite parent, final HighlightingLabelProvider<E> labelProvider) {
    super(parent, SWT.NONE);

    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    TableColumnLayout tableColumnLayout = new TableColumnLayout();
    setLayout(tableColumnLayout);/*w  w  w . ja v a 2s  .  c om*/

    viewer = new TableViewer(this, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);

    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(labelProvider);

    List<TableViewerColumn> cols = createColumns(viewer, tableColumnLayout);

    CellLabelProvider clp = new CellLabelProvider() {
        @Override
        public void update(ViewerCell cell) {
            E patch = (E) cell.getElement();
            HighlightingLabelProvider<E> lp = (HighlightingLabelProvider<E>) viewer.getLabelProvider();
            cell.setText(labelProvider.getColumnText(patch, cell.getColumnIndex()));
            cell.setImage(labelProvider.getColumnImage(patch, cell.getColumnIndex()));
            if (lp.isHighlighted(patch)) {
                cell.setFont(APPLIED_FONT);
            } else {
                cell.setFont(null);
            }
        }
    };

    for (Iterator<TableViewerColumn> it = cols.iterator(); it.hasNext();) {
        it.next().setLabelProvider(clp);
    }

    Table table = viewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
}

From source file:cop.swt.widgets.viewers.table.columns.settings.AbstractColumnSettings.java

License:LGPL

public void update(ViewerCell cell, T item) throws Exception {
    Object obj = invoke(item);/*from   w w  w  .  ja  v a  2s. com*/

    cell.setText(getCellText(obj));
    cell.setImage(getColumnImage(obj));
}