Browse Source

INO-21074 工作目录切换

persist/11.0-arabic
obo 4 months ago
parent
commit
0a8fe7a356
  1. 26
      designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java

26
designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java

@ -1,6 +1,5 @@
package com.fr.design.gui.ilable; package com.fr.design.gui.ilable;
import com.fr.base.i18n.BidiUtils;
import com.fr.design.gui.core.UITextComponent; import com.fr.design.gui.core.UITextComponent;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -28,23 +27,19 @@ public class UILabel extends JLabel implements UITextComponent {
if (image != null && text != null) { if (image != null && text != null) {
setIconTextGap(4); setIconTextGap(4);
} }
adjustLabelTextForRTL();
} }
public UILabel(String text, int horizontalAlignment) { public UILabel(String text, int horizontalAlignment) {
super(text, horizontalAlignment); super(text, horizontalAlignment);
adjustLabelTextForRTL();
} }
public UILabel(String text) { public UILabel(String text) {
super(text); super(text);
adjustLabelTextForRTL();
} }
public UILabel(String text, boolean enable) { public UILabel(String text, boolean enable) {
super(text); super(text);
this.setEnabled(enable); this.setEnabled(enable);
adjustLabelTextForRTL();
} }
public UILabel(Icon image, int horizontalAlignment) { public UILabel(Icon image, int horizontalAlignment) {
@ -69,27 +64,6 @@ public class UILabel extends JLabel implements UITextComponent {
return preferredSize; return preferredSize;
} }
/**
* 调整label的名称以适配RTL
* <p/>
* 代码中有大量的国际化文本拼接冒号或者其他硬编码字符串创建Label的行为RTL时名称需要分段反转把一部分放在UILabel构造方法中进行调整目前处理的场景如下
* <ul>
* <li>label名+冒号(:)</li>
* <li>Item 2</li>
* <li>Item 3</li>
* </ul>
*/
private void adjustLabelTextForRTL() {
if (!BidiUtils.rtl()) {
return;
}
String text = this.getText();
if (StringUtils.isNotEmpty(text) && text.length() > 1 && StringUtils.equals(String.valueOf(text.charAt(text.length() - 1)), COLON)) {
text = COLON + text.substring(0, text.length() - 1);
this.setText(text);
}
}
public static void main(String[] args) { public static void main(String[] args) {
// UILabel label = new UILabel("shishi",SwingConstants.LEFT); // UILabel label = new UILabel("shishi",SwingConstants.LEFT);
JFrame frame = new JFrame("Test"); JFrame frame = new JFrame("Test");

Loading…
Cancel
Save