Search in sources :

Example 1 with AncestorListenerAdapter

use of com.intellij.ui.AncestorListenerAdapter in project intellij-community by JetBrains.

the class StudyNewProjectPanel method initListeners.

private void initListeners() {
    myRefreshButton.addActionListener(new RefreshActionListener());
    myCoursesComboBox.addActionListener(new CourseSelectedListener());
    setupBrowseButton();
    addAncestorListener(new AncestorListenerAdapter() {

        @Override
        public void ancestorMoved(AncestorEvent event) {
            if (!isComboboxInitialized && isVisible()) {
                isComboboxInitialized = true;
                initCoursesCombobox();
            }
            CourseInfo selectedCourse = (CourseInfo) myCoursesComboBox.getSelectedItem();
            if (selectedCourse == null || selectedCourse.equals(CourseInfo.INVALID_COURSE)) {
                setError(CONNECTION_ERROR);
            }
        }
    });
}
Also used : AncestorListenerAdapter(com.intellij.ui.AncestorListenerAdapter) AncestorEvent(javax.swing.event.AncestorEvent) CourseInfo(com.jetbrains.edu.learning.courseFormat.CourseInfo)

Example 2 with AncestorListenerAdapter

use of com.intellij.ui.AncestorListenerAdapter in project android by JetBrains.

the class SdkUpdaterConfigurable method createComponent.

@Nullable
@Override
public JComponent createComponent() {
    myChannelChangedCallback = new Runnable() {

        @Override
        public void run() {
            Channel channel = StudioSettingsController.getInstance().getChannel();
            if (myCurrentChannel == null) {
                myCurrentChannel = channel;
            }
            if (!Objects.equal(channel, myCurrentChannel)) {
                myCurrentChannel = channel;
                myPanel.refresh();
            }
        }
    };
    myPanel = new SdkUpdaterConfigPanel(myChannelChangedCallback, new StudioDownloader(), StudioSettingsController.getInstance(), this);
    JComponent component = myPanel.getComponent();
    component.addAncestorListener(new AncestorListenerAdapter() {

        @Override
        public void ancestorAdded(AncestorEvent event) {
            myChannelChangedCallback.run();
        }
    });
    return myPanel.getComponent();
}
Also used : AncestorListenerAdapter(com.intellij.ui.AncestorListenerAdapter) AncestorEvent(javax.swing.event.AncestorEvent) StudioDownloader(com.android.tools.idea.sdk.StudioDownloader) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AncestorListenerAdapter (com.intellij.ui.AncestorListenerAdapter)2 AncestorEvent (javax.swing.event.AncestorEvent)2 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)1 CourseInfo (com.jetbrains.edu.learning.courseFormat.CourseInfo)1 Nullable (org.jetbrains.annotations.Nullable)1