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

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

Introduction

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

Prototype

public void setText(String text) 

Source Link

Document

Set the text for the cell.

Usage

From source file:de.walware.statet.r.ui.RLabelProvider.java

License:Open Source License

@Override
 public void update(final ViewerCell cell) {
     final Object element = cell.getElement();
     final IModelElement modelElement = LTKUtil.getModelElement(element);
     if (element instanceof IElementPartition) {
         update(cell, (IElementPartition) element, modelElement);
         super.update(cell);
     } else if (modelElement != null) {
         update(cell, modelElement);/*from  w w  w.  ja v  a2  s  .  c o m*/
         super.update(cell);
     } else {
         cell.setImage(null);
         cell.setText(element.toString());
         cell.setStyleRanges(null);
         super.update(cell);
     }
 }

From source file:de.walware.statet.r.ui.RLabelProvider.java

License:Open Source License

public void update(final ViewerCell cell, final IModelElement element) {
     Image image = null;//from   ww w  .ja va 2s . c  o m
     StyledString styledText = null;

     if (element instanceof ICombinedRElement) {
         final ICombinedRElement combined = (ICombinedRElement) element;
         if (combined.getRObjectType() == RObject.TYPE_REFERENCE) {
             final RObject realObject = ((RReference) element).getResolvedRObject();
             if (realObject instanceof ICombinedRElement) {
                 image = getImage((ICombinedRElement) realObject);
                 styledText = getStyledText((ICombinedRElement) realObject, combined.getElementName(), null);
             }
         }
     }

     if (image == null) {
         image = getImage(element);
     }
     cell.setImage(image);

     if (styledText == null) {
         styledText = getStyledText(element);
     }
     if (styledText != null) {
         cell.setText(styledText.getString());
         cell.setStyleRanges(styledText.getStyleRanges());
     } else {
         cell.setText(getText(element));
         cell.setStyleRanges(null);
     }
 }

From source file:de.walware.statet.r.ui.RLabelProvider.java

License:Open Source License

public void update(final ViewerCell cell, final IElementPartition partition, final IModelElement element) {
     cell.setImage(WaDebugImages.getImageRegistry().get(WaDebugImages.OBJ_VARIABLE_PARTITION));

     final StyledString text = new StyledString();
     text.append("["); //$NON-NLS-1$
     text.append(Long.toString((partition.getPartitionStart() + 1)));
     text.append(" ... "); //$NON-NLS-1$
     text.append(Long.toString(partition.getPartitionStart() + partition.getPartitionLength()));
     text.append("]"); //$NON-NLS-1$

     if (element instanceof RList) {
         final RList rList = (RList) element;
         String label = rList.getName(partition.getPartitionStart());
         if (label != null) {
             text.append("  "); //$NON-NLS-1$
             text.append(label, StyledString.QUALIFIER_STYLER);
             text.append(" ... ", StyledString.QUALIFIER_STYLER); //$NON-NLS-1$
             label = rList.getName(partition.getPartitionStart() + (partition.getPartitionLength() - 1));
             if (label != null) {
                 text.append(label, StyledString.QUALIFIER_STYLER);
             }/*ww w. ja va 2 s.co m*/
         }
     }

     cell.setText(text.getString());
     cell.setStyleRanges(text.getStyleRanges());
 }

From source file:de.walware.statet.rtm.base.ui.rexpr.RExprLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    final Object element = cell.getElement();
    cell.setImage(getImage(element));/*w w  w  .  j a  v  a  2  s.c  om*/
    cell.setText(getText(element));
}

From source file:edu.cmu.sei.alisa.editor.utils.AlisaLabelProvider.java

License:Apache License

/**
 * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
 *///ww  w.j av a 2  s.  c o m
