use of com.android.tools.idea.ui.properties.InvalidationListener in project android by JetBrains.
the class ChooseActivityStep method onWizardStarting.
@Override
protected void onWizardStarting(@NotNull final ModelWizard.Facade wizard) {
myListeners.listen(new SelectedIndexProperty(myTargetActivityComboBox), new InvalidationListener() {
@Override
public void onInvalidated(@NotNull ObservableValue<?> sender) {
ActivityTemplate targetTemplate = (ActivityTemplate) myTargetActivityComboBox.getSelectedItem();
// Set the target template in the model immediately (instead of waiting until
// onProceeding), since whether this is set or not affects if later steps show up.
getModel().setTargetTemplate(targetTemplate);
wizard.updateNavigationProperties();
}
});
myTargetActivityComboBox.setSelectedItem(getModel().getTargetTemplate());
}
use of com.android.tools.idea.ui.properties.InvalidationListener 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.InvalidationListener in project android by JetBrains.
the class ServicePanelBuilder method addComboBox.
public JComboBox addComboBox(@NotNull final ObservableList<String> backingList) {
final CollectionComboBoxModel<String> model = new CollectionComboBoxModel<String>(backingList) {
@NotNull
@Override
public List<String> getItems() {
return backingList;
}
};
final ComboBox comboBox = new ComboBox(model);
InvalidationListener onListModified = new InvalidationListener() {
@Override
public void onInvalidated(@NotNull ObservableValue<?> sender) {
model.update();
if (backingList.size() > 0 && comboBox.getSelectedIndex() < 0) {
comboBox.setSelectedIndex(0);
}
}
};
addComponent(comboBox);
backingList.addWeakListener(onListModified);
// Keep weak listener alive as long as the combobox is alive
comboBox.putClientProperty("onListModified", onListModified);
return comboBox;
}
use of com.android.tools.idea.ui.properties.InvalidationListener in project android by JetBrains.
the class LicenseAgreementStep method initUI.
private void initUI() {
myChangeTree.setModel(myTreeModel);
myChangeTree.setShowsRootHandles(false);
myLicenseTextField.setEditable(false);
final SelectedProperty accepted = new SelectedProperty(myAcceptRadioButton);
accepted.addListener(new InvalidationListener() {
@Override
public void onInvalidated(@NotNull ObservableValue<?> sender) {
myAcceptances.put(myCurrentLicense, accepted.get());
checkAllLicensesAreAccepted();
myChangeTree.repaint();
}
});
myChangeTree.addTreeSelectionListener(createTreeSelectionListener());
myChangeTree.setCellRenderer(createCellRenderer());
setChanges(createChangesList());
}
Aggregations