Search in sources :

Example 6 with StringValueProperty

use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.

the class BindingsManagerTest method releaseTwoWayDisconnectsTwoWayBindings.

@Test
public void releaseTwoWayDisconnectsTwoWayBindings() throws Exception {
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    StringValueProperty property1 = new StringValueProperty("First");
    StringValueProperty property2 = new StringValueProperty("Second");
    bindings.bindTwoWay(property1, property2);
    assertThat(property1.get()).isEqualTo("Second");
    bindings.releaseTwoWay(property1, property2);
    property1.set("Property1");
    assertThat(property2.get()).isEqualTo("Second");
    property2.set("Property2");
    assertThat(property1.get()).isEqualTo("Property1");
}
Also used : StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 7 with StringValueProperty

use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.

the class BindingsManagerTest method releaseDisconnectsOneWayBindings.

@Test
public void releaseDisconnectsOneWayBindings() throws Exception {
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    StringValueProperty property1 = new StringValueProperty("A");
    StringValueProperty property2 = new StringValueProperty("B");
    bindings.bind(property1, property2);
    assertThat(property1.get()).isEqualTo("B");
    bindings.release(property1);
    property2.set("Property2");
    assertThat(property1.get()).isEqualTo("B");
}
Also used : StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 8 with StringValueProperty

use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.

the class DeveloperServiceCreator method createContext.

@NotNull
private static ServiceContext createContext(@NotNull Module module) {
    String buildSystemId = getBuildSystemOperations(module.getProject()).getBuildSystemId();
    ServiceContext context = new ServiceContext(buildSystemId);
    String packageName = MergedManifest.get(module).getPackage();
    if (packageName != null) {
        context.putValue("packageName", new StringValueProperty(packageName));
    }
    AndroidPlatform platform = AndroidPlatform.getInstance(module);
    if (platform != null) {
        // Add the compileSdkVersion (or buildApiVersion) such that compatible dependencies are chosen
        AndroidVersion version = platform.getApiVersion();
        context.putValue(ATTR_BUILD_API, new IntValueProperty(version.getFeatureLevel()));
        context.putValue(ATTR_BUILD_API_STRING, new StringValueProperty(getBuildApiString(version)));
    }
    return context;
}
Also used : IntValueProperty(com.android.tools.idea.ui.properties.core.IntValueProperty) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) AndroidPlatform(org.jetbrains.android.sdk.AndroidPlatform) TemplateMetadata.getBuildApiString(com.android.tools.idea.templates.TemplateMetadata.getBuildApiString) AndroidVersion(com.android.sdklib.AndroidVersion) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with StringValueProperty

use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.

the class StringExpressionsTest method testFormatStringExpression.

@Test
public void testFormatStringExpression() throws Exception {
    IntValueProperty arg1 = new IntValueProperty(42);
    BoolValueProperty arg2 = new BoolValueProperty(true);
    StringValueProperty destValue = new StringValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(destValue, new FormatExpression("The answer is %1$s. Hitchhiker reference? %2$s", arg1, arg2));
    assertThat(destValue.get()).isEqualTo("The answer is 42. Hitchhiker reference? true");
    arg1.set(2);
    arg2.set(false);
    assertThat(destValue.get()).isEqualTo("The answer is 2. Hitchhiker reference? false");
}
Also used : IntValueProperty(com.android.tools.idea.ui.properties.core.IntValueProperty) BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) BoolValueProperty(com.android.tools.idea.ui.properties.core.BoolValueProperty) Test(org.junit.Test)

Example 10 with StringValueProperty

use of com.android.tools.idea.ui.properties.core.StringValueProperty in project android by JetBrains.

the class StringExpressionsTest method testTrimExpression.

@Test
public void testTrimExpression() throws Exception {
    StringValueProperty srcValue = new StringValueProperty();
    StringValueProperty destValue = new StringValueProperty();
    BindingsManager bindings = new BindingsManager(INVOKE_IMMEDIATELY_STRATEGY);
    bindings.bind(destValue, srcValue.trim());
    assertThat(destValue.get()).isEmpty();
    srcValue.set("    Preceded by whitespace");
    assertThat(destValue.get()).isEqualTo("Preceded by whitespace");
    srcValue.set(" Surrounded by whitespace ");
    assertThat(destValue.get()).isEqualTo("Surrounded by whitespace");
    srcValue.set("    ");
    assertThat(destValue.get()).isEmpty();
    srcValue.set(" \t  \n ");
    assertThat(destValue.get()).isEmpty();
}
Also used : BindingsManager(com.android.tools.idea.ui.properties.BindingsManager) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Aggregations

StringValueProperty (com.android.tools.idea.ui.properties.core.StringValueProperty)13 Test (org.junit.Test)12 BindingsManager (com.android.tools.idea.ui.properties.BindingsManager)4 BoolValueProperty (com.android.tools.idea.ui.properties.core.BoolValueProperty)4 IntValueProperty (com.android.tools.idea.ui.properties.core.IntValueProperty)3 StringProperty (com.android.tools.idea.ui.properties.core.StringProperty)2 AndroidVersion (com.android.sdklib.AndroidVersion)1 DomainToPackageExpression (com.android.tools.idea.npw.project.DomainToPackageExpression)1 TemplateMetadata.getBuildApiString (com.android.tools.idea.templates.TemplateMetadata.getBuildApiString)1 StringExpression (com.android.tools.idea.ui.properties.expressions.string.StringExpression)1 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)1 NotNull (org.jetbrains.annotations.NotNull)1