Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored HintsFacet into HintsFacetImpl and fixed ClassLoaderAdapte…
…rCallback for Class parameters
- Loading branch information
Showing
5 changed files
with
117 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
ui/impl/src/main/java/org/jboss/forge/ui/impl/facets/HintsFacetImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* 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.ui.impl.facets; | ||
|
||
import org.jboss.forge.environment.Environment; | ||
import org.jboss.forge.facets.BaseFacet; | ||
import org.jboss.forge.ui.UIInput; | ||
import org.jboss.forge.ui.facets.HintsFacet; | ||
import org.jboss.forge.ui.hints.HintsLookup; | ||
import org.jboss.forge.ui.hints.InputType; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
* | ||
*/ | ||
public class HintsFacetImpl extends BaseFacet<UIInput<?>> implements HintsFacet | ||
{ | ||
private HintsLookup hintsLookup; | ||
private InputType inputType; | ||
|
||
public HintsFacetImpl(UIInput<?> origin, Environment environment) | ||
{ | ||
super(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 getOrigin().hasFacet(this.getClass()); | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see org.jboss.forge.ui.facets.HintsFacet#getInputType() | ||
*/ | ||
@Override | ||
public InputType getInputType() | ||
{ | ||
if (inputType == null) | ||
{ | ||
inputType = hintsLookup.getInputType(getOrigin().getValueType()); | ||
} | ||
// TODO should we calculate and return a default input type here, or elsewhere? | ||
return inputType; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* | ||
* @see org.jboss.forge.ui.facets.HintsFacet#setInputType(org.jboss.forge.ui.hints.InputType) | ||
*/ | ||
@Override | ||
public HintsFacet setInputType(InputType type) | ||
{ | ||
inputType = type; | ||
return this; | ||
} | ||
|
||
} |