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());
}
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))));
}
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()));
}
});
}
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();
}
};
}
Aggregations