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