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

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

Introduction

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

Prototype

public int getColumnIndex() 

Source Link

Document

Get the index of the cell.

Usage

From source file:org.eclipse.rcptt.verifications.tree.ui.VerificationEditingSupport.java

License:Open Source License

@Override
protected void initializeCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
    if (cell.getElement() instanceof Row) {
        Cell tableCell = ((Row) cell.getElement()).getValues().get(cell.getColumnIndex());
        cellEditor.setValue(getValue(tableCell));
    }/*w w w  .j  a  va 2s .c o m*/
}

From source file:org.eclipse.rcptt.verifications.tree.ui.VerificationEditingSupport.java

License:Open Source License

@Override
protected void saveCellEditorValue(CellEditor cellEditor, ViewerCell cell) {
    if (cell.getElement() instanceof Row) {
        Cell tableCell = ((Row) cell.getElement()).getValues().get(cell.getColumnIndex());
        setValue(tableCell, cellEditor.getValue());
        getViewer().refresh();/* ww  w. java2 s  .  com*/
    }
}

From source file:org.eclipse.rcptt.verifications.tree.ui.VerificationTreeLabelProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (cell.getElement() instanceof Row) {
        Row row = (Row) cell.getElement();
        int ind = cell.getColumnIndex();

        if (row.getValues().size() > ind) {
            Cell cellValue = row.getValues().get(ind);
            ItemData cellData = cellValue.getData();

            if (ignoreStyle) {
                cell.setStyleRanges(null);
                cell.setText(cellData.getText());
            } else {
                StyleRange[] ranges = RangeUtils.fromEMF(cellValue.getStyle(), cell.getItem().getDisplay());

                if (skipStyledText) {
                    cell.setStyleRanges(null);
                    cell.setText(StyleRangeUtils.getNonStyledText(ranges, cellData.getText()));
                } else {
                    cell.setStyleRanges(ranges);
                    cell.setText(cellData.getText());
                }/*from   w ww  .j  av  a  2 s  .c o m*/
            }
            cell.setBackground(
                    RangeUtils.colorFromEMF(cellData.getBackgroundColor(), cell.getItem().getDisplay()));
            cell.setForeground(
                    RangeUtils.colorFromEMF(cellData.getForegroundColor(), cell.getItem().getDisplay()));
            if (drawIcons) {
                String imgPath = TreeVerificationUtils.getDecoratedImagePath(cellData.getImage());
                if (images.containsKey(imgPath)) {
                    cell.setImage(images.get(imgPath));
                }
            } else {
                cell.setImage(null);
            }
        }
    }
}

From source file:org.eclipse.richbeans.generator.DeleteLableProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    TableItem item = (TableItem) cell.getItem();
    Button button;//w ww .j a  v a  2s  .  c  o m
    Object element = cell.getElement();
    if (buttons.containsKey(element)) {
        button = buttons.get(cell.getElement());
    } else {
        button = new Button((Composite) cell.getViewerRow().getControl(), SWT.NONE);
        button.setText(action.getName());
        buttons.put(cell.getElement(), button);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    action.invoke(toModify, element);
                    button.dispose();
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                    logger.error("could not apply action", ex);
                }
            }
        });
    }
    TableEditor editor = new TableEditor(item.getParent());
    editor.grabHorizontal = true;
    editor.grabVertical = true;
    editor.setEditor(button, item, cell.getColumnIndex());
    editor.layout();
}

From source file:org.eclipse.scada.ae.ui.testing.views.EventsLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    final Object o = cell.getElement();
    if (o instanceof Event) {
        final Event info = (Event) o;

        switch (cell.getColumnIndex()) {
        case 0://from   ww w.  j a va  2 s .  c o m
            cell.setText(this.dateFormat.format(info.getSourceTimestamp()));
            break;
        case 1:
            cell.setText(this.dateFormat.format(info.getEntryTimestamp()));
            break;
        case 2:
            cell.setText(getAttributes(info, Event.Fields.SOURCE.getName()).asString(""));
            break;
        case 3:
            cell.setText(getAttributes(info, Event.Fields.MONITOR_TYPE.getName()).asString(""));
            break;
        case 4:
            cell.setText(getAttributes(info, Event.Fields.EVENT_TYPE.getName()).asString(""));
            break;
        case 5:
            cell.setText(getAttributes(info, Event.Fields.ACTOR_NAME.getName()).asString(""));
            break;
        case 6:
            cell.setText(getAttributes(info, Event.Fields.VALUE.getName()).asString(""));
            break;
        case 7:
            cell.setText(getAttributes(info, Event.Fields.MESSAGE.getName()).asString(""));
            break;
        }
    }
}

