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

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

Introduction

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

Prototype

public Object put(Object key, Object value) 

Source Link

Document

Associate the specified value with the specified key in this Hashtable.

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   w w w.  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>// w w w. j  av a2s. com
 * 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>// w  w  w  . j  av a2s  . c  om
 * 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];/*ww  w.  j a  v  a2s .  c o  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 . ja v a  2 s.co 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./* w w  w  . ja  v a  2 s. c  om*/
 * <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);
            }
        }
    }
}

From source file:org.eclipse.php.internal.ui.util.MultiElementSelection.java

License:Open Source License

private CustomHashtable createTreePathMap(IElementComparer comparer) {
    CustomHashtable result = new CustomHashtable(comparer);
    for (int i = 0; i < fAllTreePaths.length; i++) {
        TreePath path = fAllTreePaths[i];
        Object key = path.getLastSegment();
        if (key != null) {
            Object value = result.get(key);
            if (value == null) {
                result.put(key, path);
            } else if (value instanceof TreePath) {
                List l = new ArrayList();
                l.add(value);//from   w  ww  .  j a  va 2  s .c  o  m
                l.add(path);
                result.put(key, l);
            } else if (value instanceof List) {
                ((List) value).add(path);
            } else {
                Assert.isTrue(false, "Should not happen"); //$NON-NLS-1$
            }
        }
    }
    return result;
}