From c6520486b1fd2f9ceef4f4753dc9e6b9e850c9ed Mon Sep 17 00:00:00 2001 From: obo Date: Sun, 21 Jul 2024 20:40:30 +0800 Subject: [PATCH 01/91] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E7=95=8C=E9=9D=A2=E9=95=9C=E5=83=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/base/i18n/BidiUtils.java | 61 +++++++++++++++++++ .../com/fr/design/actions/UpdateAction.java | 3 +- .../actions/server/ConnectionListAction.java | 2 + .../actions/server/GlobalTableDataAction.java | 3 +- .../search/pane/TreeSearchToolbarPane.java | 7 +++ .../file/MultiTemplateTabMenuFactory.java | 21 +++++-- .../fr/design/file/MultiTemplateTabPane.java | 23 ++++--- .../icontainer/UIEastResizableContainer.java | 17 ++++-- .../gui/ilable/LocaleOrientationLabel.java | 51 ++++++++++++++++ .../com/fr/design/gui/ilable/UILabel.java | 3 +- .../com/fr/design/gui/imenu/UIMenuItemUI.java | 14 +++-- .../mainframe/CenterRegionContainerPane.java | 17 +++--- .../fr/design/mainframe/DesignerFrame.java | 12 ++-- .../mainframe/NorthRegionContainerPane.java | 4 +- .../mainframe/WestRegionContainerPane.java | 4 +- .../mainframe/loghandler/LogMessageBar.java | 2 + .../pane/TemplateTreeSearchToolbarPane.java | 4 ++ .../mainframe/toolbar/ToolBarMenuDock.java | 3 +- .../main/java/com/fr/design/menu/MenuDef.java | 5 +- .../java/com/fr/design/menu/ToolBarDef.java | 3 +- 20 files changed, 212 insertions(+), 47 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java create mode 100644 designer-base/src/main/java/com/fr/design/gui/ilable/LocaleOrientationLabel.java diff --git a/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java b/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java new file mode 100644 index 0000000000..52f251ab8b --- /dev/null +++ b/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java @@ -0,0 +1,61 @@ +package com.fr.base.i18n; + +import java.awt.BorderLayout; +import java.awt.ComponentOrientation; +import java.awt.Container; +import java.awt.FlowLayout; +import java.util.Locale; + +/** + * 根据国际化获取组件方向 + * + * @author obo + * @since 11.0 + * Created on 2024/07/17 + */ +public class BidiUtils { + + private static final Locale ar = new Locale("ar", "SA"); + private static final Locale cn = Locale.CHINA; + + private BidiUtils() { + } + + public static ComponentOrientation getOrientationByLocale() { + return ComponentOrientation.getOrientation(ar); + } + + public static void applyOrientationByLocale(Container component) { + component.applyComponentOrientation(ComponentOrientation.getOrientation(ar)); + } + + public static void applyOrientationByLocale(Container ...component) { + for (Container container : component) { + container.applyComponentOrientation(ComponentOrientation.getOrientation(ar)); + } + } + + public static boolean rtl() { + return ComponentOrientation.getOrientation(ar) == ComponentOrientation.RIGHT_TO_LEFT; + } + + public static String getBorderLayoutWest() { + return BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST; + } + + public static String getBorderLayoutEast() { + return BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST; + } + + public static int getFlowLayoutLeft() { + return BidiUtils.rtl() ? FlowLayout.RIGHT : FlowLayout.LEFT; + } + + public static int getFlowLayoutRight() { + return BidiUtils.rtl() ? FlowLayout.LEFT : FlowLayout.RIGHT; + } + + public static int getStableConstantsRight() { + return BidiUtils.rtl() ? com.fr.stable.Constants.LEFT : com.fr.stable.Constants.RIGHT; + } +} diff --git a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java index d33c04eb15..a99032586a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java @@ -6,6 +6,7 @@ package com.fr.design.actions; import com.fr.base.NameStyle; import com.fr.base.ScreenResolution; import com.fr.base.Style; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.SVGIcon; import com.fr.base.svg.IconUtils; import com.fr.design.actions.core.ActionFactory; @@ -327,6 +328,7 @@ public abstract class UpdateAction extends ShortCut implements Action { object = menuItem; this.putValue(UIMenuItem.class.getName(), object); + menuItem.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } return (UIMenuItem) object; } @@ -547,7 +549,6 @@ public abstract class UpdateAction extends ShortCut implements Action { menuItem.addActionListener(action); menuItem.setToolTipText((String) action.getValue(Action.LONG_DESCRIPTION)); menuItem.setAccelerator((KeyStroke) action.getValue(Action.ACCELERATOR_KEY)); - return menuItem; } diff --git a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java index 4742f337cd..2f2673edc1 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java @@ -1,5 +1,6 @@ package com.fr.design.actions.server; +import com.fr.base.i18n.BidiUtils; import com.fr.data.impl.Connection; import com.fr.design.actions.UpdateAction; import com.fr.design.data.datapane.connect.ConnectionShowPane; @@ -118,6 +119,7 @@ public class ConnectionListAction extends UpdateAction { menuItem.setName(getName()); setPressedIcon4Button(menuItem); setDisabledIcon4Button(menuItem); + menuItem.applyComponentOrientation(BidiUtils.getOrientationByLocale()); object = menuItem; this.putValue(UILockMenuItem.class.getName(), object); diff --git a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java index 1457f0d111..abcc898db8 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java @@ -4,6 +4,7 @@ package com.fr.design.actions.server; import com.fr.base.TableData; +import com.fr.base.i18n.BidiUtils; import com.fr.design.DesignModelAdapter; import com.fr.design.actions.UpdateAction; import com.fr.design.data.DesignTableDataManager; @@ -181,7 +182,7 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS setPressedIcon4Button(menuItem); setDisabledIcon4Button(menuItem); object = menuItem; - + menuItem.applyComponentOrientation(BidiUtils.getOrientationByLocale()); this.putValue(UILockMenuItem.class.getName(), object); ServerTableDataLockChangeChecker.getInstance().addEditLockChangeListener((UILockMenuItem)object); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java index f5266c9b6d..d192e018ba 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/TreeSearchToolbarPane.java @@ -1,5 +1,6 @@ package com.fr.design.data.datapane.management.search.pane; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.design.DesignModelAdapter; import com.fr.design.constants.UIConstants; @@ -88,6 +89,12 @@ public class TreeSearchToolbarPane extends JPanel implements TreeSearchStatusCha add(contentPane, BorderLayout.CENTER); setPreferredSize(new Dimension(240, 30)); TableDataTreeSearchManager.getInstance().registerTreeSearchStatusChangeListener(this); + this.applyComponentOrientation(BidiUtils.getOrientationByLocale()); + toolbar.applyComponentOrientation(BidiUtils.getOrientationByLocale()); + toolbarPane.applyComponentOrientation(BidiUtils.getOrientationByLocale()); + searchPane.applyComponentOrientation(BidiUtils.getOrientationByLocale()); + searchTextField.applyComponentOrientation(BidiUtils.getOrientationByLocale()); + contentPane.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } private void initContentPane() { diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java index 6210f7ba68..27f41c64e0 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabMenuFactory.java @@ -1,5 +1,6 @@ package com.fr.design.file; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; @@ -17,11 +18,14 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.ComponentOrientation; +import java.awt.Container; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.text.Bidi; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -134,7 +138,7 @@ public class MultiTemplateTabMenuFactory { button.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); button.setOpaque(true); button.setBackground(UIConstants.NORMAL_BACKGROUND); - button.setHorizontalAlignment(SwingConstants.LEFT); + button.setHorizontalAlignment(BidiUtils.rtl() ? SwingConstants.RIGHT : SwingConstants.LEFT); button.setForeground(UIConstants.FLESH_BLUE); return button; } @@ -193,10 +197,15 @@ public class MultiTemplateTabMenuFactory { menuItemButtonGroup.templateButton.setForeground(UIConstants.FLESH_BLUE); } - jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.WEST); - jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); - jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.EAST); - + if (BidiUtils.rtl()) { + jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.EAST); + jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); + jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.WEST); + } else { + jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.WEST); + jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); + jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.EAST); + } return jPanel; } @@ -237,7 +246,7 @@ public class MultiTemplateTabMenuFactory { button.setPreferredSize(new Dimension(menu.getWidth() - ITEM_SIZE * 2, ITEM_SIZE)); button.setOpaque(true); button.setBackground(UIConstants.NORMAL_BACKGROUND); - button.setHorizontalAlignment(SwingConstants.LEFT); + button.setHorizontalAlignment(BidiUtils.rtl() ? SwingConstants.RIGHT : SwingConstants.LEFT); return button; } diff --git a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java index 8f2783a3ca..64b551e086 100644 --- a/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MultiTemplateTabPane.java @@ -2,6 +2,7 @@ package com.fr.design.file; import com.fr.base.GraphHelper; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; @@ -67,6 +68,7 @@ import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; +import java.text.Bidi; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -571,7 +573,8 @@ public class MultiTemplateTabPane extends JComponent { private void showListDown() { UIScrollPopUpMenu menu = MultiTemplateTabMenuFactory.getInstance().createMenu(); - GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); + int x = BidiUtils.rtl() ? 0 : MultiTemplateTabPane.getInstance().getWidth() - menu.getPreferredSize().width; + GUICoreUtils.showPopupMenu(menu, MultiTemplateTabPane.getInstance(), x, getY() - 1 + getHeight()); } @@ -613,7 +616,7 @@ public class MultiTemplateTabPane extends JComponent { if (selectedIndex < 0) { selectedIndex = 0; } - double templateStartX = 0; + double templateStartX = BidiUtils.rtl() ? maxWidth - realWidth : 0; startX = new int[maxPaintIndex - minPaintIndex + 1]; isNeedToolTips = new boolean[maxPaintIndex - minPaintIndex + 1]; @@ -651,7 +654,7 @@ public class MultiTemplateTabPane extends JComponent { boolean isLeft = i < selectedIndex; startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); } - templateStartX += realWidth; + templateStartX = BidiUtils.rtl() ? templateStartX - realWidth : templateStartX + realWidth; } if (!DesignerMode.isVcsMode()) { @@ -682,7 +685,7 @@ public class MultiTemplateTabPane extends JComponent { private void paintListDown(Graphics2D g2d, double maxWidth) { - int x = (int) maxWidth + (LIST_BUTTON_WIDTH - listDownMode.getIconWidth()) / 2; + int x = BidiUtils.rtl() ? (LIST_BUTTON_WIDTH - listDownMode.getIconWidth()) / 2 : (int) maxWidth + (LIST_BUTTON_WIDTH - listDownMode.getIconWidth()) / 2; int y = (getHeight() - listDownMode.getIconHeight()) / 2; listDownMode.paintIcon(this, g2d, x, y); } @@ -1126,19 +1129,23 @@ public class MultiTemplateTabPane extends JComponent { private boolean isOverListDown(int evtX) { - int maxWidth = getWidth() - LIST_BUTTON_WIDTH; - return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); + if (BidiUtils.rtl()) { + return evtX >= SMALLGAP && evtX <= (LIST_BUTTON_WIDTH - SMALLGAP); + } else { + int maxWidth = getWidth() - LIST_BUTTON_WIDTH; + return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); + } } private int getTemplateIndex(int evtX) { - int textX = 0; + int textX = BidiUtils.rtl() ? (int) (getWidth() - LIST_BUTTON_WIDTH * 1.0D) - realWidth : 0; for (int i = minPaintIndex; i <= maxPaintIndex; i++) { int textWidth = showJTemplateTab(openedTemplate.get(i)) ? realWidth : 0; if (evtX >= textX && evtX < textX + textWidth) { return i; } - textX += textWidth; + textX = BidiUtils.rtl() ? textX - textWidth : textX + textWidth; } return -1; } diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index cec4b840a7..090fb2ab5e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -1,6 +1,7 @@ package com.fr.design.gui.icontainer; +import com.fr.base.i18n.BidiUtils; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; @@ -177,13 +178,19 @@ public class UIEastResizableContainer extends JPanel { if (topToolPane == null || rightPane == null) { return; } - -// topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462 - topToolPane.setBounds(0, 0, leftPaneWidth, topToolPaneHeight);//0,0,10,462 - leftPane.setBounds(0, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight); + if (BidiUtils.rtl()) { + topToolPane.setBounds(containerWidth - leftPaneWidth, 0, leftPaneWidth, topToolPaneHeight); + leftPane.setBounds(containerWidth - leftPaneWidth, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight); + rightPane.setBounds(0, 0, containerWidth - leftPaneWidth, getHeight()); + } else { + // topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462 + topToolPane.setBounds(0, 0, leftPaneWidth, topToolPaneHeight);//0,0,10,462 + leftPane.setBounds(0, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight); // parameterPane.setBounds(20, 0, 230, getParameterPaneHeight());//10,0,230,462 - rightPane.setBounds(leftPaneWidth, 0, containerWidth - leftPaneWidth, getHeight());//20,0,230,0 + rightPane.setBounds(leftPaneWidth, 0, containerWidth - leftPaneWidth, getHeight());//20,0,230,0 + } + } @Override diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/LocaleOrientationLabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/LocaleOrientationLabel.java new file mode 100644 index 0000000000..2165f05dc5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/LocaleOrientationLabel.java @@ -0,0 +1,51 @@ +package com.fr.design.gui.ilable; + +import com.fr.base.i18n.BidiUtils; + +import javax.swing.Icon; +import javax.swing.JLabel; + +/** + * description + * + * @author obo + * @since 11.0 + * Created on 2024/07/16 + */ +public class LocaleOrientationLabel extends JLabel { + + public LocaleOrientationLabel(String text, Icon image, int horizontalAlignment) { + super(text, image, horizontalAlignment); + if (image != null && text != null) { + setIconTextGap(4); + } + this.setComponentOrientation(BidiUtils.getOrientationByLocale()); + } + + public LocaleOrientationLabel(String text, int horizontalAlignment) { + super(text, horizontalAlignment); + this.setComponentOrientation(BidiUtils.getOrientationByLocale()); + } + + public LocaleOrientationLabel(String text) { + super(text); + this.setComponentOrientation(BidiUtils.getOrientationByLocale()); + } + + public LocaleOrientationLabel(Icon image, int horizontalAlignment) { + super(image, horizontalAlignment); + this.setComponentOrientation(BidiUtils.getOrientationByLocale()); + } + + public LocaleOrientationLabel(Icon image) { + super(image); + this.setComponentOrientation(BidiUtils.getOrientationByLocale()); + } + + public LocaleOrientationLabel() { + super(); + this.setComponentOrientation(BidiUtils.getOrientationByLocale()); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java b/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java index d6a7952757..b8ed7701f7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilable/UILabel.java @@ -6,7 +6,6 @@ import com.fr.stable.StringUtils; import javax.swing.Icon; import javax.swing.JFrame; -import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; @@ -19,7 +18,7 @@ import java.awt.Dimension; * Date: 13-1-23 * Time: 下午3:15 */ -public class UILabel extends JLabel implements UITextComponent { +public class UILabel extends LocaleOrientationLabel implements UITextComponent { private static final int HTML_SHIFT_HEIGHT = 3; public UILabel(String text, Icon image, int horizontalAlignment) { diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java index 0d883abfbf..b170e00e44 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java @@ -1,5 +1,6 @@ package com.fr.design.gui.imenu; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.UIConstants; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; @@ -34,20 +35,21 @@ public class UIMenuItemUI extends BasicMenuItemUI { g.setColor(UIConstants.NORMAL_BACKGROUND); g.fillRect(0, 0, menuWidth, menuHeight); + int bidiX = BidiUtils.rtl() ? 10 : 30; + int bidiWidth = BidiUtils.rtl() ? menuWidth - 35 : menuWidth - 30; if (menuItem.isOpaque()) { if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); } else { - GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); + GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); } g.setColor(oldColor); - } else if (model.isArmed() || (menuItem instanceof JMenu && - model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + } else if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, bidiX, 0, bidiWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); g.setColor(oldColor); } } - + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { ButtonModel model = menuItem.getModel(); FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index 3cceff5a75..7857c8f3b5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.i18n.BidiUtils; import com.fr.design.DesignState; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; @@ -81,7 +82,7 @@ public class CenterRegionContainerPane extends JPanel { }; toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BorderLayout.WEST); + eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BidiUtils.getBorderLayoutEast()); eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); combineUpTooBar(); eastCenterPane.add(combineUp, BorderLayout.NORTH); @@ -108,9 +109,12 @@ public class CenterRegionContainerPane extends JPanel { * 创建上工具栏 */ private void combineUpTooBar() { - combineUp = new UIToolbar(FlowLayout.LEFT); +// combineUp = new UIToolbar(BidiUtils.getFlowLayoutLeft()); +// combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); +// combineUp.setLayout(new FlowLayout(BidiUtils.getFlowLayoutLeft(), 5, 2)); + combineUp = new UIToolbar(BidiUtils.getFlowLayoutLeft()); combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); - combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); + combineUp.setLayout(new FlowLayout(BidiUtils.getFlowLayoutLeft(), 5, 2)); setUpUpToolBar(null); } @@ -229,7 +233,7 @@ public class CenterRegionContainerPane extends JPanel { } // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.CENTER); JPanel customNorthPane = strategy.customNorthPane(toolbarPane,plus); if (!isExist(customNorthPane)){ this.removeNorth(); @@ -275,9 +279,8 @@ public class CenterRegionContainerPane extends JPanel { //移除新建模板按钮 templateTabPane.remove(newWorkBookPane); } else { - eastPane.add(largeToolbar, BorderLayout.WEST); - templateTabPane.add(newWorkBookPane, BorderLayout.WEST); - + eastPane.add(largeToolbar, BidiUtils.getBorderLayoutWest()); + templateTabPane.add(newWorkBookPane, BidiUtils.getBorderLayoutWest()); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index e20debacb7..7068e712c2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -5,6 +5,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.OptimizeUtil; +import com.fr.base.i18n.BidiUtils; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -266,7 +267,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER); laoyoutWestPane(); - basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); + basePane.add(EastRegionContainerPane.getInstance(), BidiUtils.getBorderLayoutEast()); basePane.setBounds(0, 0, contentWidth, contentHeight); // 数值越小。越在底层 @@ -310,6 +311,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true)); closeMode = UIConstants.CLOSE_OF_AUTHORITY; initMenuPane(); + BidiUtils.applyOrientationByLocale(this); } public void resizeFrame() { @@ -477,7 +479,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta protected void laoyoutWestPane() { - basePane.add(WestRegionContainerPane.getInstance(), BorderLayout.WEST); + basePane.add(WestRegionContainerPane.getInstance(), BidiUtils.getBorderLayoutWest()); } // 调整windows大小 @@ -820,7 +822,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerOpenEmptyPanel designerOpenEmptyPanel = new DesignerOpenEmptyPanel(); BorderLayout layout = (BorderLayout) basePane.getLayout(); basePane.remove(layout.getLayoutComponent(BorderLayout.CENTER)); - basePane.remove(layout.getLayoutComponent(BorderLayout.EAST)); + basePane.remove(layout.getLayoutComponent(BidiUtils.getBorderLayoutEast())); basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER); resetToolkitByPlus(ToolBarMenuDock.NULLAVOID); @@ -974,10 +976,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.add(center, BorderLayout.CENTER); } if (west != null) { - basePane.add(west, BorderLayout.WEST); + basePane.add(west, BidiUtils.getBorderLayoutWest()); } if (east != null) { - basePane.add(east, BorderLayout.EAST); + basePane.add(east, BidiUtils.getBorderLayoutEast()); } jTemplate.setComposite(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java index d850e8e814..b568e4cab6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.i18n.BidiUtils; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -67,7 +68,7 @@ public class NorthRegionContainerPane extends JPanel { this.setLayout(new BorderLayout()); this.add(new UIMenuHighLight(), BorderLayout.SOUTH); - this.add(initNorthEastPane(ad), BorderLayout.EAST); + this.add(initNorthEastPane(ad), BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST); } /** @@ -180,6 +181,7 @@ public class NorthRegionContainerPane extends JPanel { MenuManager.getInstance().setMenus4Designer(designState); if (menuBar == null) { this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + menuBar.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } else { ad.resetJMenuBar(menuBar, plus); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 004fbd55a3..669673779e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.i18n.BidiUtils; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; @@ -11,7 +12,6 @@ import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.stable.Constants; public class WestRegionContainerPane extends UIResizableContainer { @@ -31,7 +31,7 @@ public class WestRegionContainerPane extends UIResizableContainer { } public WestRegionContainerPane() { - super(DesignerFrameFileDealerPane.getInstance(), Constants.RIGHT); + super(DesignerFrameFileDealerPane.getInstance(), BidiUtils.getStableConstantsRight()); setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java index fded318188..e779ad5c07 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.loghandler; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.stable.StringUtils; @@ -52,6 +53,7 @@ public class LogMessageBar extends JPanel { return; } dlg = new LogDetailPane().showDialog(); + dlg.applyComponentOrientation(BidiUtils.getOrientationByLocale()); dlg.setVisible(true); } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java b/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java index ee9b861b1e..56f83eabd1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.manager.search.searcher.control.pane; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.design.constants.UIConstants; import com.fr.design.search.event.TreeSearchStatusChangeEvent; @@ -132,6 +133,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS searchPane.add(searchLabel, BorderLayout.WEST); searchPane.add(searchTextField, BorderLayout.CENTER); searchPane.add(returnLabel, BorderLayout.EAST); + searchPane.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } private void initSearchTextField() { @@ -171,6 +173,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS } }); this.searchTextField.addKeyListener(enterPressed); + searchTextField.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } private void dealWithTextChange() { @@ -185,6 +188,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS toolbarPane = new JPanel(); toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); toolbarPane.add(toolbar, BorderLayout.CENTER); + toolbarPane.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 3372e2ad13..28f3b04cea 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -4,6 +4,7 @@ package com.fr.design.mainframe.toolbar; import com.fr.base.FRContext; +import com.fr.base.i18n.BidiUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -62,7 +63,6 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; -import com.fr.design.module.DesignModuleFactory; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.update.actions.SoftwareUpdateAction; @@ -219,6 +219,7 @@ public abstract class ToolBarMenuDock { } }; resetJMenuBar(jMenuBar, plus); + jMenuBar.applyComponentOrientation(BidiUtils.getOrientationByLocale()); return jMenuBar; } diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index ee82d256ec..875361dfaa 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -1,5 +1,6 @@ package com.fr.design.menu; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; @@ -240,7 +241,7 @@ public class MenuDef extends ShortCut { createdJMenu.getPopupMenu().addContainerListener(listener); } } - + createdJMenu.applyComponentOrientation(BidiUtils.getOrientationByLocale()); return createdJMenu; } @@ -254,6 +255,7 @@ public class MenuDef extends ShortCut { } else { createdJMenu = new UIMenu(this.getName()); } + createdJMenu.applyComponentOrientation(BidiUtils.getOrientationByLocale()); return createdJMenu; } @@ -490,6 +492,7 @@ public class MenuDef extends ShortCut { MenuDef.this.updatePopupMenu(popupMenu); GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height); } + popupMenu.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } }; diff --git a/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java b/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java index 8617ded9ba..3e5ed009a9 100644 --- a/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java @@ -1,5 +1,6 @@ package com.fr.design.menu; +import com.fr.base.i18n.BidiUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.itoolbar.UIToolBarUI; @@ -43,7 +44,7 @@ public class ToolBarDef { * 一个static的方法生成一个JToolBar */ public static UIToolbar createJToolBar() { - UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT); + UIToolbar toolbar = new UIToolbar(BidiUtils.getFlowLayoutLeft()); toolbar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); return toolbar; } From d59b14aba5625ace7e3ad9850f0d6c8caac6d4d3 Mon Sep 17 00:00:00 2001 From: obo Date: Mon, 22 Jul 2024 10:35:29 +0800 Subject: [PATCH 02/91] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E7=95=8C=E9=9D=A2=E9=95=9C=E5=83=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/actions/UpdateAction.java | 2 +- .../com/fr/design/mainframe/NorthRegionContainerPane.java | 1 - .../com/fr/design/mainframe/toolbar/ToolBarMenuDock.java | 2 -- .../src/main/java/com/fr/design/menu/MenuDef.java | 7 +++---- .../src/main/java/com/fr/start/MainDesigner.java | 8 ++++++++ 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java index a99032586a..be0c571b7c 100644 --- a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java @@ -328,7 +328,7 @@ public abstract class UpdateAction extends ShortCut implements Action { object = menuItem; this.putValue(UIMenuItem.class.getName(), object); - menuItem.applyComponentOrientation(BidiUtils.getOrientationByLocale()); + BidiUtils.applyOrientationByLocale(menuItem); } return (UIMenuItem) object; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java index b568e4cab6..78e4dbb6a1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -181,7 +181,6 @@ public class NorthRegionContainerPane extends JPanel { MenuManager.getInstance().setMenus4Designer(designState); if (menuBar == null) { this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - menuBar.applyComponentOrientation(BidiUtils.getOrientationByLocale()); } else { ad.resetJMenuBar(menuBar, plus); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 28f3b04cea..deac118275 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -4,7 +4,6 @@ package com.fr.design.mainframe.toolbar; import com.fr.base.FRContext; -import com.fr.base.i18n.BidiUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -219,7 +218,6 @@ public abstract class ToolBarMenuDock { } }; resetJMenuBar(jMenuBar, plus); - jMenuBar.applyComponentOrientation(BidiUtils.getOrientationByLocale()); return jMenuBar; } diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index 875361dfaa..b8aaeded6c 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -1,6 +1,5 @@ package com.fr.design.menu; -import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; @@ -26,6 +25,7 @@ import java.awt.event.ContainerListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.text.Bidi; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -241,7 +241,6 @@ public class MenuDef extends ShortCut { createdJMenu.getPopupMenu().addContainerListener(listener); } } - createdJMenu.applyComponentOrientation(BidiUtils.getOrientationByLocale()); return createdJMenu; } @@ -255,7 +254,6 @@ public class MenuDef extends ShortCut { } else { createdJMenu = new UIMenu(this.getName()); } - createdJMenu.applyComponentOrientation(BidiUtils.getOrientationByLocale()); return createdJMenu; } @@ -492,7 +490,8 @@ public class MenuDef extends ShortCut { MenuDef.this.updatePopupMenu(popupMenu); GUICoreUtils.showPopupMenu(popupMenu, button, 0, button.getSize().height); } - popupMenu.applyComponentOrientation(BidiUtils.getOrientationByLocale()); +// BidiUtils.applyOrientationByLocale(popupMenu); +// popupMenu.revalidate(); } }; diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index dab50eb3ce..2fcad2c03c 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -27,6 +27,7 @@ import com.fr.design.gui.ibutton.UISaveForbiddenButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.itoolbar.UILargeToolbar; +import com.fr.design.i18n.DesignI18nProviderImpl; import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.InformationCollector; @@ -68,6 +69,8 @@ import com.fr.runtime.FineRuntime; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.bridge.StableFactoryBase; +import com.fr.stable.fun.I18nProvider; import com.fr.stable.lifecycle.FineLifecycleFatalError; import com.fr.stable.xml.XMLTools; import com.fr.start.common.DesignerStartupContext; @@ -89,6 +92,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; +import java.util.ServiceLoader; import java.util.concurrent.CompletableFuture; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; @@ -123,6 +127,10 @@ public class MainDesigner extends BaseDesigner { DesignerStartupContext.getRecorder().start(); // 设置一下默认的logger,启动后再Reset FineLoggerFactory.setLogger(SystemOutLoggerProvider.getInstance()); + ServiceLoader i18nProviders = ServiceLoader.load(I18nProvider.class); + for (I18nProvider i18nProvider : i18nProviders) { + StableFactoryBase.registerMarkedClass(I18nProvider.MARK_STRING, i18nProvider.getClass()); + } showSplash(); From c6645f2d33b0b750c27d4f2abeb31428b4f84374 Mon Sep 17 00:00:00 2001 From: obo Date: Tue, 23 Jul 2024 19:38:38 +0800 Subject: [PATCH 03/91] =?UTF-8?q?=E5=B1=9E=E6=80=A7=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E9=95=9C=E5=83=8F=E5=8C=96=EF=BC=8C=E4=BC=98=E5=8C=96=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/base/i18n/BidiUtils.java | 33 ++++--------------- .../com/fr/design/actions/UpdateAction.java | 2 +- .../data/datapane/VerticalChoosePane.java | 5 +-- .../design/gui/controlpane/UIControlPane.java | 5 +-- .../fr/design/gui/frpane/RegFieldPane.java | 3 +- .../com/fr/design/gui/frpane/RegPane.java | 2 ++ .../fr/design/gui/icombobox/UIComboBox.java | 2 ++ .../fr/design/gui/icombobox/UIComboBoxUI.java | 4 ++- .../design/gui/imenu/UIMenuEastAttrItem.java | 1 + .../itableeditorpane/UITableEditorPane.java | 1 + .../itree/refreshabletree/TreeRootPane.java | 11 ++++--- .../fr/design/gui/style/TextFormatPane.java | 3 +- .../mainframe/CenterRegionContainerPane.java | 13 +++----- .../fr/design/mainframe/DesignerFrame.java | 10 +++--- .../mainframe/EastRegionContainerPane.java | 14 ++++---- .../mainframe/WestRegionContainerPane.java | 2 +- .../java/com/fr/design/menu/ToolBarDef.java | 2 +- .../fr/design/present/DictPresentPane.java | 2 ++ .../com/fr/design/utils/LinkStrUtils.java | 1 + .../btn/ButtonWithHotkeysDetailPane.java | 3 +- .../fr/design/mainframe/ReportFloatPane.java | 2 ++ .../cell/settingpane/CellExpandAttrPane.java | 3 +- .../cell/settingpane/CellOtherSetPane.java | 15 ++++++--- .../CellDesensitizationGroupsPane.java | 3 +- .../model/DesensitizationCellPane.java | 2 ++ .../settingpane/style/CustomStylePane.java | 3 ++ .../cell/settingpane/style/StylePane.java | 5 +-- .../com/fr/design/present/BarCodePane.java | 2 ++ .../fr/design/present/CurrencyLinePane.java | 4 ++- .../fr/design/widget/CellWidgetCardPane.java | 1 + .../java/com/fr/design/widget/WidgetPane.java | 3 +- .../ui/BasicWidgetPropertySettingPane.java | 3 +- .../design/widget/ui/CheckBoxDefinePane.java | 2 ++ .../ui/CustomWritableRepeatEditorPane.java | 5 +-- .../ui/DirectWriteEditorDefinePane.java | 9 +++-- .../widget/ui/FieldEditorDefinePane.java | 2 ++ .../widget/ui/IframeEditorDefinePane.java | 3 +- .../design/widget/ui/WaterMarkDictPane.java | 3 +- .../btn/TreeNodeToogleButtonDefinePane.java | 3 +- .../com/fr/quickeditor/CellQuickEditor.java | 2 ++ 40 files changed, 114 insertions(+), 80 deletions(-) diff --git a/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java b/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java index 52f251ab8b..b676619573 100644 --- a/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java +++ b/designer-base/src/main/java/com/fr/base/i18n/BidiUtils.java @@ -1,9 +1,7 @@ package com.fr.base.i18n; -import java.awt.BorderLayout; +import java.awt.Component; import java.awt.ComponentOrientation; -import java.awt.Container; -import java.awt.FlowLayout; import java.util.Locale; /** @@ -25,37 +23,18 @@ public class BidiUtils { return ComponentOrientation.getOrientation(ar); } - public static void applyOrientationByLocale(Container component) { + public static T applyOrientationByLocale(T component) { component.applyComponentOrientation(ComponentOrientation.getOrientation(ar)); + return component; } - public static void applyOrientationByLocale(Container ...component) { - for (Container container : component) { - container.applyComponentOrientation(ComponentOrientation.getOrientation(ar)); + public static void applyOrientationByLocale(Component... components) { + for (Component component : components) { + component.applyComponentOrientation(ComponentOrientation.getOrientation(ar)); } } public static boolean rtl() { return ComponentOrientation.getOrientation(ar) == ComponentOrientation.RIGHT_TO_LEFT; } - - public static String getBorderLayoutWest() { - return BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST; - } - - public static String getBorderLayoutEast() { - return BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST; - } - - public static int getFlowLayoutLeft() { - return BidiUtils.rtl() ? FlowLayout.RIGHT : FlowLayout.LEFT; - } - - public static int getFlowLayoutRight() { - return BidiUtils.rtl() ? FlowLayout.LEFT : FlowLayout.RIGHT; - } - - public static int getStableConstantsRight() { - return BidiUtils.rtl() ? com.fr.stable.Constants.LEFT : com.fr.stable.Constants.RIGHT; - } } diff --git a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java index be0c571b7c..9861887844 100644 --- a/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/UpdateAction.java @@ -340,7 +340,7 @@ public abstract class UpdateAction extends ShortCut implements Action { setPressedIcon4Button(menuItem); setDisabledIcon4Button(menuItem); this.putValue(UIMenuItem.class.getName(), menuItem); - return menuItem; + return BidiUtils.applyOrientationByLocale(menuItem); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/VerticalChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/VerticalChoosePane.java index 374efb1121..5469db1ada 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/VerticalChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/VerticalChoosePane.java @@ -1,5 +1,6 @@ package com.fr.design.data.datapane; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.data.datapane.preview.PreviewLabel; import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; @@ -41,8 +42,8 @@ public class VerticalChoosePane extends ChoosePane implements DesignerBean { rs.add(tableNameComboBox, BorderLayout.CENTER); rs.add(GUICoreUtils.createFlowPane(new Component[]{new RefreshLabel(this), previewLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); rs.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, -RIGHTBORDER)); - UILabel l1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database"), UILabel.LEFT); - UILabel l2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Model"), UILabel.LEFT); + UILabel l1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database"), BidiUtils.rtl() ? UILabel.RIGHT : UILabel.LEFT); + UILabel l2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Model"), BidiUtils.rtl() ? UILabel.RIGHT : UILabel.LEFT); UILabel l3 = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Select_Table"), MAX_WIDTH, UILabel.LEFT); if (labelSize > 0) { Dimension pSize = new Dimension(labelSize, 20); diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java index 12f904922d..c9361e0dc1 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java @@ -1,5 +1,6 @@ package com.fr.design.gui.controlpane; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.shortcutfactory.ShortCutFactory; @@ -175,8 +176,8 @@ public abstract class UIControlPane extends JControlPane { toolBarPane.add(topToolBar, BorderLayout.NORTH); JPanel leftTopPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - leftTopPane.add(toolBarPane, BorderLayout.EAST); - leftTopPane.add(addItemLabel, BorderLayout.CENTER); + leftTopPane.add(toolBarPane, BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST); + leftTopPane.add(addItemLabel, BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.CENTER); return leftTopPane; } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/RegFieldPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/RegFieldPane.java index 38e33514bc..895a260205 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/RegFieldPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/RegFieldPane.java @@ -1,5 +1,6 @@ package com.fr.design.gui.frpane; +import com.fr.base.i18n.BidiUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.ErrorMsgTextFieldAdapter; import com.fr.design.beans.UITextFieldAdapter; @@ -84,7 +85,7 @@ public class RegFieldPane extends RegPane { UILabel tipLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip")); tipLabel.setPreferredSize(new Dimension(60, 20)); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{tipLabel, errorMsgTextFieldAdapter.getErrorMsgTextField()}}, TableLayoutHelper.FILL_LASTCOLUMN, 10, LayoutConstants.VGAP_MEDIUM); - this.add(panel); + this.add(BidiUtils.applyOrientationByLocale(panel)); } private void initRegErrorMsgField() { diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java index ea92ee73ce..2b684d6851 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java @@ -1,5 +1,6 @@ package com.fr.design.gui.frpane; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; @@ -91,6 +92,7 @@ public class RegPane extends BasicPane { centerPane.add(cardPane, BorderLayout.NORTH); jPanel.add(centerPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.NORTH); + BidiUtils.applyOrientationByLocale(this); regComboBox.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { RegExp regExp = (RegExp)regComboBox.getSelectedItem(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java index e6130ca3da..c205f66f2b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBox.java @@ -1,5 +1,6 @@ package com.fr.design.gui.icombobox; +import com.fr.base.i18n.BidiUtils; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.UIObserver; @@ -71,6 +72,7 @@ public class UIComboBox extends JComboBox implements UIObserver, GlobalNameObser setRenderer(new UIComboBoxRenderer()); setEditor(new UIComboBoxEditor()); initListener(); + BidiUtils.applyOrientationByLocale(this); } protected void initListener() { diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java index d4de4e8501..ed8720bb2b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java @@ -1,5 +1,6 @@ package com.fr.design.gui.icombobox; +import com.fr.base.i18n.BidiUtils; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; @@ -96,7 +97,8 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { } g2d.setColor(linecolor); if (!comboBox.isPopupVisible()) { - g2d.drawRoundRect(0, 0, c.getWidth() - arrowButton.getWidth() + 3, c.getHeight() - 1, UIConstants.ARC, UIConstants.ARC); + int width = BidiUtils.rtl() ? c.getWidth() : c.getWidth() - arrowButton.getWidth() + 3; + g2d.drawRoundRect(0, 0, width, c.getHeight() - 1, UIConstants.ARC, UIConstants.ARC); } else { g2d.drawRoundRect(0, 0, c.getWidth(), c.getHeight() + 3, UIConstants.ARC, UIConstants.ARC); g2d.drawLine(0, c.getHeight() - 1, c.getWidth(), c.getHeight() - 1); diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java index 0df132caf4..a395071374 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuEastAttrItem.java @@ -1,5 +1,6 @@ package com.fr.design.gui.imenu; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.UIConstants; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.stable.Constants; diff --git a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java index aca38b28d2..938d4bf4c1 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java @@ -1,5 +1,6 @@ package com.fr.design.gui.itableeditorpane; +import com.fr.base.i18n.BidiUtils; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/refreshabletree/TreeRootPane.java b/designer-base/src/main/java/com/fr/design/gui/itree/refreshabletree/TreeRootPane.java index 691749fac6..c9046cd25e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/refreshabletree/TreeRootPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/refreshabletree/TreeRootPane.java @@ -1,13 +1,16 @@ package com.fr.design.gui.itree.refreshabletree; +import com.fr.base.i18n.BidiUtils; import com.fr.data.impl.TreeAttr; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.layout.FRGUIPaneFactory; +import groovy.swing.factory.LayoutFactory; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JPanel; +import java.awt.FlowLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -32,7 +35,7 @@ public class TreeRootPane extends BasicPane { public TreeRootPane() { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - JPanel checkTypePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); + JPanel checkTypePane = BidiUtils.rtl() ? FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane() : FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); checkTypePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); checkTypeCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Mutiple_Selection_Or_Not")); checkTypeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); @@ -40,7 +43,7 @@ public class TreeRootPane extends BasicPane { checkTypePane.add(checkTypeCheckBox); this.add(checkTypePane); - JPanel loadTypePane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); + JPanel loadTypePane = BidiUtils.rtl() ? FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane() : FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); checkTypePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); loadTypeCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Load_By_Async")); loadTypeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); @@ -48,14 +51,14 @@ public class TreeRootPane extends BasicPane { loadTypePane.add(loadTypeCheckBox); this.add(loadTypePane); - JPanel leafSelectPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); + JPanel leafSelectPane = BidiUtils.rtl() ? FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane() : FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); checkTypePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); leafSelectPane.add(layerTypeCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Select_Leaf_Only"))); layerTypeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.add(leafSelectPane); - JPanel returnFullPathPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); + JPanel returnFullPathPane = BidiUtils.rtl() ? FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane() : FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane_First0(); checkTypePane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); returnFullPathPane.add(returnFullPathCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Return_Full_Path"))); returnFullPathCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java index 0b8e8287ab..bd677fa1a1 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java @@ -4,6 +4,7 @@ import com.fr.base.CoreDecimalFormat; import com.fr.base.GraphHelper; import com.fr.base.Style; import com.fr.base.TextFormat; +import com.fr.base.i18n.BidiUtils; import com.fr.data.core.FormatField; import com.fr.data.core.FormatField.FormatContents; import com.fr.design.border.UIRoundedBorder; @@ -139,7 +140,7 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName protected void initLayout() { JPanel labeledFormatTypeComboBoxPane = new JPanel(new BorderLayout(20, 0)); - labeledFormatTypeComboBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format")), BorderLayout.WEST); + labeledFormatTypeComboBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format")), BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); labeledFormatTypeComboBoxPane.add(typeComboBox, BorderLayout.CENTER); JPanel labeledRoundingCheckboxPane = new JPanel(new BorderLayout(0, 0)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java index 7857c8f3b5..6f4e38ad62 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -82,7 +82,7 @@ public class CenterRegionContainerPane extends JPanel { }; toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BidiUtils.getBorderLayoutEast()); + eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST); eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); combineUpTooBar(); eastCenterPane.add(combineUp, BorderLayout.NORTH); @@ -109,12 +109,9 @@ public class CenterRegionContainerPane extends JPanel { * 创建上工具栏 */ private void combineUpTooBar() { -// combineUp = new UIToolbar(BidiUtils.getFlowLayoutLeft()); -// combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); -// combineUp.setLayout(new FlowLayout(BidiUtils.getFlowLayoutLeft(), 5, 2)); - combineUp = new UIToolbar(BidiUtils.getFlowLayoutLeft()); + combineUp = new UIToolbar(BidiUtils.rtl() ? FlowLayout.RIGHT : FlowLayout.LEFT); combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); - combineUp.setLayout(new FlowLayout(BidiUtils.getFlowLayoutLeft(), 5, 2)); + combineUp.setLayout(new FlowLayout(BidiUtils.rtl() ? FlowLayout.RIGHT : FlowLayout.LEFT, 5, 2)); setUpUpToolBar(null); } @@ -279,8 +276,8 @@ public class CenterRegionContainerPane extends JPanel { //移除新建模板按钮 templateTabPane.remove(newWorkBookPane); } else { - eastPane.add(largeToolbar, BidiUtils.getBorderLayoutWest()); - templateTabPane.add(newWorkBookPane, BidiUtils.getBorderLayoutWest()); + eastPane.add(largeToolbar, BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); + templateTabPane.add(newWorkBookPane, BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 7068e712c2..616b822a85 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -267,7 +267,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER); laoyoutWestPane(); - basePane.add(EastRegionContainerPane.getInstance(), BidiUtils.getBorderLayoutEast()); + basePane.add(EastRegionContainerPane.getInstance(), BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST); basePane.setBounds(0, 0, contentWidth, contentHeight); // 数值越小。越在底层 @@ -479,7 +479,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta protected void laoyoutWestPane() { - basePane.add(WestRegionContainerPane.getInstance(), BidiUtils.getBorderLayoutWest()); + basePane.add(WestRegionContainerPane.getInstance(), BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); } // 调整windows大小 @@ -822,7 +822,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta DesignerOpenEmptyPanel designerOpenEmptyPanel = new DesignerOpenEmptyPanel(); BorderLayout layout = (BorderLayout) basePane.getLayout(); basePane.remove(layout.getLayoutComponent(BorderLayout.CENTER)); - basePane.remove(layout.getLayoutComponent(BidiUtils.getBorderLayoutEast())); + basePane.remove(layout.getLayoutComponent(BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST)); basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER); resetToolkitByPlus(ToolBarMenuDock.NULLAVOID); @@ -976,10 +976,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta basePane.add(center, BorderLayout.CENTER); } if (west != null) { - basePane.add(west, BidiUtils.getBorderLayoutWest()); + basePane.add(west, BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); } if (east != null) { - basePane.add(east, BidiUtils.getBorderLayoutEast()); + basePane.add(east, BidiUtils.rtl() ? BorderLayout.WEST : BorderLayout.EAST); } jTemplate.setComposite(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 1357b48354..2ab7725105 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.FRContext; +import com.fr.base.i18n.BidiUtils; import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; @@ -1189,7 +1190,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { @Override public void mouseClicked(MouseEvent e) { - if (e.getX() >= ARROW_RANGE_START) { + if ((BidiUtils.rtl() && e.getX() <= 30) || (!BidiUtils.rtl() && e.getX() >= ARROW_RANGE_START)) { onPop(); } } @@ -1204,7 +1205,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { @Override public void mousePressed(MouseEvent e) { - if (e.getX() < ARROW_RANGE_START) { + if ((BidiUtils.rtl() && e.getX() > 30) || (!BidiUtils.rtl() && e.getX() < ARROW_RANGE_START)) { mouseDownCompCoords = e.getPoint(); } } @@ -1213,7 +1214,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private MouseMotionListener mouseMotionListener = new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { - if (e.getX() >= ARROW_RANGE_START) { + if ((BidiUtils.rtl() && e.getX() <= 30) || (!BidiUtils.rtl() && e.getX() >= ARROW_RANGE_START)) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else if (isMovable) { setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); @@ -1266,7 +1267,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { contentPane.setBackground(originColor); contentPane.setLayout(new BorderLayout()); UILabel label = new UILabel(title); - contentPane.add(label, BorderLayout.WEST); + contentPane.add(label, BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); contentPane.setBorder(new EmptyBorder(5, 10, 5, 0)); setLayout(new BorderLayout()); @@ -1321,7 +1322,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } else { button = UIConstants.POP_BUTTON_UP; } - SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, (ARROW_RANGE_START + 8), 4, null)); + SvgDrawUtils.doDrawSVG(g, () -> SvgDrawUtils.drawImage(g, button, BidiUtils.rtl() ? 0 : ARROW_RANGE_START + 8, 4, null)); } } @@ -1375,8 +1376,9 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } public void adjustLocation() { + this.setLocation( - getLeftPane().getLocationOnScreen().x - CONTENT_WIDTH, + BidiUtils.rtl() ? getLeftPane().getLocationOnScreen().x : getLeftPane().getLocationOnScreen().x - CONTENT_WIDTH, DesignerContext.getDesignerFrame().getLocationOnScreen().y + 228 ); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java index 669673779e..1cccd53f06 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/WestRegionContainerPane.java @@ -31,7 +31,7 @@ public class WestRegionContainerPane extends UIResizableContainer { } public WestRegionContainerPane() { - super(DesignerFrameFileDealerPane.getInstance(), BidiUtils.getStableConstantsRight()); + super(DesignerFrameFileDealerPane.getInstance(), BidiUtils.rtl() ? com.fr.stable.Constants.LEFT : com.fr.stable.Constants.RIGHT); setDownPane(TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter())); diff --git a/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java b/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java index 3e5ed009a9..2bdee656f0 100644 --- a/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java @@ -44,7 +44,7 @@ public class ToolBarDef { * 一个static的方法生成一个JToolBar */ public static UIToolbar createJToolBar() { - UIToolbar toolbar = new UIToolbar(BidiUtils.getFlowLayoutLeft()); + UIToolbar toolbar = new UIToolbar(BidiUtils.rtl() ? FlowLayout.RIGHT : FlowLayout.LEFT); toolbar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); return toolbar; } diff --git a/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java b/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java index 82cf70372b..a32566da57 100644 --- a/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java +++ b/designer-base/src/main/java/com/fr/design/present/DictPresentPane.java @@ -3,6 +3,7 @@ package com.fr.design.present; import java.awt.BorderLayout; import java.awt.event.ItemListener; +import com.fr.base.i18n.BidiUtils; import com.fr.base.present.DictPresent; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.tabledata.Prepare4DataSourceChange; @@ -21,6 +22,7 @@ public class DictPresentPane extends FurtherBasicBeanPane implement dictionaryPane = new DictionaryPane(); this.setLayout(new BorderLayout()); this.add(dictionaryPane, BorderLayout.CENTER); + BidiUtils.applyOrientationByLocale(this); } @Override diff --git a/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java b/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java index 666d17b84a..bbee1f4643 100644 --- a/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java @@ -53,6 +53,7 @@ public class LinkStrUtils { StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";"); style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";"); + //style.append("margin-bottom:").append("5px").append(";"); style.append("font-size:").append(font.getSize()).append("pt;"); style.append("color:rgb(").append(fontColor.getRed()).append(",").append(fontColor.getGreen()).append(",").append(fontColor.getBlue()).append(");"); style.append("background-color: rgb(").append(backgroundColor.getRed()).append(",").append(backgroundColor.getGreen()).append(",").append(backgroundColor.getBlue()).append(");"); diff --git a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java index d146c73099..f76f8b0bdf 100644 --- a/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/widget/btn/ButtonWithHotkeysDetailPane.java @@ -4,6 +4,7 @@ import java.awt.*; import javax.swing.*; +import com.fr.base.i18n.BidiUtils; import com.fr.design.designer.IntervalConstants; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.icombobox.DictionaryComboBox; @@ -59,7 +60,7 @@ public abstract class ButtonWithHotkeysDetailPane extends Butt } UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced"), 280, 20, advancePane); this.add(uiExpandablePane); - + BidiUtils.applyOrientationByLocale(this); } protected abstract Component createCenterPane(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java index 2e034076fc..c0e14fa688 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportFloatPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.i18n.BidiUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; @@ -71,6 +72,7 @@ public class ReportFloatPane extends JPanel { JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); leftTopPane.setBorder(BorderFactory.createEmptyBorder(12, 5, 0, 15)); this.add(leftTopPane, BorderLayout.NORTH); + BidiUtils.applyOrientationByLocale(this); } private void initInsertToolBar() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index 9549a3a7e8..c8520305f0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.cell.settingpane; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.expand.ExpandLeftFatherPane; @@ -63,7 +64,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); initAllNames(); - return layoutPane(); + return BidiUtils.applyOrientationByLocale(layoutPane()); } private void initAllNames() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index 5ac64d401a..f8a6ccfe6d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.Style; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.link.MessageWithLink; @@ -41,6 +42,7 @@ import com.fr.stable.Constants; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; +import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.JPanel; import javax.swing.SwingConstants; @@ -55,6 +57,7 @@ import java.awt.Insets; import java.awt.Rectangle; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.text.Bidi; import java.util.ArrayList; /** @@ -149,7 +152,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { contentPane.add(new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Desensitization"), HEAD_WDITH, HEAD_HEIGTH, desensitizePane())); // VerticalFlowLayout 与 实现的滚动条有冲突,因此再加一层panel JPanel jPanel = new JPanel(); - jPanel.add(contentPane); + jPanel.add(BidiUtils.applyOrientationByLocale(contentPane)); initAllNames(); return jPanel; } @@ -226,9 +229,13 @@ public class CellOtherSetPane extends AbstractCellAttrPane { return new Insets(LayoutConstants.VGAP_MEDIUM, 0, LayoutConstants.VGAP_MEDIUM, 0); } }; - VerticalFlowLayout verticalFlowLayout = new VerticalFlowLayout(VerticalFlowLayout.CENTER, 0, 0); - verticalFlowLayout.setAlignLeft(true); - basicPane.setLayout(verticalFlowLayout); + basicPane.setLayout(new BoxLayout(basicPane, BoxLayout.Y_AXIS)); + + defaultAutoRadioButton.setAlignmentX(BidiUtils.rtl() ? Component.RIGHT_ALIGNMENT : Component.LEFT_ALIGNMENT); + noAutoRadioButton.setAlignmentX(BidiUtils.rtl() ? Component.RIGHT_ALIGNMENT : Component.LEFT_ALIGNMENT); + autoHeightRadioButton.setAlignmentX(BidiUtils.rtl() ? Component.RIGHT_ALIGNMENT : Component.LEFT_ALIGNMENT); + autoWidthRadioButton.setAlignmentX(BidiUtils.rtl() ? Component.RIGHT_ALIGNMENT : Component.LEFT_ALIGNMENT); + basicPane.add(defaultAutoRadioButton); basicPane.add(noAutoRadioButton); basicPane.add(autoHeightRadioButton); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/CellDesensitizationGroupsPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/CellDesensitizationGroupsPane.java index de4e046b84..4ef09ceb00 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/CellDesensitizationGroupsPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/CellDesensitizationGroupsPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.cell.settingpane.desensitization; +import com.fr.base.i18n.BidiUtils; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -97,7 +98,7 @@ public class CellDesensitizationGroupsPane extends JPanel { JPanel controlPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); controlPane.setBackground(Color.WHITE); - controlPane.add(getbuttonPane(), BorderLayout.WEST); + controlPane.add(getbuttonPane(), BidiUtils.rtl() ? BorderLayout.EAST : BorderLayout.WEST); JPanel pane = new JPanel(new BorderLayout(4, 4)); pane.add(editTable, BorderLayout.CENTER); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java index 818a26205d..3911be9c84 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.cell.settingpane.desensitization.model; +import com.fr.base.i18n.BidiUtils; import com.fr.base.operator.org.OrganizationOperator; import com.fr.data.desensitize.rule.DesensitizationRuleManager; import com.fr.data.desensitize.rule.base.DesensitizationRule; @@ -103,6 +104,7 @@ public class DesensitizationCellPane extends BasicBeanPane { emptyTextField.setOpaque(false); editPanel.add(initTableCellPanel()); + BidiUtils.applyOrientationByLocale(editPanel, ruleTextField); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index e1e095cbfc..fca95a18d4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.cell.settingpane.style; import com.fr.base.CellBorderStyle; import com.fr.base.NameStyle; import com.fr.base.Style; +import com.fr.base.i18n.BidiUtils; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; @@ -14,6 +15,7 @@ import com.fr.design.style.BorderUtils; import javax.swing.*; import javax.swing.event.ChangeListener; import java.awt.*; +import java.text.Bidi; import java.util.ArrayList; import java.util.List; @@ -40,6 +42,7 @@ public class CustomStylePane extends MultiTabPane