GitOrigin-RevId: 0cf2f327dee92b820f9d984593e99a3b2669b618
This commit is contained in:
Alexey Kudravtsev
2019-09-09 12:31:42 +00:00
committed by intellij-monorepo-bot
parent c36079d87c
commit 3cf5f1dff4
6 changed files with 127 additions and 147 deletions
@@ -28,7 +28,8 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* *
* @return the package statement, or null if one is missing. * @return the package statement, or null if one is missing.
*/ */
@Nullable PsiPackageStatement getPackageStatement(); @Nullable
PsiPackageStatement getPackageStatement();
/** /**
* Returns the name of the package to which the file belongs. * Returns the name of the package to which the file belongs.
@@ -37,14 +38,16 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* file which has no package statement. * file which has no package statement.
*/ */
@Override @Override
@NotNull String getPackageName(); @NotNull
String getPackageName();
/** /**
* Returns the import list contained in the file. * Returns the import list contained in the file.
* *
* @return the import list, or null if this element represents a compiled class. * @return the import list, or null if this element represents a compiled class.
*/ */
@Nullable PsiImportList getImportList(); @Nullable
PsiImportList getImportList();
/** /**
* Returns the list of classes or packages which have been * Returns the list of classes or packages which have been
@@ -54,7 +57,8 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* @param checkIncludes deprecated, no longer used * @param checkIncludes deprecated, no longer used
* @return the list of PsiClass or PsiPackage elements for the imports. * @return the list of PsiClass or PsiPackage elements for the imports.
*/ */
@NotNull PsiElement[] getOnDemandImports(boolean includeImplicit, @Deprecated boolean checkIncludes); @NotNull
PsiElement[] getOnDemandImports(boolean includeImplicit, @Deprecated boolean checkIncludes);
/** /**
* Returns the list of classes which have been imported as * Returns the list of classes which have been imported as
@@ -63,7 +67,8 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* @param checkIncludes deprecated, no longer used. * @param checkIncludes deprecated, no longer used.
* @return the list of PsiClass elements for the import. * @return the list of PsiClass elements for the import.
*/ */
@NotNull PsiClass[] getSingleClassImports(@Deprecated boolean checkIncludes); @NotNull
PsiClass[] getSingleClassImports(@Deprecated boolean checkIncludes);
/** /**
* Returns the list of names of implicitly imported packages * Returns the list of names of implicitly imported packages
@@ -71,7 +76,8 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* *
* @return the list of implicitly imported package names. * @return the list of implicitly imported package names.
*/ */
@NotNull String[] getImplicitlyImportedPackages(); @NotNull
String[] getImplicitlyImportedPackages();
/** /**
* returns the list of reference elements for the * returns the list of reference elements for the
@@ -79,7 +85,8 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* *
* @return the list of implicitly imported package reference elements. * @return the list of implicitly imported package reference elements.
*/ */
@NotNull PsiJavaCodeReferenceElement[] getImplicitlyImportedPackageReferences(); @NotNull
PsiJavaCodeReferenceElement[] getImplicitlyImportedPackageReferences();
/** /**
* Returns the single-class import statement which references * Returns the single-class import statement which references
@@ -88,12 +95,15 @@ public interface PsiJavaFile extends PsiImportHolder, PsiClassOwner {
* @param aClass the class to return the import statement for. * @param aClass the class to return the import statement for.
* @return the Java code reference under the import statement, or null if there is no such statement. * @return the Java code reference under the import statement, or null if there is no such statement.
*/ */
@Nullable PsiJavaCodeReferenceElement findImportReferenceTo(PsiClass aClass); @Nullable
PsiJavaCodeReferenceElement findImportReferenceTo(PsiClass aClass);
@NotNull LanguageLevel getLanguageLevel(); @NotNull
LanguageLevel getLanguageLevel();
/** /**
* Returns a Java module declaration element, or {@code null} if the file is not a module-info one. * Returns a Java module declaration element, or {@code null} if the file is not a module-info one.
*/ */
@Nullable PsiJavaModule getModuleDeclaration(); @Nullable
PsiJavaModule getModuleDeclaration();
} }
@@ -27,6 +27,6 @@ public abstract class BaseExtensionPointName {
protected static <T> T findExtension(@NotNull BaseExtensionPointName pointName, @NotNull Class<T> instanceOf, @Nullable AreaInstance areaInstance, boolean isRequired) { protected static <T> T findExtension(@NotNull BaseExtensionPointName pointName, @NotNull Class<T> instanceOf, @Nullable AreaInstance areaInstance, boolean isRequired) {
ExtensionPointImpl<T> point = ((ExtensionsAreaImpl)(areaInstance == null ? Extensions.getRootArea() : areaInstance.getExtensionArea())).getExtensionPoint(pointName.getName()); ExtensionPointImpl<T> point = ((ExtensionsAreaImpl)(areaInstance == null ? Extensions.getRootArea() : areaInstance.getExtensionArea())).getExtensionPoint(pointName.getName());
// find by isAssignableFrom to preserve old behaviour // find by isAssignableFrom to preserve old behaviour
return point.findExtension(instanceOf, isRequired, /* strictMatch = */ false); return point.findExtension(instanceOf, isRequired, false);
} }
} }
@@ -22,7 +22,6 @@ import com.intellij.util.concurrency.EdtExecutorService;
import com.intellij.util.concurrency.SequentialTaskExecutor; import com.intellij.util.concurrency.SequentialTaskExecutor;
import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.EmptyIcon;
import com.intellij.util.ui.JBCachingScalableIcon; import com.intellij.util.ui.JBCachingScalableIcon;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.tree.TreeUtil; import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -46,7 +45,7 @@ public class DeferredIconImpl<T> extends JBCachingScalableIcon<DeferredIconImpl<
private Function<? super T, ? extends Icon> myEvaluator; private Function<? super T, ? extends Icon> myEvaluator;
private volatile boolean myIsScheduled; private volatile boolean myIsScheduled;
private T myParam; private T myParam;
private static final Icon EMPTY_ICON = JBUI.scale(EmptyIcon.create(16)); private static final Icon EMPTY_ICON = EmptyIcon.create(16).withIconPreScaled(false);
private final boolean myNeedReadAction; private final boolean myNeedReadAction;
private boolean myDone; private boolean myDone;
private final boolean myAutoUpdatable; private final boolean myAutoUpdatable;
@@ -114,10 +113,10 @@ public class DeferredIconImpl<T> extends JBCachingScalableIcon<DeferredIconImpl<
private void checkDelegationDepth() { private void checkDelegationDepth() {
int depth = 0; int depth = 0;
DeferredIconImpl each = this; DeferredIconImpl<?> each = this;
while (each.myScaledDelegateIcon instanceof DeferredIconImpl && depth < 50) { while (each.myScaledDelegateIcon instanceof DeferredIconImpl && depth < 50) {
depth++; depth++;
each = (DeferredIconImpl)each.myScaledDelegateIcon; each = (DeferredIconImpl<?>)each.myScaledDelegateIcon;
} }
if (depth >= 50) { if (depth >= 50) {
LOG.error("Too deep deferred icon nesting"); LOG.error("Too deep deferred icon nesting");
@@ -131,7 +130,7 @@ public class DeferredIconImpl<T> extends JBCachingScalableIcon<DeferredIconImpl<
@Override @Override
public void paintIcon(final Component c, @NotNull final Graphics g, final int x, final int y) { public void paintIcon(final Component c, @NotNull final Graphics g, final int x, final int y) {
if (!(myScaledDelegateIcon instanceof DeferredIconImpl && ((DeferredIconImpl)myScaledDelegateIcon).myScaledDelegateIcon instanceof DeferredIconImpl)) { if (!(myScaledDelegateIcon instanceof DeferredIconImpl && ((DeferredIconImpl<?>)myScaledDelegateIcon).myScaledDelegateIcon instanceof DeferredIconImpl)) {
myScaledDelegateIcon.paintIcon(c, g, x, y); //SOE protection myScaledDelegateIcon.paintIcon(c, g, x, y); //SOE protection
} }
@@ -284,7 +283,7 @@ public class DeferredIconImpl<T> extends JBCachingScalableIcon<DeferredIconImpl<
} }
if (icon instanceof DeferredIconImpl) { if (icon instanceof DeferredIconImpl) {
checkDoesntReferenceThis(((DeferredIconImpl)icon).myScaledDelegateIcon); checkDoesntReferenceThis(((DeferredIconImpl<?>)icon).myScaledDelegateIcon);
} }
else if (icon instanceof LayeredIcon) { else if (icon instanceof LayeredIcon) {
for (Icon layer : ((LayeredIcon)icon).getAllLayers()) { for (Icon layer : ((LayeredIcon)icon).getAllLayers()) {
@@ -387,12 +386,12 @@ public class DeferredIconImpl<T> extends JBCachingScalableIcon<DeferredIconImpl<
static boolean equalIcons(Icon icon1, Icon icon2) { static boolean equalIcons(Icon icon1, Icon icon2) {
if (icon1 instanceof DeferredIconImpl && icon2 instanceof DeferredIconImpl) { if (icon1 instanceof DeferredIconImpl && icon2 instanceof DeferredIconImpl) {
return paramsEqual((DeferredIconImpl)icon1, (DeferredIconImpl)icon2); return paramsEqual((DeferredIconImpl<?>)icon1, (DeferredIconImpl<?>)icon2);
} }
return Comparing.equal(icon1, icon2); return Comparing.equal(icon1, icon2);
} }
private static boolean paramsEqual(@NotNull DeferredIconImpl icon1, @NotNull DeferredIconImpl icon2) { private static boolean paramsEqual(@NotNull DeferredIconImpl<?> icon1, @NotNull DeferredIconImpl<?> icon2) {
return Comparing.equal(icon1.myParam, icon2.myParam) && return Comparing.equal(icon1.myParam, icon2.myParam) &&
equalIcons(icon1.myScaledDelegateIcon, icon2.myScaledDelegateIcon); equalIcons(icon1.myScaledDelegateIcon, icon2.myScaledDelegateIcon);
} }
@@ -103,6 +103,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
myPreferredFocusableComponent = component; myPreferredFocusableComponent = component;
} }
@NotNull
public PropertyChangeSupport getChangeSupport() { public PropertyChangeSupport getChangeSupport() {
return myChangeSupport; return myChangeSupport;
} }
@@ -130,6 +131,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return attributes; return attributes;
} }
@NotNull
public TabInfo clearText(final boolean invalidate) { public TabInfo clearText(final boolean invalidate) {
final String old = myText.toString(); final String old = myText.toString();
myText.clear(); myText.clear();
@@ -139,6 +141,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return this; return this;
} }
@NotNull
public TabInfo append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes) { public TabInfo append(@NotNull String fragment, @NotNull SimpleTextAttributes attributes) {
final String old = myText.toString(); final String old = myText.toString();
myText.append(fragment, attributes); myText.append(fragment, attributes);
@@ -156,11 +159,13 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return this; return this;
} }
@NotNull
public TabInfo setComponent(Component c) { public TabInfo setComponent(Component c) {
if (myComponent == c) return this; if (myComponent != c) {
JComponent old = myComponent; JComponent old = myComponent;
myComponent = (JComponent)c; myComponent = (JComponent)c;
myChangeSupport.firePropertyChange(COMPONENT, old, myComponent); myChangeSupport.firePropertyChange(COMPONENT, old, myComponent);
}
return this; return this;
} }
@@ -172,10 +177,12 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myComponent; return myComponent;
} }
@NotNull
public String getText() { public String getText() {
return myText.toString(); return myText.toString();
} }
@NotNull
public SimpleColoredText getColoredText() { public SimpleColoredText getColoredText() {
return myText; return myText;
} }
@@ -189,6 +196,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myPlace; return myPlace;
} }
@NotNull
public TabInfo setSideComponent(JComponent comp) { public TabInfo setSideComponent(JComponent comp) {
mySideComponent = comp; mySideComponent = comp;
return this; return this;
@@ -198,6 +206,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return mySideComponent; return mySideComponent;
} }
@NotNull
public TabInfo setActions(ActionGroup group, String place) { public TabInfo setActions(ActionGroup group, String place) {
ActionGroup old = myGroup; ActionGroup old = myGroup;
myGroup = group; myGroup = group;
@@ -206,6 +215,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return this; return this;
} }
@NotNull
public TabInfo setActionsContextComponent(JComponent c) { public TabInfo setActionsContextComponent(JComponent c) {
myActionsContextComponent = c; myActionsContextComponent = c;
return this; return this;
@@ -215,6 +225,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myActionsContextComponent; return myActionsContextComponent;
} }
@NotNull
public TabInfo setObject(final Object object) { public TabInfo setObject(final Object object) {
myObject = object; myObject = object;
return this; return this;
@@ -228,6 +239,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myPreferredFocusableComponent != null ? myPreferredFocusableComponent : myComponent; return myPreferredFocusableComponent != null ? myPreferredFocusableComponent : myComponent;
} }
@NotNull
public TabInfo setPreferredFocusableComponent(final JComponent component) { public TabInfo setPreferredFocusableComponent(final JComponent component) {
myPreferredFocusableComponent = component; myPreferredFocusableComponent = component;
return this; return this;
@@ -245,6 +257,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myTabActionPlace; return myTabActionPlace;
} }
@NotNull
public TabInfo setTabLabelActions(final ActionGroup tabActions, @NotNull String place) { public TabInfo setTabLabelActions(final ActionGroup tabActions, @NotNull String place) {
ActionGroup old = myTabLabelActions; ActionGroup old = myTabLabelActions;
myTabLabelActions = tabActions; myTabLabelActions = tabActions;
@@ -258,6 +271,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return SoftReference.dereference(myLastFocusOwner); return SoftReference.dereference(myLastFocusOwner);
} }
@NotNull
public TabInfo setAlertIcon(final AlertIcon alertIcon) { public TabInfo setAlertIcon(final AlertIcon alertIcon) {
AlertIcon old = myAlertIcon; AlertIcon old = myAlertIcon;
myAlertIcon = alertIcon; myAlertIcon = alertIcon;
@@ -288,6 +302,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return getText(); return getText();
} }
@NotNull
public AlertIcon getAlertIcon() { public AlertIcon getAlertIcon() {
return myAlertIcon == null ? DEFAULT_ALERT_ICON : myAlertIcon; return myAlertIcon == null ? DEFAULT_ALERT_ICON : myAlertIcon;
} }
@@ -320,6 +335,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myEnabled; return myEnabled;
} }
@NotNull
public TabInfo setDefaultStyle(@SimpleTextAttributes.StyleAttributeConstant int style) { public TabInfo setDefaultStyle(@SimpleTextAttributes.StyleAttributeConstant int style) {
myDefaultStyle = style; myDefaultStyle = style;
myDefaultAttributes = null; myDefaultAttributes = null;
@@ -327,6 +343,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return this; return this;
} }
@NotNull
public TabInfo setDefaultForeground(final Color fg) { public TabInfo setDefaultForeground(final Color fg) {
myDefaultForeground = fg; myDefaultForeground = fg;
myDefaultAttributes = null; myDefaultAttributes = null;
@@ -338,6 +355,7 @@ public final class TabInfo implements Queryable, PlaceProvider<String> {
return myDefaultForeground; return myDefaultForeground;
} }
@NotNull
public TabInfo setDefaultWaveColor(final Color waveColor) { public TabInfo setDefaultWaveColor(final Color waveColor) {
myDefaultWaveColor = waveColor; myDefaultWaveColor = waveColor;
myDefaultAttributes = null; myDefaultAttributes = null;
@@ -15,7 +15,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPane;
import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.openapi.wm.IdeGlassPaneUtil;
import com.intellij.ui.Gray;
import com.intellij.ui.GuiUtils; import com.intellij.ui.GuiUtils;
import com.intellij.ui.ScreenUtil; import com.intellij.ui.ScreenUtil;
import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.awt.RelativePoint;
@@ -57,9 +56,8 @@ public class JBTabsImpl extends JComponent
@NonNls public static final Key<Integer> SIDE_TABS_SIZE_LIMIT_KEY = Key.create("SIDE_TABS_SIZE_LIMIT_KEY"); @NonNls public static final Key<Integer> SIDE_TABS_SIZE_LIMIT_KEY = Key.create("SIDE_TABS_SIZE_LIMIT_KEY");
static final int MIN_TAB_WIDTH = JBUIScale.scale(75); static final int MIN_TAB_WIDTH = JBUIScale.scale(75);
public static final int DEFAULT_MAX_TAB_WIDTH = JBUIScale.scale(300); static final int DEFAULT_MAX_TAB_WIDTH = JBUIScale.scale(300);
public static final Color MAC_AQUA_BG_COLOR = Gray._200;
private static final Comparator<TabInfo> ABC_COMPARATOR = (o1, o2) -> StringUtil.naturalCompare(o1.getText(), o2.getText()); private static final Comparator<TabInfo> ABC_COMPARATOR = (o1, o2) -> StringUtil.naturalCompare(o1.getText(), o2.getText());
@NotNull final ActionManager myActionManager; @NotNull final ActionManager myActionManager;
@@ -114,10 +112,10 @@ public class JBTabsImpl extends JComponent
private boolean myPaintFocus; private boolean myPaintFocus;
private boolean myHideTabs = false; private boolean myHideTabs;
@Nullable private Project myProject; @Nullable private Project myProject;
private boolean myRequestFocusOnLastFocusedComponent = false; private boolean myRequestFocusOnLastFocusedComponent;
private boolean myListenerAdded; private boolean myListenerAdded;
final Set<TabInfo> myAttractions = new HashSet<>(); final Set<TabInfo> myAttractions = new HashSet<>();
private final Animator myAnimator; private final Animator myAnimator;
@@ -162,12 +160,12 @@ public class JBTabsImpl extends JComponent
private Runnable myDeferredFocusRequest; private Runnable myDeferredFocusRequest;
private int myFirstTabOffset; private int myFirstTabOffset;
protected final TabPainterAdapter myTabPainterAdapter = createTabPainterAdapter(); private final TabPainterAdapter myTabPainterAdapter = createTabPainterAdapter();
protected final JBTabPainter myTabPainter = myTabPainterAdapter.getTabPainter(); protected final JBTabPainter myTabPainter = myTabPainterAdapter.getTabPainter();
private boolean myAlphabeticalMode = false; private boolean myAlphabeticalMode;
private boolean mySupportsCompression = false; private boolean mySupportsCompression;
private String myEmptyText = null; private String myEmptyText;
private boolean myMouseInsideTabsArea = false; private boolean myMouseInsideTabsArea;
protected JBTabsBorder createTabBorder() { protected JBTabsBorder createTabBorder() {
return new JBDefaultTabsBorder(this); return new JBDefaultTabsBorder(this);
@@ -177,7 +175,7 @@ public class JBTabsImpl extends JComponent
return myTabPainter; return myTabPainter;
} }
public TabPainterAdapter getTabPainterAdapter() { TabPainterAdapter getTabPainterAdapter() {
return myTabPainterAdapter; return myTabPainterAdapter;
} }
@@ -269,7 +267,7 @@ public class JBTabsImpl extends JComponent
MouseEvent me = (MouseEvent)event; MouseEvent me = (MouseEvent)event;
Point point = me.getPoint(); Point point = me.getPoint();
SwingUtilities.convertPointToScreen(point, me.getComponent()); SwingUtilities.convertPointToScreen(point, me.getComponent());
Rectangle rect = JBTabsImpl.this.getVisibleRect(); Rectangle rect = getVisibleRect();
rect = rect.intersection(mySingleRowLayout.myLastSingRowLayout.tabRectangle); rect = rect.intersection(mySingleRowLayout.myLastSingRowLayout.tabRectangle);
Point p = rect.getLocation(); Point p = rect.getLocation();
SwingUtilities.convertPointToScreen(p, JBTabsImpl.this); SwingUtilities.convertPointToScreen(p, JBTabsImpl.this);
@@ -289,13 +287,10 @@ public class JBTabsImpl extends JComponent
} }
}; };
Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_MOTION_EVENT_MASK); Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_MOTION_EVENT_MASK);
Disposer.register(this, new Disposable() { Disposer.register(this, () -> {
@Override Toolkit toolkit = Toolkit.getDefaultToolkit();
public void dispose() { if (toolkit != null) {
Toolkit toolkit = Toolkit.getDefaultToolkit(); toolkit.removeAWTEventListener(listener);
if (toolkit != null) {
toolkit.removeAWTEventListener(listener);
}
} }
}); });
@@ -322,12 +317,7 @@ public class JBTabsImpl extends JComponent
} }
Disposer.register(child, myAnimator); Disposer.register(child, myAnimator);
Disposer.register(child, new Disposable() { Disposer.register(child, () -> removeTimerUpdate());
@Override
public void dispose() {
removeTimerUpdate();
}
});
IdeGlassPane gp = IdeGlassPaneUtil.find(child); IdeGlassPane gp = IdeGlassPaneUtil.find(child);
myTabActionsAutoHideListenerDisposable = Disposer.newDisposable("myTabActionsAutoHideListener"); myTabActionsAutoHideListenerDisposable = Disposer.newDisposable("myTabActionsAutoHideListener");
@@ -335,12 +325,9 @@ public class JBTabsImpl extends JComponent
gp.addMouseMotionPreprocessor(myTabActionsAutoHideListener, myTabActionsAutoHideListenerDisposable); gp.addMouseMotionPreprocessor(myTabActionsAutoHideListener, myTabActionsAutoHideListenerDisposable);
myGlassPane = gp; myGlassPane = gp;
UIUtil.addAwtListener(new AWTEventListener() { UIUtil.addAwtListener(__ -> {
@Override if (mySingleRowLayout.myMorePopup != null) return;
public void eventDispatched(final AWTEvent event) { processFocusChange();
if (mySingleRowLayout.myMorePopup != null) return;
processFocusChange();
}
}, AWTEvent.FOCUS_EVENT_MASK, child); }, AWTEvent.FOCUS_EVENT_MASK, child);
myDragHelper = new DragHelper(child); myDragHelper = new DragHelper(child);
@@ -352,13 +339,9 @@ public class JBTabsImpl extends JComponent
} }
}; };
UIUtil.putClientProperty( UIUtil.putClientProperty(
this, UIUtil.NOT_IN_HIERARCHY_COMPONENTS, new Iterable<JComponent>() { this, UIUtil.NOT_IN_HIERARCHY_COMPONENTS,
@Override (Iterable<JComponent>)() -> JBIterable.from(getVisibleInfos()).filter(Conditions.not(Conditions.is(mySelectedInfo))).transform(
public Iterator<JComponent> iterator() { info -> info.getComponent()).iterator());
return JBIterable.from(getVisibleInfos()).filter(Conditions.not(Conditions.is(mySelectedInfo))).transform(
info -> info.getComponent()).iterator();
}
});
} }
public boolean isMouseInsideTabsArea() { public boolean isMouseInsideTabsArea() {
@@ -421,7 +404,7 @@ public class JBTabsImpl extends JComponent
} }
} }
public void unHover(TabLabel label) { void unHover(TabLabel label) {
if(tabLabelAtMouse == label) { if(tabLabelAtMouse == label) {
tabLabelAtMouse = null; tabLabelAtMouse = null;
label.repaint(); label.repaint();
@@ -441,7 +424,7 @@ public class JBTabsImpl extends JComponent
return false; return false;
} }
public boolean supportsCompression() { boolean supportsCompression() {
return mySupportsCompression; return mySupportsCompression;
} }
@@ -490,7 +473,7 @@ public class JBTabsImpl extends JComponent
myLastLayoutPass = null; myLastLayoutPass = null;
} }
protected void resetTabsCache() { void resetTabsCache() {
ApplicationManager.getApplication().assertIsDispatchThread(); ApplicationManager.getApplication().assertIsDispatchThread();
myAllTabs = null; myAllTabs = null;
} }
@@ -605,7 +588,7 @@ public class JBTabsImpl extends JComponent
return myDropInfo != null && myDropInfo == info; return myDropInfo != null && myDropInfo == info;
} }
protected void setDropInfoIndex(int dropInfoIndex) { private void setDropInfoIndex(int dropInfoIndex) {
myDropInfoIndex = dropInfoIndex; myDropInfoIndex = dropInfoIndex;
} }
@@ -718,12 +701,7 @@ public class JBTabsImpl extends JComponent
item.setForeground(each.getDefaultForeground()); item.setForeground(each.getDefaultForeground());
item.setBackground(each.getTabColor()); item.setBackground(each.getTabColor());
mySingleRowLayout.myMorePopup.add(item); mySingleRowLayout.myMorePopup.add(item);
item.addActionListener(new ActionListener() { item.addActionListener(__ -> select(each, true));
@Override
public void actionPerformed(final ActionEvent e) {
select(each, true);
}
});
} }
mySingleRowLayout.myMorePopup.addPopupMenuListener(new PopupMenuListener() { mySingleRowLayout.myMorePopup.addPopupMenuListener(new PopupMenuListener() {
@@ -766,13 +744,11 @@ public class JBTabsImpl extends JComponent
toFocus = info.getLastFocusOwner(); toFocus = info.getLastFocusOwner();
} }
if (toFocus == null && info.getPreferredFocusableComponent() == null) {
return null;
}
if (toFocus == null) { if (toFocus == null) {
toFocus = info.getPreferredFocusableComponent(); toFocus = info.getPreferredFocusableComponent();
if (toFocus == null) {
return null;
}
final JComponent policyToFocus = myFocusManager.getFocusTargetFor(toFocus); final JComponent policyToFocus = myFocusManager.getFocusTargetFor(toFocus);
if (policyToFocus != null) { if (policyToFocus != null) {
toFocus = policyToFocus; toFocus = policyToFocus;
@@ -796,12 +772,7 @@ public class JBTabsImpl extends JComponent
@Override @Override
public boolean requestFocusInWindow() { public boolean requestFocusInWindow() {
final JComponent toFocus = getToFocus(); final JComponent toFocus = getToFocus();
if (toFocus != null) { return toFocus != null ? toFocus.requestFocusInWindow() : super.requestFocusInWindow();
return toFocus.requestFocusInWindow();
}
else {
return super.requestFocusInWindow();
}
} }
@@ -894,7 +865,7 @@ public class JBTabsImpl extends JComponent
return myPopupGroup != null ? myPopupGroup.get() : null; return myPopupGroup != null ? myPopupGroup.get() : null;
} }
public String getPopupPlace() { String getPopupPlace() {
return myPopupPlace; return myPopupPlace;
} }
@@ -963,9 +934,7 @@ public class JBTabsImpl extends JComponent
} }
}); });
} }
else { return executeSelectionChange(info, requestFocus);
return executeSelectionChange(info, requestFocus);
}
} }
@NotNull @NotNull
@@ -1064,7 +1033,7 @@ public class JBTabsImpl extends JComponent
} }
void fireTabRemoved(@NotNull TabInfo info) { private void fireTabRemoved(@NotNull TabInfo info) {
for (TabsListener eachListener : myTabListeners) { for (TabsListener eachListener : myTabListeners) {
if (eachListener != null) { if (eachListener != null) {
eachListener.tabRemoved(info); eachListener.tabRemoved(info);
@@ -1078,9 +1047,8 @@ public class JBTabsImpl extends JComponent
if (isShowing()) { if (isShowing()) {
return myFocusManager.requestFocus(toFocus, true); return myFocusManager.requestFocus(toFocus, true);
} else {
return ActionCallback.REJECTED;
} }
return ActionCallback.REJECTED;
} }
@NotNull @NotNull
@@ -1215,20 +1183,18 @@ public class JBTabsImpl extends JComponent
} }
private int getIndexInVisibleArray(TabInfo each) { private int getIndexInVisibleArray(TabInfo each) {
Integer index = myHiddenInfos.get(each); Integer info = myHiddenInfos.get(each);
if (index == null) { int index = info == null ? myVisibleInfos.size() : info.intValue();
index = Integer.valueOf(myVisibleInfos.size());
}
if (index > myVisibleInfos.size()) { if (index > myVisibleInfos.size()) {
index = myVisibleInfos.size(); index = myVisibleInfos.size();
} }
if (index.intValue() < 0) { if (index < 0) {
index = 0; index = 0;
} }
return index.intValue(); return index;
} }
private void updateIcon(final TabInfo tabInfo) { private void updateIcon(final TabInfo tabInfo) {
@@ -1338,7 +1304,7 @@ public class JBTabsImpl extends JComponent
} }
@Nullable @Nullable
protected TabInfo findEnabledForward(int from, boolean cycle) { TabInfo findEnabledForward(int from, boolean cycle) {
if (from < 0) return null; if (from < 0) return null;
int index = from; int index = from;
List<TabInfo> infos = getVisibleInfos(); List<TabInfo> infos = getVisibleInfos();
@@ -1361,7 +1327,7 @@ public class JBTabsImpl extends JComponent
} }
@Nullable @Nullable
protected TabInfo findEnabledBackward(int from, boolean cycle) { TabInfo findEnabledBackward(int from, boolean cycle) {
if (from < 0) return null; if (from < 0) return null;
int index = from; int index = from;
List<TabInfo> infos = getVisibleInfos(); List<TabInfo> infos = getVisibleInfos();
@@ -1379,7 +1345,7 @@ public class JBTabsImpl extends JComponent
return null; return null;
} }
protected Toolbar createToolbarComponent(final TabInfo tabInfo) { private Toolbar createToolbarComponent(final TabInfo tabInfo) {
return new Toolbar(this, tabInfo); return new Toolbar(this, tabInfo);
} }
@@ -1564,9 +1530,7 @@ public class JBTabsImpl extends JComponent
if (myPosition == JBTabsPosition.top || myPosition == JBTabsPosition.bottom) { if (myPosition == JBTabsPosition.top || myPosition == JBTabsPosition.bottom) {
return new Dimension(getSize().width, myHorizontalSide ? Math.max(max.myLabel.height, max.myToolbar.height) : max.myLabel.height); return new Dimension(getSize().width, myHorizontalSide ? Math.max(max.myLabel.height, max.myToolbar.height) : max.myLabel.height);
} }
else { return new Dimension(max.myLabel.width + (myHorizontalSide ? 0 : max.myToolbar.width), getSize().height);
return new Dimension(max.myLabel.width + (myHorizontalSide ? 0 : max.myToolbar.width), getSize().height);
}
} }
public Rectangle layoutComp(int componentX, int componentY, final JComponent comp, int deltaWidth, int deltaHeight) { public Rectangle layoutComp(int componentX, int componentY, final JComponent comp, int deltaWidth, int deltaHeight) {
@@ -2161,10 +2125,6 @@ public class JBTabsImpl extends JComponent
return this; return this;
} }
static int getBorder(int size) {
return size == -1 ? 1 : size;
}
@Override @Override
@NotNull @NotNull
public JBTabsPresentation setActiveTabFillIn(@Nullable final Color color) { public JBTabsPresentation setActiveTabFillIn(@Nullable final Color color) {
@@ -2207,7 +2167,7 @@ public class JBTabsImpl extends JComponent
@NotNull private final ActionManager myActionManager; @NotNull private final ActionManager myActionManager;
private final JBTabsImpl myTabs; private final JBTabsImpl myTabs;
protected BaseNavigationAction(@NotNull String copyFromID, @NotNull JBTabsImpl tabs, @NotNull ActionManager mgr) { BaseNavigationAction(@NotNull String copyFromID, @NotNull JBTabsImpl tabs, @NotNull ActionManager mgr) {
myActionManager = mgr; myActionManager = mgr;
myTabs = tabs; myTabs = tabs;
myShadow = new ShadowAction(this, myActionManager.getAction(copyFromID), tabs, tabs); myShadow = new ShadowAction(this, myActionManager.getAction(copyFromID), tabs, tabs);
@@ -2228,7 +2188,7 @@ public class JBTabsImpl extends JComponent
} }
@Nullable @Nullable
protected JBTabsImpl findNavigatableTabs(JBTabsImpl tabs) { JBTabsImpl findNavigatableTabs(JBTabsImpl tabs) {
// The debugger UI contains multiple nested JBTabsImpl, where the innermost JBTabsImpl has only one tab. In this case, // The debugger UI contains multiple nested JBTabsImpl, where the innermost JBTabsImpl has only one tab. In this case,
// the action should target the outer JBTabsImpl. // the action should target the outer JBTabsImpl.
if (tabs == null || tabs != myTabs) { if (tabs == null || tabs != myTabs) {
@@ -2500,7 +2460,7 @@ public class JBTabsImpl extends JComponent
} }
public static boolean isSelectionClick(final MouseEvent e, boolean canBeQuick) { static boolean isSelectionClick(final MouseEvent e, boolean canBeQuick) {
if (e.getClickCount() == 1 || canBeQuick) { if (e.getClickCount() == 1 || canBeQuick) {
if (!e.isPopupTrigger()) { if (!e.isPopupTrigger()) {
return e.getButton() == MouseEvent.BUTTON1 && !e.isControlDown() && !e.isAltDown() && !e.isMetaDown(); return e.getButton() == MouseEvent.BUTTON1 && !e.isControlDown() && !e.isAltDown() && !e.isMetaDown();
@@ -2585,7 +2545,7 @@ public class JBTabsImpl extends JComponent
return myPosition; return myPosition;
} }
public TimedDeadzone.Length getTabActionsMouseDeadzone() { TimedDeadzone.Length getTabActionsMouseDeadzone() {
return myTabActionsMouseDeadzone; return myTabActionsMouseDeadzone;
} }
@@ -2608,7 +2568,7 @@ public class JBTabsImpl extends JComponent
return this; return this;
} }
public boolean isTabDraggingEnabled() { boolean isTabDraggingEnabled() {
return myTabDraggingEnabled && !mySplitter.isDragging(); return myTabDraggingEnabled && !mySplitter.isDragging();
} }
@@ -2723,10 +2683,9 @@ public class JBTabsImpl extends JComponent
*/ */
protected class AccessibleJBTabsImpl extends AccessibleJComponent implements AccessibleSelection { protected class AccessibleJBTabsImpl extends AccessibleJComponent implements AccessibleSelection {
public AccessibleJBTabsImpl() { AccessibleJBTabsImpl() {
super();
getAccessibleComponent(); getAccessibleComponent();
JBTabsImpl.this.addListener(new TabsListener() { addListener(new TabsListener() {
@Override @Override
public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) { public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) {
firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null); firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null);
@@ -2783,7 +2742,7 @@ public class JBTabsImpl extends JComponent
@Override @Override
public int getAccessibleSelectionCount() { public int getAccessibleSelectionCount() {
return (getSelectedInfo() == null ? 0 : 1); return getSelectedInfo() == null ? 0 : 1;
} }
@Override @Override
@@ -2795,7 +2754,7 @@ public class JBTabsImpl extends JComponent
@Override @Override
public boolean isAccessibleChildSelected(int i) { public boolean isAccessibleChildSelected(int i) {
return (i == getIndexOf(getSelectedInfo())); return i == getIndexOf(getSelectedInfo());
} }
@Override @Override
@@ -2832,8 +2791,10 @@ public class JBTabsImpl extends JComponent
private class AccessibleTabPage extends AccessibleContext private class AccessibleTabPage extends AccessibleContext
implements Accessible, AccessibleComponent, AccessibleAction { implements Accessible, AccessibleComponent, AccessibleAction {
private final @NotNull JBTabsImpl myParent; @NotNull
private final @NotNull TabInfo myTabInfo; private final JBTabsImpl myParent;
@NotNull
private final TabInfo myTabInfo;
private final Component myComponent; private final Component myComponent;
AccessibleTabPage(@NotNull TabInfo tabInfo) { AccessibleTabPage(@NotNull TabInfo tabInfo) {
@@ -2844,16 +2805,17 @@ public class JBTabsImpl extends JComponent
initAccessibleContext(); initAccessibleContext();
} }
private @NotNull TabInfo getTabInfo() { @NotNull
private TabInfo getTabInfo() {
return myTabInfo; return myTabInfo;
} }
private int getTabIndex() { private int getTabIndex() {
return JBTabsImpl.this.getIndexOf(myTabInfo); return getIndexOf(myTabInfo);
} }
private TabLabel getTabLabel() { private TabLabel getTabLabel() {
return JBTabsImpl.this.myInfo2Label.get(getTabInfo()); return myInfo2Label.get(getTabInfo());
} }
/* /*
@@ -2861,9 +2823,8 @@ public class JBTabsImpl extends JComponent
*/ */
void initAccessibleContext() { void initAccessibleContext() {
// Note: null checks because we do not want to load Accessibility classes unnecessarily. // Note: null checks because we do not want to load Accessibility classes unnecessarily.
if (JBTabsImpl.this.accessibleContext != null && myComponent instanceof Accessible) { if (accessibleContext != null && myComponent instanceof Accessible) {
AccessibleContext ac; AccessibleContext ac = myComponent.getAccessibleContext();
ac = myComponent.getAccessibleContext();
if (ac != null) { if (ac != null) {
ac.setAccessibleParent(this); ac.setAccessibleParent(this);
} }
@@ -2928,8 +2889,7 @@ public class JBTabsImpl extends JComponent
@Override @Override
public AccessibleStateSet getAccessibleStateSet() { public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states; AccessibleStateSet states = myParent.getAccessibleContext().getAccessibleStateSet();
states = myParent.getAccessibleContext().getAccessibleStateSet();
states.add(AccessibleState.SELECTABLE); states.add(AccessibleState.SELECTABLE);
TabInfo info = myParent.getSelectedInfo(); TabInfo info = myParent.getSelectedInfo();
if (info == getTabInfo()) { if (info == getTabInfo()) {
@@ -2948,20 +2908,12 @@ public class JBTabsImpl extends JComponent
// Expose the tab content only if it is active, as the content for // Expose the tab content only if it is active, as the content for
// inactive tab does is usually not ready (i.e. may never have been // inactive tab does is usually not ready (i.e. may never have been
// activated). // activated).
if (JBTabsImpl.this.getSelectedInfo() == getTabInfo() && myComponent instanceof Accessible) { return getSelectedInfo() == getTabInfo() && myComponent instanceof Accessible ? 1 : 0;
return 1;
} else {
return 0;
}
} }
@Override @Override
public Accessible getAccessibleChild(int i) { public Accessible getAccessibleChild(int i) {
if (JBTabsImpl.this.getSelectedInfo() == getTabInfo() && myComponent instanceof Accessible) { return getSelectedInfo() == getTabInfo() && myComponent instanceof Accessible ? (Accessible)myComponent : null;
return (Accessible) myComponent;
} else {
return null;
}
} }
@Override @Override
@@ -3102,11 +3054,7 @@ public class JBTabsImpl extends JComponent
@Override @Override
public Accessible getAccessibleAt(Point p) { public Accessible getAccessibleAt(Point p) {
if (myComponent instanceof Accessible) { return myComponent instanceof Accessible ? (Accessible)myComponent : null;
return (Accessible) myComponent;
} else {
return null;
}
} }
@Override @Override
@@ -3168,7 +3116,7 @@ public class JBTabsImpl extends JComponent
if (i != 0) if (i != 0)
return false; return false;
JBTabsImpl.this.select(getTabInfo(), true); select(getTabInfo(), true);
return true; return true;
} }
} }
@@ -3186,7 +3134,9 @@ public class JBTabsImpl extends JComponent
*/ */
@Deprecated @Deprecated
protected static class ShapeInfo { protected static class ShapeInfo {
public ShapeInfo() {} public ShapeInfo() {
}
public ShapeTransform path; public ShapeTransform path;
public ShapeTransform fillPath; public ShapeTransform fillPath;
public ShapeTransform labelPath; public ShapeTransform labelPath;
@@ -548,10 +548,11 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Disposa
@Override @Override
@NotNull @NotNull
public Module[] getModules() { public Module[] getModules() {
if (myModuleModel.myIsWritable) { ModuleModelImpl model = myModuleModel;
if (model.myIsWritable) {
ApplicationManager.getApplication().assertReadAccessAllowed(); ApplicationManager.getApplication().assertReadAccessAllowed();
} }
return myModuleModel.getModules(); return model.getModules();
} }
private volatile Module[] myCachedSortedModules; private volatile Module[] myCachedSortedModules;
@@ -609,7 +610,8 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Disposa
graph = myModuleModel.moduleGraph(includeTests); graph = myModuleModel.moduleGraph(includeTests);
if (includeTests) { if (includeTests) {
myCachedModuleTestGraph = graph; myCachedModuleTestGraph = graph;
} else { }
else {
myCachedModuleProductionGraph = graph; myCachedModuleProductionGraph = graph;
} }
@@ -933,8 +935,9 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Disposa
if (!myIsWritable) { if (!myIsWritable) {
return false; return false;
} }
return !myModules.equals(myManager.myModuleModel.myModules) ModuleModelImpl model = myManager.myModuleModel;
|| !Comparing.equal(myManager.myModuleModel.myModuleGroupPath, myModuleGroupPath) return !myModules.equals(model.myModules)
|| !Comparing.equal(model.myModuleGroupPath, myModuleGroupPath)
|| !myModuleToNewName.isEmpty(); || !myModuleToNewName.isEmpty();
} }