From source file:org.eclipse.scada.ae.ui.testing.views.MonitorsLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    final Object o = cell.getElement();
    if (o instanceof MonitorStatusBean) {
        final MonitorStatusBean info = (MonitorStatusBean) o;
        switch (cell.getColumnIndex()) {
        case 0: // id
            cell.setText(info.getId());// ww w.jav  a2s.  c  o  m
            break;
        case 1: // state
            cell.setText(info.getStatus().toString());
            break;
        case 2: // timestamp
            cell.setText(getTimestamp(info.getStatusTimestamp()));
            break;
        case 3: // priority
            cell.setText(getAttribute(info.getAttributes(), "priority", "<none>"));
            break;
        case 4: // value
            cell.setText(getValue(info.getValue(), "<none>"));
            break;
        case 5: // ack user
            cell.setText(info.getLastAknUser() != null ? info.getLastAknUser() : "<unknown>");
            break;
        case 6: // ack timestamp
            cell.setText(getTimestamp(info.getLastAknTimestamp()));
            break;
        case 7: // fail timestamp
            cell.setText(getTimestamp(info.getLastFailTimestamp()));
            break;
        }
    }
}

From source file:org.eclipse.scada.ca.ui.editor.config.ConfigurationCellLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    final Map.Entry<?, ?> cfg = (Map.Entry<?, ?>) cell.getElement();
    switch (cell.getColumnIndex()) {
    case 0://from  w w w.ja v  a  2 s.co m
        cell.setText("" + cfg.getKey());
        break;
    case 1:
        cell.setText("" + cfg.getValue());
        break;
    }
    super.update(cell);
}

From source file:org.eclipse.scada.ca.ui.editor.factory.FactoryCellLabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    final ConfigurationDescriptor cfg = (ConfigurationDescriptor) cell.getElement();
    switch (cell.getColumnIndex()) {
    case 0://from ww  w.ja v  a  2  s. co  m
        cell.setText(cfg.getConfigurationInformation().getId());
        break;
    case 1:
        cell.setText("" + cfg.getConfigurationInformation().getState());
        break;
    }

    if (cfg.getConfigurationInformation().getErrorInformation() != null) {
        cell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    } else {
        cell.setBackground(null);
    }

    super.update(cell);
}

From source file:org.eclipse.scada.ca.ui.importer.wizard.DiffEntryLabelProvider.java

License:Open Source License

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

    if (ele instanceof DiffEntry) {
        final DiffEntry entry = (DiffEntry) ele;

        final int idx = cell.getColumnIndex();
        switch (idx) {
        case 0:/*from   w w w  .  ja v a2 s.com*/
            cell.setText(entry.getFactoryId());
            break;

        case 1:
            cell.setText(entry.getConfigurationId());
            break;

        case 2:
            cell.setText(entry.getOperation().toString());
            break;

        case 3:
            cell.setText(formatData(entry.getAddedOrUpdatedData(), MAX_STR_LENGTH));
            break;

        case 4:
            cell.setText(formatData(entry.getOldData(), MAX_STR_LENGTH));
            break;
        }
    }

    else if (ele instanceof DiffSubEntry) {
        final DiffSubEntry entry = (DiffSubEntry) ele;

        final int idx = cell.getColumnIndex();

        final boolean isEqual = equals(entry.getNewValue(), entry.getOldValue());
        if (isEqual) {
            cell.setForeground(this.equalFgColor);
        }

        switch (idx) {
        case 0:
            break;

        case 1:
            cell.setText(entry.getKey());
            break;

        case 2:
            break;

        case 3:
            cell.setText(entry.getNewValue());
            break;

        case 4:
            cell.setText(entry.getOldValue());
            break;
        }
    }
}

From source file:org.eclipse.scada.core.ui.connection.information.LabelProvider.java

License:Open Source License

@Override
public void update(final ViewerCell cell) {
    if (cell.getElement() instanceof ConnectionInformationProvider) {
        final ConnectionInformationProvider provider = (ConnectionInformationProvider) cell.getElement();
        switch (cell.getColumnIndex()) {
        case 0://from  ww w  .ja v  a2  s .co  m
            cell.setText(provider.getLabel());
            break;
        }
    } else if (cell.getElement() instanceof InformationBean) {
        final InformationBean bean = (InformationBean) cell.getElement();
        switch (cell.getColumnIndex()) {
        case 0:
            cell.setText(bean.getLabel());
            break;
        case 1:
            cell.setText(format(bean.getValue()));
            break;
        case 2:
            cell.setText(format(bean.getMin()));
            break;
        case 3:
            cell.setText(format(bean.getMax()));
            break;
        }
    }
    super.update(cell);
}