Package ca.odell.glazedlists

Examples of ca.odell.glazedlists.EventList


   
    /**
     * Tests that diff works for a large number of elements.
     */
    public void testMemory() {
        EventList sequence = new BasicEventList(new SparseDifferencesList(new ReallyBigList(1000 * 1000)));
        List modifiedSequence = new SparseDifferencesList(new ReallyBigList(1000 * 1000));
        assertEquals(0, getChangeCount(sequence, modifiedSequence, false, null));

        Random dice = new Random(2);
        for(int i = 0; i < 10; i++) {
View Full Code Here


     *
     * <p>If case sensitivity is specified, an appropriate {@link Comparator} will be
     * used to determine equality between elements.
     */
    private int getChangeCount(String target, String source, boolean caseSensitive) {
        EventList targetList = new BasicEventList();
        targetList.addAll(stringToList(target));
        List sourceList = stringToList(source);

        return getChangeCount(targetList, sourceList, false, caseSensitive ? GlazedLists.caseInsensitiveComparator() : null);
    }
View Full Code Here

            System.out.println("Usage: LCS <alpha> <beta>");
            return;
        }

        String alpha = args[ 0 ];
        EventList alphaList = new BasicEventList();
        for (int c = 0; c < alpha.length(); c++) {
            alphaList.add(new Character(alpha.charAt(c)));
        }

        String beta = args[ 1 ];
        List betaList = new ArrayList();
        for (int c = 0; c < beta.length(); c++) {
View Full Code Here

        for(int i = 0; i < 50; i++) {
            eventList.add(new Integer(i + 100));
        }

        // get the sublist
        EventList subListBefore = (EventList)eventList.subList(25, 75);
        ListConsistencyListener.install(subListBefore);

        // change the source list to be 0,1,2,3,...49,50,51,..99,100,101...149
        for(int i = 0; i < 50; i++) {
            eventList.add(50+i, new Integer(50+i));
        }

        // ensure the sublist took the change
        EventList subListAfter = (EventList)eventList.subList(25, 125);
        assertEquals(subListBefore, subListAfter);

        // change the lists again, deleting all odd numbered entries
        for(Iterator i = eventList.iterator(); i.hasNext(); ) {
            Integer current = (Integer)i.next();
            if(current.intValue() % 2 == 1) i.remove();
        }

        // ensure the sublists took the change
        subListAfter = (EventList)eventList.subList(13, 63);
        assertEquals(subListBefore, subListAfter);
       
        // make some set calls
        eventList.set(15, "Fifteen");
        eventList.set(18, "Eighteen");
        eventList.set(21, "Twenty-One");
        eventList.set(24, "Twenty-Four");
        assertEquals("Fifteen", subListAfter.get(2));
        assertEquals("Eighteen", subListAfter.get(5));
        subListBefore.set(14, "Twenty-Seven");
        assertEquals("Twenty-Seven", eventList.get(27));
        assertEquals(subListAfter, subListBefore);
    }
View Full Code Here

    /**
     * Verifies that conflicting threads are resolved intelligently.
     */
    public void guiTestConflictingThreads_FixMe() {
        EventList labelsList = new BasicEventList();
        labelsList.add(new JLabel("7-up"));
        labelsList.add(new JLabel("Pepsi"));
        labelsList.add(new JLabel("Dr. Pepper"));

        String[] properties = new String[] { "text", "toolTipText" };
        String[] headers = new String[] { "Text", "Tool Tip" };
        boolean[] editable = new boolean[] { true, true };
        TableFormat labelsTableFormat = GlazedLists.tableFormat(JLabel.class, properties, headers, editable);

        EventTableModel labelsTable = new EventTableModel(labelsList, labelsTableFormat);

        doBackgroundTask(new ClearListRunnable(labelsList), true);

        labelsList.getReadWriteLock().writeLock().lock();
        assertEquals(0, labelsList.size());
        labelsList.add(new JLabel("Coca-Cola"));
        labelsList.getReadWriteLock().writeLock().unlock();

        // This fails. We know it fails. Do not fix this!
        //
        // The problem is that changes pending on an EventList are invisible to
        // the EDT if those changes happened before the current dispatch but
View Full Code Here

      reader_min_pause_ms = Long.parseLong(args[4]);
      reader_max_pause_ms = Long.parseLong(args[5]);
    }

    // Setup
    EventList list = new BasicEventList();
    list.add("one");
    list.add("two");
    list.add("three");

    System.out.println("ReadWriteLock class: " +
      LockFactory.DEFAULT.createReadWriteLock().getClass().getName());

    System.out.print("Starting threads...");
View Full Code Here

     * @param listFactory factory for EventLists
     */
    public PersistentEventList(SessionImplementor session, EventListFactory listFactory) {
        super(session);

        final EventList delegate = listFactory.createEventList();

        // instantiate list here to avoid NullPointerExceptions with lazy loading
        updates = new ListEventAssembler(this, delegate.getPublisher());
        delegate.addListEventListener(this);
        list = delegate;
    }
View Full Code Here

    }

    /** {@inheritDoc} */
    public Object replaceElements(Object original, Object target, CollectionPersister persister,
            Object owner, Map copyCache, SessionImplementor session) throws HibernateException {
        final EventList result = (EventList) target;
        final EventList source = (EventList) original;
        result.clear();
        result.addAll(source);
        return result;
    }
