@Override
 public void dispose() {
   // Unregister the listener
   if (null != resourceListChangedListener) {
     UiListenerHandler.getInstance()
         .removeResourceListChangedUIListener(resourceListChangedListener);
     resourceManager.resourceSelectionChanged(null);
   }
   if (null != resourcePropertiesChangedListener) {
     UiListenerHandler.getInstance()
         .removeResourcePropertiesChangedUIListener(resourcePropertiesChangedListener);
   }
   super.dispose();
 }
  private void addAutomationMenu(final Menu menu, final SingleResource selectedResource) {
    MenuItem startItem = new MenuItem(menu, SWT.NONE);
    startItem.setText(Constants.START_RESOURCE_AUTOMATION);
    startItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            // Block starting resource level
            // automation if any attribute level
            // automation is in progress for the
            // selected resource
            boolean started = resourceManager.isAttributeAutomationStarted(selectedResource);
            if (started) {
              MessageDialog.openInformation(
                  Display.getDefault().getActiveShell(),
                  "Attribute automation is in progress",
                  "Attribute level automation for this resource is already in progress!!!\nPlease stop all "
                      + "running attribute level automations to start resource level automation.");
            } else {
              // Start the automation
              // Fetch the settings data
              List<AutomationSettingHelper> automationSettings;
              automationSettings = AutomationSettingHelper.getAutomationSettings(null);

              // Open the settings dialog
              AutomationSettingDialog dialog =
                  new AutomationSettingDialog(
                      Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
                      automationSettings);
              dialog.create();
              if (dialog.open() == Window.OK) {
                String automationType = dialog.getAutomationType();
                String updateFreq = dialog.getUpdateFrequency();

                AutoUpdateType autoType = AutoUpdateType.valueOf(automationType);
                int updFreq = Utility.getUpdateIntervalFromString(updateFreq);
                boolean status =
                    resourceManager.startResourceAutomationUIRequest(
                        autoType, updFreq, selectedResource);
                if (!status) {
                  String statusMsg = "Automation request failed!!!";
                  MessageDialog.openInformation(
                      Display.getDefault().getActiveShell(), "Automation Status", statusMsg);
                }
              }
            }
          }
        });

    MenuItem stopItem = new MenuItem(menu, SWT.NONE);
    stopItem.setText(Constants.STOP_RESOURCE_AUTOMATION);
    stopItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            boolean status = resourceManager.stopResourceAutomationUIRequest(selectedResource);
            if (!status) {
              String statusMsg = "Automation stop failed.";
              MessageDialog.openInformation(
                  Display.getDefault().getActiveShell(), "Automation Status", statusMsg);
            }
          }
        });

    // Set the initial visibility of menu items
    boolean status = resourceManager.isResourceAutomationStarted(selectedResource);
    startItem.setEnabled(!status);
    stopItem.setEnabled(status);
  }
 public void changeDeleteVisibility() {
   boolean visibility = resourceManager.isAnyResourceExist();
   if (null != deleteButton && !deleteButton.isDisposed()) {
     deleteButton.setEnabled(visibility);
   }
 }