Search in sources :

Example 1 with TailingDebouncer

use of com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer in project azure-tools-for-java by Microsoft.

the class AzureComboBox method init.

protected void init() {
    this.loadingSpinner = new AzureComboBoxLoadingSpinner();
    this.inputEditor = new AzureComboBoxEditor();
    this.setEditable(true);
    this.setEditor(this.inputEditor);
    this.setRenderer(new SimpleListCellRenderer<>() {

        @Override
        public void customize(@Nonnull final JList<? extends T> l, final T t, final int i, final boolean b, final boolean b1) {
            setText(getItemText(t));
            setIcon(getItemIcon(t));
        }
    });
    if (isFilterable()) {
        this.addPopupMenuListener(new AzureComboBoxPopupMenuListener());
    }
    final TailingDebouncer valueDebouncer = new TailingDebouncer(() -> {
        @SuppressWarnings("unchecked") final ValueListener<T>[] listeners = this.listenerList.getListeners(ValueListener.class);
        for (final ValueListener<T> listener : listeners) {
            listener.onValueChanged(this.getValue());
        }
    }, DEBOUNCE_DELAY);
    this.addItemListener((e) -> {
        if (e.getStateChange() == ItemEvent.SELECTED) {
            this.refreshValue();
        }
    });
}
Also used : TailingDebouncer(com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer)

Example 2 with TailingDebouncer

use of com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer in project azure-tools-for-java by Microsoft.

the class SpringCloudAppConfigPanel method init.

private void init() {
    final TailingDebouncer debouncer = new TailingDebouncer(this::onDataChanged, 300);
    this.toggleStorage.addActionListener(e -> {
        toggleStorage("enable".equals(e.getActionCommand()));
        debouncer.debounce();
    });
    this.toggleEndpoint.addActionListener(e -> {
        toggleEndpoint("enable".equals(e.getActionCommand()));
        debouncer.debounce();
    });
    this.txtStorage.setBorder(JBUI.Borders.empty(0, 2));
    this.useJava8.addActionListener((e) -> debouncer.debounce());
    this.useJava11.addActionListener((e) -> debouncer.debounce());
    this.txtJvmOptions.getDocument().addDocumentListener(new DocumentAdapter() {

        @Override
        protected void textChanged(DocumentEvent documentEvent) {
            debouncer.debounce();
        }
    });
    this.envTable.addChangeListener((e) -> debouncer.debounce());
    this.numCpu.addActionListener((e) -> debouncer.debounce());
    this.numMemory.addActionListener((e) -> debouncer.debounce());
    this.numInstance.addChangeListener((e) -> debouncer.debounce());
}
Also used : TailingDebouncer(com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer) DocumentAdapter(com.intellij.ui.DocumentAdapter) DocumentEvent(javax.swing.event.DocumentEvent)

Aggregations

TailingDebouncer (com.microsoft.azure.toolkit.lib.common.utils.TailingDebouncer)2 DocumentAdapter (com.intellij.ui.DocumentAdapter)1 DocumentEvent (javax.swing.event.DocumentEvent)1