View Full Code Here

    }

    @Override
    public void listChanged(ListEvent listChanges) {

        EventList changeList = listChanges.getSourceList();

        while (listChanges.next()) {
            try {
                int sourceIndex = listChanges.getIndex();
                int changeType = listChanges.getType();

                switch (changeType) {
                    case ListEvent.DELETE:
                        changeList.getReadWriteLock().readLock().lock();
                        TaskData t1 = (TaskData) listChanges.getOldValue();
                        changeList.getReadWriteLock().readLock().unlock();
                        t1.removePropertyChangeListener(this);
                        saveList();
                        break;
                    case ListEvent.INSERT:
                        changeList.getReadWriteLock().readLock().lock();
                        TaskData t2 = (TaskData) changeList.get(sourceIndex);
                        changeList.getReadWriteLock().readLock().unlock();
                        t2.addPropertyChangeListener(this);
                        saveList();
                        break;
                    case ListEvent.UPDATE:
View Full Code Here

    }

    @Override
    public void listChanged(ListEvent listChanges) {

        EventList changeList = listChanges.getSourceList();
        while (listChanges.next()) {
            int sourceIndex = listChanges.getIndex();
            int changeType = listChanges.getType();

            switch (changeType) {
                case ListEvent.DELETE:
                    changeList.getReadWriteLock().readLock().lock();
                    Download d1 = (Download) listChanges.getOldValue();
                    changeList.getReadWriteLock().readLock().unlock();

                    d1.removePropertyChangeListener(this);
                    md5ValuesMap.remove(d1);
                    linkStateValuesMap.remove(d1);

                    if (saveDelete) {
                        dao.deleteDownload(d1.getId());
                    }


                    WordSaver wordSaver = wordSavers.get(d1);
                    d1.removeWordsListener(wordSaver);
                    wordSavers.remove(d1);

                    HrefLinkSaver hrefSaver = hrefSavers.get(d1);
                    d1.removeHrefLinksListener(hrefSaver);
                    hrefSavers.remove(d1);

                    SrcLinkSaver srcSaver = srcSavers.get(d1);
                    d1.removeSrcLinksListener(srcSaver);
                    srcSavers.remove(d1);

                    LocationSaver locationSaver = locationSavers.get(d1);
                    d1.removeSrcLinksListener(locationSaver);
                    locationSavers.remove(d1);
                    break;
                case ListEvent.INSERT:
                    changeList.getReadWriteLock().readLock().lock();
                    Download d2 = (Download) changeList.get(sourceIndex);
                    changeList.getReadWriteLock().readLock().unlock();

                    d2.addPropertyChangeListener(this);
                    dao.insertDownload(d2);

                    wordSavers.put(d2, new WordSaver(d2));
                    hrefSavers.put(d2, new HrefLinkSaver(d2));
                    srcSavers.put(d2, new SrcLinkSaver(d2));
                    locationSavers.put(d2, new LocationSaver(d2));
                    break;
                case ListEvent.UPDATE:

                    changeList.getReadWriteLock().readLock().lock();
                    Download d3 = (Download) changeList.get(sourceIndex);
                    changeList.getReadWriteLock().readLock().unlock();

                    updateMD5(d3);
                    updateLinkState(d3);
                    break;
            }
View Full Code Here

TOP

Related Classes of ca.odell.glazedlists.EventList

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.