/*******************************************************************************
 * Pentaho Big Data
 * <p/>
 * Copyright (C) 2002-2019 by Hitachi Vantara : http://www.pentaho.com
 * <p/>
 * ******************************************************************************
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package org.pentaho.di.ui.hadoop.configuration;

import org.pentaho.di.core.logging.LogChannel;
import org.pentaho.di.core.logging.LogChannelInterface;
import org.pentaho.di.ui.spoon.SpoonLifecycleListener;
import org.pentaho.di.ui.spoon.SpoonPerspective;
import org.pentaho.di.ui.spoon.SpoonPlugin;
import org.pentaho.di.ui.spoon.SpoonPluginCategories;
import org.pentaho.di.ui.spoon.SpoonPluginInterface;
import org.pentaho.di.ui.spoon.XulSpoonResourceBundle;
import org.pentaho.ui.xul.XulDomContainer;
import org.pentaho.ui.xul.XulException;

import java.util.ResourceBundle;

/**
 * Created by bryan on 8/10/15.
 */
@SpoonPluginCategories( { "spoon" } )
@SpoonPlugin( id = "HadoopConfigurationsSpoonPlugin", image = "" )
public class HadoopConfigurationsSpoonPlugin implements SpoonPluginInterface {

  private static Class<?> PKG = HadoopConfigurationsSpoonPlugin.class;

  private LogChannelInterface log = new LogChannel( HadoopConfigurationsSpoonPlugin.class.getName() );

  private ResourceBundle resourceBundle = new XulSpoonResourceBundle( PKG );

  public void applyToContainer( String category, XulDomContainer container ) throws XulException {
    try {
      container.registerClassLoader( getClass().getClassLoader() );
      container.loadOverlay( "org/pentaho/di/ui/hadoop/configuration/toolbar-overlay.xul", resourceBundle );
      HadoopConfigurationsController controller = new HadoopConfigurationsController();
      container.addEventHandler( controller );
    } catch ( XulException e ) {
      log.logError( e.getMessage() );
    }
    //todo:no more active shim require needed - here ui rethink when select shim for step
//    HadoopConfigurationBootstrap.getInstance().setPrompter( new HadoopConfigurationPrompter() {
//      @Override
//      public String getConfigurationSelection( final List<HadoopConfigurationInfo> hadoopConfigurationInfos ) {
//        final Spoon spoon = Spoon.getInstance();
//        final AtomicReference<String> atomicReference = new AtomicReference<>();
//        spoon.getDisplay().syncExec( new Runnable() {
//          @Override
//          public void run() {
//            // If there are no shims, bring up the "no shims" dialog, otherwise bring up the shim select dialog
//            atomicReference
//              .set( Const.isEmpty( hadoopConfigurationInfos )
//                ? new NoHadoopConfigurationsXulDialog( spoon.getShell() ).open()
//                : new HadoopConfigurationsXulDialog( spoon.getShell(), hadoopConfigurationInfos ).open() );
//          }
//        } );
//        return atomicReference.get();
//      }
//
//      @Override
//      public void promptForRestart() {
//        final Spoon spoon = Spoon.getInstance();
//        spoon.getDisplay().syncExec( new Runnable() {
//          @Override
//          public void run() {
//            new HadoopConfigurationRestartXulDialog( spoon.getShell() ).open();
//          }
//        } );
//      }
//    } );
  }

  public SpoonLifecycleListener getLifecycleListener() {
    return null;
  }

  public SpoonPerspective getPerspective() {
    return null;
  }

}

@@ -967,111 +967,8 @@
 n;%0A%0A
-import org.pentaho.di.core.logging.LogChannel;%0Aimport org.pentaho.di.core.logging.LogChannelInterface;%0A
 impo
@@ -1241,159 +1241,30 @@
 aho.
-di.ui.spoon.XulSpoonResourceBundle;%0Aimport org.pentaho.ui.xul.XulDomContainer;%0Aimport org.pentaho.ui.xul.XulException;%0A%0Aimport java.util.ResourceBundle
+ui.xul.XulDomContainer
 ;%0A%0A/
@@ -1494,547 +1494,84 @@
 %0A  p
-rivate static Class%3C?%3E PKG = HadoopConfigurationsSpoonPlugin.class;%0A%0A  private LogChannelInterface log = new LogChannel( HadoopConfigurationsSpoonPlugin.class.getName() );%0A%0A  private ResourceBundle resourceBundle = new XulSpoonResourceBundle( PKG );%0A%0A  public void applyToContainer( String category, XulDomContainer container ) throws XulException %7B%0A    try %7B%0A      container.registerClassLoader( getClass().getClassLoader() );%0A      container.loadOverlay( %22org/pentaho/di/ui/hadoop/configuration/toolbar-overlay.xul%22, resourceBundle );%0A  
+ublic void applyToContainer( String category, XulDomContainer container ) %7B%0A
     
@@ -1656,18 +1656,16 @@
 ();%0A    
-  
 containe
@@ -1701,1484 +1701,8 @@
  );%0A
-    %7D catch ( XulException e ) %7B%0A      log.logError( e.getMessage() );%0A    %7D%0A    //todo:no more active shim require needed - here ui rethink when select shim for step%0A//    HadoopConfigurationBootstrap.getInstance().setPrompter( new HadoopConfigurationPrompter() %7B%0A//      @Override%0A//      public String getConfigurationSelection( final List%3CHadoopConfigurationInfo%3E hadoopConfigurationInfos ) %7B%0A//        final Spoon spoon = Spoon.getInstance();%0A//        final AtomicReference%3CString%3E atomicReference = new AtomicReference%3C%3E();%0A//        spoon.getDisplay().syncExec( new Runnable() %7B%0A//          @Override%0A//          public void run() %7B%0A//            // If there are no shims, bring up the %22no shims%22 dialog, otherwise bring up the shim select dialog%0A//            atomicReference%0A//              .set( Const.isEmpty( hadoopConfigurationInfos )%0A//                ? new NoHadoopConfigurationsXulDialog( spoon.getShell() ).open()%0A//                : new HadoopConfigurationsXulDialog( spoon.getShell(), hadoopConfigurationInfos ).open() );%0A//          %7D%0A//        %7D );%0A//        return atomicReference.get();%0A//      %7D%0A//%0A//      @Override%0A//      public void promptForRestart() %7B%0A//        final Spoon spoon = Spoon.getInstance();%0A//        spoon.getDisplay().syncExec( new Runnable() %7B%0A//          @Override%0A//          public void run() %7B%0A//            new HadoopConfigurationRestartXulDialog( spoon.getShell() ).open();%0A//          %7D%0A//        %7D );%0A//      %7D%0A//    %7D );%0A
   %7D%0A

Remove the Hadoop Distribution... menu option from Spoon; no longer needed. This entire legacy plugin needs to be re-examined for relevance.