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; }