diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java index 69910417c7f3..88a23eea3428 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java @@ -35,6 +35,7 @@ import com.intellij.psi.codeStyle.CodeStyleManager; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable; import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider; +import com.intellij.ui.AncestorListenerAdapter; import com.intellij.ui.components.JBTabbedPane; import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; @@ -46,7 +47,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.*; @@ -236,21 +236,11 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr } }); previewPanel.add(tabbedPane, BorderLayout.CENTER); - previewPanel.addAncestorListener(new AncestorListener() { + previewPanel.addAncestorListener(new AncestorListenerAdapter() { @Override public void ancestorAdded(AncestorEvent event) { selectCurrentLanguageTab(); } - - @Override - public void ancestorRemoved(AncestorEvent event) { - // Do nothing - } - - @Override - public void ancestorMoved(AncestorEvent event) { - // Do nothing - } }); } else { diff --git a/platform/platform-api/src/com/intellij/ui/AncestorListenerAdapter.java b/platform/platform-api/src/com/intellij/ui/AncestorListenerAdapter.java new file mode 100644 index 000000000000..604e70c1079c --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/AncestorListenerAdapter.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui; + +import javax.swing.event.AncestorEvent; +import javax.swing.event.AncestorListener; + +public abstract class AncestorListenerAdapter implements AncestorListener { + @Override + public void ancestorAdded(AncestorEvent event) { + } + + @Override + public void ancestorRemoved(AncestorEvent event) { + } + + @Override + public void ancestorMoved(AncestorEvent event) { + } +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java index 66efacdd5347..6db8dc7e82ab 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLogToolWindowFactory.java @@ -31,12 +31,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.SimpleToolWindowPanel; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowFactory; +import com.intellij.ui.AncestorListenerAdapter; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; import org.jetbrains.annotations.NonNls; import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; /** * @author peter @@ -143,7 +143,7 @@ public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware { } } - private static class LogShownTracker implements AncestorListener { + private static class LogShownTracker extends AncestorListenerAdapter { private final Project myProject; public LogShownTracker(Project project) { @@ -157,13 +157,5 @@ public class EventLogToolWindowFactory implements ToolWindowFactory, DumbAware { EventLog.getLogModel(myProject).logShown(); } } - - @Override - public void ancestorRemoved(AncestorEvent event) { - } - - @Override - public void ancestorMoved(AncestorEvent event) { - } } } diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java index c029af24256d..ec92040f4a77 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java @@ -24,6 +24,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter; import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; +import com.intellij.ui.AncestorListenerAdapter; import com.intellij.ui.ColoredListCellRendererWrapper; import com.intellij.ui.EditorTextField; import com.intellij.ui.SimpleTextAttributes; @@ -33,7 +34,6 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Arrays; @@ -75,6 +75,7 @@ public class LanguagePanel extends AbstractInjectionPanel { } }); myLanguage.addItemListener(new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { updateHighlighters(); @@ -82,16 +83,11 @@ public class LanguagePanel extends AbstractInjectionPanel { } }); - myRoot.addAncestorListener(new AncestorListener() { + myRoot.addAncestorListener(new AncestorListenerAdapter() { + @Override public void ancestorAdded(AncestorEvent event) { updateHighlighters(); } - - public void ancestorRemoved(AncestorEvent event) { - } - - public void ancestorMoved(AncestorEvent event) { - } }); } @@ -149,18 +145,21 @@ public class LanguagePanel extends AbstractInjectionPanel { } } + @Override protected void resetImpl() { setLanguage(myOrigInjection.getInjectedLanguageId()); setPrefix(myOrigInjection.getPrefix()); setSuffix(myOrigInjection.getSuffix()); } + @Override protected void apply(BaseInjection i) { i.setInjectedLanguageId(getLanguage()); i.setPrefix(getPrefix()); i.setSuffix(getSuffix()); } + @Override public JPanel getComponent() { return myRoot; }