Example usage for org.eclipse.jface.viewers CustomHashtable containsKey

List of usage examples for org.eclipse.jface.viewers CustomHashtable containsKey

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers CustomHashtable containsKey.

Prototype

public boolean containsKey(Object key) 

Source Link

Document

Answers if this Hashtable contains the specified object as a key of one of the key/value pairs.

Usage

From source file:com.tocea.scertify.eclipse.scertifycode.ui.util.table.EnhancedCheckBoxTableViewer.java

License:Open Source License

protected void preservingSelection(Runnable updateCode) {

    TableItem[] children = this.getTable().getItems();
    final CustomHashtable checked = this.newAHashtable(children.length * 2 + 1);
    final CustomHashtable grayed = this.newAHashtable(children.length * 2 + 1);

    for (final TableItem item : children) {
        final Object data = item.getData();
        if (data != null) {
            if (item.getChecked()) {
                checked.put(data, data);
            }/*from   www.  j a  v a  2  s.c om*/
            if (item.getGrayed()) {
                grayed.put(data, data);
            }
        }
    }

    super.preservingSelection(updateCode);

    children = this.getTable().getItems();
    for (final TableItem item : children) {
        final Object data = item.getData();
        if (data != null) {
            item.setChecked(checked.containsKey(data));
            item.setGrayed(grayed.containsKey(data));
        }
    }
}

From source file:com.tocea.scertify.eclipse.scertifycode.ui.util.table.EnhancedCheckBoxTableViewer.java

License:Open Source License

/**
 * Sets which nodes are checked in this viewer. The given list contains the
 * elements that are to be checked; all other nodes are to be unchecked.
 * <p>/*from   w  w  w.  j a va2  s  .  c  o  m*/
 * This method is typically used when restoring the interesting state of a viewer captured by an earlier call to
 * <code>getCheckedElements</code>.
 * </p>
 * 
 * @param elements
 *            the list of checked elements (element type: <code>Object</code>)
 * @see #getCheckedElements
 */
public void setCheckedElements(Object[] elements) {

    this.assertElementsNotNull(elements);
    final CustomHashtable set = this.newAHashtable(elements.length * 2 + 1);
    for (final Object element : elements) {
        set.put(element, element);
    }
    final TableItem[] items = this.getTable().getItems();
    for (final TableItem item : items) {
        final Object element = item.getData();
        if (element != null) {
            final boolean check = set.containsKey(element);
            // only set if different, to avoid flicker
            if (item.getChecked() != check) {
                item.setChecked(check);
            }
        }
    }
}

From source file:com.tocea.scertify.eclipse.scertifycode.ui.util.table.EnhancedCheckBoxTableViewer.java

License:Open Source License

/**
 * Sets which nodes are grayed in this viewer. The given list contains the
 * elements that are to be grayed; all other nodes are to be ungrayed.
 * <p>/*from   w  w w  .j  a  va2  s.c o m*/
 * This method is typically used when restoring the interesting state of a viewer captured by an earlier call to
 * <code>getGrayedElements</code>.
 * </p>
 * 
 * @param elements
 *            the array of grayed elements
 * @see #getGrayedElements
 */
public void setGrayedElements(Object[] elements) {

    this.assertElementsNotNull(elements);
    final CustomHashtable set = this.newAHashtable(elements.length * 2 + 1);
    for (final Object element : elements) {
        set.put(element, element);
    }
    final TableItem[] items = this.getTable().getItems();
    for (final TableItem item : items) {
        final Object element = item.getData();
        if (element != null) {
            final boolean gray = set.containsKey(element);
            // only set if different, to avoid flicker
            if (item.getGrayed() != gray) {
                item.setGrayed(gray);
            }
        }
    }
}

From source file:net.sf.eclipsecs.ui.util.table.EnhancedCheckBoxTableViewer.java

License:Open Source License

protected void preservingSelection(Runnable updateCode) {

    TableItem[] children = getTable().getItems();
    CustomHashtable checked = newHashtable(children.length * 2 + 1);
    CustomHashtable grayed = newHashtable(children.length * 2 + 1);

    for (int i = 0; i < children.length; i++) {
        TableItem item = children[i];// w  w w . j av a  2  s  .co m
        Object data = item.getData();
        if (data != null) {
            if (item.getChecked()) {
                checked.put(data, data);
            }
            if (item.getGrayed()) {
                grayed.put(data, data);
            }
        }
    }

    super.preservingSelection(updateCode);

    children = getTable().getItems();
    for (int i = 0; i < children.length; i++) {
        TableItem item = children[i];
        Object data = item.getData();
        if (data != null) {
            item.setChecked(checked.containsKey(data));
            item.setGrayed(grayed.containsKey(data));
        }
    }
}

From source file:net.sf.eclipsecs.ui.util.table.EnhancedCheckBoxTableViewer.java

License:Open Source License

/**
 * Sets which nodes are checked in this viewer. The given list contains the elements that are to be checked; all
 * other nodes are to be unchecked.//from  w  w w  . j  a v a 2 s  . c  o m
 * <p>
 * This method is typically used when restoring the interesting state of a viewer captured by an earlier call to
 * <code>getCheckedElements</code>.
 * </p>
 *
 * @param elements
 *            the list of checked elements (element type: <code>Object</code>)
 * @see #getCheckedElements
 */
public void setCheckedElements(Object[] elements) {
    assertElementsNotNull(elements);
    CustomHashtable set = newHashtable(elements.length * 2 + 1);
    for (int i = 0; i < elements.length; ++i) {
        set.put(elements[i], elements[i]);
    }
    TableItem[] items = getTable().getItems();
    for (int i = 0; i < items.length; ++i) {
        TableItem item = items[i];
        Object element = item.getData();
        if (element != null) {
            boolean check = set.containsKey(element);
            // only set if different, to avoid flicker
            if (item.getChecked() != check) {
                item.setChecked(check);
            }
        }
    }
}

From source file:net.sf.eclipsecs.ui.util.table.EnhancedCheckBoxTableViewer.java

License:Open Source License

/**
 * Sets which nodes are grayed in this viewer. The given list contains the elements that are to be grayed; all other
 * nodes are to be ungrayed./*from w  ww .  j a  v a2s.  c o  m*/
 * <p>
 * This method is typically used when restoring the interesting state of a viewer captured by an earlier call to
 * <code>getGrayedElements</code>.
 * </p>
 *
 * @param elements
 *            the array of grayed elements
 * @see #getGrayedElements
 */
public void setGrayedElements(Object[] elements) {
    assertElementsNotNull(elements);
    CustomHashtable set = newHashtable(elements.length * 2 + 1);
    for (int i = 0; i < elements.length; ++i) {
        set.put(elements[i], elements[i]);
    }
    TableItem[] items = getTable().getItems();
    for (int i = 0; i < items.length; ++i) {
        TableItem item = items[i];
        Object element = item.getData();
        if (element != null) {
            boolean gray = set.containsKey(element);
            // only set if different, to avoid flicker
            if (item.getGrayed() != gray) {
                item.setGrayed(gray);
            }
        }
    }
}