Exemplo n.º 1
0
    /**
     *
     * @return
     */
    @Override
    public IVItem[] getItems() {
        IVItem[] _items = items;
        if (_items == null) {
            IVItem[] _rawItems = rawItems(NullOut.cNull, backcall);
            rawItems = _rawItems;
            releaseItems();
            _items = items = filterItems(NullOut.cNull, _rawItems);
        }
        if ((_items == null || _items.length == 0) && !(filter.toString().equals(""))) {
            Viewer titleViewer = new Viewer(new ViewString(" filter= "));
            titleViewer.setBorder(new SolidBorder(ViewColor.cThemeAccent));

            Viewer filterViewer = new Viewer(new ViewString(filter));
            filterViewer.setBorder(new SolidBorder(ViewColor.cThemeAccent));

            titleViewer.place(filterViewer, UV.cEW);

            Viewer v = new Viewer(titleViewer);
            VItem item = new VItem(v);
            item.setBorder(new ViewBorder());
            item.paint();
            return new IVItem[]{item};
        }
        return _items;
    }
Exemplo n.º 2
0
 /**
  *
  * @param e
  */
 @Override
 public void keyPressed(KeyPressed e) {
     if (e.isControlDown()) {
         int code = e.getKeyCode();
         switch (code) {
             case IKeyEventConstants.cA:
                 selectAllItems();
                 break;
         }
         return;
     }
     if (filter.modify(e)) {
         filterModified(null);
     }
 }
Exemplo n.º 3
0
 /**
  *
  * @param _
  * @param _rawItems
  * @return
  */
 protected IVItem[] filterItems(IOut _, IVItem[] _rawItems) {
     if (_rawItems == null) {
         return new IVItem[0];
     }
     if (comparator != null) {
         Arrays.sort(_rawItems, comparator);
     }
     int count = 0;
     int len = _rawItems.length;
     IVItem[] filteredItems = new IVItem[len];
     Pattern pattern = null;
     String regx = "";
     if (filter != null) {
         regx = filter.toString();
     }
     if (regx.length() > 0) {
         try {
             pattern = Pattern.compile(regx);
         } catch (Exception x) {
             if (_ != null) {
                 _.out(x);
             }
         }
     }
     for (int i = 0; i < len; i++) {
         if (_ != null) {
             _.out(i, len);
         }
         IVItem next = _rawItems[i];
         IVItem filtered = filter(next, pattern);
         if (filtered == null) {
             continue;
         }
         filteredItems[count++] = filtered;
     }
     if (count < len) {
         filteredItems = (IVItem[]) UArray.trim(filteredItems, new IVItem[count]);
     } else if (count == 0) {
         filteredItems = new IVItem[0];
     }
     return filteredItems;
 }
Exemplo n.º 4
0
 @Override
 public String toString() {
     return (filter == null) ? "" : filter.toString();
 }
Exemplo n.º 5
0
 /**
  *
  * @return
  */
 @Override
 public String getFilter() {
     return filter.toString();
 }
Exemplo n.º 6
0
 /**
  *
  * @param _filter
  */
 @Override
 public void setFilter(String _filter) {
     filter.setText((_filter == null) ? "" : _filter);
     filterModified(null);//??
 }