Package util.ui.customizableitems

Examples of util.ui.customizableitems.SelectableItem


      mPluginItemList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
          try {
            if (!e.getValueIsAdjusting()) {
              targetPanel.removeAll();
              SelectableItem pluginItem = (SelectableItem) mPluginItemList
                  .getSelectedValue();

              final ProgramReceiveIf plugin = (ProgramReceiveIf) pluginItem
                  .getItem();
              mCurrentTargets = plugin.getProgramReceiveTargets();

              if (mCurrentTargets != null) {
                Arrays.sort(mCurrentTargets);
                ArrayList<ProgramReceiveTarget> targets = mReceiveTargetTable
                    .get(plugin);
                if (targets == null || !pluginItem.isSelected()) {
                  targets = new ArrayList<ProgramReceiveTarget>();
                }
                if (pluginItem.isSelected() && targets.isEmpty()) {
                  targets.add(mCurrentTargets[0]);
                }
                mReceiveTargetTable.put(plugin, targets);
                final SelectableItemList targetList = new SelectableItemList(
                    targets.toArray(), mCurrentTargets, disabledReceiveTargets);
                targetPanel.add(targetList, BorderLayout.CENTER);
                targetList
                    .addListSelectionListener(new ListSelectionListener() {

                      @Override
                      public void valueChanged(ListSelectionEvent listEvent) {
                        if (!listEvent.getValueIsAdjusting()) {
                          SelectableItem currPluginItem = (SelectableItem) mPluginItemList
                              .getSelectedValue();
                          ProgramReceiveIf currPlugin = (ProgramReceiveIf) currPluginItem
                              .getItem();
                          Object[] sel = targetList.getSelection();
                          ArrayList<ProgramReceiveTarget> selTargets = new ArrayList<ProgramReceiveTarget>(
                              sel.length);
                          for (Object obj : sel) {
                            selTargets.add((ProgramReceiveTarget) obj);
                          }
                          if (currPluginItem.isSelected() != (sel.length > 0)) {
                            currPluginItem.setSelected(sel.length > 0);
                            mPluginItemList.updateUI();
                          }
                          mReceiveTargetTable.put(currPlugin, selTargets);
                        }
                      }
View Full Code Here


    mList.addMouseListener(new MouseAdapter() {
      public void mouseReleased(MouseEvent evt) {
        if (evt.getX() < mItemRenderer.getSelectionWidth() && mIsEnabled) {
          int index = mList.locationToIndex(evt.getPoint());
          if (index != -1) {
            SelectableItem item = (SelectableItem) mListModel.elementAt(index);
            item.setSelected(! item.isSelected());
            mList.repaint();
          }
        }
      }
    });
    mList.addKeyListener(new KeyAdapter(){
      public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_SPACE) {
          Object[] objs = mList.getSelectedValues();
          for (Object obj : objs) {
            if (obj instanceof SelectableItem) {
              SelectableItem item = (SelectableItem) obj;
              item.setSelected(!item.isSelected());
            }
          }
          mList.repaint();
        }
      }
View Full Code Here

  private void setEntries(Object[] currOrder, Object[] allItems) {
    mListModel.removeAllElements();
    for (Object element : currOrder) {
      if (contains(allItems, element)) {
        SelectableItem item = new SelectableItem(element, true);
        mListModel.addElement(item);
      }
    }
    for (int i = 0; i < allItems.length; i++) {
      if (! contains(currOrder, allItems[i])) {
        SelectableItem item = new SelectableItem(allItems[i], false);
        mListModel.addElement(item);
      }
    }
  }
View Full Code Here

 

  public Object[] getOrder() {
    ArrayList<Object> objList = new ArrayList<Object>();
    for (int i = 0; i < mListModel.size(); i++) {
      SelectableItem item = (SelectableItem) mListModel.elementAt(i);
      if (item.isSelected()) {
        objList.add(item.getItem());
      }
    }

    Object[] asArr = new Object[objList.size()];
    objList.toArray(asArr);
View Full Code Here

  }

  public void invertSelection() {
    if(mIsEnabled) {
      for (int i = 0; i < mListModel.size(); i++) {
        SelectableItem item = (SelectableItem) mListModel.elementAt(i);
        item.setSelected(!item.isSelected());
      }
      mList.repaint();
    }
  }
View Full Code Here

  }

  public void selectAll() {
    if(mIsEnabled) {
      for (int i = 0; i < mListModel.size(); i++) {
        SelectableItem item = (SelectableItem) mListModel.elementAt(i);
        item.setSelected(true);
      }
      mList.repaint();
    }
  }
View Full Code Here

  }
 
  public void clearSelection() {
    if(mIsEnabled) {
      for (int i = 0; i < mListModel.size(); i++) {
        SelectableItem item = (SelectableItem) mListModel.elementAt(i);
        item.setSelected(false);
      }
      mList.repaint();
    }
  }
View Full Code Here

   *
   * @param value
   * @since 2.5.1
   */
  public void addElement(Object value) {
    SelectableItem item = new SelectableItem(value,true);
    mListModel.addElement(item);
    mList.repaint();
  }
View Full Code Here

   * @return The selected value of this list.
   * @since 2.5.1
   */
  public Object getSelectedValue() {
    if(mList.getSelectedValue() != null) {
      SelectableItem item = (SelectableItem)mList.getSelectedValue();
      return item.getItem();
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of util.ui.customizableitems.SelectableItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.