Browse Source

PreferencePane标签创建方式重构,布局生成方式还原

persist/11.0-arabic
obo 7 months ago
parent
commit
64bf604d1d
  1. 41
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 26
      designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java

41
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -45,7 +45,6 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.FRFont;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.general.log.Log4jConfig;
@ -53,7 +52,6 @@ import com.fr.io.attr.ImageExportAttr;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.report.ReportConfigManager;
import com.fr.scheduler.tool.FineScheduler;
import com.fr.stable.Constants;
import com.fr.stable.os.OperatingSystem;
import com.fr.third.apache.logging.log4j.Level;
@ -77,13 +75,11 @@ import javax.swing.ButtonGroup;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.KeyStroke;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.Timer;
@ -396,8 +392,8 @@ public class PreferencePane extends BasicPane {
previewRenderGroup.add(previewRenderSpeed);
JPanel imageExportSettingPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JComponent[][] templateComps = {
{new UILabel(createLabelColonName("Fine-Design_Report_Engine_Enlarge_Or_Reduce")), this.previewResolutionBtnS, this.previewResolutionBtnM},
{new UILabel(createLabelColonName("Fine-Design_Image_Export_Rendering_Quality")), this.previewRenderQuality, this.previewRenderSpeed},
{new UILabel(Toolkit.i18nText("Fine-Design_Report_Engine_Enlarge_Or_Reduce") + ":"), this.previewResolutionBtnS, this.previewResolutionBtnM},
{new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Rendering_Quality") + ":"), this.previewRenderQuality, this.previewRenderSpeed},
};
imageExportSettingPane.add(
TableLayoutHelper.createGapTableLayoutPane(
@ -444,9 +440,9 @@ public class PreferencePane extends BasicPane {
//gc面板
gcControlPane = createGcControlPane();
JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeadingZeroLayout());
JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
enableVcsPanel.add(remindVcsLabel);
JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeadingZeroLayout());
JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
final UILabel everyLabel = new UILabel(i18nText("Fine-Design_Vcs_Every"));
final UILabel delayLabel = new UILabel(i18nText("Fine-Design_Vcs_Delay"));
intervalPanel.add(useIntervalCheckBox);
@ -474,7 +470,7 @@ public class PreferencePane extends BasicPane {
}
}
});
vcsPane.add(remindVcsLabel);
vcsPane.add(enableVcsPanel);
vcsPane.add(intervalPanel);
if (VcsHelper.getInstance().isLegacyMode()) {
vcsPane.add(saveCommitCheckBox);
@ -512,7 +508,7 @@ public class PreferencePane extends BasicPane {
};
private JPanel createAutoCleanPane() {
JPanel autoCleanPane = new JPanel(FRGUIPaneFactory.createLeadingZeroLayout());
JPanel autoCleanPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
useVcsAutoCleanScheduleCheckBox = new UICheckBox();
autoCleanIntervalComboBox = new UIComboBox(INTERVAL);
autoCleanIntervalComboBox.setSelectedIndex(DEFAULT_INDEX);
@ -560,7 +556,7 @@ public class PreferencePane extends BasicPane {
}
private JPanel createSaveIntervalPane() {
JPanel saveIntervalPane = new JPanel(FRGUIPaneFactory.createLeadingZeroLayout());
JPanel saveIntervalPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
useVcsAutoSaveScheduleCheckBox = new UICheckBox();
autoSaveIntervalEditor = new UIPositiveIntEditor(60);
saveIntervalPane.add(useVcsAutoSaveScheduleCheckBox);
@ -662,7 +658,7 @@ public class PreferencePane extends BasicPane {
}
});
JPanel keyStrokePane = new JPanel(new BorderLayout());
keyStrokePane.add(new UILabel(createLabelColonName("Fine-Design_Basic_Support_Auto_Complete_Shortcut")), BorderLayout.LINE_START);
keyStrokePane.add(new UILabel(i18nText("Fine-Design_Basic_Support_Auto_Complete_Shortcut") + ":"), BorderLayout.WEST);
shortCutLabel = new UILabel();
keyStrokePane.add(shortCutLabel, BorderLayout.CENTER);
keyStrokePane.setBorder(new EmptyBorder(0, 10,0,0));
@ -741,10 +737,10 @@ public class PreferencePane extends BasicPane {
paginationLineColorTBButton.setEnabled(this.isEnabled());
JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
leftPane.add(new UILabel(createLabelColonName("Fine-Design_Basic_Preference_Grid_Line_Color")));
leftPane.add(new UILabel(i18nText("Fine-Design_Basic_Preference_Grid_Line_Color") + ":"));
leftPane.add(gridLineColorTBButton);
JPanel rightPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
rightPane.add(new UILabel(createLabelColonName("Fine-Design_Basic_Preference_Pagination_Line_Color")));
rightPane.add(new UILabel(i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color") + ":"));
rightPane.add(paginationLineColorTBButton);
colorSettingPane.add(leftPane);
colorSettingPane.add(rightPane);
@ -756,7 +752,7 @@ public class PreferencePane extends BasicPane {
advancePane.add(logPane);
JPanel logExportPane = FRGUIPaneFactory.createTitledBorderPane("log" + i18nText("Fine-Design_Basic_Export_Setting"));
logPane.add(logExportPane);
UILabel logLabel = new UILabel(i18nText(createLabelColonName("Fine-Design_Basic_Select_Export_Log_Directory")));
UILabel logLabel = new UILabel(i18nText("Fine-Design_Basic_Select_Export_Log_Directory") + ":");
logExportPane.add(logLabel, BorderLayout.WEST);
logExportDirectoryField = new UITextField(24);
logExportPane.add(logExportDirectoryField, BorderLayout.CENTER);
@ -876,8 +872,8 @@ public class PreferencePane extends BasicPane {
reportLengthComboBox = new UIComboBox(UnitConvertUtil.getUnitItems());
reportLengthComboBox.setPreferredSize(new Dimension(80, 20));
reportLengthComboBox.setMinimumSize(new Dimension(80, 20));
UILabel pagelengthLabel = new UILabel(createLabelColonName("Fine-Design_Basic_Page_Setup_Scale_Units"));
UILabel reportLengthLabel = new UILabel(createLabelColonName("Fine-Design_Basic_Report_Design_Ruler_Units"));
UILabel pagelengthLabel = new UILabel(i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":");
UILabel reportLengthLabel = new UILabel(i18nText("Fine-Design_Basic_Report_Design_Ruler_Units") + ":");
Component[][] lengthComponents = {
{pagelengthLabel, pageLengthComboBox, reportLengthLabel, reportLengthComboBox},
};
@ -896,7 +892,7 @@ public class PreferencePane extends BasicPane {
portEditor.setPreferredSize(new Dimension(80, 20));
portEditor.setMinimumSize(new Dimension(80, 20));
UILabel notiJlabel = new UILabel(i18nText("Fine-Design_Basic_Work_After_Restart_Designer"));
UILabel serverPortLabel = new UILabel(createLabelColonName("Fine-Design_Basic_Web_Preview_Port"));
UILabel serverPortLabel = new UILabel(i18nText("Fine-Design_Basic_Web_Preview_Port") + ":");
Component[][] portComponents = {
{serverPortLabel, portEditor, notiJlabel},
};
@ -911,7 +907,7 @@ public class PreferencePane extends BasicPane {
i18nText("Fine-Design_Basic_Preference_Caching_Template_Tip"), MEMORY_TIP_LABEL_MAX_WIDTH);
memoryTipLabel.setBorder(BorderFactory.createEmptyBorder(0, CACHING_GAP, 0, 0));
cachingTemplateSpinner = new UISpinner(0, CACHING_MAX, 1, CACHING_DEFAULT);
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeadingZeroLayout());
JPanel memorySpace = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
memorySpace.add(memoryLabel);
memorySpace.add(cachingTemplateSpinner);
memorySpace.add(memoryTipLabel);
@ -1490,12 +1486,5 @@ public class PreferencePane extends BasicPane {
return gcButton;
}
/**
* 创建带冒号的label名适配RTL
*/
private String createLabelColonName(String i18nKey) {
return BidiUtils.reverseConcatenateStrings(i18nText(i18nKey) + ":");
}
}

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

@ -1,5 +1,6 @@
package com.fr.design.gui.ilable;
import com.fr.base.i18n.BidiUtils;
import com.fr.design.gui.core.UITextComponent;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.StringUtils;
@ -27,19 +28,23 @@ public class UILabel extends JLabel implements UITextComponent {
if (image != null && text != null) {
setIconTextGap(4);
}
adjustLabelTextForRTL();
}
public UILabel(String text, int horizontalAlignment) {
super(text, horizontalAlignment);
adjustLabelTextForRTL();
}
public UILabel(String text) {
super(text);
adjustLabelTextForRTL();
}
public UILabel(String text, boolean enable) {
super(text);
this.setEnabled(enable);
adjustLabelTextForRTL();
}
public UILabel(Icon image, int horizontalAlignment) {
@ -64,6 +69,27 @@ public class UILabel extends JLabel implements UITextComponent {
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 (text.length() > 1 && text.charAt(text.length() - 1) == ':') {
text = ":" + text.substring(0, text.length() - 1);
this.setText(text);
}
}
public static void main(String[] args) {
// UILabel label = new UILabel("shishi",SwingConstants.LEFT);
JFrame frame = new JFrame("Test");

Loading…
Cancel
Save