Package javax.swing

Examples of javax.swing.ListSelectionModel


      });
    m_AttPanel.getSelectionModel()
      .addListSelectionListener(new ListSelectionListener() {
  public void valueChanged(ListSelectionEvent e) {
    if (!e.getValueIsAdjusting()) {   
      ListSelectionModel lm = (ListSelectionModel) e.getSource();
      for (int i = e.getFirstIndex(); i <= e.getLastIndex(); i++) {
        if (lm.isSelectedIndex(i)) {
    m_AttSummaryPanel.setAttribute(i);
    m_AttVisualizePanel.setAttribute(i);
    break;
        }
      }
View Full Code Here


        return objForm;
    }

    @Override
    protected void deleteSelectedItems() {
        ListSelectionModel sm = getSelectionModel();

        if (sm.isSelectionEmpty()) {
            return;
        }

        int min = sm.getMinSelectionIndex();
        int max = sm.getMaxSelectionIndex();

        // Loop backwards and delete each selected item in the interval
        for (int index = max; index >= min; index--) {
            if (sm.isSelectedIndex(index)) {
                // do not remove from list => propertyChange listener will do this
                Object o = getMasterEventList().get(index);
                dao.detach((T) o);
            }
        }
View Full Code Here

        // do we need to hack? http://forum.springframework.org/showthread.php?t=68899
    }

    protected void cloneSelectedItems() {
        ListSelectionModel sm = getSelectionModel();

        if (sm.isSelectionEmpty()) {
            return;
        }

        int min = sm.getMinSelectionIndex();
        int max = sm.getMaxSelectionIndex();

        // Loop backwards and delete each selected item in the interval
        for (int index = max; index >= min; index--) {
            if (sm.isSelectedIndex(index)) {
                // do not remove from list => propertyChange listener will do this
                Object o = getMasterEventList().get(index);
                T obj = dao.create();
                Helper.copyProperties(o, obj);
View Full Code Here

                logger.error(e, e);
            }

            ListCellRenderer renderer = list.getCellRenderer();
            ListModel dataModel = list.getModel();
            ListSelectionModel selModel = list.getSelectionModel();
            if ((renderer == null) || (dataModel.getSize() == 0))
                return;

            // Compute the area we're going to paint in terms of the affected
            // columns/rows (firstPaintColumn, firstPaintRow, lastPaintColumn,
View Full Code Here

   */
  public void copySystemPropertiesToClipboard()
  {

    final StringBuffer buffer = new StringBuffer(500);
    final ListSelectionModel selection = this.table.getSelectionModel();
    final int firstRow = selection.getMinSelectionIndex();
    final int lastRow = selection.getMaxSelectionIndex();
    if ((firstRow != -1) && (lastRow != -1))
    {
      for (int r = firstRow; r <= lastRow; r++)
      {
        for (int c = 0; c < this.table.getColumnCount(); c++)
View Full Code Here

    {
      final KeyedComboBoxModel keyedComboBoxModel =
          DefaultParameterComponentFactory.createModel(listParameter, parameterContext);
      list.setModel(keyedComboBoxModel);

      final ListSelectionModel selectionModel = list.getSelectionModel();
      final Object value = updateContext.getParameterValue(listParameter.getName());
      final HashSet keylist = getNormalizedSet(value);
      selectionModel.setValueIsAdjusting(true);
      list.clearSelection();

      final int size = keyedComboBoxModel.getSize();
      for (int i = 0; i < size; i++)
      {
        final Object key = keyedComboBoxModel.getKeyAt(i);
        if (isSafeMatch(key, keylist))
        {
          selectionModel.addSelectionInterval(i, i);
        }
      }
      selectionModel.setValueIsAdjusting(false);
    }
    finally
    {
      adjustingToExternalInput = false;
    }
View Full Code Here

      try
      {
        adjustingToUserInput = true;

        final KeyedComboBoxModel listModel = (KeyedComboBoxModel) list.getModel();
        final ListSelectionModel selectionModel = list.getSelectionModel();
        selectionModel.setValueIsAdjusting(true);

        // Determine if this selection has added or removed items
        final HashSet<Integer> newSelections = new HashSet<Integer>();
        final int size = listModel.getSize();
        for (int i = 0; i < size; i++)
        {
          if (selectionModel.isSelectedIndex(i))
          {
            newSelections.add(IntegerCache.getInteger(i));
          }
        }

        // Turn on everything that was selected previously
        Iterator it = selectionCache.iterator();
        while (it.hasNext())
        {
          final Integer integer = (Integer) it.next();
          final int index = integer.intValue();
          selectionModel.addSelectionInterval(index, index);
        }

        // Add or remove the delta

        if (newSelections.containsAll(selectionCache) == false)
        {
          it = newSelections.iterator();
          while (it.hasNext())
          {
            final Integer nextInt = (Integer) it.next();
            final int index = nextInt.intValue();
            if (selectionCache.contains(nextInt))
            {
              selectionModel.removeSelectionInterval(index, index);
            }
            else
            {
              selectionModel.addSelectionInterval(index, index);
            }
          }

          // Save selections for next time
          selectionCache.clear();
          for (int i = 0; i < size; i++)
          {
            if (selectionModel.isSelectedIndex(i))
            {
              selectionCache.add(IntegerCache.getInteger(i));
            }
          }
        }

        selectionModel.setValueIsAdjusting(false);

        final int[] indices = list.getSelectedIndices();
        final Object[] keys = new Object[indices.length];
        for (int i = 0; i < keys.length; i++)
        {
View Full Code Here

      super.setProperty(name, value);
    }
  }

  private void setSelectionValues(TableRow[] values) {
    ListSelectionModel model = table.getSelectionModel();
    if (values == null) {
      table.clearSelection();
    } else {
      table.clearSelection();
      for (int i = 0; i < values.length; i++) {
View Full Code Here

      }
    }
  }

  private void setSelectionIndices(int[] indices) {
    ListSelectionModel model = table.getSelectionModel();
    if (indices == null) {
      table.clearSelection();
    } else {
      table.clearSelection();
      for (int i = 0; i < indices.length; i++) {
View Full Code Here

        DbfTableModel model = layer.getModel();
        JTable table = new JTable(model);
        JScrollPane pane = new JScrollPane(table);
        frame.getContentPane().add(pane, BorderLayout.CENTER);

        ListSelectionModel lsm = table.getSelectionModel();
        lsm.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting()) {
                    return;
                }
                ListSelectionModel lsm2 = (ListSelectionModel) e.getSource();
                if (lsm2.isSelectionEmpty()) {
                    //no rows are selected
                } else {
                    int index = lsm2.getMinSelectionIndex();
                    EsriGraphicList list = layer.getEsriGraphicList();
                    OMGraphic graphic = list.getOMGraphicAt(index);
                    graphic.select();
                    list.generate(_mapBean.getProjection());
                    layer.repaint();
View Full Code Here

TOP

Related Classes of javax.swing.ListSelectionModel

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.