66import org .eclipse .core .runtime .Platform ;
77import org .eclipse .jface .action .Action ;
88import org .eclipse .jface .action .MenuManager ;
9- import org .eclipse .jface .preference .PreferenceDialog ;
109import org .eclipse .jface .resource .ImageDescriptor ;
1110import org .eclipse .jface .viewers .ISelectionChangedListener ;
1211import org .eclipse .jface .viewers .IStructuredSelection ;
2524import org .eclipse .swt .widgets .Shell ;
2625import org .eclipse .swt .widgets .Tree ;
2726import org .eclipse .ui .PlatformUI ;
28- import org .eclipse .ui .dialogs .PreferencesUtil ;
2927import org .eclipse .ui .part .ViewPart ;
3028import org .osgi .framework .Bundle ;
3129
@@ -149,34 +147,34 @@ public void setFocus() {
149147 public void setNodeText (BaseTreeNode node , String text ) {
150148 node .setText (text );
151149 Display .getDefault ().asyncExec (() -> {
152- this .treeViewer .refresh (node , true );
150+ this .treeViewer .refresh (node , true );
153151 });
154152 }
155153
156154 @ Override
157155 public void setNodeIcon (ImageDescriptor icon ) {
158156 // TODO Auto-generated method stub
159-
157+
160158 }
161159
162160 @ Override
163161 public void addIssueNode (BaseTreeNode parent , BaseTreeNode toBeAdded ) {
164162 // TODO Auto-generated method stub
165-
163+
166164 }
167165
168166 @ Override
169167 public void addFileNode (BaseTreeNode parent , BaseTreeNode toBeAdded ) {
170168 // TODO Auto-generated method stub
171-
169+
172170 }
173171
174172 @ Override
175173 public void addInfoNode (BaseTreeNode parent , BaseTreeNode toBeAdded ) {
176174 toBeAdded .setParent (parent );
177175 parent .addChild (toBeAdded );
178176 Display .getDefault ().asyncExec (() -> {
179- this .treeViewer .refresh (parent , true );
177+ this .treeViewer .refresh (parent , true );
180178 });
181179 }
182180
@@ -203,15 +201,38 @@ public BaseTreeNode getRoot() {
203201 @ Override
204202 public void refreshTree () {
205203 Display .getDefault ().asyncExec (() -> {
206- this .treeViewer .refresh (true );
204+ this .treeViewer .refresh (true );
207205 });
208206 }
209207
210208 @ Override
211209 public void resetNode (BaseTreeNode node ) {
212210 node .reset ();
213211 Display .getDefault ().asyncExec (() -> {
214- this .treeViewer .refresh (node , true );
212+ this .treeViewer .refresh (node , true );
213+ });
214+ }
215+
216+ public void clearTree () {
217+ clearRoot ();
218+ Display .getDefault ().asyncExec (() -> {
219+ if (this .treeViewer != null && !this .treeViewer .getTree ().isDisposed ()) {
220+ this .treeViewer .refresh ();
221+ this .treeViewer .expandAll (); // Optional: if you want to expand all nodes after clearing
222+ }
215223 });
216224 }
225+
226+ private void clearRoot () {
227+ if (this .rootObject != null ) {
228+ this .rootObject .removeChildren ();
229+ this .rootObject .reset ();
230+ }
231+ }
232+
233+ @ Override
234+ public TreeViewer getTreeViewer () {
235+ return this .treeViewer ;
236+ }
237+
217238}
0 commit comments