新しいノードと接続でグラフを再描画できるように、すべてのノードと接続から Zest グラフをクリアしようとしています。私が次のメソッドを書いたことを理解するために
public void clearGraph( Graph graph ) {
Object[] objects = graph.getConnections().toArray() ;
for (int i = 0 ; i < objects.length; i++){
GraphConnection graCon = (GraphConnection) objects[i];
graCon.dispose();
//graCon.setVisible(false);
}
objects = graph.getNodes().toArray();
for ( int i = 0 ; i < objects.length; i++){
GraphNode graNode = (GraphNode) objects[i];
graNode.dispose();
//graNode.setVisible(false);
}
}
これにより、プログラムがエラーでクラッシュします
スレッド「メイン」org.eclipse.swt.SWTException の例外: ウィジェットが破棄されました
回避策として、ノードと接続を非表示に設定しようとしましたが、それは機能しますが、非表示のオブジェクトが Zest レイアウトを台無しにしているように見えるので、ノードと接続を実際に破棄する方法がある場合は、その方法を優先します。
エラーメッセージはこちら
Exception in thread "main" org.eclipse.swt.SWTException: Widget is disposed
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Widget.error(Unknown Source)
at org.eclipse.swt.widgets.Widget.checkWidget(Unknown Source)
at org.eclipse.swt.widgets.Item.getText(Unknown Source)
at com.mycom.timelineview.views.IndicatorFactorVisualisationView$2.mouseDoubleClick(IndicatorFactorVisualisationView.java:221)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.mycom.timelineview.views.IndicatorFactorVisualisationView.indicatorFactorWindow(IndicatorFactorVisualisationView.java:249)
at com.mycom.timelineview.views.IndicatorFactorVisualisationView.<init>(IndicatorFactorVisualisationView.java:71)
at com.mycom.timelineview.views.SpiderWebMouseListener.chartMouseClicked(SpiderWebMouseListener.java:102)
at org.jfree.experimental.chart.swt.ChartComposite.mouseDown(ChartComposite.java:1621)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.mycom.timelineview.views.SpiderWebView.createPartControl1(SpiderWebView.java:622)
at com.mycom.timelineview.views.InformationPlatformAppView2$7.handleEvent(InformationPlatformAppView2.java:628)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.mycom.timelineview.views.InformationPlatformAppView2.main(InformationPlatformAppView2.java:1330)
編集: Baz のおかげで、間違いを見つけました。マウスリスナーは、私が以前に破棄したグラフノードでテキストを検索する必要があったため、もちろんプログラムはクラッシュしなければなりませんでした。これを回避するためにコードを変更したところ、Baz が提案した方法が完全に実行されるようになりました。