Search in sources :

Example 1 with AncestorEvent

use of javax.swing.event.AncestorEvent 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 AncestorEvent

use of javax.swing.event.AncestorEvent 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)

Example 3 with AncestorEvent

use of javax.swing.event.AncestorEvent in project smile by haifengl.

the class PlotCanvas method initContextMenauAndToolBar.

/**
     * Initialize context menu and toolbar.
     */
private void initContextMenauAndToolBar() {
    toolbar = new JToolBar();
    toolbar.add(new Button(saveAction));
    toolbar.add(new Button(printAction));
    toolbar.addSeparator();
    toolbar.add(new Button(zoomInAction));
    toolbar.add(new Button(zoomOutAction));
    toolbar.add(new Button(resetAction));
    toolbar.addSeparator();
    toolbar.add(new Button(enlargePlotAreaAction));
    toolbar.add(new Button(shrinkPlotAreaAction));
    toolbar.add(new Button(increaseHeightAction));
    toolbar.add(new Button(decreaseHeightAction));
    toolbar.add(new Button(increaseWidthAction));
    toolbar.add(new Button(decreaseWidthAction));
    toolbar.addSeparator();
    toolbar.add(new Button(propertyAction));
    decreaseHeightAction.setEnabled(false);
    decreaseWidthAction.setEnabled(false);
    //Initialize popup menu.
    popup = new JPopupMenu();
    popup.add(new JMenuItem(saveAction));
    popup.add(new JMenuItem(printAction));
    popup.addSeparator();
    popup.add(new JMenuItem(zoomInAction));
    popup.add(new JMenuItem(zoomOutAction));
    popup.add(new JMenuItem(resetAction));
    popup.addSeparator();
    popup.add(new JMenuItem(enlargePlotAreaAction));
    popup.add(new JMenuItem(shrinkPlotAreaAction));
    popup.add(new JMenuItem(increaseHeightAction));
    popup.add(new JMenuItem(decreaseHeightAction));
    popup.add(new JMenuItem(increaseWidthAction));
    popup.add(new JMenuItem(decreaseWidthAction));
    popup.addSeparator();
    popup.add(new JMenuItem(propertyAction));
    AncestorListener ancestorListener = new AncestorListener() {

        @Override
        public void ancestorAdded(AncestorEvent ae) {
            boolean inScrollPane = false;
            Container parent = getParent();
            while (parent != null) {
                if (parent instanceof JScrollPane) {
                    inScrollPane = true;
                    scrollPane = (JScrollPane) parent;
                    break;
                }
                parent = parent.getParent();
            }
            increaseHeightAction.setEnabled(inScrollPane);
            increaseWidthAction.setEnabled(inScrollPane);
        }

        @Override
        public void ancestorRemoved(AncestorEvent ae) {
        }

        @Override
        public void ancestorMoved(AncestorEvent ae) {
        }
    };
    addAncestorListener(ancestorListener);
}
Also used : JScrollPane(javax.swing.JScrollPane) Container(java.awt.Container) Button(smile.swing.Button) JButton(javax.swing.JButton) AncestorListener(javax.swing.event.AncestorListener) JToolBar(javax.swing.JToolBar) JMenuItem(javax.swing.JMenuItem) AncestorEvent(javax.swing.event.AncestorEvent) JPopupMenu(javax.swing.JPopupMenu)

Example 4 with AncestorEvent

use of javax.swing.event.AncestorEvent in project intellij-elixir by KronicDeth.

the class ElixirCompilerOptionsConfigurable method setupUiListeners.

private void setupUiListeners() {
    myConfigureMixButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            DataContext context = DataManager.getInstance().getDataContext(myConfigureMixButton);
            Settings settings = ObjectUtils.assertNotNull(Settings.KEY.getData(context));
            Configurable configurable = settings.find(ElixirExternalToolsConfigurable.ELIXIR_RELATED_TOOLS);
            if (configurable != null) {
                settings.select(configurable);
            }
        }
    });
    myRootPanel.addAncestorListener(new AncestorAdapter() {

        @Override
        public void ancestorAdded(AncestorEvent event) {
            reset();
        }
    });
}
Also used : DataContext(com.intellij.openapi.actionSystem.DataContext) AncestorAdapter(org.elixir_lang.utils.AncestorAdapter) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) CompilerConfigurable(com.intellij.compiler.options.CompilerConfigurable) ElixirExternalToolsConfigurable(org.elixir_lang.settings.ElixirExternalToolsConfigurable) Configurable(com.intellij.openapi.options.Configurable) AncestorEvent(javax.swing.event.AncestorEvent) Settings(com.intellij.openapi.options.ex.Settings) MixSettings(org.elixir_lang.mix.settings.MixSettings)

Aggregations

AncestorEvent (javax.swing.event.AncestorEvent)4 AncestorListenerAdapter (com.intellij.ui.AncestorListenerAdapter)2 StudioDownloader (com.android.tools.idea.sdk.StudioDownloader)1 CompilerConfigurable (com.intellij.compiler.options.CompilerConfigurable)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Configurable (com.intellij.openapi.options.Configurable)1 Settings (com.intellij.openapi.options.ex.Settings)1 CourseInfo (com.jetbrains.edu.learning.courseFormat.CourseInfo)1 Container (java.awt.Container)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JButton (javax.swing.JButton)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JScrollPane (javax.swing.JScrollPane)1 JToolBar (javax.swing.JToolBar)1 AncestorListener (javax.swing.event.AncestorListener)1 MixSettings (org.elixir_lang.mix.settings.MixSettings)1 ElixirExternalToolsConfigurable (org.elixir_lang.settings.ElixirExternalToolsConfigurable)1 AncestorAdapter (org.elixir_lang.utils.AncestorAdapter)1