Example usage for org.eclipse.jface.util Util isWpf

List of usage examples for org.eclipse.jface.util Util isWpf

Introduction

In this page you can find the example usage for org.eclipse.jface.util Util isWpf.

Prototype

public static boolean isWpf() 

Source Link

Document

Common WS query helper method.

Usage

From source file:com.google.dart.tools.ui.omni.OmniBoxPopup.java

License:Open Source License

private int refreshTable(OmniElement perfectMatch, List<OmniEntry>[] entries) {

    if (table.isDisposed()) {
        return 0;
    }//w w w. j a  va2  s .  c o  m

    //used to restore selection post-refresh
    OmniEntry previousSelection = getCurrentSelection();

    //TODO (pquitslund): clearing to force a complete redraw; prime for future optimization
    //if (table.getItemCount() > entries.length && table.getItemCount() - entries.length > 20) {
    //  table.removeAll();
    //}
    table.removeAll();

    //elements flagged as duplicates get rendered with disambiguating details
    markDuplicates(entries);

    TableItem[] items = table.getItems();
    int selectionIndex = -1;
    int index = 0;
    TableItem item = null;
    for (int i = 0; i < providers.length; i++) {
        if (entries[i] != null) {

            Iterator<OmniEntry> iterator = entries[i].iterator();

            //create headers for non-empty categories
            if (iterator.hasNext()) {
                item = new TableItem(table, SWT.NONE);
                item.setData(new OmniEntry(new HeaderElement(providers[i]), providers[i], new int[0][0],
                        new int[0][0]));
            }
            //create entries
            for (Iterator<OmniEntry> it = entries[i].iterator(); it.hasNext();) {
                OmniEntry entry = it.next();
                if (!it.hasNext()) {
                    entry.lastInCategory = true;
                }
                if (index < items.length) {
                    item = items[index];
                    table.clear(index);
                } else {
                    item = new TableItem(table, SWT.NONE);
                }
                if (perfectMatch == entry.element && selectionIndex == -1) {
                    selectionIndex = index;
                    cachedSelection = null;
                } else if (previousSelection != null) {
                    if (entry.element.isSameAs(previousSelection.element)) {
                        //NOTE: with async table updates, selection index is not sufficient
                        cachedSelection = item;
                    }
                }
                item.setData(entry);
                item.setText(0, entry.provider.getName());
                item.setText(1, entry.element.getLabel());

                if (Util.isWpf()) {
                    item.setImage(1, entry.getImage(entry.element, resourceManager));
                }
                index++;
            }
        }
    }
    if (index < items.length) {
        table.remove(index, items.length - 1);
    }

    //last entry should not be flagged since that will produce a trailing separator
    if (item != null) {
        ((OmniEntry) item.getData()).lastInCategory = false;
    }

    adjustBounds();

    if (selectionIndex == -1) {
        selectionIndex = 0;
    }
    return selectionIndex;
}

From source file:org.eclipse.ui.internal.quickaccess.QuickAccessContents.java

License:Open Source License

private int refreshTable(QuickAccessElement perfectMatch, List[] entries) {
    if (table.getItemCount() > entries.length && table.getItemCount() - entries.length > 20) {
        table.removeAll();//w  w w  .j  a  v a 2  s.  c o  m
    }
    TableItem[] items = table.getItems();
    int selectionIndex = -1;
    int index = 0;
    for (int i = 0; i < providers.length; i++) {
        if (entries[i] != null) {
            boolean firstEntry = true;
            for (Iterator it = entries[i].iterator(); it.hasNext();) {
                QuickAccessEntry entry = (QuickAccessEntry) it.next();
                entry.firstInCategory = firstEntry;
                firstEntry = false;
                if (!it.hasNext()) {
                    entry.lastInCategory = true;
                }
                TableItem item;
                if (index < items.length) {
                    item = items[index];
                    table.clear(index);
                } else {
                    item = new TableItem(table, SWT.NONE);
                }
                if (perfectMatch == entry.element && selectionIndex == -1) {
                    selectionIndex = index;
                }
                item.setData(entry);
                item.setText(0, entry.provider.getName());
                item.setText(1, entry.element.getLabel());
                if (Util.isWpf()) {
                    item.setImage(1, entry.getImage(entry.element, resourceManager));
                }
                index++;
            }
        }
    }
    if (index < items.length) {
        table.remove(index, items.length - 1);
    }
    if (selectionIndex == -1) {
        selectionIndex = 0;
    }
    return selectionIndex;
}