mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CPP-7228 CMake console doesn't display broken configurations on Windows
- supporting icons in tab names - and using icons in CMake console tabs
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.ui.content;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
@@ -35,5 +36,7 @@ public interface TabbedContent extends Content {
|
||||
List<Pair<String, JComponent>> getTabs();
|
||||
String getTitlePrefix();
|
||||
void setTitlePrefix(String titlePrefix);
|
||||
@Nullable
|
||||
String getTabNameWithoutPrefix(String fullTabName);
|
||||
void split();
|
||||
}
|
||||
|
||||
+23
-2
@@ -19,6 +19,7 @@ import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.reference.SoftReference;
|
||||
import com.intellij.ui.ClickListener;
|
||||
@@ -27,6 +28,7 @@ import com.intellij.ui.content.TabbedContent;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
@@ -52,7 +54,7 @@ public class TabbedContentTabLabel extends ContentTabLabel {
|
||||
}
|
||||
};
|
||||
private final TabbedContent myContent;
|
||||
private Reference<JBPopup> myPopupReference = null;
|
||||
@Nullable private Reference<JBPopup> myPopupReference = null;
|
||||
|
||||
public TabbedContentTabLabel(TabbedContent content, TabContentLayout layout) {
|
||||
super(content, layout);
|
||||
@@ -82,6 +84,7 @@ public class TabbedContentTabLabel extends ContentTabLabel {
|
||||
@Override
|
||||
public JComponent fun(Object dom) {
|
||||
label.setText(dom.toString());
|
||||
setTabIconInLabel(dom.toString(), label);
|
||||
return label;
|
||||
}
|
||||
});
|
||||
@@ -90,6 +93,10 @@ public class TabbedContentTabLabel extends ContentTabLabel {
|
||||
int index = list.getSelectedIndex();
|
||||
if (index != -1) {
|
||||
myContent.selectContent(index);
|
||||
JComponent tabComponent = myContent.getTabs().get(index).getSecond();
|
||||
if (tabComponent instanceof Iconable) {
|
||||
setIcon(((Iconable)tabComponent).getIcon(Iconable.ICON_FLAG_VISIBILITY));
|
||||
}
|
||||
}
|
||||
}).createPopup();
|
||||
myPopupReference = new WeakReference<JBPopup>(popup);
|
||||
@@ -100,11 +107,25 @@ public class TabbedContentTabLabel extends ContentTabLabel {
|
||||
public void update() {
|
||||
super.update();
|
||||
if (myContent != null) {
|
||||
setText(myContent.getTabName());
|
||||
String tabName = myContent.getTabName();
|
||||
setText(tabName);
|
||||
setTabIconInLabel(tabName, this);
|
||||
}
|
||||
setHorizontalAlignment(LEFT);
|
||||
}
|
||||
|
||||
private void setTabIconInLabel(String tabName, JLabel jLabel) {
|
||||
for (Pair<String, JComponent> nextTabWithName : myContent.getTabs()) {
|
||||
if (nextTabWithName.getFirst().equals(tabName)
|
||||
|| nextTabWithName.getFirst().equals(myContent.getTabNameWithoutPrefix(tabName))) {
|
||||
JComponent tab = nextTabWithName.getSecond();
|
||||
if (tab instanceof Iconable) {
|
||||
jLabel.setIcon(((Iconable)tab).getIcon(Iconable.ICON_FLAG_VISIBILITY));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
final Dimension size = super.getPreferredSize();
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.content.TabbedContent;
|
||||
import com.intellij.util.ContentUtilEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -158,6 +159,16 @@ public class TabbedContentImpl extends ContentImpl implements TabbedContent {
|
||||
myPrefix = titlePrefix;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getTabNameWithoutPrefix(String fullTabName) {
|
||||
int titlePrefixLength = getTitlePrefix().length() + 2;
|
||||
if (fullTabName.startsWith(getTitlePrefix())) {
|
||||
return fullTabName.substring(titlePrefixLength);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void split() {
|
||||
List<Pair<String, JComponent>> copy = new ArrayList<Pair<String, JComponent>>(myTabs);
|
||||
|
||||
Reference in New Issue
Block a user