mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Show pin icon in pinned Find Usages tabs
This commit is contained in:
@@ -93,6 +93,30 @@ public class IconUtil {
|
||||
return new ImageIcon(img);
|
||||
}
|
||||
|
||||
public static Icon cropIcon(@NotNull Icon icon, Rectangle area) {
|
||||
if (!new Rectangle(icon.getIconWidth(), icon.getIconHeight()).contains(area)) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
final BufferedImage image = GraphicsEnvironment
|
||||
.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice()
|
||||
.getDefaultConfiguration()
|
||||
.createCompatibleImage(icon.getIconWidth(), icon.getIconHeight(), Transparency.TRANSLUCENT);
|
||||
final Graphics2D g = image.createGraphics();
|
||||
icon.paintIcon(new JPanel(), g, 0, 0);
|
||||
g.dispose();
|
||||
|
||||
final BufferedImage img = UIUtil.createImage(area.width, area.height, Transparency.TRANSLUCENT);
|
||||
for (int col = 0; col < area.width; col++) {
|
||||
for (int row = 0; row < area.height; row++) {
|
||||
img.setRGB(col, row, image.getRGB(col + area.x, row + area.y));
|
||||
}
|
||||
}
|
||||
|
||||
return new ImageIcon(img);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Icon flip(@NotNull Icon icon, boolean horizontal) {
|
||||
int w = icon.getIconWidth();
|
||||
|
||||
@@ -83,6 +83,7 @@ public class UsageViewManagerImpl extends UsageViewManager {
|
||||
content.setTabName(tabName);
|
||||
content.setToolwindowTitle(toolwindowTitle);
|
||||
content.putUserData(contentKey, Boolean.TRUE);
|
||||
content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
|
||||
|
||||
myFindContentManager.addContent(content);
|
||||
myFindContentManager.setSelectedContent(content);
|
||||
|
||||
@@ -27,7 +27,9 @@ import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.ui.content.AlertIcon;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.util.IconUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -36,6 +38,8 @@ import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
|
||||
public class ContentImpl extends UserDataHolderBase implements Content {
|
||||
private static Icon ourEmptyPinIcon = null;
|
||||
|
||||
private String myDisplayName;
|
||||
private String myDescription;
|
||||
private JComponent myComponent;
|
||||
@@ -113,13 +117,23 @@ public class ContentImpl extends UserDataHolderBase implements Content {
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
if (myIsLocked) {
|
||||
return myIcon == null ? AllIcons.Nodes.PinToolWindow : myLayeredIcon;
|
||||
return myIcon == null ? getEmptyPinIcon() : myLayeredIcon;
|
||||
}
|
||||
else {
|
||||
return myIcon;
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Icon getEmptyPinIcon() {
|
||||
if (ourEmptyPinIcon == null) {
|
||||
Icon icon = AllIcons.Nodes.PinToolWindow;
|
||||
int width = icon.getIconWidth();
|
||||
ourEmptyPinIcon = IconUtil.cropIcon(icon, new Rectangle(width / 2, 0, width - width / 2, icon.getIconHeight()));
|
||||
}
|
||||
return ourEmptyPinIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String displayName) {
|
||||
String oldValue = myDisplayName;
|
||||
|
||||
Reference in New Issue
Block a user