Examples of DNDList


Examples of com.salas.bb.utils.dnd.DNDList

        public void propertyChange(final PropertyChangeEvent evt)
        {
            boolean isDraggingFinished = !(Boolean)evt.getNewValue();
            if (isDraggingFinished)
            {
                DNDList source = DNDListContext.getSource();
                IDNDObject object = DNDListContext.getObject();
                int insertPosition = source.getInsertPosition();
                Object[] guidesI = object.getItems();

                if (insertPosition >= 0 && guidesI.length > 0)
                {
                    IGuide currentSelection = GlobalModel.SINGLETON.getSelectedGuide();
                    int oldSelectionIndex = currentSelection == null
                        ? -1 : model.indexOf(currentSelection);

                    boolean selectedGuideMoved = false;

                    // We need to translate insert position into guide set coordinates
                    if (insertPosition < guidesListModel.getSize())
                    {
                        IGuide after = (IGuide)guidesListModel.getElementAt(insertPosition);
                        insertPosition = model.indexOf(after);
                    } else if (guidesListModel.getSize() > 0)
                    {
                        IGuide before = (IGuide)guidesListModel.getElementAt(insertPosition - 1);
                        insertPosition = model.indexOf(before) + 1;
                    } else insertPosition = 0;

                    // Move selected guides now
                    int index = insertPosition;
                    for (int i = 0; i < guidesI.length; i++)
                    {
                        IGuide guide = (IGuide)guidesI[guidesI.length - i - 1];

                        int currentIndex = model.indexOf(guide);
                        if (currentIndex < index) index--;
                        selectedGuideMoved |= currentIndex == oldSelectionIndex;

                        GlobalController.SINGLETON.moveGuide(guide, index);
                    }

                    int currentSelectionIndex = currentSelection == null
                        ? -1 : guidesListModel.indexOf(currentSelection);

                    ListSelectionModel selModel = source.getSelectionModel();
                    if (selectedGuideMoved)
                    {
                        selModel.setSelectionInterval(index, index + guidesI.length - 1);
                        selModel.addSelectionInterval(currentSelectionIndex, currentSelectionIndex);
                        selModel.setLeadSelectionIndex(currentSelectionIndex);
View Full Code Here

Examples of com.salas.bb.utils.dnd.DNDList

        setHeaderControl(createSubtoolbar());

        GlobalModel globalModel = GlobalModel.SINGLETON;

        GuideModel model = globalModel.getGuideModel();
        feedsList = new DNDList(model);
        model.setListComponent(feedsList);

        // Set the background
        setBackground(feedsList.getBackground());
View Full Code Here

Examples of com.salas.bb.utils.dnd.DNDList

            final IGuide sourceGuide = GlobalModel.SINGLETON.getSelectedGuide();

            boolean isDraggingFinished = !(Boolean)evt.getNewValue();
            if (isDraggingFinished && sourceGuide instanceof StandardGuide)
            {
                final DNDList source = DNDListContext.getSource();
                IDNDObject object = DNDListContext.getObject();
                int insertPosition = source.getInsertPosition();
                final Object[] feedsI = object.getItems();
                StandardGuide guide = (StandardGuide)sourceGuide;

                if (feedsList.isDraggingInternal())
                {
                    final GuideModel model = (GuideModel)feedsList.getModel();

                    // Dragging operation finished within the same list
                    final IFeed currentSelection = GlobalModel.SINGLETON.getSelectedFeed();

                    int index = insertPosition;
                    for (int i = 0; i < feedsI.length; i++)
                    {
                        IFeed feed = (IFeed)feedsI[feedsI.length - i - 1];

                        int currentIndex = model.indexOf(feed);
                        if (currentIndex < index) index--;

                        GlobalController.SINGLETON.moveFeed(feed, guide, guide, index);
                    }

                    // We call it in new EDT task as the model will be updated
                    // in the next event only, so we have to schedule ourselves
                    // after that update to get correct indexes.
                    SwingUtilities.invokeLater(new Runnable()
                    {
                        public void run()
                        {
                            int curSelNewIndex = model.indexOf(currentSelection);

                            boolean curSelIsOnTheList = false;
                            int[] newIndices = new int[feedsI.length];
                            for (int i = 0; i < feedsI.length; i++)
                            {
                                newIndices[i] = model.indexOf((IFeed)feedsI[i]);
                                curSelIsOnTheList |= newIndices[i] == curSelNewIndex;
                            }

                            ListSelectionModel selModel = source.getSelectionModel();
                            if (!curSelIsOnTheList)
                            {
                                selModel.setSelectionInterval(curSelNewIndex, curSelNewIndex);
                            } else
                            {
                                source.setSelectedIndices(newIndices);
                            }

                            selModel.setLeadSelectionIndex(curSelNewIndex);

                            // Return focus to the guide
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.