@Override
public void update(ViewerCell cell) {
    int index = cell.getColumnIndex();
    String text = "N/A";

    if (cell.getElement() instanceof Stakeholder) {
        Stakeholder stakeholder = (Stakeholder) cell.getElement();
        switch (index) {
        case 0:
            text = stakeholder.getName();
            break;
        case 1:
            text = stakeholder.getTitle();
            break;
        case 2:
            text = stakeholder.getDescription();
            break;
        case 3:
            text = stakeholder.getRole();
            break;
        }
    }

    if (cell.getElement() instanceof VerificationActivity) {
        VerificationActivity va = (VerificationActivity) cell.getElement();
        switch (index) {
        case 0:
            text = va.getName();
            break;
        case 1:
            text = va.getTitle();
            break;
        case 2:
            text = va.getDescription();
            break;
        case 3:
            text = va.getMethod();
            break;
        case 4:
            text = Utils.getStakeholderListAsString(va.getAssignedTo());
            break;
        }
    }

    if (cell.getElement() instanceof Goal) {
        Goal goal = (Goal) cell.getElement();
        switch (index) {
        case 0:
            text = goal.getName();
            break;
        case 2:
            text = goal.getTitle();
            break;
        case 3:
            text = goal.getDescription();
            break;
        case 4:
            text = goal.getAssert();
            break;
        case 5:
            text = goal.getRationale();
            break;
        case 6:
            text = Utils.getStringListAsString(goal.getIssue());
            break;
        case 7:
            text = Utils.getStakeholderListAsString(goal.getStakeholderReference());
            break;
        }

    }

    if (cell.getElement() instanceof Requirement) {
        Requirement req = (Requirement) cell.getElement();
        Requirements reqs = (Requirements) req.eContainer();

        String target;
        switch (index) {
        case 0:
            text = Utils.getCategoryListAsString(req.getCategory());
            break;
        case 1:
            text = reqs.getName() + "." + req.getName();
            break;
        case 2:
            NamedElement cl = reqs.getTarget();
            target = req.getTarget();
            text = cl.getName() + (target != null ? "." + target : "");
            break;
        case 3:
            text = req.getTitle();
            break;
        case 4:
            text = req.getDescription();
            break;
        case 5:
            text = req.getAssert();
            break;
        case 6:
            text = req.getRationale();
            break;
        case 7:
            text = Utils.getStringListAsString(req.getIssue());
            break;
        }
    }

    if (cell.getElement() instanceof ExternalDocument) {
        ExternalDocument extdoc = (ExternalDocument) cell.getElement();
        switch (index) {
        case 0:
            text = extdoc.getName();
            break;
        case 1:
            text = extdoc.getExternalReference();
            break;
        }
    }

    cell.setText(text);
    super.update(cell);
}

From source file:era.foss.ui.contrib.EmfObservableMapVaildatingStyledCellLabelProvider.java

License:Open Source License

public void update(ViewerCell cell) {
    Object element = cell.getElement();
    Object value = attributeMaps[0].get(element);
    cell.setText(value == null ? "" : value.toString()); //$NON-NLS-1$
}

From source file:es.cv.gvcase.fefem.common.composites.EMFPropertyMultipleEEnumComposite.java

License:Open Source License

@Override
protected CellLabelProvider getLabelProvider() {
    return new CellLabelProvider() {

        @Override//from  w  ww .j  ava  2  s . c  o m
        public void update(ViewerCell cell) {

            if (cell.getElement() instanceof EEnumLiteral) {
                EEnumLiteral e = (EEnumLiteral) cell.getElement();
                cell.setText(e.getLiteral());
            }

            else
                cell.setText(cell.getElement().toString());

        }

    };
}

