全てを再実装したJdbcAcsessです。
Revision | 1f299e0d3d20e95ebb5f66589f03eeb466dfba9c (tree) |
---|---|
Time | 2012-02-16 23:15:34 |
Author | shimakazuro |
Commiter | shimakazuro |
[SQLパネル選択中以外を全て閉じる]に、CopyOnWriteArrayListを使用する
@@ -30,6 +30,7 @@ | ||
30 | 30 | import java.sql.SQLException; |
31 | 31 | import java.util.ArrayList; |
32 | 32 | import java.util.List; |
33 | +import java.util.concurrent.CopyOnWriteArrayList; | |
33 | 34 | |
34 | 35 | import javax.swing.AbstractAction; |
35 | 36 | import javax.swing.Action; |
@@ -585,30 +586,18 @@ | ||
585 | 586 | @Override |
586 | 587 | public void actionPerformed(ActionEvent e) { |
587 | 588 | JTabbedPane tab = view.getCurrentJPanelSession().getJTabbedPaneSql(); |
588 | - if (tab.getTabCount() <= 1) { | |
589 | - return; | |
590 | - } | |
591 | 589 | |
592 | 590 | int index = view.getCurrentJPanelSession().tabbedPaneMousePointer.getFocusedComponentIndex(); |
593 | 591 | if (index == -1) { |
594 | 592 | return; |
595 | 593 | } |
596 | 594 | |
597 | - // Iterator操作中に削除出来無いのでコピーする | |
598 | - ArrayList<JPanelSql> list = new ArrayList<JPanelSql>(); | |
599 | - for (int i = 1; i < tab.getTabCount(); i++) { | |
600 | - if (i != index) { | |
601 | - Object o = tab.getComponentAt(i); | |
602 | - if (o instanceof JPanelSql) { | |
603 | - list.add((JPanelSql) o); | |
604 | - } | |
595 | + Component c = tab.getComponentAt(index); | |
596 | + for (Component component : new CopyOnWriteArrayList<Component>(tab.getComponents())) { | |
597 | + if (component instanceof JPanelSql && component != c) { | |
598 | + tab.remove(component); | |
605 | 599 | } |
606 | 600 | } |
607 | - | |
608 | - for (JPanelSql component : list) { | |
609 | - tab.remove(component); | |
610 | - } | |
611 | - list.clear(); | |
612 | 601 | } |
613 | 602 | }; |
614 | 603 |