Package com.tulskiy.musique.plugins.discogs.model

Examples of com.tulskiy.musique.plugins.discogs.model.DiscogsDefaultListModel


 
  private void moveSelectedTracklistingItems(final JList list, final int direction) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                DiscogsDefaultListModel listModel = (DiscogsDefaultListModel) list.getModel();
                ListSelectionModel lsm = list.getSelectionModel();

                int indexStart = list.getSelectedIndices()[0];
                int indexEnd = list.getSelectedIndices()[list.getSelectedIndices().length - 1];
                int indexObj;
                Object obj;

                if (direction < 0) {
                    indexObj = indexStart - 1;
                    obj = listModel.getEx(indexObj);
                    listModel.remove(indexObj);
                    if (listModel.size() == indexEnd) {
                        listModel.addElement(obj);
                    }
                    else {
                        listModel.add(indexEnd, obj);
                    }
                    lsm.setSelectionInterval(indexStart - 1, indexEnd - 1);
                }
                else if (direction > 0) {
                    indexObj = indexEnd + 1;
                    obj = listModel.getEx(indexObj);
                    listModel.remove(indexObj);
                    listModel.add(indexStart, obj);
                    lsm.setSelectionInterval(indexStart + 1, indexEnd + 1);
                }
            }
        });
  }
View Full Code Here

TOP

Related Classes of com.tulskiy.musique.plugins.discogs.model.DiscogsDefaultListModel

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.