Search in sources :

Example 1 with InvalidationListener

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());
}
Also used : SelectedIndexProperty(com.android.tools.idea.ui.properties.swing.SelectedIndexProperty) InvalidationListener(com.android.tools.idea.ui.properties.InvalidationListener) ActivityTemplate(com.android.tools.idea.wizard.model.demo.npw.android.ActivityTemplate)

Example 2 with InvalidationListener

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()));
        }
    });
}
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 3 with InvalidationListener

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;
}
Also used : ComboBox(com.intellij.openapi.ui.ComboBox) ObservableValue(com.android.tools.idea.ui.properties.ObservableValue) CollectionComboBoxModel(com.intellij.ui.CollectionComboBoxModel) InvalidationListener(com.android.tools.idea.ui.properties.InvalidationListener) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with InvalidationListener

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());
}
Also used : InvalidationListener(com.android.tools.idea.ui.properties.InvalidationListener) SelectedProperty(com.android.tools.idea.ui.properties.swing.SelectedProperty)

Aggregations

InvalidationListener (com.android.tools.idea.ui.properties.InvalidationListener)4 SelectedProperty (com.android.tools.idea.ui.properties.swing.SelectedProperty)2 ObservableValue (com.android.tools.idea.ui.properties.ObservableValue)1 BoolProperty (com.android.tools.idea.ui.properties.core.BoolProperty)1 StringProperty (com.android.tools.idea.ui.properties.core.StringProperty)1 FormatExpression (com.android.tools.idea.ui.properties.expressions.string.FormatExpression)1 EnabledProperty (com.android.tools.idea.ui.properties.swing.EnabledProperty)1 SelectedIndexProperty (com.android.tools.idea.ui.properties.swing.SelectedIndexProperty)1 TextProperty (com.android.tools.idea.ui.properties.swing.TextProperty)1 ActivityTemplate (com.android.tools.idea.wizard.model.demo.npw.android.ActivityTemplate)1 ComboBox (com.intellij.openapi.ui.ComboBox)1 CollectionComboBoxModel (com.intellij.ui.CollectionComboBoxModel)1 NotNull (org.jetbrains.annotations.NotNull)1