use of org.apache.tapestry5.Binding in project Aliucord by Aliucord.
the class ConfirmDialog method onViewBound.
@Override
public void onViewBound(View view) {
super.onViewBound(view);
binding = WidgetLeaveGuildDialog$binding$2.INSTANCE.invoke(view);
LoadingButton okButton = getOKButton();
okButton.setText("OK");
okButton.setIsLoading(false);
okButton.setOnClickListener(onOkListener != null ? onOkListener : e -> dismiss());
var btnColor = isDangerous ? R.c.uikit_btn_bg_color_selector_red : R.c.uikit_btn_bg_color_selector_brand;
okButton.setBackgroundColor(ContextCompat.getColor(view.getContext(), btnColor));
getCancelButton().setOnClickListener(onCancelListener != null ? onCancelListener : e -> dismiss());
getHeader().setText(title != null ? title : "Confirm");
getBody().setText(description != null ? description : "Are you sure?");
getBody().setMovementMethod(LinkMovementMethod.getInstance());
}
use of org.apache.tapestry5.Binding in project flytekit-java by flyteorg.
the class ProtoUtilTest method createNode.
private Node createNode(String id) {
String taskName = "task-" + id;
String version = "version-" + id;
String input_name = "input-name-" + id;
String input_scalar = "input-scalar-" + id;
TaskNode taskNode = TaskNode.builder().referenceId(PartialTaskIdentifier.builder().domain(DOMAIN).project(PROJECT).name(taskName).version(version).build()).build();
List<Binding> inputs = singletonList(Binding.builder().var_(input_name).binding(BindingData.ofScalar(Scalar.ofPrimitive(Primitive.ofStringValue(input_scalar)))).build());
return Node.builder().id(id).taskNode(taskNode).inputs(inputs).upstreamNodeIds(emptyList()).build();
}
use of org.apache.tapestry5.Binding in project tapestry-5 by apache.
the class PageElementFactoryImpl method parseAttributeExpansionExpression.
private StringProvider parseAttributeExpansionExpression(String expression, ComponentResources resources, final Location location) {
final List<StringProvider> providers = newList();
int startx = 0;
while (true) {
int expansionx = expression.indexOf(InternalConstants.EXPANSION_START, startx);
if (expansionx < 0) {
if (startx < expression.length())
providers.add(new LiteralStringProvider(expression.substring(startx)));
break;
}
if (startx != expansionx)
providers.add(new LiteralStringProvider(expression.substring(startx, expansionx)));
int endx = expression.indexOf("}", expansionx);
if (endx < 0)
throw new TapestryException(String.format("Attribute expression '%s' is missing a closing brace.", expression), location, null);
String expansion = expression.substring(expansionx + 2, endx);
final Binding binding = bindingSource.newBinding("attribute expansion", resources, resources, BindingConstants.PROP, expansion, location);
final StringProvider provider = new StringProvider() {
public String provideString() {
try {
Object raw = binding.get();
return typeCoercer.coerce(raw, String.class);
} catch (Exception ex) {
throw new TapestryException(ex.getMessage(), location, ex);
}
}
};
providers.add(provider);
// Restart the search after '}'
startx = endx + 1;
}
if (providers.size() == 1)
return providers.get(0);
return new StringProvider() {
public String provideString() {
StringBuilder builder = new StringBuilder();
for (StringProvider provider : providers) builder.append(provider.provideString());
return builder.toString();
}
};
}
use of org.apache.tapestry5.Binding in project tapestry-5 by apache.
the class BindingSourceImplTest method expression_has_no_prefix.
@Test
public void expression_has_no_prefix() {
BindingFactory factory = mockBindingFactory();
Binding binding = mockBinding();
ComponentResources container = mockComponentResources();
ComponentResources component = mockComponentResources();
Location l = mockLocation();
String defaultPrefix = "def";
String description = "descrip";
String expression = "full expression";
train_newBinding(factory, description, container, component, expression, l, binding);
replay();
Map<String, BindingFactory> map = newMap();
map.put(defaultPrefix, factory);
BindingSource source = new BindingSourceImpl(map, interner);
Binding actual = source.newBinding(description, container, component, defaultPrefix, expression, l);
assertSame(actual, binding);
verify();
}
use of org.apache.tapestry5.Binding in project tapestry-5 by apache.
the class BindingSourceImplTest method expression_prefix_not_in_configuration.
@Test
public void expression_prefix_not_in_configuration() {
BindingFactory factory = mockBindingFactory();
Binding binding = mockBinding();
ComponentResources container = mockComponentResources();
ComponentResources component = mockComponentResources();
Location l = mockLocation();
String defaultPrefix = "def";
String description = "descrip";
String expression = "javascript:not-a-known-prefix";
train_newBinding(factory, description, container, component, expression, l, binding);
replay();
Map<String, BindingFactory> map = newMap();
map.put(defaultPrefix, factory);
BindingSource source = new BindingSourceImpl(map, interner);
Binding actual = source.newBinding(description, container, component, defaultPrefix, expression, l);
assertSame(actual, binding);
verify();
}
Aggregations