-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIInput/SelectOne/SelectMany functional
- Loading branch information
1 parent
ac1fad5
commit aec8260
Showing
12 changed files
with
380 additions
and
67 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
51 changes: 51 additions & 0 deletions
51
ui/api/src/main/java/org/jboss/forge/ui/UIInputComponent.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,51 @@ | ||
/* | ||
* Copyright 2012 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; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
import org.jboss.forge.container.services.Exported; | ||
import org.jboss.forge.facets.Faceted; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
*/ | ||
@Exported | ||
public interface UIInputComponent<IMPLTYPE, VALUETYPE> extends Faceted | ||
{ | ||
UICompleter<VALUETYPE> getCompleter(); | ||
|
||
String getLabel(); | ||
|
||
String getName(); | ||
|
||
Class<VALUETYPE> getValueType(); | ||
|
||
VALUETYPE getValue(); | ||
|
||
boolean isEnabled(); | ||
|
||
boolean isRequired(); | ||
|
||
IMPLTYPE setCompleter(UICompleter<VALUETYPE> completer); | ||
|
||
IMPLTYPE setDefaultValue(VALUETYPE value); | ||
|
||
IMPLTYPE setDefaultValue(Callable<VALUETYPE> callback); | ||
|
||
IMPLTYPE setEnabled(boolean b); | ||
|
||
IMPLTYPE setEnabled(Callable<Boolean> callable); | ||
|
||
IMPLTYPE setLabel(String label); | ||
|
||
IMPLTYPE setRequired(boolean required); | ||
|
||
IMPLTYPE setRequired(Callable<Boolean> required); | ||
|
||
IMPLTYPE setValue(VALUETYPE value); | ||
} |
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
171 changes: 171 additions & 0 deletions
171
ui/impl/src/main/java/org/jboss/forge/ui/impl/UIInputComponentBase.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,171 @@ | ||
/* | ||
* Copyright 2012 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; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
import javax.enterprise.inject.Vetoed; | ||
|
||
import org.jboss.forge.facets.BaseFaceted; | ||
import org.jboss.forge.facets.Facet; | ||
import org.jboss.forge.ui.UICompleter; | ||
import org.jboss.forge.ui.UIInput; | ||
import org.jboss.forge.ui.UIInputComponent; | ||
import org.jboss.forge.ui.facets.HintsFacet; | ||
import org.jboss.forge.ui.util.Callables; | ||
|
||
/** | ||
* Implementation of a {@link UIInput} object | ||
* | ||
* @author <a href="mailto:ggastald@redhat.com">George Gastaldi</a> | ||
* | ||
* @param <VALUETYPE> | ||
*/ | ||
@Vetoed | ||
public abstract class UIInputComponentBase<IMPLTYPE extends UIInputComponent<IMPLTYPE, VALUETYPE>, VALUETYPE> extends BaseFaceted | ||
implements UIInputComponent<IMPLTYPE, VALUETYPE> | ||
{ | ||
private final String name; | ||
private final Class<VALUETYPE> type; | ||
|
||
private String label; | ||
private Callable<Boolean> enabled; | ||
private VALUETYPE value; | ||
private Callable<Boolean> required; | ||
private Callable<VALUETYPE> defaultValue; | ||
private UICompleter<VALUETYPE> completer; | ||
|
||
@SuppressWarnings("unchecked") | ||
public UIInputComponentBase(String name, Class<?> type) | ||
{ | ||
this.name = name; | ||
this.type = (Class<VALUETYPE>) type; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public UICompleter<VALUETYPE> getCompleter() | ||
{ | ||
return this.completer == null ? new NoopCompleter() : this.completer; | ||
} | ||
|
||
@Override | ||
public String getLabel() | ||
{ | ||
return label; | ||
} | ||
|
||
@Override | ||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
@Override | ||
public VALUETYPE getValue() | ||
{ | ||
return (value == null) ? Callables.call(defaultValue) : value; | ||
} | ||
|
||
@Override | ||
public Class<VALUETYPE> getValueType() | ||
{ | ||
return type; | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() | ||
{ | ||
return Callables.call(enabled); | ||
} | ||
|
||
@Override | ||
public boolean isRequired() | ||
{ | ||
return Callables.call(required); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setCompleter(UICompleter<VALUETYPE> completer) | ||
{ | ||
this.completer = completer; | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setDefaultValue(Callable<VALUETYPE> callback) | ||
{ | ||
this.defaultValue = callback; | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setDefaultValue(VALUETYPE value) | ||
{ | ||
this.defaultValue = Callables.returning(value); | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setEnabled(boolean enabled) | ||
{ | ||
this.enabled = Callables.returning(enabled); | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setEnabled(Callable<Boolean> callback) | ||
{ | ||
enabled = callback; | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setLabel(String label) | ||
{ | ||
this.label = label; | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setRequired(boolean required) | ||
{ | ||
this.required = Callables.returning(required); | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setRequired(Callable<Boolean> required) | ||
{ | ||
this.required = required; | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public IMPLTYPE setValue(VALUETYPE value) | ||
{ | ||
this.value = value; | ||
return (IMPLTYPE) this; | ||
} | ||
|
||
@Override | ||
public boolean supports(Class<? extends Facet<?>> type) | ||
{ | ||
return HintsFacet.class.isAssignableFrom(type); | ||
} | ||
|
||
} |
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
Oops, something went wrong.