Search in sources :

Example 21 with Binding

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());
}
Also used : AppDialog(com.discord.app.AppDialog) LinearLayout(android.widget.LinearLayout) Utils(com.aliucord.Utils) TextView(android.widget.TextView) MaterialButton(com.google.android.material.button.MaterialButton) View(android.view.View) LinkMovementMethod(android.text.method.LinkMovementMethod) LeaveGuildDialogBinding(com.discord.databinding.LeaveGuildDialogBinding) ContextCompat(androidx.core.content.ContextCompat) LoadingButton(com.discord.views.LoadingButton) R(com.lytefast.flexinput.R) WidgetLeaveGuildDialog$binding$2(com.discord.widgets.guilds.leave.WidgetLeaveGuildDialog$binding$2) LoadingButton(com.discord.views.LoadingButton)

Example 22 with Binding

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();
}
Also used : Binding(org.flyte.api.v1.Binding) TaskNode(org.flyte.api.v1.TaskNode) Matchers.containsString(org.hamcrest.Matchers.containsString)

Example 23 with Binding

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();
        }
    };
}
Also used : Binding(org.apache.tapestry5.Binding) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException)

Example 24 with Binding

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();
}
Also used : Binding(org.apache.tapestry5.Binding) BindingSource(org.apache.tapestry5.services.BindingSource) BindingFactory(org.apache.tapestry5.services.BindingFactory) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 25 with Binding

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();
}
Also used : Binding(org.apache.tapestry5.Binding) BindingSource(org.apache.tapestry5.services.BindingSource) BindingFactory(org.apache.tapestry5.services.BindingFactory) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Aggregations

Binding (com.google.iam.v1.Binding)71 Policy (com.google.iam.v1.Policy)68 Test (org.junit.Test)51 AbstractMessage (com.google.protobuf.AbstractMessage)47 Test (org.testng.annotations.Test)38 Binding (org.apache.tapestry5.Binding)34 ComponentResources (org.apache.tapestry5.ComponentResources)33 SetIamPolicyRequest (com.google.iam.v1.SetIamPolicyRequest)30 Location (org.apache.tapestry5.commons.Location)30 GetIamPolicyRequest (com.google.iam.v1.GetIamPolicyRequest)26 ResourceName (com.google.api.resourcenames.ResourceName)20 ByteString (com.google.protobuf.ByteString)20 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)12 InternalComponentResources (org.apache.tapestry5.internal.InternalComponentResources)10 BindingFactory (org.apache.tapestry5.services.BindingFactory)10 Component (org.apache.tapestry5.runtime.Component)8 CryptoKeyName (com.google.cloud.kms.v1.CryptoKeyName)6 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)6 InternalPropBinding (org.apache.tapestry5.internal.bindings.InternalPropBinding)6 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)6