Destiny.Lin
2 years ago
92 changed files with 2332 additions and 540 deletions
@ -0,0 +1,349 @@
|
||||
package com.fr.design.file; |
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
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.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 = IconUtils.readIcon("/com/fr/design/standard/close/close"); |
||||
private static final Icon MOUSE_OVER_CLOSE = IconUtils.readIcon("/com/fr/design/standard/close/close_mouseover.svg"); |
||||
private static final Icon MOUSE_PRESS_CLOSE = IconUtils.readIcon("/com/fr/design/standard/close/close_press.svg"); |
||||
|
||||
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().closeOtherByOperatorType(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,47 @@
|
||||
package com.fr.design.i18n; |
||||
|
||||
import com.fr.general.CloudCenter; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* 国际化链接获取工具 |
||||
* 根据配置文件key获取云中心key对应的链接或者默认链接 |
||||
* |
||||
* @author obo |
||||
* @since 11.0 |
||||
* Created on 2023/4/7 |
||||
*/ |
||||
public final class LocaleLinkProvider { |
||||
|
||||
private LocaleLinkProvider(){}; |
||||
|
||||
/** |
||||
* 单一实例 |
||||
*/ |
||||
private static final LocaleLinkProvider INSTANCE = new LocaleLinkProvider(); |
||||
|
||||
/** |
||||
* 返回LocaleLinkProvider的单一实例 |
||||
* |
||||
* @return LocaleLinkProvider单一实例 |
||||
*/ |
||||
public static LocaleLinkProvider getInstance(){ |
||||
return INSTANCE; |
||||
} |
||||
|
||||
/** |
||||
* 根据配置文件项中的key获取链接 |
||||
* |
||||
* @param propsKey 配置项key |
||||
* @param defaultKey 默认链接项key |
||||
* @return 对应的生成器 |
||||
*/ |
||||
public String getLink(String propsKey, String defaultKey) { |
||||
String cloudKey = DesignI18nImpl.getInstance().i18nText(propsKey); |
||||
String url = CloudCenter.getInstance().acquireUrlByKind(cloudKey); |
||||
if(StringUtils.isEmpty(url)) { |
||||
return DesignI18nImpl.getInstance().i18nText(defaultKey); |
||||
} |
||||
return url; |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.worker.save.type; |
||||
|
||||
/** |
||||
* 保存的类别 |
||||
* |
||||
* @author John.Ying |
||||
* @since 11.0 |
||||
* Created on 2023/4/14 |
||||
*/ |
||||
public class SaveType { |
||||
|
||||
private TypeEnum type; |
||||
//保存时间是否慢(是否展示了保存中的UI界面)
|
||||
private boolean slowly; |
||||
|
||||
public TypeEnum getType() { |
||||
return type; |
||||
} |
||||
|
||||
public void setType(TypeEnum saveType) { |
||||
this.type = saveType; |
||||
} |
||||
|
||||
public boolean isSlowly() { |
||||
return slowly; |
||||
} |
||||
|
||||
public void setSlowly(boolean slowly) { |
||||
this.slowly = slowly; |
||||
} |
||||
|
||||
/** |
||||
* 保存类型:save or saveAs or empty |
||||
*/ |
||||
public enum TypeEnum { |
||||
/** |
||||
* 保存 |
||||
*/ |
||||
SAVE, |
||||
/** |
||||
* 另存 |
||||
*/ |
||||
SAVE_AS, |
||||
/** |
||||
* 空保存 |
||||
*/ |
||||
EMPTY; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,81 @@
|
||||
package com.fr.design.worker.save.type; |
||||
|
||||
|
||||
import com.fr.concurrent.FineExecutors; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.DesignerFrameFileDealerPane; |
||||
import com.fr.design.mainframe.EastRegionContainerPane; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.design.ui.util.UIUtil; |
||||
import com.fr.third.org.apache.commons.lang3.time.StopWatch; |
||||
|
||||
import javax.swing.SwingWorker; |
||||
import java.util.concurrent.Callable; |
||||
import java.util.concurrent.ExecutorService; |
||||
|
||||
/** |
||||
* 判断保存类别时执行的worker |
||||
* |
||||
* @author John.Ying |
||||
* @since 11.0 |
||||
* Created on 2023/4/14 |
||||
*/ |
||||
public class SaveTypeWorker extends SwingWorker<SaveType, Void> { |
||||
|
||||
public static final ExecutorService SAVE_TYPE_POOL = FineExecutors.newSingleThreadExecutor(); |
||||
|
||||
private final Callable<SaveType.TypeEnum> callable; |
||||
|
||||
private static final int TIME_OUT = 400; |
||||
|
||||
private final JTemplate<?, ?> template; |
||||
|
||||
private final SaveType saveType; |
||||
|
||||
|
||||
|
||||
public SaveTypeWorker(Callable<SaveType.TypeEnum> callable, JTemplate<?, ?> template) { |
||||
this.callable = callable; |
||||
this.template = template; |
||||
this.saveType = new SaveType(); |
||||
} |
||||
|
||||
@Override |
||||
protected SaveType doInBackground() throws Exception { |
||||
this.saveType.setType(callable.call()); |
||||
return this.saveType; |
||||
} |
||||
|
||||
@Override |
||||
protected void done() { |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 启动saveTypeWorker |
||||
*/ |
||||
public void start() { |
||||
StopWatch stopWatch = StopWatch.createStarted(); |
||||
this.template.setSaving(true); |
||||
this.execute(); |
||||
SAVE_TYPE_POOL.execute(() -> { |
||||
while (true) { |
||||
//大于最大等待时间或者worker已经完成该线程都要结束循环
|
||||
if (stopWatch.getTime() > TIME_OUT || isDone()) { |
||||
//如果是大于最大等待时间结束的,就需要进行等待中界面的覆盖
|
||||
if (!isDone()) { |
||||
saveType.setSlowly(true); |
||||
UIUtil.invokeLaterIfNeeded(() -> { |
||||
// 开始禁用
|
||||
EastRegionContainerPane.getInstance().updateAllPropertyPane(); |
||||
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showCover(); |
||||
DesignerFrameFileDealerPane.getInstance().stateChange(); |
||||
}); |
||||
} |
||||
stopWatch.stop(); |
||||
break; |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -1 +1,2 @@
|
||||
Fine-Designer_Login=i7hP48WAcuTrmxfN |
||||
Fine-Designer_Reu_Share_CERTIFICATE_PUBLIC_KEY=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtsz62CPSWXZE/IYZRiAuTSZkw1WOwer8+JFktK0uKLAUuQoBr+UjAMFtRA8W7JgKMDwZy/2liEAiXEOSPU/hrdV8DtT541LnGi1X/hXiRwuttPWYN3L2GYm/d5blU+FBNwghBIrdAxXTzYBc6P4KL/oYXnMdTIrkz8tYkG3QoFQIDAQAB |
@ -0,0 +1,126 @@
|
||||
package com.fr.design.widget.ui.btn; |
||||
|
||||
import com.fr.design.ExtraDesignClassManager; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.WidgetAdvancedPaneProvider; |
||||
import com.fr.design.gui.icombobox.DictionaryComboBox; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.widget.btn.ButtonWithHotkeysDetailPane; |
||||
import com.fr.form.ui.Button; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.plugin.observer.PluginEvent; |
||||
import com.fr.plugin.observer.PluginEventListener; |
||||
import org.jetbrains.annotations.Nullable; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
import java.util.Set; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 用来处理额外的按钮属性 |
||||
* |
||||
* @author John.Ying |
||||
* @since 11.0 |
||||
* Created on 2023/4/19 |
||||
*/ |
||||
public abstract class AbstractExtraButtonPane<T extends Button> extends ButtonWithHotkeysDetailPane<T> { |
||||
protected JPanel extraPane; |
||||
protected boolean containsExtraPane; |
||||
protected static double F = TableLayout.FILL; |
||||
protected static double P = TableLayout.PREFERRED; |
||||
|
||||
protected void initExtraPane() { |
||||
initPluginListener(); |
||||
refreshExtraAdvancedPane(classType()); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 根据按钮类别判断需要返回什么类型的属性界面 |
||||
*/ |
||||
protected void refreshExtraAdvancedPane(Class cls) { |
||||
extraPaneList.clear(); |
||||
boolean containsExtraPane = false; |
||||
Set<WidgetAdvancedPaneProvider<T>> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); |
||||
for (WidgetAdvancedPaneProvider<T> provider : providers) { |
||||
if (!provider.accept(cls)) { |
||||
continue; |
||||
} |
||||
insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); |
||||
containsExtraPane = true; |
||||
} |
||||
if (containsExtraPane) { |
||||
extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); |
||||
for (BasicBeanPane<T> pane : extraPaneList) { |
||||
extraPane.add(pane); |
||||
} |
||||
} |
||||
this.containsExtraPane = containsExtraPane; |
||||
|
||||
} |
||||
|
||||
protected void initPluginListener() { |
||||
GeneralContext.listenPluginRunningChanged(new PluginEventListener() { |
||||
@Override |
||||
public void on(PluginEvent event) { |
||||
refreshExtraAdvancedPane(classType()); |
||||
} |
||||
}, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG)); |
||||
} |
||||
|
||||
/** |
||||
* 插入配置项面板 |
||||
* |
||||
* @param index 插入的位置 |
||||
* @param pane 配置项面板 |
||||
*/ |
||||
protected void insertShortCut(int index, BasicBeanPane<T> pane) { |
||||
int size = extraPaneList.size(); |
||||
index = Math.min(index, size); |
||||
extraPaneList.add(index, pane); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(T button) { |
||||
super.populate(button); |
||||
for (BasicBeanPane<T> pane : extraPaneList) { |
||||
pane.populateBean(button); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public T update() { |
||||
T button = super.update(); |
||||
for (BasicBeanPane<T> pane : extraPaneList) { |
||||
pane.updateBean(button); |
||||
} |
||||
return button; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected DictionaryComboBox createCustomButtonTypeComboBox() { |
||||
return createButtonTypeComboBox(containsExtraPane); |
||||
} |
||||
|
||||
/** |
||||
* 生成额外的属性界面 |
||||
*/ |
||||
protected Component createExtraPane(@Nullable BasicPane pane) { |
||||
initExtraPane(); |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{pane, null}, |
||||
new Component[]{extraPane, null} |
||||
}; |
||||
double[] rowSize = {P, P}; |
||||
double[] columnSize = {P, F}; |
||||
int[][] rowCount = {{1, 1},{1, 1}}; |
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, 10, 7); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue