Leo.Qin
2 years ago
20 changed files with 729 additions and 113 deletions
@ -0,0 +1,350 @@
|
||||
package com.fr.design.file; |
||||
|
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.imenu.UIMenuItem; |
||||
import com.fr.design.gui.imenu.UIScrollPopUpMenu; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.utils.TemplateUtils; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.collections.CollectionUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.Icon; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.SwingConstants; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
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.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 右侧下拉菜单的工厂类 |
||||
* @author Carlson |
||||
* @since 11.0 |
||||
* created on 2023-04-14 |
||||
**/ |
||||
public class MultiTemplateTabMenuFactory { |
||||
|
||||
private static final Icon CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); |
||||
private static final Icon MOUSE_OVER_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); |
||||
private static final Icon MOUSE_PRESS_CLOSE = IOUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); |
||||
|
||||
private static final int ITEM_SIZE = 25; |
||||
|
||||
private UIScrollPopUpMenu menu = null; |
||||
|
||||
private static MultiTemplateTabMenuFactory INSTANCE = new MultiTemplateTabMenuFactory(); |
||||
|
||||
private MultiTemplateTabMenuFactory() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 返回右侧下拉菜单的工厂类 |
||||
* @return |
||||
*/ |
||||
public static MultiTemplateTabMenuFactory getInstance() { |
||||
return INSTANCE; |
||||
} |
||||
|
||||
/** |
||||
* tab上的下拉菜单 |
||||
*/ |
||||
public UIScrollPopUpMenu createMenu() { |
||||
menu = new UIScrollPopUpMenu(); |
||||
menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); |
||||
|
||||
menu.add(initCloseOther()); |
||||
menu.add(createEmptyRow()); |
||||
menu.addSeparator(); |
||||
menu.add(createEmptyRow()); |
||||
menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Current_Category_Templates"))); |
||||
Component[] items = createCurrentCategory(); |
||||
for (Component item : items) { |
||||
menu.add(item); |
||||
} |
||||
items = createOtherCategory(); |
||||
if (items.length > 0) { |
||||
menu.addSeparator(); |
||||
menu.add(createEmptyRow()); |
||||
menu.add(createCategory(Toolkit.i18nText("Fine-Design_Basic_Tab_Other_Category_Templates"))); |
||||
for (Component item : items) { |
||||
menu.add(item); |
||||
} |
||||
} |
||||
Dimension dimension = menu.getPreferredSize(); |
||||
dimension.width += ITEM_SIZE; |
||||
menu.setPreferredSize(dimension); |
||||
return menu; |
||||
} |
||||
|
||||
/** |
||||
* 关闭其它按钮 |
||||
*/ |
||||
private UIMenuItem initCloseOther() { |
||||
UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_Tab_Close_Other_Templates_Of_Current_Category")); |
||||
closeOther.setHorizontalAlignment(SwingConstants.CENTER); |
||||
Dimension dimension = closeOther.getPreferredSize(); |
||||
dimension.height = ITEM_SIZE; |
||||
closeOther.setPreferredSize(dimension); |
||||
String currentOperator = getCurrentTabOperatorType(); |
||||
closeOther.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
|
||||
MultiTemplateTabPane.getInstance().closeAllByOperatorType(currentOperator); |
||||
} |
||||
}); |
||||
if (MultiTemplateTabPane.getInstance().getOpenedJTemplatesByOperator(currentOperator).size() <= 1) { |
||||
closeOther.setEnabled(false); |
||||
} |
||||
return closeOther; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 美观用 |
||||
*/ |
||||
private JPanel createEmptyRow() { |
||||
return new JPanel() { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
Dimension d = super.getPreferredSize(); |
||||
d.height = 1; |
||||
return d; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
/** |
||||
* 模板分类item |
||||
*/ |
||||
private UIButton createCategory(String categoryName) { |
||||
UIButton button = new UIButton(categoryName); |
||||
button.setBorderPainted(false); |
||||
button.setExtraPainted(false); |
||||
button.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); |
||||
button.setOpaque(true); |
||||
button.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
button.setHorizontalAlignment(SwingConstants.LEFT); |
||||
button.setForeground(UIConstants.FLESH_BLUE); |
||||
return button; |
||||
} |
||||
|
||||
/** |
||||
* 创建 当前分类模板 item数组 |
||||
*/ |
||||
private Component[] createCurrentCategory() { |
||||
return createListDownItem(MultiTemplateTabPane.getInstance().getOpenedJTemplatesByOperator(getCurrentTabOperatorType())); |
||||
} |
||||
|
||||
private String getCurrentTabOperatorType(){ |
||||
JTemplate jTemplate= HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); |
||||
return jTemplate.getTemplateTabOperatorType(); |
||||
} |
||||
|
||||
/** |
||||
* 创建 其它分类模板 item数组 |
||||
*/ |
||||
private Component[] createOtherCategory() { |
||||
String currentOperator = getCurrentTabOperatorType(); |
||||
List<JTemplate<?, ?>> openedTemplates = new ArrayList<>(); |
||||
Map<String, List<JTemplate<?, ?>>> map = MultiTemplateTabPane.getInstance().getOpenedJTemplatesByCategory(); |
||||
for (Map.Entry<String, List<JTemplate<?, ?>>> entry : map.entrySet()) { |
||||
if (!StringUtils.equals(currentOperator, entry.getKey())) { |
||||
openedTemplates.addAll(entry.getValue()); |
||||
} |
||||
} |
||||
return createListDownItem(openedTemplates); |
||||
} |
||||
|
||||
/** |
||||
* 根据template列表创建多个item |
||||
*/ |
||||
private Component[] createListDownItem(List<JTemplate<?, ?>> openedTemplates) { |
||||
if (!CollectionUtils.isEmpty(openedTemplates)) { |
||||
Component[] templates = new Component[openedTemplates.size()]; |
||||
for (int i = 0; i < openedTemplates.size(); i++) { |
||||
templates[i] = createListDownMenuItem(openedTemplates.get(i)); |
||||
} |
||||
return templates; |
||||
} |
||||
return new Component[0]; |
||||
} |
||||
|
||||
/** |
||||
* 根据template对象创建item |
||||
*/ |
||||
private Component createListDownMenuItem(JTemplate<?, ?> template) { |
||||
JPanel jPanel = new JPanel(); |
||||
jPanel.setPreferredSize(new Dimension(menu.getWidth(), ITEM_SIZE)); |
||||
jPanel.setLayout(new BorderLayout()); |
||||
|
||||
MenuItemButtonGroup menuItemButtonGroup = new MenuItemButtonGroup(template); |
||||
if (template == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) { |
||||
menuItemButtonGroup.templateButton.setForeground(UIConstants.FLESH_BLUE); |
||||
} |
||||
|
||||
jPanel.add(menuItemButtonGroup.iconButton, BorderLayout.WEST); |
||||
jPanel.add(menuItemButtonGroup.templateButton, BorderLayout.CENTER); |
||||
jPanel.add(menuItemButtonGroup.closeButton, BorderLayout.EAST); |
||||
|
||||
return jPanel; |
||||
} |
||||
|
||||
/** |
||||
* menu的item由模板图标、模板名、模板关闭按钮组成 |
||||
*/ |
||||
private class MenuItemButtonGroup { |
||||
|
||||
private final UIButton iconButton; |
||||
private final UIButton templateButton; |
||||
private final UIButton closeButton; |
||||
|
||||
public MenuItemButtonGroup(JTemplate<?, ?> template) { |
||||
iconButton = createIconButton(template); |
||||
templateButton = createTemplateButton(template); |
||||
closeButton = createCloseButton(); |
||||
initListener(template); |
||||
} |
||||
|
||||
/** |
||||
* item[0] 模板图标按钮初始化 |
||||
*/ |
||||
private UIButton createIconButton(JTemplate<?, ?> template) { |
||||
UIButton button = new UIButton(template.getIcon(), template.getIcon(), template.getIcon()); |
||||
button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); |
||||
button.setOpaque(true); |
||||
button.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
return button; |
||||
} |
||||
|
||||
/** |
||||
* item[1] 切换模板按钮初始化 |
||||
*/ |
||||
private UIButton createTemplateButton(JTemplate<?, ?> template) { |
||||
UIButton button = new UIButton(TemplateUtils.createLockeTemplatedName(template, template.getTemplateName())); |
||||
button.setBorderPainted(false); |
||||
button.setExtraPainted(false); |
||||
button.setPreferredSize(new Dimension(menu.getWidth() - ITEM_SIZE * 2, ITEM_SIZE)); |
||||
button.setOpaque(true); |
||||
button.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
button.setHorizontalAlignment(SwingConstants.LEFT); |
||||
return button; |
||||
} |
||||
|
||||
/** |
||||
* item[2] 关闭模板图标按钮初始化 |
||||
*/ |
||||
private UIButton createCloseButton() { |
||||
UIButton button = new UIButton(CLOSE, MOUSE_OVER_CLOSE, MOUSE_PRESS_CLOSE); |
||||
button.setPreferredSize(new Dimension(ITEM_SIZE, ITEM_SIZE)); |
||||
button.setOpaque(true); |
||||
button.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
button.setVisible(false); |
||||
return button; |
||||
} |
||||
|
||||
private void initListener(JTemplate<?, ?> template) { |
||||
initIconButtonListener(); |
||||
initTemplateButtonListener(template); |
||||
initCloseButtonListener(template); |
||||
} |
||||
|
||||
/** |
||||
* item[0] 模板图标按钮鼠标事件 |
||||
*/ |
||||
private void initIconButtonListener() { |
||||
iconButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
fireMouseEnteredEvent(); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
fireMouseExitedEvent(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* item[1] 切换模板按钮鼠标事件 |
||||
*/ |
||||
private void initTemplateButtonListener(JTemplate<?, ?> template) { |
||||
templateButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
menu.setVisible(false); |
||||
MultiTemplateTabPane.getInstance().switchJTemplate(template); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
fireMouseEnteredEvent(); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
fireMouseExitedEvent(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* item[2] 关闭模板按钮鼠标事件 |
||||
*/ |
||||
private void initCloseButtonListener(JTemplate<?, ?> template) { |
||||
closeButton.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
menu.setVisible(false); |
||||
MultiTemplateTabPane.getInstance().setIsCloseCurrent(template == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); |
||||
MultiTemplateTabPane.getInstance().closeFormat(template); |
||||
MultiTemplateTabPane.getInstance().closeSpecifiedTemplate(template); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
fireMouseEnteredEvent(); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
fireMouseExitedEvent(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* mouse移入item范围 |
||||
*/ |
||||
private void fireMouseEnteredEvent() { |
||||
iconButton.setBackground(UIConstants.HOVER_BLUE); |
||||
templateButton.setBackground(UIConstants.HOVER_BLUE); |
||||
closeButton.setBackground(UIConstants.HOVER_BLUE); |
||||
closeButton.setVisible(true); |
||||
} |
||||
|
||||
/** |
||||
* mouse移出item范围 |
||||
*/ |
||||
private void fireMouseExitedEvent() { |
||||
iconButton.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
templateButton.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
closeButton.setBackground(UIConstants.NORMAL_BACKGROUND); |
||||
closeButton.setVisible(false); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.design.i18n.LocaleLinkProvider; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
|
||||
/** |
||||
* 根据图片信息生成获取国际化服务器图标工具 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/4/19 |
||||
*/ |
||||
public class DataMaskMark implements LocaleMark<String> { |
||||
|
||||
/** |
||||
* 云中心数据脱敏帮助链接链接在配置文件中对应的配置文件key |
||||
*/ |
||||
private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Data_Mask"; |
||||
|
||||
/** |
||||
* 云中心数据脱敏默认帮助链接在配置文件中对应的配置文件key |
||||
*/ |
||||
private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design_Report_Desensitization_Help_Document_Url"; |
||||
|
||||
@Override |
||||
public String getValue() { |
||||
return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.design.locale.impl; |
||||
|
||||
import com.fr.design.i18n.LocaleLinkProvider; |
||||
import com.fr.general.locale.LocaleMark; |
||||
|
||||
/** |
||||
* 根据国际化获取启用行式引擎执行层式报表帮助文档链接 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/4/19 |
||||
*/ |
||||
public class LineEngineMark implements LocaleMark<String> { |
||||
|
||||
/** |
||||
* 云中心启用行式引擎执行层式报表帮助链接链接在配置文件中对应的配置文件key |
||||
*/ |
||||
private static final String PROPS_LINK_KEY = "Fine-Design-CloudCenter_Line_Engine"; |
||||
|
||||
/** |
||||
* 云中心启用行式引擎执行层式报表默认帮助链接在配置文件中对应的配置文件key |
||||
*/ |
||||
private static final String PROPS_LINK_KEY_DEFAULT = "Fine-Design-CloudCenter_Line_Engine_Default"; |
||||
@Override |
||||
public String getValue() { |
||||
return LocaleLinkProvider.getInstance().getLink(PROPS_LINK_KEY, PROPS_LINK_KEY_DEFAULT); |
||||
} |
||||
} |
Loading…
Reference in new issue