Search in sources :

Example 1 with StringProperty

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

the class DomainToPackageExpressionTest method packageNameDeriverSantizesCompanyDomainKey.

@Test
public void packageNameDeriverSantizesCompanyDomainKey() {
    StringProperty companyDomain = new StringValueProperty("sub.exa-mple.com");
    StringProperty applicationName = new StringValueProperty("My&App");
    Expression<String> computedPackageName = new DomainToPackageExpression(companyDomain, applicationName);
    assertEquals("com.exa_mple.sub.myapp", computedPackageName.get());
    companyDomain.set("#.badstartchar.com");
    assertEquals("com.badstartchar.myapp", computedPackageName.get());
    companyDomain.set("TEST.ALLCAPS.COM");
    assertEquals("com.allcaps.test.myapp", computedPackageName.get());
    applicationName.set("#My $AppLICATION");
    assertEquals("com.allcaps.test.myapplication", computedPackageName.get());
}
Also used : DomainToPackageExpression(com.android.tools.idea.npw.project.DomainToPackageExpression) StringProperty(com.android.tools.idea.ui.properties.core.StringProperty) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Example 2 with StringProperty

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

the class AnyCheckedDemo method init.

public void init() {
    StringProperty yesNoText = new TextProperty(myYesNoLabel);
    myBindings.bind(yesNoText, new YesNoExpression(any(new SelectedProperty(myCheckBox1), new SelectedProperty(myCheckBox2), new SelectedProperty(myCheckBox3), new SelectedProperty(myCheckBox4))));
}
Also used : StringProperty(com.android.tools.idea.ui.properties.core.StringProperty) TextProperty(com.android.tools.idea.ui.properties.swing.TextProperty) SelectedProperty(com.android.tools.idea.ui.properties.swing.SelectedProperty)

Example 3 with StringProperty

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

the class SyncFieldsDemo method init.

public void init() {
    // Wrap UI elements in properties
    final StringProperty projectText = new TextProperty(myProjectNameField);
    final StringProperty activityText = new TextProperty(myActivityNameField);
    final BoolProperty isSynced = new SelectedProperty(mySyncActivityNameCheckBox);
    final BoolProperty createActivity = new SelectedProperty(myCreateActivityCheckBox);
    BoolProperty isActivityEnabled = new EnabledProperty(myActivityNameField);
    BoolProperty isLinkEnabled = new EnabledProperty(mySyncActivityNameCheckBox);
    projectText.set("MyProject");
    // Bind activityText <- nameExpression(projectText), but only if conditions are met
    final FormatExpression activityNameExpression = new FormatExpression("%1$sActivity", projectText);
    myBindings.bind(activityText, activityNameExpression, isSynced.and(createActivity));
    myBindings.bind(isActivityEnabled, createActivity);
    myBindings.bind(isLinkEnabled, createActivity);
    // Listen to activityText - if it is changed by the user and not its binding, break syncing!
    activityText.addListener(new InvalidationListener() {

        @Override
        public void onInvalidated(@NotNull ObservableValue<?> sender) {
            isSynced.set(activityText.get().equals(activityNameExpression.get()));
        }
    });
}
Also used : StringProperty(com.android.tools.idea.ui.properties.core.StringProperty) EnabledProperty(com.android.tools.idea.ui.properties.swing.EnabledProperty) InvalidationListener(com.android.tools.idea.ui.properties.InvalidationListener) BoolProperty(com.android.tools.idea.ui.properties.core.BoolProperty) TextProperty(com.android.tools.idea.ui.properties.swing.TextProperty) FormatExpression(com.android.tools.idea.ui.properties.expressions.string.FormatExpression) SelectedProperty(com.android.tools.idea.ui.properties.swing.SelectedProperty)

Example 4 with StringProperty

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

the class ExpressionTest method expressionsNeedAtLeastOneObservable.

@Test(expected = IllegalArgumentException.class)
public void expressionsNeedAtLeastOneObservable() throws Exception {
    final StringProperty value = new StringValueProperty();
    Expression expr = new // This should be "new StringExpression(value)"
    StringExpression() {

        @NotNull
        @Override
        public String get() {
            return value.get();
        }
    };
}
Also used : StringExpression(com.android.tools.idea.ui.properties.expressions.string.StringExpression) StringExpression(com.android.tools.idea.ui.properties.expressions.string.StringExpression) StringProperty(com.android.tools.idea.ui.properties.core.StringProperty) StringValueProperty(com.android.tools.idea.ui.properties.core.StringValueProperty) Test(org.junit.Test)

Aggregations

StringProperty (com.android.tools.idea.ui.properties.core.StringProperty)4 StringValueProperty (com.android.tools.idea.ui.properties.core.StringValueProperty)2 SelectedProperty (com.android.tools.idea.ui.properties.swing.SelectedProperty)2 TextProperty (com.android.tools.idea.ui.properties.swing.TextProperty)2 Test (org.junit.Test)2 DomainToPackageExpression (com.android.tools.idea.npw.project.DomainToPackageExpression)1 InvalidationListener (com.android.tools.idea.ui.properties.InvalidationListener)1 BoolProperty (com.android.tools.idea.ui.properties.core.BoolProperty)1 FormatExpression (com.android.tools.idea.ui.properties.expressions.string.FormatExpression)1 StringExpression (com.android.tools.idea.ui.properties.expressions.string.StringExpression)1 EnabledProperty (com.android.tools.idea.ui.properties.swing.EnabledProperty)1