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:tubame.portability.plugin.view.ConvertToolTipSupport.java

License:Apache License

/**
 * {@inheritDoc}//from ww  w  .  j  a va2 s .  c  om
 */
@Override
protected boolean shouldCreateToolTip(Event event) {
    ViewerCell cell = viewer.getCell(new Point(event.x, event.y));
    if (cell != null) {
        int index = cell.getColumnIndex();
        ConvertLabelProvider cellLabelProvider = (ConvertLabelProvider) viewer.getLabelProvider(index);
        cellLabelProvider.setToolTipIndex(index);
    }
    return super.shouldCreateToolTip(event);
}

From source file:uk.ac.gda.common.rcp.jface.viewers.ObservableMapCellControlProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    TableItem item = (TableItem) cell.getItem();
    Control control = null;/* w  w w  .  j ava  2  s .  c  o m*/

    Object e = cell.getElement();
    Object itemData = item.getData(uniqueKey);
    if (itemData != null && itemData instanceof TableEditor) {
        control = ((TableEditor) itemData).getEditor();
    }
    if (control == null) {
        control = controlFactory.createControl((Composite) cell.getViewerRow().getControl());
        TableEditor editor = new TableEditor(item.getParent());
        editor.grabHorizontal = true;
        editor.grabVertical = true;
        editor.setEditor(control, item, cell.getColumnIndex());
        editor.layout();
        //we need to dispose the TableEditor and ProgressBar when the TableItem is disposed otherwise there will be a build up
        //of TableEditor and ProgressBars being constructed as the list changes which will only
        //be disposed when the table is disposed. 
        item.setData(uniqueKey, editor);
        item.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                Object data = e.widget.getData(uniqueKey);
                if (data != null) {
                    TableEditor tableEditor = (TableEditor) data;
                    tableEditor.getEditor().dispose();
                    tableEditor.dispose();
                }
            }
        });
    }
    Object value = attributeMaps[0].get(e);
    controlFactory.updateControl(control, value);
}

From source file:uk.ac.gda.ui.doe.FieldColumnProvider.java

License:Open Source License

@Override
public void update(ViewerCell cell) {
    if (properties != null && properties.length > 0) {
        this.property = properties[cell.getColumnIndex()];
    }//from   w  w w .j  av a  2 s  . c om
    super.update(cell);
}

From source file:uk.ac.stfc.isis.ibex.ui.configserver.editing.ButtonCellLabelProvider.java

License:Open Source License

private void setEditor(ViewerCell cell, Button button) {
    TableItem item = (TableItem) cell.getItem();
    TableEditor editor = new TableEditor(item.getParent());
    editor.horizontalAlignment = SWT.FILL;
    editor.verticalAlignment = SWT.FILL;
    editor.grabHorizontal = true;/*from   w  w  w.j a  v  a  2s.c  o  m*/
    editor.grabVertical = true;
    editor.setEditor(button, item, cell.getColumnIndex());
    editor.layout();

    cellEditors.put(cell, editor);
}

From source file:uk.ac.stfc.isis.ibex.ui.widgets.ControlCellLabelProvider.java

License:Open Source License

protected void setEditor(ViewerCell cell, Control control) {
    TableItem item = (TableItem) cell.getItem();
    TableEditor editor = new TableEditor(item.getParent());
    editor.horizontalAlignment = SWT.FILL;
    editor.verticalAlignment = SWT.FILL;
    editor.grabHorizontal = true;/*from w ww . j av  a 2s.c om*/
    editor.grabVertical = true;
    editor.setEditor(control, item, cell.getColumnIndex());
    editor.layout();

    cellEditors.put(cell, editor);

}

From source file:ummisco.gama.ui.viewers.csv.CSVLabelProvider.java

/**
 * @see org.eclipse.jface.viewers.StyledCellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
 *//*from   w w w  .j  ava 2 s  .c  om*/
@Override
public void update(final ViewerCell cell) {
    final CSVRow element = (CSVRow) cell.getElement();
    final int index = cell.getColumnIndex();
    final String columnText = getColumnText(element, index);
    cell.setText(columnText);
    cell.setImage(null);
    if (searchText != null && searchText.length() > 0) {
        final int intRangesCorrectSize[] = SearchResultStyle.getSearchTermOccurrences(searchText, columnText);
        final List<StyleRange> styleRange = new ArrayList<StyleRange>();
        for (int i = 0; i < intRangesCorrectSize.length / 2; i++) {
            final StyleRange myStyleRange = new StyleRange(0, 0, null, searchColor);
            myStyleRange.start = intRangesCorrectSize[i];
            myStyleRange.length = intRangesCorrectSize[++i];
            styleRange.add(myStyleRange);
        }
        cell.setStyleRanges(styleRange.toArray(new StyleRange[styleRange.size()]));
    } else {
        cell.setStyleRanges(null);
    }

    super.update(cell);
}

From source file:ummisco.gama.ui.viewers.gis.geotools.control.MaplayerTableViewer.java

@Override
protected void triggerEditorActivationEvent(final ColumnViewerEditorActivationEvent event) {
    super.triggerEditorActivationEvent(event);
    final ViewerCell source = (ViewerCell) event.getSource();
    final int columnIndex = source.getColumnIndex();
    if (columnIndex == 1) {
        final Layer element = (Layer) source.getElement();
        element.setVisible(!element.isVisible());
        refresh();/*from w w w . j a  va 2s .c  o  m*/
        pane.redraw();
    } else if (columnIndex == 2) {
        final Layer element = (Layer) source.getElement();
        try {
            doSetStyle(element);
        } catch (final IOException e) {
            e.printStackTrace();
        }
        pane.redraw();
    }
}