Package org.jboss.forge.addon.ui.impl.facets

Source Code of org.jboss.forge.addon.ui.impl.facets.HintsFacetImpl

/*
* Copyright 2013 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Eclipse Public License version 1.0, available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.jboss.forge.addon.ui.impl.facets;

import org.jboss.forge.addon.environment.Environment;
import org.jboss.forge.addon.facets.AbstractFacet;
import org.jboss.forge.addon.ui.facets.HintsFacet;
import org.jboss.forge.addon.ui.hints.HintsLookup;
import org.jboss.forge.addon.ui.input.InputComponent;

/**
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*
*/
public class HintsFacetImpl extends AbstractFacet<InputComponent<?, ?>> implements HintsFacet
{
   private HintsLookup hintsLookup;
   private String inputType;

   public HintsFacetImpl(InputComponent<?, ?> origin, Environment environment)
   {
      super.setFaceted(origin);
      if (environment == null)
      {
         throw new IllegalStateException("Environment must not be null.");
      }

      this.hintsLookup = new HintsLookup(environment);
   }

   @Override
   public boolean install()
   {
      return true;
   }

   @Override
   public boolean isInstalled()
   {
      return getFaceted().hasFacet(this.getClass());
   }

   @Override
   public String getInputType()
   {
      if (inputType == null)
      {
         inputType = hintsLookup.getInputType(getFaceted().getValueType());
      }
      return inputType;
   }

   @Override
   public HintsFacet setInputType(String type)
   {
      inputType = type;
      return this;
   }

}
TOP

Related Classes of org.jboss.forge.addon.ui.impl.facets.HintsFacetImpl

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.