Java 类com.intellij.ui.AncestorListenerAdapter 实例源码

项目:educational-plugin    文件:StudyNewProjectPanel.java   
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();
      }
      Course selectedCourse = (Course)myCoursesComboBox.getSelectedItem();
      if (selectedCourse == null || selectedCourse.equals(Course.INVALID_COURSE)) {
        setError(CONNECTION_ERROR);
      }
    }
  });
}
项目:intellij-ce-playground    文件:SdkUpdaterConfigurable.java   
@Nullable
@Override
public JComponent createComponent() {
  AndroidSdkData data = AndroidSdkUtils.tryToChooseAndroidSdk();
  if (data == null) {
    JPanel errorPanel = new JPanel();
    errorPanel.add(new JBLabel("Failed to find android sdk"));
    return errorPanel;
  }
  final Runnable channelChangedCallback = new Runnable() {
    @Override
    public void run() {
      boolean newIncludePreview =
        SdkComponentSource.PREVIEW_CHANNEL.equals(UpdateSettings.getInstance().getExternalUpdateChannels().get(SdkComponentSource.NAME));
      if (newIncludePreview != myIncludePreview) {
        myIncludePreview = newIncludePreview;
        myPanel.setIncludePreview(myIncludePreview);
      }
    }
  };
  SdkState state = SdkState.getInstance(data);
  myPanel = new SdkUpdaterConfigPanel(state, channelChangedCallback);
  JComponent component = myPanel.getComponent();
  component.addAncestorListener(new AncestorListenerAdapter() {
    @Override
    public void ancestorAdded(AncestorEvent event) {
      channelChangedCallback.run();
    }
  });

  return myPanel.getComponent();
}
项目:tools-idea    文件:MultilanguageCodeStyleAbstractPanel.java   
@Override
protected void installPreviewPanel(final JPanel previewPanel) {
  if (getSettingsType() != LanguageCodeStyleSettingsProvider.SettingsType.LANGUAGE_SPECIFIC) {
    tabbedPane = new JBTabbedPane();
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
    Language[] langs = LanguageCodeStyleSettingsProvider.getLanguagesWithSharedPreview();
    if (langs.length == 0) return;
    for (Language lang : langs) {
      tabbedPane.addTab(getTabName(lang), createDummy());
    }
    tabbedPane.setComponentAt(0, getEditor().getComponent());
    myLangSelectionIndex = 0;
    if (myLanguage == null) {
      setPanelLanguage(langs[0]);
    }
    else {
      updatePreview(true);
    }
    tabbedPane.addChangeListener(new ChangeListener() {
      @Override
      public void stateChanged(ChangeEvent e) {
        onTabSelection((JTabbedPane)e.getSource());
      }
    });
    previewPanel.add(tabbedPane, BorderLayout.CENTER);
    previewPanel.addAncestorListener(new AncestorListenerAdapter() {
      @Override
      public void ancestorAdded(AncestorEvent event) {
        selectCurrentLanguageTab();
      }
    });
  }
  else {
    // If settings are language-specific
    previewPanel.add(getEditor().getComponent(), BorderLayout.CENTER);
    updatePreview(true);
  }
}
项目:intellij-ce-playground    文件:LanguagePanel.java   
public LanguagePanel(Project project, BaseInjection injection) {
  super(injection, project);
  $$$setupUI$$$();

  final String[] languageIDs = InjectedLanguage.getAvailableLanguageIDs();
  Arrays.sort(languageIDs);

  myLanguage.setModel(new DefaultComboBoxModel(languageIDs));
  myLanguage.setRenderer(new ColoredListCellRendererWrapper<String>() {
    final Set<String> IDs = new HashSet<String>(Arrays.asList(languageIDs));

    @Override
    protected void doCustomize(JList list, String s, int index, boolean selected, boolean hasFocus) {
      final SimpleTextAttributes attributes =
          IDs.contains(s) ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.ERROR_ATTRIBUTES;
      append(s, attributes);

      final Language language = InjectedLanguage.findLanguageById(s);
      if (language != null) {
        final FileType fileType = language.getAssociatedFileType();
        if (fileType != null) {
          setIcon(fileType.getIcon());
          append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          append("(" + fileType.getDescription() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
        }
      }
    }
  });
  myLanguage.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        updateHighlighters();
      }
    }
  });

  myRoot.addAncestorListener(new AncestorListenerAdapter() {
    @Override
    public void ancestorAdded(AncestorEvent event) {
      updateHighlighters();
    }
  });
}
项目:tools-idea    文件:LanguagePanel.java   
public LanguagePanel(Project project, BaseInjection injection) {
  super(injection, project);
  $$$setupUI$$$();

  final String[] languageIDs = InjectedLanguage.getAvailableLanguageIDs();
  Arrays.sort(languageIDs);

  myLanguage.setModel(new DefaultComboBoxModel(languageIDs));
  myLanguage.setRenderer(new ColoredListCellRendererWrapper<String>() {
    final Set<String> IDs = new HashSet<String>(Arrays.asList(languageIDs));

    @Override
    protected void doCustomize(JList list, String s, int index, boolean selected, boolean hasFocus) {
      final SimpleTextAttributes attributes =
          IDs.contains(s) ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.ERROR_ATTRIBUTES;
      append(s, attributes);

      final Language language = InjectedLanguage.findLanguageById(s);
      if (language != null) {
        final FileType fileType = language.getAssociatedFileType();
        if (fileType != null) {
          setIcon(fileType.getIcon());
          append(" ", SimpleTextAttributes.REGULAR_ATTRIBUTES);
          append("(" + fileType.getDescription() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
        }
      }
    }
  });
  myLanguage.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        updateHighlighters();
      }
    }
  });

  myRoot.addAncestorListener(new AncestorListenerAdapter() {
    @Override
    public void ancestorAdded(AncestorEvent event) {
      updateHighlighters();
    }
  });
}