From source file:es.cv.gvcase.fefem.common.widgets.FilteredLoadResourceDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    // If the EditingDomain is available then the dialog shows current loaded resources
    if (this.domain != null) {

        Group resContainer = new Group(parent, SWT.BORDER);
        resContainer.setText(Messages.FilteredLoadResourceDialog_LoadedResources);
        FillLayout rescontainerLayout = new FillLayout();
        rescontainerLayout.type = SWT.VERTICAL;
        rescontainerLayout.marginHeight = 5;
        rescontainerLayout.marginWidth = 5;
        rescontainerLayout.spacing = 5;//from   ww w .j  a v  a 2s.c  o  m
        resContainer.setLayout(rescontainerLayout);
        resContainer.setLayoutData(new GridData(GridData.FILL_BOTH));

        Table table = new Table(resContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);

        String[] columnNames = { Messages.FilteredLoadResourceDialog_ResourceLocation };

        TableViewer tableViewer = new TableViewer(table);
        tableViewer.setContentProvider(new ArrayContentProvider());
        tableViewer.setInput(this.domain.getResourceSet().getResources());
        tableViewer.setColumnProperties(columnNames);
        tableViewer.setLabelProvider(new CellLabelProvider() {

            @Override
            public void update(ViewerCell cell) {

                cell.setText(((Resource) cell.getElement()).getURI().toString());

            }

        });

        TableColumn tc0 = new TableColumn(table, SWT.LEFT);
        tc0.setText(columnNames[0]);
        tc0.setWidth(150);

        table.setHeaderVisible(true);
        table.setLinesVisible(true);
    }

    Group container = new Group(parent, SWT.BORDER);
    container.setText(Messages.FilteredLoadResourceDialog_ResourcePatterns);
    FillLayout containerLayout = new FillLayout();
    containerLayout.type = SWT.VERTICAL;
    containerLayout.marginHeight = 5;
    containerLayout.marginWidth = 5;
    containerLayout.spacing = 5;
    container.setLayout(containerLayout);
    container.setLayoutData(new GridData(GridData.FILL_BOTH));

    Table table = new Table(container, SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);

    String[] columnNames = { Messages.FilteredLoadResourceDialog_ResourcePattern,
            Messages.FilteredLoadResourceDialog_ResourcePatternDescription };

    TableColumn tc0 = new TableColumn(table, SWT.LEFT);
    tc0.setText(columnNames[0]);
    tc0.setWidth(100);
    TableColumn tc1 = new TableColumn(table, SWT.LEFT);
    tc1.setText(columnNames[1]);
    tc1.setWidth(140);

    CheckboxTableViewer tableViewer = new CheckboxTableViewer(table);
    tableViewer.setContentProvider(new ArrayContentProvider());
    tableViewer.setInput(resourcePatterns);
    tableViewer.setColumnProperties(columnNames);
    tableViewer.setLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {

            if (cell.getColumnIndex() == 0)
                cell.setText(((ResourceFilePattern) cell.getElement()).getPattern());
            else if (cell.getColumnIndex() == 1)
                cell.setText(((ResourceFilePattern) cell.getElement()).getDescription());

        }

    });

    tableViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent e) {
            ResourceFilePattern r = (ResourceFilePattern) e.getElement();

            if (!filter.isRegisteredExtensionPattern(r.getPattern())) {
                filter.registerExtensionPattern(r.getPattern());
            } else
                filter.unregisterExtensionPattern(r.getPattern());
        }
    });

    tableViewer.setAllChecked(true);

    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    return super.createDialogArea(parent);
}

From source file:es.cv.gvcase.gvm.glossary.formseditor.providers.GlossaryLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getColumnIndex() == 0) { //Name
        cell.setText(((Term) cell.getElement()).getName());
    } else { //Type
        String className = cell.getElement().getClass().getSimpleName();
        //Remove the "Impl" part of the name
        className = className.substring(0, className.length() - 4);
        cell.setText(className);//  w w w. j  ava 2s.  c  o m
        if (cell.getElement() instanceof EObject) {
            cell.setImage(getImage((EObject) cell.getElement()));
        }

    }
}

From source file:es.uah.aut.srg.micobs.util.impl.MICOBSAdapterFactoryLabelProvider.java

License:Open Source License

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

    StyledString styledString = getStyledText(element);
    String newText = styledString.toString();

    StyleRange[] oldStyleRanges = cell.getStyleRanges();
    StyleRange[] newStyleRanges = isOwnerDrawEnabled() ? styledString.getStyleRanges() : null;

    if (!Arrays.equals(oldStyleRanges, newStyleRanges)) {
        cell.setStyleRanges(newStyleRanges);
        if (cell.getText().equals(newText)) {
            // make sure there will be a refresh from a change
            cell.setText(""); //$NON-NLS-1$
        }/*from w  ww.j  a  va 2  s . com*/
    }

    cell.setText(newText);
    cell.setImage(getImage(element));
    cell.setFont(getFont(element));
    cell.setForeground(getForeground(element));
    cell.setBackground(getBackground(element));

    // no super call required. changes on item will trigger the refresh.
}