diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java index 4d5556ef95..a0b651acbd 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java @@ -3,6 +3,7 @@ */ package com.fr.design.data.datapane.connect; +import com.fr.data.driver.util.JarFileParseUtil; import com.fr.data.impl.Connection; import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.data.impl.JNDIDatabaseConnection; @@ -32,10 +33,12 @@ import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JDialog; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.ScrollPaneConstants; +import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.UIManager; @@ -55,6 +58,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.File; import java.net.URI; import java.util.concurrent.ExecutionException; @@ -93,120 +97,7 @@ public abstract class DatabaseConnectionPane connectionThread = new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - Connection database = DatabaseConnectionPane.this.updateBean(); - // 返回连接结果 - DriverPage.updateCache(); - final Exception[] exception = new Exception[1]; - WorkContext.getCurrent().get(DataOperatorProvider.class, new ExceptionHandler() { - @Override - public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) { - // 正常调用发生的异常也会被捕获,因此需要对异常类型进行判断,如果是NoSuchMethodException 就要去调用 testConnection - // 如果不是 NoSuchMethodException 保存下异常上下文 - // 两种情况下异常都需要抛出 - if (exceptionInfo.getException() instanceof NoSuchMethodException) { - if (!WorkContext.getCurrent().get(DataOperatorProvider.class).testConnection(database)) { - exception[0] = new Exception(Toolkit.i18nText("Fine-Design_Description_Of_Test_Connection")); - } - } else { - exception[0] = exceptionInfo.getException(); - } - return null; - } - }).testConnectionWithException(database); - if (exception[0] != null) { - throw exception[0]; - } - return null; - } - - @Override - protected void done() { - try { - get(); - dialog.setSize(new Dimension(380, 125)); - okButton.setEnabled(true); - uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); - message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); - } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (ExecutionException e) { - dialog.setSize(new Dimension(380, 142)); - midPane.setVisible(true); - hiddenPanel.setVisible(false); - okButton.setEnabled(true); - uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); - message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")); - Connection database = DatabaseConnectionPane.this.updateBean(); - SolutionProcessor select = ExceptionSolutionSelector.get().select(e, database); - if (select instanceof ClassNotFoundExceptionSolutionProcessor) { - JPanel gridJpanel = new JPanel(); - gridJpanel.setLayout(new GridLayout(5, 1, 0, 5)); - UILabel driverTips = new UILabel(); - driverTips.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver")); - gridJpanel.add(driverTips); - UILabel deatail = new UILabel(); - String content = Toolkit.i18nText("Fine_Designer_Not_Found") + " " + select.getResultException().getDetailMessage() + " " + Toolkit.i18nText("Fine_Designer_Driver"); - deatail.setText(content); - deatail.setToolTipText(content); - gridJpanel.add(deatail); - String solution = select.getResultException().getSolution(); - UILabel redirect = new UILabel(); - if (solution != null) { - redirect.setText(Toolkit.i18nText("Fine_Designer_Download_Driver")); - redirect.setForeground(Color.BLUE); - redirect.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - try { - Desktop.getDesktop().browse(new URI(solution)); - } catch (Exception clickException) { - FineLoggerFactory.getLogger().warn("can not open browser with {}", solution); - } - } - - @Override - public void mouseEntered(MouseEvent e) { - redirect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } - - @Override - public void mouseExited(MouseEvent e) { - redirect.setCursor(Cursor.getDefaultCursor()); - } - }); - } else { - redirect.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver_No_Solution")); - } - gridJpanel.add(redirect); - hiddenPanel.add(gridJpanel); - gridJpanel.setBackground(Color.WHITE); - } else { - JPanel borderPanel = new JPanel(); - borderPanel.setLayout(new BorderLayout()); - JTextArea jta = new JTextArea(); - JScrollPane jsp = new JScrollPane(jta); - jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - jta.append(select.getResultException().getDetailMessage() + "\n"); - jta.append(select.getResultException().getSolution()); - jta.setCaretPosition(0); - jta.setEditable(false); - jta.getCaret().addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - jta.getCaret().setVisible(true); - } - }); - borderPanel.add(jsp, BorderLayout.CENTER); - hiddenPanel.add(borderPanel); - } - okButton.setEnabled(true); - } - } - }; + final SwingWorker connectionThread = new TestConnectionWorker(); midPane.setVisible(false); hiddenPanel.setVisible(false); initDialogPane(); @@ -530,4 +421,191 @@ public abstract class DatabaseConnectionPane { + @Override + protected Void doInBackground() throws Exception { + Connection database = DatabaseConnectionPane.this.updateBean(); + // 返回连接结果 + DriverPage.updateCache(); + final Exception[] exception = new Exception[1]; + WorkContext.getCurrent().get(DataOperatorProvider.class, new ExceptionHandler() { + @Override + public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) { + // 正常调用发生的异常也会被捕获,因此需要对异常类型进行判断,如果是NoSuchMethodException 就要去调用 testConnection + // 如果不是 NoSuchMethodException 保存下异常上下文 + // 两种情况下异常都需要抛出 + if (exceptionInfo.getException() instanceof NoSuchMethodException) { + if (!WorkContext.getCurrent().get(DataOperatorProvider.class).testConnection(database)) { + exception[0] = new Exception(Toolkit.i18nText("Fine-Design_Description_Of_Test_Connection")); + } + } else { + exception[0] = exceptionInfo.getException(); + } + return null; + } + }).testConnectionWithException(database); + if (exception[0] != null) { + throw exception[0]; + } + return null; + } + + @Override + protected void done() { + try { + get(); + dialog.setSize(new Dimension(380, 125)); + okButton.setEnabled(true); + uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); + message.setText(Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully")); + } catch (InterruptedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (ExecutionException e) { + dealWithException(e); + } + } + + private void dealWithException(ExecutionException e) { + dialog.setSize(new Dimension(380, 142)); + midPane.setVisible(true); + hiddenPanel.setVisible(false); + okButton.setEnabled(true); + uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); + message.setText(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")); + Connection database = DatabaseConnectionPane.this.updateBean(); + SolutionProcessor select = ExceptionSolutionSelector.get().select(e, database); + String detail = select.getResultException().getDetailMessage(); + String solution = select.getResultException().getSolution(); + if (select instanceof ClassNotFoundExceptionSolutionProcessor) { + showClassNotFoundUI(select.getResultException().getDetailMessage(), select.getResultException().getSolution()); + } else { + showExceptionMessageUI(detail, solution); + } + okButton.setEnabled(true); + } + + private void showClassNotFoundUI(String detailMessage, String solution) { + JPanel gridJpanel = new JPanel(); + gridJpanel.setLayout(new GridLayout(5, 1, 0, 5)); + UILabel driverTips = new UILabel(); + driverTips.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver")); + gridJpanel.add(driverTips); + UILabel deatail = new UILabel(); + String content = Toolkit.i18nText("Fine_Designer_Not_Found") + " " + detailMessage+ " " + Toolkit.i18nText("Fine_Designer_Driver"); + deatail.setText(content); + deatail.setToolTipText(content); + gridJpanel.add(deatail); + UILabel redirect = new UILabel(); + if (solution != null) { + redirect.setText(Toolkit.i18nText("Fine_Designer_Download_Driver")); + redirect.setForeground(Color.BLUE); + redirect.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + try { + Desktop.getDesktop().browse(new URI(solution)); + } catch (Exception clickException) { + FineLoggerFactory.getLogger().warn("can not open browser with {}", solution); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + redirect.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + redirect.setCursor(Cursor.getDefaultCursor()); + } + }); + } else { + redirect.setText(Toolkit.i18nText("Fine_Designer_Not_Found_Driver_No_Solution")); + } + gridJpanel.add(redirect); + hiddenPanel.add(gridJpanel); + gridJpanel.setBackground(Color.WHITE); + } + + private void showExceptionMessageUI(String detail, String solution) { + JPanel borderPanel = new JPanel(); + borderPanel.setLayout(new BorderLayout()); + JTextArea jta = new JTextArea(); + JScrollPane jsp = new JScrollPane(jta); + jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); + jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + + Connection con = DatabaseConnectionPane.this.updateBean(); + if(con instanceof JDBCDatabaseConnection) { + String driverPath = JarFileParseUtil.getDriverClassPath((JDBCDatabaseConnection) con); + jta.append(Toolkit.i18nText("Fine_Designer_Current_Driver_Path") + ":" + driverPath + "\n"); + JPanel testDriverPanel = generateTestDriverPanel((JDBCDatabaseConnection) con, driverPath); + borderPanel.add(testDriverPanel, BorderLayout.NORTH); + } + jta.append(detail + "\n"); + jta.append(solution); + jta.setCaretPosition(0); + jta.setEditable(false); + jta.getCaret().addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + jta.getCaret().setVisible(true); + } + }); + borderPanel.add(jsp, BorderLayout.CENTER); + hiddenPanel.add(borderPanel); + } + + private JPanel generateTestDriverPanel(JDBCDatabaseConnection con, String driverPath) { + JPanel xBorderPanel = new JPanel(); + xBorderPanel.setLayout(new BorderLayout()); + UILabel driverTestTip = new UILabel(); + JLabel testResult = new JLabel(); + driverTestTip.setForeground(Color.BLUE); + driverTestTip.setVisible(true); + testResult.setVisible(false); + testResult.setHorizontalAlignment(SwingConstants.CENTER); + driverTestTip.setText(Toolkit.i18nText("Fine_Designer_Driver_Path_Test")); + xBorderPanel.add(driverTestTip, BorderLayout.WEST); + xBorderPanel.add(testResult, BorderLayout.CENTER); + + driverTestTip.addMouseListener(new MouseAdapter() { + @Override + public void mouseEntered(MouseEvent e) { + driverTestTip.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + driverTestTip.setCursor(Cursor.getDefaultCursor()); + } + @Override + public void mouseClicked(MouseEvent e) { + try { + String path; + if(driverPath.endsWith(JarFileParseUtil.JAR_MARKER)) { + path = new File(driverPath).getParent(); + } else { + path = driverPath; + } + if(JarFileParseUtil.hasDuplicateDriver(con.getDriver(), path)) { + testResult.setForeground(Color.RED); + testResult.setText(Toolkit.i18nText("Fine_Designer_Driver_Conflict")); + } else { + testResult.setForeground(Color.BLACK); + testResult.setText(Toolkit.i18nText("Fine_Designer_Driver_No_Conflict")); + } + testResult.setVisible(true); + } catch (Exception clickException) { + FineLoggerFactory.getLogger().warn(clickException, "can not test driver conflict"); + } + } + }); + return xBorderPanel; + } + + + } + } diff --git a/designer-base/src/main/java/com/fr/design/fun/TemplateThemePaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/TemplateThemePaneProvider.java new file mode 100644 index 0000000000..f05d85318c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/TemplateThemePaneProvider.java @@ -0,0 +1,35 @@ +package com.fr.design.fun; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.stable.fun.mark.Mutable; + +/** + * 设计器模板主题管理-细节定制部分,支持添加tab + * + * @author Bruce.Deng + * @version 11.0 + * Created by Bruce.Deng on 2023/2/7 + */ +public interface TemplateThemePaneProvider extends Mutable { + + String XML_TAG = "TemplateThemePaneProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 插入tab的位置 + * + * @param total 已插入的tab数 + * @return 插入位置,如果想放到最后,则返回-1 + */ + int getInsertPosition(int total); + + + /** + * 获取tab对象 + * + * @return tab对象 + */ + BasicBeanPane getTab(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateThemePaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateThemePaneProvider.java new file mode 100644 index 0000000000..7e8fe617dc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractTemplateThemePaneProvider.java @@ -0,0 +1,26 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.TemplateThemePaneProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author Bruce.Deng + * @version 11.0 + * @see TemplateThemePaneProvider + * Created by Bruce.Deng on 2023/2/7 + */ +@API(level = TemplateThemePaneProvider.CURRENT_LEVEL) +public abstract class AbstractTemplateThemePaneProvider extends AbstractProvider implements TemplateThemePaneProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java index 798bb73c59..eb15a657f5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/FormThemeProfilePane.java @@ -4,12 +4,14 @@ import com.fr.base.theme.FormTheme; import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedFormBodyStyle; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.edit.ChartStyleFormEditPane; import com.fr.design.mainframe.theme.edit.ComponentStyleEditPane; import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane; import com.fr.design.mainframe.theme.preview.FormThemePreviewPane; +import com.fr.design.mainframe.theme.processor.ThemePreviewPaneProcessor; import javax.swing.JPanel; @@ -31,7 +33,11 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane { } @Override - public FormThemePreviewPane createThemePreviewPane() { + public TemplateThemePreviewPane createThemePreviewPane() { + ThemePreviewPaneProcessor processor = ExtraDesignClassManager.getInstance().getSingle(ThemePreviewPaneProcessor.XML_TAG); + if (processor != null) { + return processor.createFormThemePreviewPane(); + } return new FormThemePreviewPane(); } @@ -61,6 +67,7 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane { componentStyleSettingPane = new ComponentStyleEditPane(); addCustomEditorPane(i18nText("Fine-Design_Predefined_Component_Style"), componentStyleSettingPane); + refreshExtraAdvancedPane(); } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java index f0f25f677f..57e6ddf5f1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/ReportThemeProfilePane.java @@ -2,10 +2,11 @@ package com.fr.design.mainframe.theme; import com.fr.base.theme.ReportTheme; import com.fr.base.theme.TemplateThemeConfig; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.theme.edit.ReportBodyStyleEditPane; import com.fr.design.mainframe.theme.preview.ReportThemePreviewPane; -import javax.swing.JPanel; +import com.fr.design.mainframe.theme.processor.ThemePreviewPaneProcessor; /** * @author Starryi @@ -20,7 +21,11 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane createThemePreviewPane() { + ThemePreviewPaneProcessor processor = ExtraDesignClassManager.getInstance().getSingle(ThemePreviewPaneProcessor.XML_TAG); + if (processor != null) { + return processor.createReportThemePreviewPane(); + } return new ReportThemePreviewPane(); } @@ -44,6 +49,7 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane extends J protected ColorListPane colorListPane; protected CellStyleListEditPane cellStyleSettingPane; protected ChartStyleEditPane chartStyleSettingPane; + protected final List> extraPaneList = new ArrayList<>(); protected boolean isPopulating = false; protected UITabbedPane uiTabbedPane; @@ -171,7 +178,7 @@ public abstract class TemplateThemeEditorPane extends J uiTabbedPane = new UITabbedPane(); uiTabbedPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 1)); container.add(uiTabbedPane, BorderLayout.CENTER); - + initPluginListener(); return container; } @@ -192,6 +199,33 @@ public abstract class TemplateThemeEditorPane extends J }); uiTabbedPane.addTab(title, settingPane); } + + protected void refreshExtraAdvancedPane() { + extraPaneList.clear(); + Set> providers = ExtraDesignClassManager.getInstance().getArray(TemplateThemePaneProvider.XML_TAG); + for (TemplateThemePaneProvider provider : providers) { + insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.getTab()); + } + for (BasicBeanPane pane : extraPaneList) { + addCustomEditorPane(pane.getTitle(), pane); + } + } + + private void insertShortCut(int index, BasicBeanPane pane) { + int size = extraPaneList.size(); + index = Math.min(index, size); + extraPaneList.add(index, pane); + } + + private void initPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshExtraAdvancedPane(); + } + }, pluginContext -> pluginContext.getRuntime().contain(TemplateThemePaneProvider.XML_TAG)); + } + protected JPanel createCellStyleSettingPane() { JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); cellStyleSettingPane = new CellStyleListEditPane(); @@ -223,6 +257,9 @@ public abstract class TemplateThemeEditorPane extends J colorListPane.populate(theme.getColorScheme().getColors()); populateBean4CustomEditors(theme); + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(theme); + } isPopulating = false; } @@ -243,7 +280,9 @@ public abstract class TemplateThemeEditorPane extends J theme.setColorScheme(colorScheme); updateBean4CustomEditors(theme); - + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(theme); + } return theme; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/processor/AbstractThemePreviewPaneProcessor.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/processor/AbstractThemePreviewPaneProcessor.java new file mode 100644 index 0000000000..839944d9fe --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/processor/AbstractThemePreviewPaneProcessor.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe.theme.processor; + +import com.fr.stable.fun.mark.API; + +/** + * @author Bruce.Deng + * @version 11.0 + * Created by Bruce.Deng on 2023/2/14 + */ +@API(level = ThemePreviewPaneProcessor.CURRENT_LEVEL) +public abstract class AbstractThemePreviewPaneProcessor implements ThemePreviewPaneProcessor { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public int layerIndex() { + return DEFAULT_LAYER_INDEX; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/processor/ThemePreviewPaneProcessor.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/processor/ThemePreviewPaneProcessor.java new file mode 100644 index 0000000000..93b17b8e92 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/processor/ThemePreviewPaneProcessor.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.theme.processor; + +import com.fr.base.theme.FormTheme; +import com.fr.base.theme.ReportTheme; +import com.fr.design.mainframe.theme.TemplateThemePreviewPane; +import com.fr.stable.fun.mark.Immutable; + +/** + * 主题样式预览界面接口 + * + * @author Bruce.Deng + * @version 11.0 + * Created by Bruce.Deng on 2023/2/14 + */ +public interface ThemePreviewPaneProcessor extends Immutable { + + String XML_TAG = "ThemePreviewPaneProcessor"; + + int CURRENT_LEVEL = 1; + + /** + * 创建报表主题样式预览界面 + * + * @return 报表主题样式预览界面 + */ + TemplateThemePreviewPane createReportThemePreviewPane(); + + /** + * 创建决策报表主题样式预览界面 + * + * @return 决策报表主题样式预览界面 + */ + TemplateThemePreviewPane createFormThemePreviewPane(); + +} diff --git a/designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java b/designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java new file mode 100644 index 0000000000..eafa70b239 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/fun/WidgetAdvancedPaneProvider.java @@ -0,0 +1,42 @@ +package com.fr.design.fun; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.designer.creator.XCreator; +import com.fr.stable.fun.mark.Mutable; + +/** + * 设计器控件的属性设置下“高级”设置项扩展,支持追加设置项 + * + * @author Bruce.Deng + * @version 11.0 + * Created by Bruce.Deng on 2023/2/15 + */ +public interface WidgetAdvancedPaneProvider extends Mutable { + + String XML_TAG = "WidgetAdvancedPaneProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 获取插入的位置 + * + * @param total 已插入的面板数 + * @return 插入位置,如果想放到最后,则返回-1 + */ + int getInsertPosition(int total); + + /** + * 根据XCreator判断是否需要处理 + * + * @param creator + * @return true:需要处理;false:不处理 + */ + boolean accept(XCreator creator); + + /** + * 创建控件高级设置项的追加面板 + * + * @return 高级设置项追加面板 + */ + BasicBeanPane createExtraAdvancedPane(); +} diff --git a/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java new file mode 100644 index 0000000000..6b60eb56a8 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/fun/impl/AbstractWidgetAdvancedPaneProvider.java @@ -0,0 +1,26 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.WidgetAdvancedPaneProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author Bruce.Deng + * @version 11.0 + * @see WidgetAdvancedPaneProvider + * Created by Bruce.Deng on 2023/2/15 + */ +@API(level = WidgetAdvancedPaneProvider.CURRENT_LEVEL) +public abstract class AbstractWidgetAdvancedPaneProvider extends AbstractProvider implements WidgetAdvancedPaneProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java b/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java index 9b4dfb4c44..86e3f49986 100644 --- a/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/parameter/RootDesignDefinePane.java @@ -2,6 +2,7 @@ package com.fr.design.parameter; import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.CRPropertyDescriptor; @@ -13,6 +14,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fit.common.TemplateTool; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.fun.ParameterExpandablePaneUIProvider; +import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -32,6 +34,9 @@ import com.fr.design.widget.ui.designer.AbstractDataModify; import com.fr.design.widget.ui.designer.component.UIBoundSpinner; import com.fr.form.ui.container.WParameterLayout; import com.fr.general.Background; +import com.fr.general.GeneralContext; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.report.stable.FormConstants; import javax.swing.BorderFactory; @@ -41,6 +46,8 @@ import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; import java.util.Set; /** @@ -59,6 +66,8 @@ public class RootDesignDefinePane extends AbstractDataModify { //是否是新设计模式下决策报表 private boolean newForm; private PropertyGroupPane extraPropertyGroupPane; + protected final List> extraPaneList = new ArrayList<>(); + private JPanel backgroundPane; public RootDesignDefinePane(XCreator xCreator) { super(xCreator); @@ -144,7 +153,6 @@ public class RootDesignDefinePane extends AbstractDataModify { fireAfterEditor.setSelected(false); } }); - background = new AccessibleBackgroundEditor(); Icon[] hAlignmentIconArray = {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"),}; @@ -152,6 +160,8 @@ public class RootDesignDefinePane extends AbstractDataModify { hAlignmentPane = new UIButtonGroup(hAlignmentIconArray, hAlignment); hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Left") , com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_StyleAlignment_Right")}); + backgroundPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.initExtraPane(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p, p, p, p, p}; @@ -159,7 +169,7 @@ public class RootDesignDefinePane extends AbstractDataModify { int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), backgroundPane}, new Component[]{displayReport, null}, new Component[]{useParamsTemplate, null}, new Component[]{fireAfterEditor, null}, @@ -176,6 +186,54 @@ public class RootDesignDefinePane extends AbstractDataModify { return jPanel; } + private void initExtraPane() { + initPluginListener(); + refreshExtraAdvancedPane(); + } + + private void initPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshExtraAdvancedPane(); + } + }, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG)); + } + + private void refreshExtraAdvancedPane() { + extraPaneList.clear(); + backgroundPane.removeAll(); + Set> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); + for (WidgetAdvancedPaneProvider provider : providers) { + if (!provider.accept(creator)) { + continue; + } + insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); + } + if (extraPaneList.isEmpty()) { + if (background == null) { + background = new AccessibleBackgroundEditor(); + } + backgroundPane.add(background); + } else { + for (BasicBeanPane pane : extraPaneList) { + backgroundPane.add(pane); + } + } + } + + /** + * 插入配置项面板 + * + * @param index 插入的位置 + * @param pane 配置项面板 + */ + public void insertShortCut(int index, BasicBeanPane pane) { + int size = extraPaneList.size(); + index = Math.min(index, size); + extraPaneList.add(index, pane); + } + /** * @param * @Description: 获取新决策报表的AdvancePane @@ -199,8 +257,8 @@ public class RootDesignDefinePane extends AbstractDataModify { fireAfterEditor.setSelected(false); } }); - background = new AccessibleBackgroundEditor(); - + backgroundPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.initExtraPane(); double f = TableLayout.FILL; double p = TableLayout.PREFERRED; double[] rowSize = {p, p, p, p, p}; @@ -208,7 +266,7 @@ public class RootDesignDefinePane extends AbstractDataModify { int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; Component[][] components = new Component[][]{ new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Label_Name")), labelNameTextField}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), background}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background")), backgroundPane}, new Component[]{displayReport, null}, new Component[]{useParamsTemplate, null}, new Component[]{fireAfterEditor, null}, @@ -229,7 +287,13 @@ public class RootDesignDefinePane extends AbstractDataModify { @Override public void populateBean(WParameterLayout ob) { labelNameTextField.setText(ob.getLabelName()); - background.setValue(ob.getBackground()); + if (extraPaneList.isEmpty()) { + background.setValue(ob.getBackground()); + } else { + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(ob); + } + } displayReport.setSelected(ob.isDelayDisplayContent()); useParamsTemplate.setSelected(ob.isUseParamsTemplate()); fireAfterEditor.setEnabled(ob.isUseParamsTemplate()); @@ -277,8 +341,14 @@ public class RootDesignDefinePane extends AbstractDataModify { wParameterLayout.setParamsFireStopEdit(fireAfterEditor.isSelected()); JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); - wParameterLayout.setBackground((Background) background.getValue()); wParameterLayout.setPosition((Integer) hAlignmentPane.getSelectedItem()); + if (extraPaneList.isEmpty()) { + wParameterLayout.setBackground((Background) background.getValue()); + } else { + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(wParameterLayout); + } + } return wParameterLayout; } @@ -299,6 +369,13 @@ public class RootDesignDefinePane extends AbstractDataModify { JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); jTemplate.needAddTemplateIdAttr(useParamsTemplate.isSelected()); wParameterLayout.setBackground((Background) background.getValue()); + if (extraPaneList.isEmpty()) { + background.setValue(wParameterLayout.getBackground()); + } else { + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(wParameterLayout); + } + } //设置参数模板面板的高度 int height = (int) paraHeight.getTextField().getValue(); FormDesigner designer = TemplateTool.getCurrentEditingNewJForm().getFormDesign(); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java index 4ee699e0fe..1777a027ba 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/FieldEditorDefinePane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.ErrorMsgTextFieldAdapter; import com.fr.design.beans.UITextFieldAdapter; import com.fr.design.constants.LayoutConstants; @@ -12,6 +13,7 @@ import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.fun.TextFieldAdapterProvider; +import com.fr.design.fun.WidgetAdvancedPaneProvider; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; @@ -19,7 +21,10 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.widget.ui.designer.component.FontSizeComboPane; import com.fr.form.ui.FieldEditor; +import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -27,6 +32,9 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; public abstract class FieldEditorDefinePane extends AbstractDataModify { protected UICheckBox allowBlankCheckBox; @@ -35,7 +43,8 @@ public abstract class FieldEditorDefinePane extends Abstr protected JPanel validatePane; protected FontSizeComboPane fontSizePane; protected UITextField labelNameTextField; - + private final List> extraPaneList = new ArrayList<>(); + private JPanel extraPane; public FieldEditorDefinePane(XCreator xCreator) { super(xCreator); @@ -49,8 +58,11 @@ public abstract class FieldEditorDefinePane extends Abstr allowBlankCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); fontSizePane = new FontSizeComboPane(); JPanel contentPane = this.setFirstContentPane(); - JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - jPanel.add(contentPane, BorderLayout.CENTER); + JPanel jPanel = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + jPanel.add(contentPane); + extraPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + jPanel.add(extraPane); + this.initExtraPane(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); if (contentPane != null) { UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, jPanel); @@ -59,12 +71,35 @@ public abstract class FieldEditorDefinePane extends Abstr this.addValidatePane(); } + private void initExtraPane() { + initPluginListener(); + refreshExtraAdvancedPane(); + } + + private void refreshExtraAdvancedPane() { + extraPaneList.clear(); + extraPane.removeAll(); + Set> providers = ExtraDesignClassManager.getInstance().getArray(WidgetAdvancedPaneProvider.XML_TAG); + for (WidgetAdvancedPaneProvider provider : providers) { + if (!provider.accept(creator)) { + continue; + } + insertShortCut(provider.getInsertPosition(extraPaneList.size()), provider.createExtraAdvancedPane()); + } + for (BasicBeanPane pane : extraPaneList) { + extraPane.add(pane); + } + } + @Override public void populateBean(T ob) { this.allowBlankCheckBox.setSelected(ob.isAllowBlank()); this.errorMsgTextField.setText(ob.getErrorMessage()); this.fontSizePane.setValue(ob.getFontSize()); this.labelNameTextField.setText(ob.getLabelName()); + for (BasicBeanPane pane : extraPaneList) { + pane.populateBean(ob); + } populateSubFieldEditorBean(ob); } @@ -78,6 +113,9 @@ public abstract class FieldEditorDefinePane extends Abstr e.setErrorMessage(this.errorMsgTextField.getText()); e.setFontSize(fontSizePane.getValue()); e.setLabelName(labelNameTextField.getText()); + for (BasicBeanPane pane : extraPaneList) { + pane.updateBean(e); + } return e; } @@ -152,4 +190,25 @@ public abstract class FieldEditorDefinePane extends Abstr return null; } + /** + * 插入配置项面板 + * + * @param index 插入的位置 + * @param pane 配置项面板 + */ + private void insertShortCut(int index, BasicBeanPane pane) { + int size = extraPaneList.size(); + index = Math.min(index, size); + extraPaneList.add(index, pane); + } + + private void initPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshExtraAdvancedPane(); + } + }, pluginContext -> pluginContext.getRuntime().contain(WidgetAdvancedPaneProvider.XML_TAG)); + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index cab4c6a185..d4fa7ed5cf 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1311,6 +1311,7 @@ public class JWorkBook extends JTemplate { boolean shouldCreateUndoState = compatible == TemplateThemeCompatible.NONE && !StringUtils.equals(oldTheme.getName(), newTheme.getName()); getTarget().setTemplateTheme(newTheme, compatible); + getTarget().getReportParameterAttr().onTemplateUsingThemeChange(newTheme, compatible); setTarget((WorkBook) FineColorSynchronizer.flush(getTarget(), newTheme, compatible)); if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate() == this) { @@ -1318,6 +1319,8 @@ public class JWorkBook extends JTemplate { reportComposite.setSelectedIndex(reportComposite.getSelectedIndex()); TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + // 刷新参数面板界面 + populateReportParameterAttr(); } super.setTemplateTheme(newTheme, compatible); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/AbstractSocketConfig.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/AbstractSocketConfig.java index 2f86907763..8562ccbbdb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/AbstractSocketConfig.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/AbstractSocketConfig.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.socketio; -import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.report.RemoteDesignConstants; @@ -14,6 +13,8 @@ import com.fr.workspace.Workspace; import com.fr.workspace.base.WorkspaceConstants; import com.fr.workspace.connect.WorkspaceConnection; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.server.socket.SocketIOVerifier; +import com.fr.workspace.server.socket.SocketVerifierOperator; import io.socket.client.IO; import io.socket.engineio.client.transports.Polling; import io.socket.engineio.client.transports.WebSocket; @@ -83,14 +84,17 @@ public abstract class AbstractSocketConfig { WorkspaceConnection connection = current.getConnection(); currentProtocol = getCurrentProtocolFromUrl(url); String[] result = new String[ports.length]; + // REPORT-89007: websocket 避免url明文传输token。兼容旧版本服务器:旧版传递token,新版传递加密后的wsid + String token = connection.getToken(); + SocketIOVerifier verifier = WorkContext.getCurrent().get(SocketVerifierOperator.class).getVerifier(token); for (int i = 0; i < ports.length; i++) { result[i] = String.format("%s://%s:%s%s?%s=%s&%s=%s", currentProtocol, url.getHost(), ports[i], WorkspaceConstants.WS_NAMESPACE, - DecisionServiceConstants.WEB_SOCKET_TOKEN_NAME, - connection.getToken(), + verifier.getVerifierPrefix(), + verifier.getVerifierCode(), RemoteDesignConstants.USER_LOCK_ID, connection.getId()); }