Integrated resource model related changes with eclipse plug-ins.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ClientControllerPlugin / src / oic / simulator / clientcontroller / view / ResourceManagerView.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.clientcontroller.view;
18
19 import java.util.List;
20 import java.util.Set;
21
22 import oic.simulator.clientcontroller.Activator;
23 import oic.simulator.clientcontroller.listener.IFindResourceUIListener;
24 import oic.simulator.clientcontroller.manager.ResourceManager;
25 import oic.simulator.clientcontroller.manager.UiListenerHandler;
26 import oic.simulator.clientcontroller.remoteresource.RemoteResource;
27 import oic.simulator.clientcontroller.utils.Constants;
28 import oic.simulator.clientcontroller.view.dialogs.FindResourceWizard;
29 import oic.simulator.clientcontroller.view.dialogs.LoadRAMLDialog;
30 import oic.simulator.clientcontroller.view.dialogs.ResourceWizardDialog;
31
32 import org.eclipse.jface.dialogs.MessageDialog;
33 import org.eclipse.jface.viewers.ISelectionChangedListener;
34 import org.eclipse.jface.viewers.IStructuredSelection;
35 import org.eclipse.jface.viewers.ITreeContentProvider;
36 import org.eclipse.jface.viewers.LabelProvider;
37 import org.eclipse.jface.viewers.SelectionChangedEvent;
38 import org.eclipse.jface.viewers.TreeViewer;
39 import org.eclipse.jface.viewers.Viewer;
40 import org.eclipse.jface.window.Window;
41 import org.eclipse.jface.wizard.WizardDialog;
42 import org.eclipse.swt.SWT;
43 import org.eclipse.swt.custom.CTabFolder;
44 import org.eclipse.swt.custom.CTabItem;
45 import org.eclipse.swt.events.MenuAdapter;
46 import org.eclipse.swt.events.MenuEvent;
47 import org.eclipse.swt.events.SelectionAdapter;
48 import org.eclipse.swt.events.SelectionEvent;
49 import org.eclipse.swt.graphics.Color;
50 import org.eclipse.swt.graphics.Image;
51 import org.eclipse.swt.layout.GridData;
52 import org.eclipse.swt.layout.GridLayout;
53 import org.eclipse.swt.widgets.Button;
54 import org.eclipse.swt.widgets.Composite;
55 import org.eclipse.swt.widgets.Display;
56 import org.eclipse.swt.widgets.Group;
57 import org.eclipse.swt.widgets.Menu;
58 import org.eclipse.swt.widgets.MenuItem;
59 import org.eclipse.swt.widgets.Tree;
60 import org.eclipse.ui.PlatformUI;
61 import org.eclipse.ui.dialogs.FilteredTree;
62 import org.eclipse.ui.dialogs.PatternFilter;
63 import org.eclipse.ui.part.ViewPart;
64 import org.oic.simulator.SimulatorException;
65
66 /**
67  * This class manages and shows the resource manager view in the perspective.
68  */
69 public class ResourceManagerView extends ViewPart {
70
71     public static final String      VIEW_ID = "oic.simulator.clientcontroller.view.resourcemanager";
72
73     private Button                  findResButton;
74     private Button                  refreshButton;
75
76     private TreeViewer              treeViewer;
77     private TreeViewer              favTreeViewer;
78
79     private CTabFolder              folder;
80     private CTabItem                foundResTab;
81     private CTabItem                favResTab;
82
83     private ResourceManager         resourceManager;
84
85     private IFindResourceUIListener findListener;
86
87     private Boolean                 foundResource;
88
89     private MessageDialog           findDialog;
90
91     private MessageDialog           refreshDialog;
92
93     private Thread                  sleepThreadHandle;
94
95     public ResourceManagerView() {
96         resourceManager = Activator.getDefault().getResourceManager();
97
98         findListener = new IFindResourceUIListener() {
99
100             @Override
101             public void onNewResourceFound(final RemoteResource resource) {
102                 if (null == resource) {
103                     return;
104                 }
105                 // Changing the status of the find operation.
106                 setFoundResource(true);
107
108                 // Interrupt the sleep thread.
109                 if (null != sleepThreadHandle && sleepThreadHandle.isAlive()) {
110                     sleepThreadHandle.interrupt();
111                 }
112
113                 // Update the tree viewer
114                 Display.getDefault().asyncExec(new Runnable() {
115                     @Override
116                     public void run() {
117                         if (!treeViewer.getControl().isDisposed()) {
118                             treeViewer.refresh();
119                         }
120
121                         if (!favTreeViewer.getControl().isDisposed()) {
122                             favTreeViewer.refresh();
123                         }
124
125                         // Close the find dialog
126                         if (null != findDialog) {
127                             findDialog.close();
128                         }
129
130                         // Close the refresh dialog
131                         if (null != refreshDialog) {
132                             refreshDialog.close();
133                         }
134                     }
135                 });
136             }
137         };
138     }
139
140     @Override
141     public void createPartControl(Composite parent) {
142         Composite compContent = new Composite(parent, SWT.NONE);
143         compContent.setLayout(new GridLayout());
144         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
145         compContent.setLayoutData(gd);
146
147         Composite buttonComp = new Composite(compContent, SWT.NONE);
148         buttonComp.setLayout(new GridLayout(2, false));
149
150         gd = new GridData();
151         gd.horizontalAlignment = SWT.FILL;
152         gd.grabExcessHorizontalSpace = true;
153
154         buttonComp.setLayoutData(gd);
155
156         findResButton = new Button(buttonComp, SWT.PUSH);
157         findResButton.setText("Find Resources");
158         findResButton.setToolTipText("Find OIC resources");
159
160         gd = new GridData();
161         gd.widthHint = 130;
162         findResButton.setLayoutData(gd);
163
164         refreshButton = new Button(buttonComp, SWT.PUSH);
165         refreshButton.setText("Refresh");
166         refreshButton.setToolTipText("Restart the search once again");
167
168         gd = new GridData();
169         gd.widthHint = 90;
170         refreshButton.setLayoutData(gd);
171
172         // Create a Tab Folder.
173         folder = new CTabFolder(compContent, SWT.BORDER);
174         gd = new GridData(SWT.FILL, SWT.FILL, true, true);
175         folder.setLayoutData(gd);
176         folder.setSimple(false);
177         folder.setUnselectedCloseVisible(false);
178         folder.setUnselectedImageVisible(false);
179         folder.addSelectionListener(new SelectionAdapter() {
180             @Override
181             public void widgetSelected(SelectionEvent e) {
182                 // Tab is switched.
183                 treeViewer.setSelection(null);
184                 favTreeViewer.setSelection(null);
185                 resourceManager.resourceSelectionChanged(null);
186             }
187         });
188
189         createFoundResourcesArea();
190
191         createFavoriteResourcesArea();
192
193         folder.setSelection(foundResTab);
194
195         findDialog = new MessageDialog(Display.getDefault().getActiveShell(),
196                 "Finding Servers", null,
197                 "Finding the requested servers\nPlease wait...",
198                 MessageDialog.INFORMATION, new String[] { "Cancel" }, 0);
199         // findDialog.setBlockOnOpen(false);
200
201         refreshDialog = new MessageDialog(
202                 Display.getDefault().getActiveShell(),
203                 "Finding Servers",
204                 null,
205                 "Refreshing the search and finding the requested servers once again\nPlease wait...",
206                 MessageDialog.INFORMATION, new String[] { "Cancel" }, 0);
207         // refreshDialog.setBlockOnOpen(false);
208
209         addUIListeners();
210
211         addManagerListeners();
212
213         // Setting the initial visibility of refresh based on the last known
214         // search operation.
215         Set<String> prevSearchTypes = resourceManager.getLastKnownSearchTypes();
216         if (null == prevSearchTypes || prevSearchTypes.size() < 1) {
217             refreshButton.setEnabled(false);
218         } else {
219             refreshButton.setEnabled(true);
220         }
221     }
222
223     private void createFoundResourcesArea() {
224         foundResTab = new CTabItem(folder, SWT.NULL);
225         foundResTab.setText("Found Resources");
226
227         // Create a group to show all the discovered resources.
228         // Adding the group to the folder.
229         Group resourceGroup = new Group(folder, SWT.NONE);
230         // resourceGroup.setText("Discovered Resources");
231
232         Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
233         resourceGroup.setBackground(color);
234
235         resourceGroup.setLayout(new GridLayout(1, false));
236         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
237         resourceGroup.setLayoutData(gd);
238
239         PatternFilter filter = new PatternFilter();
240         FilteredTree filteredTree = new FilteredTree(resourceGroup,
241                 SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE, filter, true);
242         treeViewer = filteredTree.getViewer();
243         treeViewer.getTree().setLayoutData(
244                 new GridData(SWT.FILL, SWT.FILL, true, true));
245         treeViewer.setContentProvider(new TreeContentProvider());
246         treeViewer.setLabelProvider(new TreeLabelProvider());
247         treeViewer.setInput(new Object());
248
249         addMenuToFoundResources();
250
251         foundResTab.setControl(resourceGroup);
252     }
253
254     private void addMenuToFoundResources() {
255
256         if (null != treeViewer) {
257             final Tree resourceTreeHead = treeViewer.getTree();
258             if (null != resourceTreeHead) {
259                 // Below code creates menu entries and shows them on right
260                 // clicking a resource
261                 final Menu menu = new Menu(resourceTreeHead);
262                 resourceTreeHead.setMenu(menu);
263                 menu.addMenuListener(new MenuAdapter() {
264                     @Override
265                     public void menuShown(MenuEvent e) {
266                         // Clear existing menu items
267                         MenuItem[] items = menu.getItems();
268                         for (int index = 0; index < items.length; index++) {
269                             items[index].dispose();
270                         }
271                         setupUploadRamlMenuItem(menu);
272
273                         final RemoteResource resource = (RemoteResource) ((IStructuredSelection) treeViewer
274                                 .getSelection()).getFirstElement();
275                         if (null == resource) {
276                             return;
277                         }
278                         String menuText = !resource.isFavorite() ? "Add to favorites"
279                                 : "Remove from favorites";
280                         MenuItem addToFavMenuItem = new MenuItem(menu, SWT.NONE);
281                         addToFavMenuItem.setText(menuText);
282                         addToFavMenuItem
283                                 .addSelectionListener(new SelectionAdapter() {
284                                     @Override
285                                     public void widgetSelected(SelectionEvent e) {
286                                         if (!resource.isFavorite()) {
287                                             resourceManager
288                                                     .addResourcetoFavorites(resource);
289                                             resourceManager
290                                                     .addResourceURItoFavorites(resource);
291                                         } else {
292                                             resourceManager
293                                                     .removeResourceFromFavorites(resource);
294                                             resourceManager
295                                                     .removeResourceURIFromFavorites(resource);
296                                         }
297                                         favTreeViewer.refresh();
298                                     }
299                                 });
300                     }
301                 });
302             }
303         }
304     }
305
306     private void createFavoriteResourcesArea() {
307         favResTab = new CTabItem(folder, SWT.NULL);
308         favResTab.setText("Favorite Resources");
309
310         // Create a group to show all the discovered resources.
311         // Adding the group to the folder.
312         Group resourceGroup = new Group(folder, SWT.NONE);
313         // resourceGroup.setText("Discovered Resources");
314
315         Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);
316         resourceGroup.setBackground(color);
317
318         resourceGroup.setLayout(new GridLayout(1, false));
319         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
320         resourceGroup.setLayoutData(gd);
321
322         PatternFilter filter = new PatternFilter();
323         FilteredTree filteredTree = new FilteredTree(resourceGroup,
324                 SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE, filter, true);
325         favTreeViewer = filteredTree.getViewer();
326         favTreeViewer.getTree().setLayoutData(
327                 new GridData(SWT.FILL, SWT.FILL, true, true));
328         favTreeViewer.setContentProvider(new FavTreeContentProvider());
329         favTreeViewer.setLabelProvider(new TreeLabelProvider());
330         favTreeViewer.setInput(new Object());
331
332         favResTab.setControl(resourceGroup);
333
334         addMenuToFavResources();
335     }
336
337     private void addMenuToFavResources() {
338         if (null != favTreeViewer) {
339             final Tree resourceTreeHead = favTreeViewer.getTree();
340             if (null != resourceTreeHead) {
341                 // Below code creates menu entries and shows them on right
342                 // clicking a resource
343                 final Menu menu = new Menu(resourceTreeHead);
344                 resourceTreeHead.setMenu(menu);
345                 menu.addMenuListener(new MenuAdapter() {
346                     @Override
347                     public void menuShown(MenuEvent e) {
348                         // Clear existing menu items
349                         MenuItem[] items = menu.getItems();
350                         for (int index = 0; index < items.length; index++) {
351                             items[index].dispose();
352                         }
353
354                         setupUploadRamlMenuItem(menu);
355
356                         MenuItem addToFavMenuItem = new MenuItem(menu, SWT.NONE);
357                         addToFavMenuItem.setText("Remove from favorites");
358                         addToFavMenuItem
359                                 .addSelectionListener(new SelectionAdapter() {
360                                     @Override
361                                     public void widgetSelected(SelectionEvent e) {
362                                         RemoteResource resource = (RemoteResource) ((IStructuredSelection) favTreeViewer
363                                                 .getSelection())
364                                                 .getFirstElement();
365                                         if (null == resource) {
366                                             return;
367                                         }
368                                         resourceManager
369                                                 .removeResourceFromFavorites(resource);
370                                         resourceManager
371                                                 .removeResourceURIFromFavorites(resource);
372                                         favTreeViewer.refresh();
373                                     }
374                                 });
375                     }
376                 });
377             }
378         }
379     }
380
381     private void setupUploadRamlMenuItem(Menu menu) {
382         MenuItem uploadRAMLItem = new MenuItem(menu, SWT.NONE);
383         uploadRAMLItem.setText("Upload RAML Configuration");
384         uploadRAMLItem.addSelectionListener(new SelectionAdapter() {
385             @Override
386             public void widgetSelected(SelectionEvent e) {
387                 // Open the RAML configuration dialog if
388                 // RAML file is not yet uploaded for the
389                 // currently selected resource
390                 RemoteResource resource = resourceManager
391                         .getCurrentResourceInSelection();
392                 if (null == resource) {
393                     return;
394                 }
395                 if (resource.isConfigUploaded()) {
396                     boolean answer = MessageDialog
397                             .openQuestion(
398                                     Display.getDefault().getActiveShell(),
399                                     "Upload Another RAML",
400                                     "This resource is already configured with RAML.\n"
401                                             + "Do you want to upload a new configuration?");
402                     if (!answer) {
403                         return;
404                     }
405                 }
406                 // Open the dialog in a separate
407                 // UI thread.
408                 PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() {
409                     @Override
410                     public void run() {
411                         LoadRAMLDialog ramlDialog = new LoadRAMLDialog(Display
412                                 .getDefault().getActiveShell());
413                         if (ramlDialog.open() != Window.OK) {
414                             return;
415                         }
416                         String configFilePath = ramlDialog.getConfigFilePath();
417                         if (null == configFilePath
418                                 || configFilePath.length() < 1) {
419                             MessageDialog.openInformation(Display.getDefault()
420                                     .getActiveShell(),
421                                     "Invalid RAML Config path",
422                                     "Configuration file path is invalid.");
423                             return;
424                         }
425                         try {
426                             boolean result = resourceManager.setConfigFilePath(
427                                     resourceManager
428                                             .getCurrentResourceInSelection(),
429                                     configFilePath);
430                             if (!result) {
431                                 MessageDialog
432                                         .openInformation(Display.getDefault()
433                                                 .getActiveShell(),
434                                                 "Operation failed",
435                                                 "Failed to obtain the details from the given RAML.");
436                             }
437                         } catch (SimulatorException e) {
438                             MessageDialog.openInformation(Display.getDefault()
439                                     .getActiveShell(), "Invalid RAML",
440                                     "Given configuration file is invalid.");
441                         }
442                     }
443                 });
444             }
445         });
446     }
447
448     private void addUIListeners() {
449         findResButton.addSelectionListener(new SelectionAdapter() {
450             @Override
451             public void widgetSelected(SelectionEvent e) {
452                 PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
453
454                     @Override
455                     public void run() {
456                         FindResourceWizard findWizard = new FindResourceWizard();
457                         ResourceWizardDialog wizardDialog = new ResourceWizardDialog(
458                                 PlatformUI.getWorkbench().getDisplay()
459                                         .getActiveShell(), findWizard);
460                         int open = wizardDialog.open();
461                         if (open == WizardDialog.OK) {
462                             // Setting initial value on starting the find
463                             // operation.
464                             setFoundResource(false);
465
466                             Set<String> searchTypes = findWizard
467                                     .getSearchTypes();
468                             // Delete cached details of resources based on the
469                             // given search types.
470                             // If there are no resource types to search, then
471                             // all resources
472                             // will be deleted.
473                             resourceManager.deleteResources(searchTypes);
474
475                             // Update the tree
476                             treeViewer.refresh();
477                             favTreeViewer.refresh();
478
479                             // Call native method to find Resources
480                             boolean result = resourceManager
481                                     .findResourceRequest(searchTypes);
482                             if (result) {
483                                 searchUIOperation(false);
484                             } else {
485                                 MessageDialog
486                                         .openError(Display.getDefault()
487                                                 .getActiveShell(),
488                                                 "Find Resource status",
489                                                 "Operation failed due to some problems in core layer.");
490                             }
491
492                             // Store this information for refresh
493                             // functionality
494                             resourceManager
495                                     .setLastKnownSearchTypes(searchTypes);
496
497                             // Change the refresh visibility
498                             refreshButton.setEnabled(true);
499                         }
500                     }
501                 });
502             }
503         });
504
505         refreshButton.addSelectionListener(new SelectionAdapter() {
506             @Override
507             public void widgetSelected(SelectionEvent e) {
508                 Set<String> searchTypes = resourceManager
509                         .getLastKnownSearchTypes();
510                 setFoundResource(false);
511
512                 // Delete cached details of resources based on the given search
513                 // types.
514                 // If there are no resource types to search, then all resources
515                 // will be deleted.
516                 resourceManager.deleteResources(searchTypes);
517
518                 // Update the tree
519                 treeViewer.refresh();
520                 favTreeViewer.refresh();
521
522                 // Call native method to find Resources
523                 boolean result = resourceManager
524                         .findResourceRequest(searchTypes);
525                 if (result) {
526                     searchUIOperation(true);
527                 } else {
528                     MessageDialog
529                             .openError(Display.getDefault().getActiveShell(),
530                                     "Find Resource status",
531                                     "Operation failed due to some problems in core layer.");
532                 }
533             }
534         });
535
536         // Below code adds a listener to the tree for selection changes
537         // and notifies the resource manager
538         ISelectionChangedListener treeSelectionListener = new ISelectionChangedListener() {
539
540             @Override
541             public void selectionChanged(SelectionChangedEvent e) {
542                 if (e.getSelection().isEmpty()) {
543                     return;
544                 }
545                 if (e.getSelection() instanceof IStructuredSelection) {
546                     IStructuredSelection selection = (IStructuredSelection) e
547                             .getSelection();
548                     RemoteResource resource = (RemoteResource) selection
549                             .getFirstElement();
550                     if (null == resource) {
551                         return;
552                     }
553                     resourceManager.resourceSelectionChanged(resource);
554                 }
555             }
556         };
557
558         treeViewer.addSelectionChangedListener(treeSelectionListener);
559         favTreeViewer.addSelectionChangedListener(treeSelectionListener);
560     }
561
562     // If refresh is true, then Refresh Dialog else Find Dialog will be shown.
563     private void searchUIOperation(boolean refresh) {
564         final MessageDialog targetDialog;
565         if (refresh) {
566             targetDialog = refreshDialog;
567         } else {
568             targetDialog = findDialog;
569         }
570         // Open the dialog in a new thread.
571         PlatformUI.getWorkbench().getDisplay().syncExec(new Thread() {
572
573             @Override
574             public void run() {
575                 if (isFoundResource()) {
576                     setFoundResource(false);
577                     return;
578                 }
579
580                 PlatformUI.getWorkbench().getDisplay().asyncExec(new Thread() {
581                     @Override
582                     public void run() {
583                         targetDialog.open(); // This method returns once the
584                         // cancel button is pressed.
585
586                         // Interrupt the sleep thread.
587                         if (null != sleepThreadHandle
588                                 && sleepThreadHandle.isAlive()) {
589                             sleepThreadHandle.interrupt();
590                         }
591
592                         // Set the status of find.
593                         setFoundResource(false);
594                     }
595                 });
596
597                 // Thread for find time-out.
598                 sleepThreadHandle = new Thread() {
599                     Thread child;
600
601                     public void run() {
602                         try {
603                             Thread.sleep(Constants.FIND_RESOURCES_TIMEOUT * 1000);
604                         } catch (InterruptedException e) {
605                             return;
606                         }
607
608                         child = new Thread() {
609                             @Override
610                             public void run() {
611                                 if (null != targetDialog) {
612                                     targetDialog.close();
613
614                                     // Check if any new resources are
615                                     // discovered.
616                                     // Is no new resources, then display a
617                                     // message box.
618                                     if (!isFoundResource()) {
619                                         MessageDialog
620                                                 .openInformation(
621                                                         Display.getDefault()
622                                                                 .getActiveShell(),
623                                                         "No servers found",
624                                                         "No servers are available as of now.\n"
625                                                                 + "Please check the servers' status and press"
626                                                                 + "'Refresh' button to restart the search.");
627                                     } else {
628                                         // Resetting the status to false for
629                                         // ensuring safety.
630                                         setFoundResource(false);
631                                     }
632                                 }
633                             }
634                         };
635
636                         PlatformUI.getWorkbench().getDisplay().syncExec(child);
637                     }
638                 };
639                 sleepThreadHandle.start();
640             }
641         });
642     }
643
644     private void addManagerListeners() {
645         UiListenerHandler.getInstance().addFindresourceUIListener(findListener);
646     }
647
648     @Override
649     public void dispose() {
650         // Unregister the listener
651         if (null != findListener) {
652             UiListenerHandler.getInstance().removeFindresourceUIListener(
653                     findListener);
654             resourceManager.resourceSelectionChanged(null);
655         }
656         super.dispose();
657     }
658
659     @Override
660     public void setFocus() {
661     }
662
663     public synchronized void setFoundResource(boolean value) {
664         foundResource = value;
665     }
666
667     public synchronized boolean isFoundResource() {
668         return foundResource;
669     }
670 }
671
672 class TreeContentProvider implements ITreeContentProvider {
673
674     @Override
675     public void dispose() {
676     }
677
678     @Override
679     public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
680
681     }
682
683     @Override
684     public Object[] getChildren(Object parent) {
685         return null;
686     }
687
688     @Override
689     public Object[] getElements(Object parent) {
690         List<RemoteResource> resourceList = Activator.getDefault()
691                 .getResourceManager().getResourceList();
692         return resourceList.toArray();
693     }
694
695     @Override
696     public Object getParent(Object child) {
697         return null;
698     }
699
700     @Override
701     public boolean hasChildren(Object parent) {
702         return false;
703     }
704
705 }
706
707 class FavTreeContentProvider implements ITreeContentProvider {
708
709     @Override
710     public void dispose() {
711     }
712
713     @Override
714     public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
715
716     }
717
718     @Override
719     public Object[] getChildren(Object parent) {
720         return null;
721     }
722
723     @Override
724     public Object[] getElements(Object parent) {
725         List<RemoteResource> resourceList = Activator.getDefault()
726                 .getResourceManager().getFavResourceList();
727         return resourceList.toArray();
728     }
729
730     @Override
731     public Object getParent(Object child) {
732         return null;
733     }
734
735     @Override
736     public boolean hasChildren(Object parent) {
737         return false;
738     }
739
740 }
741
742 class TreeLabelProvider extends LabelProvider {
743     @Override
744     public String getText(Object element) {
745         RemoteResource resource = (RemoteResource) element;
746         return resource.getRemoteResourceRef().getURI();
747     }
748
749     @Override
750     public Image getImage(Object element) {
751         return null;
752     }
753 }