mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Utility method for text alignment
This commit is contained in:
@@ -41,9 +41,11 @@ import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.plaf.ButtonUI;
|
||||
import javax.swing.plaf.ComboBoxUI;
|
||||
import javax.swing.plaf.ProgressBarUI;
|
||||
import javax.swing.plaf.basic.BasicComboBoxUI;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
import javax.swing.plaf.basic.ComboPopup;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
import javax.swing.text.JTextComponent;
|
||||
@@ -2954,4 +2956,34 @@ public class UIUtil {
|
||||
char rightArrow = '\u2192';
|
||||
return getLabelFont().canDisplay(rightArrow) ? String.valueOf(rightArrow) : "->";
|
||||
}
|
||||
|
||||
public static EmptyBorder getTextAlignBorder(@NotNull JToggleButton alignSource) {
|
||||
ButtonUI ui = alignSource.getUI();
|
||||
int leftGap = alignSource.getIconTextGap();
|
||||
Border border = alignSource.getBorder();
|
||||
if (border != null) {
|
||||
leftGap += border.getBorderInsets(alignSource).left;
|
||||
}
|
||||
if (ui instanceof BasicRadioButtonUI) {
|
||||
leftGap += ((BasicRadioButtonUI)alignSource.getUI()).getDefaultIcon().getIconWidth();
|
||||
}
|
||||
else {
|
||||
Method method = ReflectionUtil.getMethod(ui.getClass(), "getDefaultIcon", JComponent.class);
|
||||
if (method != null) {
|
||||
try {
|
||||
Object o = method.invoke(ui, alignSource);
|
||||
if (o instanceof Icon) {
|
||||
leftGap += ((Icon)o).getIconWidth();
|
||||
}
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new EmptyBorder(0, leftGap, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-5
@@ -20,6 +20,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.components.JBLabel;
|
||||
import com.intellij.ui.popup.util.DetailView;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.xdebugger.XDebuggerBundle;
|
||||
import com.intellij.xdebugger.XExpression;
|
||||
import com.intellij.xdebugger.breakpoints.XBreakpointManager;
|
||||
@@ -32,8 +33,6 @@ import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerExpressionComboBox;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.plaf.basic.BasicRadioButtonUI;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -125,9 +124,7 @@ public class XLightBreakpointPropertiesPanel<B extends XBreakpointBase<?,?,?>> i
|
||||
if (debuggerEditorsProvider != null) {
|
||||
myConditionEnabledCheckbox = new JBCheckBox(XDebuggerBundle.message("xbreakpoints.condition.checkbox"));
|
||||
JBLabel conditionEnabledLabel = new JBLabel(XDebuggerBundle.message("xbreakpoints.condition.checkbox"));
|
||||
conditionEnabledLabel.setBorder(new EmptyBorder(0, ((BasicRadioButtonUI)myConditionEnabledCheckbox.getUI()).getDefaultIcon().getIconWidth() +
|
||||
myConditionEnabledCheckbox.getIconTextGap() +
|
||||
myConditionEnabledCheckbox.getBorder().getBorderInsets(myConditionEnabledCheckbox).left, 0, 0));
|
||||
conditionEnabledLabel.setBorder(UIUtil.getTextAlignBorder(myConditionEnabledCheckbox));
|
||||
myConditionEnabledPanel.add(myConditionEnabledCheckbox, CONDITION_ENABLED_CHECKBOX);
|
||||
myConditionEnabledPanel.add(conditionEnabledLabel, CONDITION_ENABLED_LABEL);
|
||||
myConditionComboBox = new XDebuggerExpressionComboBox(project, debuggerEditorsProvider, CONDITION_HISTORY_ID, myBreakpoint.getSourcePosition());
|
||||
|
||||
Reference in New Issue
Block a user