0

以下のように2つのglazedListテーブルがあります。最初のテーブルをクリックして 2 番目のテーブルに入力すると、IllegalStateException が発生します。

誰かが理由を知っていて、それに対する最良の解決策は何ですか?

Exception in thread "AWT-EventQueue-1" java.lang.IllegalStateException: Reentrant fireEvent() by "[jj.temto.sten.crc.order.MecationItem@f8f6ea]"
    at ca.odell.glazedlists.event.SequenceDependenciesEventPublisher.fireEvent(SequenceDependenciesEventPublisher.java:307)
    at ca.odell.glazedlists.event.ListEventAssembler.commitEvent(ListEventAssembler.java:316)
    at ca.odell.glazedlists.BasicEventList.add(BasicEventList.java:140)
    at jj.temto.sten.crc.medor.ScriptionSummarModel$4.done(ScriptionSummarModel.java:356)
    at org.jdesktop.swingworker.SwingWorker$5.run(Unknown Source)
    at org.jdesktop.swingworker.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
    at org.jdesktop.swingworker.AccumulativeRunnable.run(Unknown Source)
    at org.jdesktop.swingworker.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
    at javax.swing.Timer.fireActionPerformed(Timer.java:271)
    at javax.swing.Timer$DoPostEvent.run(Timer.java:201)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
    at jj.temto.webutil.gui.WebEventQueue.dispatchEvent(WebEventQueue.java:63)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

コード:

        // build the first table
        String[] propertyNames = retrievepropertyNames();
        String[] columnsLabels = retrievecolumnsLabels();
        TableFormat<Order> tableFormat = GlazedLists.tableFormat(Order.class,propertyNames,columnsLabels);
        SortedList<Order> orderSortedList = new SortedList<Order>(model.getOrderEvenList(),null);
        table = new WebTable(new EventTableModel<Order>(orderSortedList,tableFormat));

        // Configures the first table
        TableComparatorChooser tableSorter = TableComparatorChooser.install(table, orderSortedList, TableComparatorChooser.SINGLE_COLUMN);
        tableSorter.appendComparator(1,0,true);
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        table.setAutoResizeMode(WebTable.AUTO_RESIZE_ALL_COLUMNS);
        table.setAutoscrolls(true);
        table.addMouseListener(retrieveTableMouseListener());
        table.getModel().addTableModelListener(retrieveTableModelListener());

        // In the same way as above i build the second table


        private MouseListener retrieveTableMouseListener()
        {
            return new MouseAdapter()
            {
             @Override
                public void mouseClicked(MouseEvent e)
                {
                    int row = table.rowAtPoint(e.getPoint());
                    int nr = Integer.parseInt(table.getValueAt(row, 1).toString());
                    model.retrieveAllItems(vo.getId(),nr);//At this point i'm filling second table
                }
            };
        }





public void retrieveAllItems(final String id,final int nr )
    {
        SwingWorker worker = new SwingWorker()
        {
            List<Item> list = GenericsUtil.makeList();
            @Override
            protected Object doInBackground() throws Exception
            {
                if (pat != null)
                {
                    try
                    {   
                        Collection<Medo> allItems = SERVER.selectItemDAO(id);
                        if ((allItems != null) && (!allItems.isEmpty()))
                        {
                            for (Medo bedItem : allItems)
                            {
                                if(bedItem.OrdrId==nr){
                                    Item Item = new Item();
                                    Item.setId(bedItem.getId());
                                    Item.setMediId(bedItem.mediId);
                                    Item.setTypeName(bedItem.typeName);
                                    list.add(Item);
                                }
                            }
                        }
                        else
                        {
                            // no items found on SERVER
                        }
                    } catch (SQLException e) {
                        Debug.display(e.getMessage());
                    } catch (RemoteException e) {
                        Debug.display(e.getMessage());
                    }
                }
                else
                {
                    JOptionPane.showMessageDialog(panel, "First item then ...");
                }
                return list;
            }

            @Override
            protected void done()
            {
                super.done();
                orderItemEvenList.clear();
                for(Item Item:list){
                    orderItemEvenList.add(Item);// this is eventList of second table
                }
            }
        };
        worker.execute();
    }
4

1 に答える 1

0

マルチスレッド環境で EventList を使用する場合、EventList にアクセスする前にロックを取得する必要があります。

何かのようなもの :

orderitemEvenList.getReadWriteLock().writeLock().lock();
try {
  orderItemEvenList.clear();
  for(Item Item:list){
     orderItemEvenList.add(Item);// this is eventList of second table
  }
} finally {
  orderitemEvenList.getReadWriteLock().writeLock().unlock();
}
于 2013-02-01T08:33:28.290 に答える