mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
label hiding support for toolwindow
This commit is contained in:
+10
-4
@@ -51,7 +51,7 @@ class ComboContentLayout extends ContentLayout {
|
||||
@Override
|
||||
public void layout() {
|
||||
Rectangle bounds = myUi.getBounds();
|
||||
Dimension idSize = myIdLabel.getPreferredSize();
|
||||
Dimension idSize = isIdVisible() ? myIdLabel.getPreferredSize() : new Dimension(0, 0);
|
||||
|
||||
int eachX = 0;
|
||||
int eachY = 0;
|
||||
@@ -60,7 +60,7 @@ class ComboContentLayout extends ContentLayout {
|
||||
eachX += idSize.width;
|
||||
|
||||
Dimension comboSize = myComboLabel.getPreferredSize();
|
||||
int spaceLeft = bounds.width - eachX - (isToDrawCombo() ? 3 : 0);
|
||||
int spaceLeft = bounds.width - eachX - (isToDrawCombo() && isIdVisible() ? 3 : 0);
|
||||
|
||||
int width = comboSize.width;
|
||||
if (width > spaceLeft) {
|
||||
@@ -95,7 +95,7 @@ class ComboContentLayout extends ContentLayout {
|
||||
g2d.dispose();
|
||||
}
|
||||
|
||||
g.drawImage(myImage, r.x, r.y, null);
|
||||
g.drawImage(myImage, isIdVisible() ? r.x : r.x - 2, r.y, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,6 +112,7 @@ class ComboContentLayout extends ContentLayout {
|
||||
@Override
|
||||
public void update() {
|
||||
updateIdLabel(myIdLabel);
|
||||
myIdLabel.setVisible(!"true".equals(myUi.myWindow.getComponent().getClientProperty(ToolWindowContentUi.HIDE_ID_LABEL)));
|
||||
myComboLabel.update();
|
||||
}
|
||||
|
||||
@@ -130,6 +131,10 @@ class ComboContentLayout extends ContentLayout {
|
||||
return myUi.myManager.getContentCount() > 1;
|
||||
}
|
||||
|
||||
boolean isIdVisible() {
|
||||
return myIdLabel.isVisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contentAdded(ContentManagerEvent event) {
|
||||
}
|
||||
@@ -145,7 +150,8 @@ class ComboContentLayout extends ContentLayout {
|
||||
|
||||
@Override
|
||||
public void showContentPopup(ListPopup listPopup) {
|
||||
listPopup.setMinimumSize(new Dimension(myComboLabel.getSize().width, 0));
|
||||
final int width = myComboLabel.getSize().width;
|
||||
listPopup.setMinimumSize(new Dimension(isIdVisible() ? width : width - 2, 0));
|
||||
listPopup.showUnderneathOf(myComboLabel);
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -20,6 +20,7 @@ import com.intellij.ide.actions.CloseAction;
|
||||
import com.intellij.ide.actions.ShowContentAction;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListSeparator;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.ActionCallback;
|
||||
@@ -48,11 +49,14 @@ import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyChangeListener, DataProvider, SwitchProvider {
|
||||
public static final String POPUP_PLACE = "ToolwindowPopup";
|
||||
// when client property is put in toolwindow component, hides toolwindow label
|
||||
public static final String HIDE_ID_LABEL = "HideIdLabel";
|
||||
|
||||
ContentManager myManager;
|
||||
|
||||
@@ -431,13 +435,19 @@ public class ToolWindowContentUi extends JPanel implements ContentUI, PropertyCh
|
||||
|
||||
@Override
|
||||
public Icon getIconFor(Content aValue) {
|
||||
return aValue.getIcon();
|
||||
return aValue.getPopupIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMnemonicsNavigationEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListSeparator getSeparatorAbove(Content value) {
|
||||
final String separator = value.getSeparator();
|
||||
return separator != null ? new ListSeparator(separator) : super.getSeparatorAbove(value);
|
||||
}
|
||||
};
|
||||
|
||||
step.setDefaultOptionIndex(Arrays.asList(myManager.getContents()).indexOf(myManager.getSelectedContent()));
|
||||
|
||||
Reference in New Issue
Block a user