Package org.jboss.forge.addon.shell.aesh.completion

Source Code of org.jboss.forge.addon.shell.aesh.completion.CompletionStrategyFactory

package org.jboss.forge.addon.shell.aesh.completion;

import org.jboss.forge.addon.ui.facets.HintsFacet;
import org.jboss.forge.addon.ui.hints.InputType;
import org.jboss.forge.addon.ui.input.InputComponent;
import org.jboss.forge.addon.ui.input.SelectComponent;

/**
* Returns the completion based on the input component
*
* @author <a href="ggastald@redhat.com">George Gastaldi</a>
*/
public class CompletionStrategyFactory
{
   public static CompletionStrategy getCompletionFor(InputComponent<?, Object> component)
   {
      InputType inputType = component.getFacet(HintsFacet.class).getInputType();
      CompletionStrategy strategy = null;
      if (inputType == InputType.FILE_PICKER)
      {
         strategy = new FileInputCompletionStrategy(false);
      }
      else if (inputType == InputType.DIRECTORY_PICKER)
      {
         strategy = new FileInputCompletionStrategy(true);
      }
      if (component instanceof SelectComponent)
      {
         strategy = new SelectComponentCompletionStrategy();
      }
      // Always try UICompleter first and then fallback to the chosen strategy
      strategy = new UICompleterCompletionStrategy(strategy);
      return strategy;
   }
}
TOP

Related Classes of org.jboss.forge.addon.shell.aesh.completion.CompletionStrategyFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.