diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index cd030145c..effd32b14 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -361,7 +361,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { File envFile100 = getOldEnvFile(VERSION100); // 从10.0往前递进是否存在更老版本的配置文件 if (envFile100.exists()) { - compatibilityPrevVersion(envFile90); + compatibilityPrevVersion(envFile100); } else if (envFile90.exists()) { compatibilityPrevVersion(envFile90); } else if (envFile80.exists()) { diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 6881c8445..cd9c835f3 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -8,6 +8,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteWorkspace; @@ -105,6 +106,7 @@ public class EnvChangeEntrance { private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); try { diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index f1758f068..ab86a0d6f 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -161,10 +161,18 @@ public abstract class DesignTableDataManager { } public static String getChangedDsNameByOldDsName(String oldDsName) { + String changeName; + if (isDsNameChanged(oldDsName)) { - return dsNameChangedMap.get(oldDsName); + changeName = dsNameChangedMap.get(oldDsName); + } else { + changeName = StringUtils.EMPTY; + } + + if (StringUtils.isNotEmpty(changeName)) { + return getChangedDsNameByOldDsName(changeName); } else { - return StringUtils.EMPTY; + return oldDsName; } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java index 8964ff8de..422a3a49a 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java @@ -9,6 +9,7 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.file.TableDataConfig; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; @@ -80,12 +81,13 @@ public class TreeTableDataComboBox extends UIComboBox { } public void setSelectedTableDataByName(String name) { + refresh(); TableDataWrapper tableDataWrapper; - if (res_map.get(name) != null) { - tableDataWrapper = res_map.get(name); - } else { - String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name); + String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name); + if (StringUtils.isNotEmpty(changeName)) { tableDataWrapper = res_map.get(changeName); + } else { + tableDataWrapper = res_map.get(name); } this.getModel().setSelectedItem(tableDataWrapper); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java index f1f1c6c75..175ddbfda 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataDictPane.java @@ -64,7 +64,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { tableFlowPane.add(tableDataNameComboBox); tableDataNameComboBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { - tdChange(); + tdChange(true); } }); tableFlowPane.add(new PreviewLabel(this)); @@ -73,19 +73,21 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { this.add(centerPane, BorderLayout.CENTER); parentMarkRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Tree_Accord_Parent_Marked_Filed"), true); lengthMarkRadio = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Build_Tree_Accord_Marked_Filed_Length")); - parentMarkRadio.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + parentMarkRadio.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { if (isBuildByParentFiled()) { makeParentEnable(); - tdChange(); + tdChange(false); } } }); - lengthMarkRadio.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + lengthMarkRadio.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { if (!isBuildByParentFiled()) { makeLengthEnable(); - tdChange(); + tdChange(false); } } }); @@ -169,7 +171,7 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { } - private void tdChange() { + private void tdChange(boolean isChangeDS) { TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); if (tableDataWrappe == null) { return; @@ -186,7 +188,9 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { String[] columnNames = new String[len]; namelist.toArray(columnNames); for (int i = 0; i < valueEditorPanes.length; i++) { - valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]); + if (isChangeDS || isNoSelectedColumnName(valueEditorPanes[i])) { + valueEditorPanes[i].setEditors(new Editor[]{new ColumnNameEditor(columnNames), new ColumnIndexEditor(len)}, columnNames[0]); + } } } catch (Exception e) { for (int i = 0; i < valueEditorPanes.length; i++) { @@ -197,6 +201,10 @@ public class TreeTableDataDictPane extends BasicPane implements Previewable { } } + private boolean isNoSelectedColumnName(ValueEditorPane valueEditorPane) { + return (Integer) valueEditorPane.update() == -1; + } + @Override protected String title4PopupWindow() { return "TreeTableDataDictionay"; diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java index 334958124..5a8c13889 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java @@ -7,6 +7,7 @@ import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombobox.UIComboBoxUI; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; @@ -32,6 +33,8 @@ import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; +import javax.swing.plaf.ComboBoxUI; +import javax.swing.plaf.basic.ComboPopup; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -275,8 +278,9 @@ public class JDBCDefPane extends JPanel { } dbtypeComboBox.addActionListener(dbtypeActionListener); dbtypeComboBox.setMaximumRowCount(10); - driverLoaderBox = new UIComboBox(); + driverLoaderBox = new SpecialUIComboBox(); refreshDriverLoader(); + driverLoaderBox.setPreferredSize(new Dimension(200, driverLoaderBox.getPreferredSize().height)); driverLoaderBox.setEditable(false); driverManageBox = new UIComboBox(); refreshDriverManage(true); @@ -350,7 +354,7 @@ public class JDBCDefPane extends JPanel { odbcTipsPane.add(driverManageLabel); odbcTipsPane.add(odbcTipsLink); JPanel driverComboBoxAndTips = new JPanel(new BorderLayout()); - JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 5, 0); normalFlowInnerContainer_s_pane.add(driverManageBox); normalFlowInnerContainer_s_pane.add(driverComboBox); normalFlowInnerContainer_s_pane.add(driverLoaderBox); @@ -507,7 +511,6 @@ public class JDBCDefPane extends JPanel { this.dbtypeComboBox.setSelectedItem(OTHER_DB); } } - this.jdbcDatabase.setIdentity(jdbcDatabase.getIdentity()); // jdbcDatabase.getDriverSource() 只会是空或者是有值,但是为了保险起见,还是应该做个处理 String driverSource = jdbcDatabase.getDriverSource(); if (driverSource == null) { @@ -717,4 +720,22 @@ public class JDBCDefPane extends JPanel { private String driver; private String url; } + + private static class SpecialUIComboBox extends UIComboBox { + + @Override + public ComboBoxUI getUIComboBoxUI() { + return new SpecialUIComboBoxUI(); + } + } + + private static class SpecialUIComboBoxUI extends UIComboBoxUI { + + @Override + public ComboPopup createPopup() { + return createHorizontalNeverUIComboPopUp(); + } + + } + } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java index 7baf51ddd..eb8d188a1 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java @@ -48,9 +48,17 @@ public class CopyableJTable extends SortableJTable { boolean mouseDrag = false; boolean headerSelect = false; - DefaultTableCellRenderer tableHeaderCellRenderer = new DefaultTableCellRenderer() { + + class CopyableTableHeaderCellRenderer implements TableCellRenderer { + TableCellRenderer tableCellRenderer; + + CopyableTableHeaderCellRenderer(TableCellRenderer tableCellRenderer) { + this.tableCellRenderer = tableCellRenderer; + } + + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + JComponent comp = (JComponent) this.tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (isChoose(row, column)) { comp.setBackground(selectBackGround); } else { @@ -58,13 +66,13 @@ public class CopyableJTable extends SortableJTable { } return comp; } - }; + } public CopyableJTable(TableSorter tableModel) { super(tableModel); initListener(); - this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer); + this.getTableHeader().setDefaultRenderer(new CopyableTableHeaderCellRenderer(this.getTableHeader().getDefaultRenderer())); } private void initListener() { diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 8b8099ab4..453e4bc94 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -19,7 +19,6 @@ import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.sql.PreviewPerformedSqlPane; import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fr.design.data.tabledata.strategy.StrategyConfigHandler; -import com.fr.design.data.tabledata.tabledatapane.db.DBTableDataSavedHook; import com.fr.design.data.tabledata.tabledatapane.db.StrategyConfigFrom; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; @@ -45,6 +44,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.esd.core.strategy.config.StrategyConfig; import com.fr.esd.core.strategy.config.StrategyConfigHelper; import com.fr.esd.core.strategy.config.service.StrategyConfigService; +import com.fr.esd.data.db.DBTableDataSavedHook; import com.fr.esd.event.DSMapping; import com.fr.esd.event.DsNameTarget; import com.fr.esd.event.StrategyEventsNotifier; diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/DBTableDataSavedHook.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/DBTableDataSavedHook.java deleted file mode 100644 index 8d9a51249..000000000 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/db/DBTableDataSavedHook.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.design.data.tabledata.tabledatapane.db; - -import com.fr.data.impl.DBTableData; -import com.fr.esd.event.DSMapping; -import com.fr.esd.event.DsNameTarget; -import com.fr.esd.event.StrategyEventsNotifier; -import com.fr.esd.event.xml.XMLSavedHook; -import com.fr.stable.StringUtils; - -public class DBTableDataSavedHook implements XMLSavedHook { - - private static final long serialVersionUID = 4925391747683335372L; - - private final String tplPath; - private String origName; - - private String origConnection; - - private String origQuery; - - public DBTableDataSavedHook(String tplPath, DBTableData origDBTableData) { - this.tplPath = tplPath; - this.origName = origDBTableData.getDsName(); - this.origConnection = origDBTableData.getDatabase().toString(); - this.origQuery = origDBTableData.getQuery(); - } - - @Override - public void doAfterSaved(DBTableData saved) { - String dsName = saved.getDsName(); - String conn = saved.getDatabase().toString(); - String query = saved.getQuery(); - - - //检查数据集名称、数据链接和sql是否修改,如果修改需要触发缓存监听事件 - if (!dsName.equals(origName) || !conn.equals(origConnection) || !query.equals(origQuery)) { - if (StringUtils.isNotEmpty(tplPath) && StringUtils.isNotEmpty(origName)) { - //新建数据集的origName为null,不用触发 - StrategyEventsNotifier.modifyDataSet(new DSMapping(tplPath, new DsNameTarget(origName))); - } - } - - this.origName = dsName; - this.origConnection = conn; - this.origQuery = query; - } -} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java new file mode 100644 index 000000000..ba8a5b09f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java @@ -0,0 +1,20 @@ +package com.fr.design.env; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/24 + */ +public class DesignerWorkspaceInfoContext { + + private static DesignerWorkspaceInfo workspaceInfo; + + public static DesignerWorkspaceInfo getWorkspaceInfo() { + return workspaceInfo; + } + + public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) { + DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo; + } +} diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index 2aa3c5504..a7d6eb6c1 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -3,6 +3,7 @@ package com.fr.design.env; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.locale.InterProviderFactory; +import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; @@ -31,7 +32,7 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { } REPORT_ENGINE_JAR = properties.getProperty(REPORT_ENGINE_KEY, "default.jar"); } - + private String name; private String path; @@ -107,8 +108,8 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { File engineLib = new File(StableUtils.pathJoin(this.path, ProjectConstants.LIB_NAME, REPORT_ENGINE_JAR)); // 非安装版本允许自由切换 - boolean notExistLib = !ComparatorUtils.equals(GeneralUtils.readFullBuildNO(), InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build")) - && !engineLib.exists(); + boolean notExistLib = !CoreConstants.DOT.equals(StableUtils.getInstallHome()) + && !engineLib.exists(); if (notExistLib) { throw new MainVersionNotMatchException(); } diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index f3c85f6fb..363eb1ab0 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -93,7 +93,7 @@ public class TemplateTreePane extends JPanel implements FileOperations { @Override public void mousePressed(MouseEvent evt) { - if (evt.getClickCount() == 2) { + if (reportletsTree.getPathForLocation(evt.getX(), evt.getY()) != null && evt.getClickCount() == 2) { openFile(); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java index b15b9eab9..648cb03f3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java @@ -3,6 +3,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.shortcutfactory.ShortCutFactory; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itoolbar.UIToolBarUI; import com.fr.design.gui.itoolbar.UIToolbar; @@ -277,6 +278,10 @@ public abstract class UIControlPane extends JControlPane { this.requestFocus(); return; } + if (JavaFxNativeFileChooser.isShowDialogState()) { + JavaFxNativeFileChooser.setShowDialogState(false); + return; + } saveSettings(); setVisible(false); PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java index 6103e6800..83c52ac78 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java @@ -27,13 +27,16 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.stable.StringUtils; -import java.awt.*; + +import javax.swing.JPanel; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; -import javax.swing.*; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable { private TreeTableDataComboBox treeTableDataComboBox; diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java index bab3e8851..5769fdacf 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/UnitInputPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.GeneralUtils; import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; @@ -27,7 +28,8 @@ import java.math.BigDecimal; * For input Number. */ public abstract class UnitInputPane extends BasicPane { - private static final double NUM_POINT = 0.000001; + private static final double MAX_NUM = 3000.0D; + private static final double NUM_POINT = 0.000001; private int scale = -1; String title; @@ -46,7 +48,7 @@ public abstract class UnitInputPane extends BasicPane { centerPane.add(titleLabel); // Denny:在对话框中加入JSpinner对象 - numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 999, 1)); + numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, MAX_NUM, 1)); GUICoreUtils.setColumnForSpinner(numberFieldSpinner, 24); numberFieldSpinner.setPreferredSize(new Dimension(60, 20)); numberFieldSpinner.setMinimumSize(new Dimension(60, 20)); @@ -71,17 +73,17 @@ public abstract class UnitInputPane extends BasicPane { public void populate(float floatValue) { popValue = floatValue; - numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, 999.00, 0.01)); + numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, MAX_NUM, 0.01)); JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); addChangeListener(temp); - BigDecimal de = new BigDecimal(floatValue + ""); + BigDecimal de = new BigDecimal(GeneralUtils.objectToString(floatValue)); if (scale > 0) { floatValue = de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); } else { floatValue = de.floatValue(); } - //选中多列, 并且列宽不完全一致的话, 就不显示值了. + //选中多列, 并且列宽不完全一致的话, 就不显示值了. temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); // denny:默认应该为选中,方便用户修改 @@ -99,8 +101,8 @@ public abstract class UnitInputPane extends BasicPane { public double update() throws ValueNotChangeException { // 值没变就不改 if (!changed) { - throw vncExp; - } + throw vncExp; + } // Denny: get numberFieldSpinner 的 TextField JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); @@ -108,7 +110,8 @@ public abstract class UnitInputPane extends BasicPane { if (temp.getText().length() == 0) { return 0; } - BigDecimal de = new BigDecimal(temp.getText()); + + BigDecimal de = new BigDecimal(GeneralUtils.objectToString(temp.getValue())); if (scale > 0) { return de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); } else { @@ -176,4 +179,4 @@ public abstract class UnitInputPane extends BasicPane { // 鼠标按键在组件上单击时 } }; -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java index f15bbc52a..d4de4e850 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java @@ -10,12 +10,26 @@ import com.fr.stable.Constants; import com.fr.stable.StringUtils; import sun.swing.DefaultLookup; -import javax.swing.*; +import javax.swing.AbstractButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ScrollPaneConstants; +import javax.swing.UIManager; import javax.swing.plaf.ButtonUI; import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.ComboPopup; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.RenderingHints; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; @@ -159,6 +173,10 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { return new UIComboPopup(comboBox); } + protected ComboPopup createHorizontalNeverUIComboPopUp() { + return new HorizontalNeverUIComboPopup(comboBox); + } + private void setRollover(boolean isRollover) { if (this.isRollover != isRollover) { this.isRollover = isRollover; @@ -270,4 +288,16 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener { } } + + private class HorizontalNeverUIComboPopup extends UIComboPopup { + + public HorizontalNeverUIComboPopup(JComboBox comboBox) { + super(comboBox); + } + + @Override + protected JScrollPane createScroller() { + return new UIScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java index a14c10f3c..55ba64b0e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java @@ -3,8 +3,11 @@ package com.fr.design.gui.icontainer; import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; -import javax.swing.*; -import java.awt.*; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.ScrollPaneConstants; +import java.awt.Color; +import java.awt.Component; /** * @author zhou @@ -16,7 +19,11 @@ public class UIScrollPane extends JScrollPane { private static final int INCREAMENT = 30; public UIScrollPane(Component c) { - super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + this(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } + + public UIScrollPane(Component c, int vertical, int horizontal) { + super(c, vertical, horizontal); this.setHorizontalScrollBar(createHorizontalScrollBar()); this.getVerticalScrollBar().setUnitIncrement(INCREAMENT); this.getVerticalScrollBar().setBlockIncrement(INCREAMENT); diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java index 038212bfd..8be467810 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.concurrent.CountDownLatch; public class JavaFxNativeFileChooser implements FileChooserProvider { + private static boolean showDialogState = false; private File[] selectedFiles = new File[0]; private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); @@ -43,8 +44,17 @@ public class JavaFxNativeFileChooser implements FileChooserProvider { return null; } + public static boolean isShowDialogState() { + return showDialogState; + } + + public static void setShowDialogState(boolean showDialogState) { + JavaFxNativeFileChooser.showDialogState = showDialogState; + } + @Override public int showDialog(Component parent) { + setShowDialogState(true); final CountDownLatch latch = new CountDownLatch(1); PlatformImpl.startup(() -> { }); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java index 9e8f8dca3..33420ded7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/ComponentTitleStylePane.java @@ -234,8 +234,8 @@ public class ComponentTitleStylePane extends AbstractBorderPackerPane { TitlePacker widgetTitle = style == null ? new WidgetTitle() : style.getTitle(); widgetTitle = widgetTitle == null ? new WidgetTitle() : widgetTitle; boolean titleVisible = style != null && style.getType() != LayoutBorderStyle.STANDARD; - visibleCheckbox.setSelected(isSupportTitleContent && titleVisible); - titleContentPane.setVisible(titleVisible); + visibleCheckbox.setSelected(isSupportTitleVisible && titleVisible); + titleContentPane.setVisible(isSupportTitleContent && titleVisible); titleOtherSettingPane.setVisible(isSupportTitleOtherSetting && titleVisible); this.textContentPane.populateBean(widgetTitle.getTextObject().toString()); diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java index 9a4c4181c..c7c1da0ef 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FollowingThemePane.java @@ -57,6 +57,7 @@ public class FollowingThemePane extends BasicPane implements UIObserver { for (FollowingThemeActionChangeListener changeListener : changeListeners) { changeListener.onFollowingTheme(isFollowingTheme()); } + invalidate(); // 与主题相关的属性面板更新完毕后,再通知外层更新数据 if (uiObserverListener != null) { diff --git a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java index a1546025f..f3367206f 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java @@ -117,7 +117,9 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane list = parameterViewPane.update(); @@ -158,6 +160,7 @@ public class ExportJavaScriptPane extends AbstractHyperLinkPane> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener, ThemedTemplate { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null + private static final int PREDEFINED_ICON_WIDTH = 27; private static final int PREFIX_NUM = 3000; protected FILE editingFILE = null; // alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存 @@ -1421,8 +1423,15 @@ public abstract class JTemplate> } protected UIButton createTemplateThemeButton() { - UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")); - button.setToolTipText(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Title")); + UIButton button = new UIButton(IOUtils.readIcon("/com/fr/design/icon/icon_predefined_style.png")) { + @Override + public Dimension getPreferredSize() { + FontMetrics metrics = getFontMetrics(getFont()); + int width = Math.min(metrics.stringWidth(getText()) + PREDEFINED_ICON_WIDTH, 100); + return new Dimension(width, 20); + } + }; + button.setToolTipText(getTemplateTheme().getName()); button.setText(getTemplateTheme().getName()); button.setAlignmentX(SwingConstants.LEFT); button.set4ToolbarButton(); @@ -1714,8 +1723,8 @@ public abstract class JTemplate> return runtimeId; } - private void setUpTheme4NewTemplate() { - TemplateTheme theme = getUsingTemplateThemeConfig().getTheme4NewTemplate(); + protected void setUpTheme4NewTemplate() { + TemplateTheme theme = getUsingTemplateThemeConfig().cachedFetchTheme4NewTemplate(); TemplateThemeAttrMark themeAttrMark = template.getAttrMark(TemplateThemeAttrMark.XML_TAG); if (themeAttrMark == null) { themeAttrMark = new TemplateThemeAttrMark(); @@ -1728,6 +1737,8 @@ public abstract class JTemplate> @Override public void setTemplateTheme(TemplateTheme newTheme, TemplateThemeCompatible compatible) { ThemedTemplate.super.setTemplateTheme(newTheme, compatible); - templateThemeButton.setText(newTheme.getName()); + String name = newTheme.getName(); + templateThemeButton.setText(name); + templateThemeButton.setToolTipText(name); } } 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 dc10d8883..9f10ba829 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 @@ -48,6 +48,7 @@ public class LogMessageBar extends JPanel { public void mouseClicked(MouseEvent e) { if (dlg != null && dlg.isVisible()) { dlg.setExtendedState(JFrame.NORMAL); + dlg.requestFocus(); return; } dlg = new LogDetailPane().showDialog(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java new file mode 100644 index 000000000..add47d6a0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/AsyncThemeFetcher.java @@ -0,0 +1,86 @@ +package com.fr.design.mainframe.theme; + +import com.fr.base.theme.TemplateTheme; +import com.fr.base.theme.TemplateThemeConfig; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.module.ModuleContext; + +import java.util.concurrent.ExecutorService; + +/** + * @author Starryi + * @version 1.0 + * Created by Starryi on 2021/8/24 + */ +public class AsyncThemeFetcher { + + private final ExecutorService executorService; + private final TemplateThemeConfig config; + + public AsyncThemeFetcher(int threads, TemplateThemeConfig config) { + this.executorService = ModuleContext.getExecutor().newFixedThreadPool( + threads, + new NamedThreadFactory(this.getClass().getName()) + ); + this.config = config; + } + + public void shutdown() { + executorService.shutdown(); + } + + public boolean isShutdown() { + return executorService.isShutdown(); + } + + public void submit(String themeName, AsyncThemeFetchCallback callback) { + callback.beforeCachedFetch(); + executorService.submit(new Runnable() { + @Override + public void run() { + if (executorService.isShutdown()) { + return; + } + T theme = config.cachedFetch(themeName, new TemplateThemeConfig.CacheCondition() { + @Override + public boolean shouldCacheTheme(T theme) { + return callback.shouldCache(AsyncThemeFetcher.this, theme); + } + }); + if (executorService.isShutdown()) { + return; + } + callback.afterCachedFetch(theme); + } + }); + } + + public interface AsyncThemeFetchCallback { + void beforeCachedFetch(); + boolean shouldCache(AsyncThemeFetcher fetcher, T theme); + void afterCachedFetch(T theme); + } + + public static class AsyncThemeFetchCallbackAdapter implements AsyncThemeFetchCallback { + + @Override + public void beforeCachedFetch() { + + } + + @Override + public boolean shouldCache(AsyncThemeFetcher fetcher, T theme) { + // 如果Fetcher已经关闭就不放进缓存里了 + // 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个, + // 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存. + // TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个 + // TODO: 后续看情况再优化吧. + return !fetcher.isShutdown(); + } + + @Override + public void afterCachedFetch(T theme) { + + } + } +} 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 b06119b6c..ef35f7e02 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 @@ -5,6 +5,7 @@ import com.fr.base.theme.TemplateThemeConfig; import com.fr.base.theme.FormTheme; import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.base.theme.settings.ThemedFormBodyStyle; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.theme.edit.ComponentStyleEditPane; import com.fr.design.mainframe.theme.edit.FormBodyStyleEditPane; import com.fr.design.mainframe.theme.preview.FormThemePreviewPane; @@ -87,4 +88,9 @@ public class FormThemeProfilePane extends TemplateThemeProfilePane { ThemedComponentStyle componentStyle = componentStyleSettingPane.updateBean(); theme.setComponentStyle(componentStyle); } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Basic_Form_Theme_Profile_Dialog_Title"); + } } 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 bcc50a8d3..091262b58 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 @@ -66,4 +66,9 @@ public class ReportThemeProfilePane extends TemplateThemeProfilePane extends JPanel { private final Icon theme4currentTemplateMarkIcon = IOUtils.readIcon("/com/fr/design/form/images/theme4currentTemplate.png"); private final Icon theme4NewTemplateMarkIcon= IOUtils.readIcon("/com/fr/design/form/images/theme4newTemplate.png"); private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/icon/icon_edit.png"); + private final boolean displayTheme4NewTemplateMarker; private UILabel thumbnailLabel; // UIButton会影响Block的手势监听,这里使用UILabel代替,点击事件也有Block代为处理 @@ -55,16 +58,15 @@ public class TemplateThemeBlock extends JPanel { private boolean hovering = false; private MouseAdapter clickListener; - private final ExecutorService asyncThemeFetcher; public TemplateThemeBlock(String name, + boolean displayTheme4NewTemplateMarker, TemplateThemeConfig config, - TemplateThemeProfilePane profilePane, - ExecutorService asyncThemeFetcher) { + TemplateThemeProfilePane profilePane) { this.name = name; + this.displayTheme4NewTemplateMarker = displayTheme4NewTemplateMarker; this.config = config; this.profilePane = profilePane; - this.asyncThemeFetcher = asyncThemeFetcher; initializePane(); addMouseListener(new MouseAdapter() { @@ -91,8 +93,6 @@ public class TemplateThemeBlock extends JPanel { repaint(); } }); - - fetchTheme(); } private void initializePane() { @@ -109,7 +109,7 @@ public class TemplateThemeBlock extends JPanel { UILabel titleLabel = new UILabel(name); titleLabel.setToolTipText(name); - infoPane.add(titleLabel, BorderLayout.WEST); + infoPane.add(titleLabel, BorderLayout.CENTER); if (profilePane != null) { addProfileButton(infoPane); @@ -119,6 +119,21 @@ public class TemplateThemeBlock extends JPanel { add(infoPane, BorderLayout.SOUTH); } + public void setTheme(T theme) { + this.theme = theme; + thumbnailLabel.setIcon(null); + if (theme != null) { + ThemeThumbnail thumbnail = theme.getThumbnail(); + if (thumbnail != null) { + Image image = thumbnail.getImage(); + if (image != null) { + thumbnailLabel.setIcon(new ImageIcon(image)); + } + } + } + repaint(); + } + public T getTheme() { return this.theme; } @@ -166,62 +181,21 @@ public class TemplateThemeBlock extends JPanel { profileDialog.setVisible(true); } - public void fetchTheme() { - if (asyncThemeFetcher.isShutdown()) { - return; - } - asyncThemeFetcher.submit(new Runnable() { - @Override - public void run() { - if (asyncThemeFetcher.isShutdown()) { - return; - } - - theme = null; - // 耗时的同步操作,如远程设计器场景 - theme = config.cachedFetch(name, new TemplateThemeConfig.CacheCondition() { - @Override - public boolean shouldCacheTheme(T theme) { - // 如果Fetcher已经关闭就不放进缓存里了 - // 因为可切换工作目录,所以submit时的工作目录环境与最终获取到主题数据时的工作目录环境可能不是同一个, - // 如果仍然放进缓存中,会污染当前工作目录环境的主题缓存. - // TODO: 除了根据asyncThemeFetch的关闭情况来判断是否缓存主题,也可以更加精细的判断前后的工作目录环境是否时同一个 - // TODO: 后续看情况再优化吧. - return !asyncThemeFetcher.isShutdown(); - } - }); - - if (asyncThemeFetcher.isShutdown()) { - return; - } - if (theme != null) { - ThemeThumbnail thumbnail = theme.getThumbnail(); - if (thumbnail != null) { - Image image = thumbnail.getImage(); - if (image != null) { - thumbnailLabel.setIcon(new ImageIcon(image)); - } - } - } - repaint(); - } - }); - } - @Override public void paint(Graphics g) { super.paint(g); + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { TemplateThemeConfig templateUsingConfig = template.getUsingTemplateThemeConfig(); TemplateTheme templateTheme = template.getTemplateTheme(); - if (templateUsingConfig == this.config && StringUtils.equals(templateTheme.getName(), theme.getName())) { - theme4currentTemplateMarkIcon.paintIcon(this, g, 176, 0); + if (templateUsingConfig == this.config && StringUtils.equals(templateTheme.getName(), name)) { + theme4currentTemplateMarkIcon.paintIcon(this, g, getWidth() - 25, 0); } } - T theme4newTemplate = config.getTheme4NewTemplate(); - if (StringUtils.equals(theme4newTemplate.getName(), name)) { + if (displayTheme4NewTemplateMarker && StringUtils.equals(config.getThemeName4NewTemplate(), name)) { theme4NewTemplateMarkIcon.paintIcon(this, g, 0, 0); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java index 247c37370..524c272ac 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeListPane.java @@ -2,14 +2,12 @@ package com.fr.design.mainframe.theme; import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.TemplateThemeConfig; -import com.fr.concurrent.NamedThreadFactory; import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.module.ModuleContext; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -22,7 +20,6 @@ import java.awt.event.MouseEvent; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ExecutorService; /** * @author Starryi @@ -33,13 +30,11 @@ public class TemplateThemeListPane extends BasicPane { public static final int BLOCK_COUNT_ROW_LINE = 3; public static final int BLOCK_GAP = IntervalConstants.INTERVAL_L1; public static final int CONTENT_WIDTH = 630; + public static final int ASYNC_FETCH_THEME_THREAD_COUNT = 10; - private final ExecutorService asyncThemeFetcher = - ModuleContext.getExecutor().newFixedThreadPool( - 10, - new NamedThreadFactory("TemplateThemeListPane") - ); + private final AsyncThemeFetcher asyncThemeFetcher; + private final boolean displayTheme4NewTemplateMarker; protected final TemplateThemeConfig config; private final TemplateThemeProfilePane profilePane; private final JPanel contentListPane; @@ -53,10 +48,12 @@ public class TemplateThemeListPane extends BasicPane { private ChangeListener changeListener; - public TemplateThemeListPane(TemplateThemeConfig config, TemplateThemeProfilePane profilePane) { + public TemplateThemeListPane(boolean displayTheme4NewTemplateMarker, TemplateThemeConfig config, TemplateThemeProfilePane profilePane) { + this.displayTheme4NewTemplateMarker = displayTheme4NewTemplateMarker; this.config = config; this.profilePane = profilePane; this.contentListPane = new JPanel(); + this.asyncThemeFetcher = new AsyncThemeFetcher<>(ASYNC_FETCH_THEME_THREAD_COUNT, config); initializePane(); } @@ -84,7 +81,7 @@ public class TemplateThemeListPane extends BasicPane { if (config.contains(name)) { TemplateThemeBlock block = createCachedTemplateThemeBlock(name); contentListPane.add(block); - if (StringUtils.equals(name, config.getTheme4NewTemplate().getName())) { + if (StringUtils.equals(name, config.getThemeName4NewTemplate())) { block4newTemplate = block; } } @@ -100,7 +97,7 @@ public class TemplateThemeListPane extends BasicPane { } private TemplateThemeBlock createNewTemplateThemeBlock(String name) { - final TemplateThemeBlock block = new TemplateThemeBlock<>(name, config, profilePane, asyncThemeFetcher); + final TemplateThemeBlock block = new TemplateThemeBlock<>(name, displayTheme4NewTemplateMarker, config, profilePane); block.addClickListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { @@ -108,6 +105,19 @@ public class TemplateThemeListPane extends BasicPane { setSelectedBlock(block); } }); + asyncThemeFetcher.submit(name, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + block.setTheme(null); + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + block.setTheme(theme); + } + }); return block; } @@ -128,6 +138,10 @@ public class TemplateThemeListPane extends BasicPane { } } + private void asyncFetchTheme(String themeName) { + asyncThemeFetcher.submit(themeName, new AsyncThemeListItemFetchCallback(themeName)); + } + @Override protected String title4PopupWindow() { return null; @@ -142,21 +156,22 @@ public class TemplateThemeListPane extends BasicPane { themeConfigChangeListener = new TemplateThemeConfig.ThemeConfigChangeListener() { @Override public void onThemeConfigChanged(TemplateThemeConfig.ThemeConfigEvent event) { + String themeName = event.themName; TemplateThemeBlock existingBlock = blockCache.get(event.themName); switch (event.action) { case DEFAULT_THEME_4_NEW_TEMPLATE_UPDATE: { if (block4newTemplate != null) { - block4newTemplate.fetchTheme(); + block4newTemplate.repaint(); } if (existingBlock != null) { - existingBlock.fetchTheme(); + existingBlock.repaint(); } block4newTemplate = existingBlock; break; } case UPDATE: { if (existingBlock != null) { - existingBlock.fetchTheme(); + asyncFetchTheme(themeName); } break; } @@ -176,6 +191,7 @@ public class TemplateThemeListPane extends BasicPane { if (existingBlock == null) { // TODO 这里是否还能继续优化? fillContentListPane(); + asyncFetchTheme(themeName); validate(); repaint(); } @@ -198,4 +214,29 @@ public class TemplateThemeListPane extends BasicPane { public void stopAsyncFetchTheme() { asyncThemeFetcher.shutdown(); } + + private class AsyncThemeListItemFetchCallback extends AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter { + private final String themeName; + public AsyncThemeListItemFetchCallback(String themeName) { + this.themeName = themeName; + } + + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + TemplateThemeBlock block = blockCache.get(themeName); + if (block != null) { + block.setTheme(null); + } + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + TemplateThemeBlock block = blockCache.get(themeName); + if (block != null) { + block.setTheme(theme); + } + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java index 5dab5b7f3..24358a29e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeManagePane.java @@ -22,8 +22,6 @@ import com.fr.design.menu.ToolBarDef; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import com.fr.third.checkerframework.checker.nullness.qual.Nullable; -import com.fr.third.guava.util.concurrent.FutureCallback; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; @@ -60,6 +58,8 @@ public class TemplateThemeManagePane extends BasicPane private final TemplateThemeListPane themeListPane; private final TemplateThemeProfilePane profilePane; + private final AsyncThemeFetcher asyncThemeFetcher; + public static TemplateThemeManagePane createFormThemesManagerPane() { FormThemeConfig config = FormThemeConfig.getInstance(); FormThemeProfilePane editPane = new FormThemeProfilePane(config); @@ -75,9 +75,10 @@ public class TemplateThemeManagePane extends BasicPane public TemplateThemeManagePane(TemplateThemeConfig config, TemplateThemeProfilePane profilePane) { this.config = config; this.profilePane = profilePane; - this.themeListPane = new TemplateThemeListPane<>(config, profilePane); + this.themeListPane = new TemplateThemeListPane<>(true, config, profilePane); this.removeAction = new RemoveThemeAction(false); - this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Default_Setting")); + this.setTheme4NewTemplateButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Default_Setting")); + this.asyncThemeFetcher = new AsyncThemeFetcher<>(1, config); initializePane(); } @@ -138,7 +139,7 @@ public class TemplateThemeManagePane extends BasicPane return; } - T currentTheme4NewTemplate = config.getTheme4NewTemplate(); + T currentTheme4NewTemplate = config.cachedFetchTheme4NewTemplate(); if (currentTheme4NewTemplate == null) { setTheme4NewTemplateButton.setEnabled(true); return; @@ -169,9 +170,9 @@ public class TemplateThemeManagePane extends BasicPane setTheme4NewTemplateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - T style = themeListPane.getSelectedTheme(); - if (style != null) { - config.setTheme4NewTemplate(style.getName()); + T theme = themeListPane.getSelectedTheme(); + if (theme != null) { + config.setThemeName4NewTemplate(theme.getName()); } } }); @@ -190,15 +191,15 @@ public class TemplateThemeManagePane extends BasicPane MenuDef menuDef = new MenuDef(Toolkit.i18nText("Fine-Design_Basic_Action_Add")); menuDef.setIconPath(IconPathConstants.ADD_POPMENU_ICON_PATH); menuDef.setRePaint(true); - menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightTheme4New())); - menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkTheme4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Light_Theme"), config.getLightThemeName4New())); + menuDef.addShortCut(new AddThemeAction(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Create_Dark_Theme"), config.getDarkThemeName4New())); return menuDef; } @Override protected String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"); + return Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title"); } private class RemoveThemeAction extends UpdateAction { @@ -213,8 +214,11 @@ public class TemplateThemeManagePane extends BasicPane @Override public void actionPerformed(ActionEvent e) { T theme = TemplateThemeManagePane.this.themeListPane.getSelectedTheme(); + if (theme == null) { + return; + } int result = FineJOptionPane.showConfirmDialog(SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this), - Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Pane_Delete_Tip", theme.getName()), + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Pane_Delete_Tip", theme.getName()), Toolkit.i18nText("Fine-Design_Basic_Delete"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.YES_OPTION) { Configurations.modify(new WorkerFacade(config.getClass()) { @@ -228,20 +232,35 @@ public class TemplateThemeManagePane extends BasicPane } private class AddThemeAction extends UpdateAction { - private final T theme4New; + private T prototypeTheme; - public AddThemeAction(String name, T theme4New) { + public AddThemeAction(String name, String prototypeThemeName) { setName(name); setMnemonic('R'); - this.theme4New = theme4New; + asyncThemeFetcher.submit(prototypeThemeName, new AsyncThemeFetcher.AsyncThemeFetchCallbackAdapter() { + @Override + public void beforeCachedFetch() { + super.beforeCachedFetch(); + prototypeTheme = null; + } + + @Override + public void afterCachedFetch(T theme) { + super.afterCachedFetch(theme); + prototypeTheme = theme; + } + }); } @Override public void actionPerformed(ActionEvent e) { + if (prototypeTheme == null) { + return; + } Window parent = SwingUtilities.getWindowAncestor(TemplateThemeManagePane.this); TemplateThemeProfileDialog profileDialog = new TemplateThemeProfileDialog<>(parent, profilePane); try { - T theme = (T) theme4New.clone(); + T theme = (T) prototypeTheme.clone(); theme.setName(StringUtils.EMPTY); theme.setMutable(true); theme.setRemovable(true); @@ -287,6 +306,7 @@ public class TemplateThemeManagePane extends BasicPane } public void stopAsyncFetchTheme() { + asyncThemeFetcher.shutdown(); themeListPane.stopAsyncFetchTheme(); } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java index e0f5c06a2..79053f357 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/TemplateThemeProfilePane.java @@ -25,6 +25,7 @@ import com.fr.design.mainframe.theme.edit.ui.ColorListPane; import com.fr.design.mainframe.theme.edit.ui.LabelUtils; import com.fr.design.mainframe.theme.ui.BorderUtils; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.Configurations; @@ -122,13 +123,13 @@ public abstract class TemplateThemeProfilePane extends @Override public String title4PopupWindow() { - return Toolkit.i18nText("Fine-Design_Predefined_Style_Edit"); + return Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Dialog_Title"); } private JPanel createLeftPane() { JPanel titleContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); titleContainer.setPreferredSize(new Dimension(LEFT_TITLE_PANE_WIDTH, LEFT_TITLE_PANE_HEIGHT)); - titleContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Template_Theme_Preview_Pane_Title"), TITLE_BORDER_FONT)); + titleContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Preview_Pane_Title"), TITLE_BORDER_FONT)); JPanel previewContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); previewContainer.setBorder(BorderFactory.createEmptyBorder(5, 4, 10, 4)); @@ -166,7 +167,7 @@ public abstract class TemplateThemeProfilePane extends private JPanel createNameEditPane() { JPanel container = new JPanel(new BorderLayout(30, 0)); container.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); - container.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Name")), BorderLayout.WEST); + container.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Name")), BorderLayout.WEST); JPanel settingContainer = new JPanel(new BorderLayout(10, 0)); container.add(settingContainer, BorderLayout.CENTER); @@ -235,11 +236,11 @@ public abstract class TemplateThemeProfilePane extends double[] columnSize = {p, p}; JPanel previewLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - previewLabelPane.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Color_Scheme_Preview_Label")), BorderLayout.NORTH); + previewLabelPane.add(LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Preview_Label")), BorderLayout.NORTH); JPanel content = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ - {LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListPane}, - {null, LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Color_Scheme_Edit_Tip"), new Color(0XC6C6C6), 10)}, + {LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Label")), colorListPane}, + {null, LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Edit_Tip"), new Color(0XC6C6C6), 10)}, {previewLabelPane, extendedContainer}, }, rowSize, columnSize, 18, 7); @@ -247,7 +248,7 @@ public abstract class TemplateThemeProfilePane extends JPanel borderContainer = new JPanel(new BorderLayout()); borderContainer.setPreferredSize(new Dimension(COLOR_SCHEME_TITLE_PANE_WIDTH, COLOR_SCHEME_TITLE_PANE_HEIGHT)); - borderContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Color_Scheme_Title"))); + borderContainer.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Color_Scheme_Title"))); borderContainer.add(content); JPanel container = new JPanel(new BorderLayout()); @@ -265,7 +266,7 @@ public abstract class TemplateThemeProfilePane extends } protected JPanel createCustomEditorsPane() { JPanel container = new JPanel(new BorderLayout()); - container.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Custom_Settings_Title"))); + container.setBorder(BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Custom_Settings_Title"))); uiTabbedPane = new UITabbedPane(); uiTabbedPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 1)); @@ -311,7 +312,11 @@ public abstract class TemplateThemeProfilePane extends } public void populateBean(T theme) { - this.theme = theme; + try { + this.theme = (T) theme.clone(); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } isPopulating = true; String name = theme.getName(); @@ -370,7 +375,7 @@ public abstract class TemplateThemeProfilePane extends public UIButton createSaveButton() { saveButton = new UIButton(); - saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Save")); + saveButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save")); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override @@ -401,7 +406,7 @@ public abstract class TemplateThemeProfilePane extends public UIButton createSaveAsButton(final TemplateThemeProfileDialog profileDialog) { saveAsButton = new UIButton(); saveAsButton.removeAll(); - saveAsButton.setText(Toolkit.i18nText("Fine-Design_Basic_Predefined_Save_As_New")); + saveAsButton.setText(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Profile_Pane_Save_As")); saveAsButton.setEnabled(false); saveAsButton.addActionListener(new ActionListener() { @Override @@ -421,7 +426,7 @@ public abstract class TemplateThemeProfilePane extends public SaveAsDialog(TemplateThemeProfileDialog dialog) { super(dialog, ModalityType.APPLICATION_MODAL); - setTitle(Toolkit.i18nText("Fine-Design_Template_Theme_Save_As_Dialog_Title")); + setTitle(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Save_As_Dialog_Title")); setResizable(false); setSize(new Dimension(300, 140)); GUICoreUtils.centerWindow(this); @@ -448,26 +453,7 @@ public abstract class TemplateThemeProfilePane extends confirmButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - T theme = updateBean(); - boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); - if (canBeSaved && theme != null) { - theme.setName(nameTextField.getText()); - theme.setRemovable(true); - theme.setMutable(true); - Configurations.modify(new WorkerFacade(config.getClass()) { - @Override - public void run() { - config.addTheme(theme, true); - } - }.addCallBack(new CallBackAdaptor() { - @Override - public void afterCommit() { - super.afterCommit(); - exit(); - parent.exit(); - } - })); - } + saveAsNew(nameTextField.getText()); } }); @@ -531,8 +517,9 @@ public abstract class TemplateThemeProfilePane extends JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane(); JPanel nameTextPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(20, 5); + nameTextPane.setBorder(BorderFactory.createEmptyBorder(20, 0, 0, 0)); + nameTextPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Save_As_Pane_Name_Label"))); nameTextPane.add(nameTextField); - nameTextPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Template_Theme_Save_As_Pane_Name_Label"))); container.add(nameTextPane, BorderLayout.CENTER); container.add(nameErrorLabel, BorderLayout.SOUTH); @@ -540,6 +527,36 @@ public abstract class TemplateThemeProfilePane extends return container; } + private void saveAsNew(String name) { + T newThemeObject = null; + try { + newThemeObject = (T) updateBean().clone(); + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + return; + } + boolean canBeSaved = checkThemeCanBeSavedAndUpdateUI(true, nameTextField, nameErrorLabel, confirmButton); + if (canBeSaved && newThemeObject != null) { + newThemeObject.setName(name); + newThemeObject.setRemovable(true); + newThemeObject.setMutable(true); + T finalNewThemeObject = newThemeObject; + Configurations.modify(new WorkerFacade(config.getClass()) { + @Override + public void run() { + config.addTheme(finalNewThemeObject, true); + } + }.addCallBack(new CallBackAdaptor() { + @Override + public void afterCommit() { + super.afterCommit(); + exit(); + parent.exit(); + } + })); + } + } + public void exit() { this.dispose(); } @@ -555,17 +572,14 @@ public abstract class TemplateThemeProfilePane extends String error = StringUtils.EMPTY; String name = textField.getText(); if (isThemeNameEmpty(name)) { - error = Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Empty_Name_Error_Tip"); + error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Empty_Name_Error_Tip"); } else if (checkDuplicated && isThemeNameDuplicated(name)) { - error = Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip"); + error = Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Duplicated_Name_Error_Tip"); } errorLabel.setText(error); boolean valid = StringUtils.isEmpty(error); - if (!valid) { - textField.requestFocus(); - } errorLabel.setVisible(!valid); if (actionButtons != null && actionButtons.length > 0) { for (UIButton button : actionButtons) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java index 3eeee55fe..e7acb8d8a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeManageDialog.java @@ -31,14 +31,14 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { private final TemplateThemeManageDialogContentPane contentPane; public TemplateThemeManageDialog(Window parent) { - super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + super(parent, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); contentPane = new TemplateThemeManageDialogContentPane(); setContentPane(createDialogContentPane(contentPane, new UIButton[]{ createCompleteButton() })); } private UIButton createCompleteButton() { - UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Complete")); + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Complete")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -70,8 +70,8 @@ public class TemplateThemeManageDialog extends TemplateThemeDialog { reportThemesManagerPane = TemplateThemeManagePane.createReportThemesManagerPane(); reportThemesManagerPane.startListenThemeConfig(); - tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_FORM_TAB"), formThemesManagerPane); - tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane); + tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_FORM_TAB"), formThemesManagerPane); + tabbedPane.addTab(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_REPORT_TAB"), reportThemesManagerPane); tabbedPane.setSelectedIndex(0); JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java index 31d00043d..84853943b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeProfileDialog.java @@ -40,7 +40,7 @@ public class TemplateThemeProfileDialog extends Templat public static final int CONTENT_HEIGHT = 570; public TemplateThemeProfileDialog(Window parent, TemplateThemeProfilePane profilePane) { - super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Profile_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + super(parent, profilePane.getTitle(), CONTENT_WIDTH, CONTENT_HEIGHT); JPanel content = FRGUIPaneFactory.createBorderLayout_S_Pane(); content.setPreferredSize(new Dimension(CONTENT_WIDTH, CONTENT_HEIGHT)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java index 7d1a99825..1d17bb4eb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/dialog/TemplateThemeUsingDialog.java @@ -12,6 +12,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.TemplateThemeListPane; import com.fr.design.mainframe.theme.ui.BorderUtils; import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -26,7 +27,8 @@ import java.awt.event.ActionListener; * @version 1.0 * Created by Starryi on 2021/8/13 */ -public class TemplateThemeUsingDialog extends TemplateThemeDialog { +public class +TemplateThemeUsingDialog extends TemplateThemeDialog { public static final int CONTENT_WIDTH = 660; public static final int CONTENT_HEIGHT = 515; @@ -34,10 +36,10 @@ public class TemplateThemeUsingDialog extends TemplateT private final ThemedTemplate currentTemplate; public TemplateThemeUsingDialog(Window parent, ThemedTemplate template, TemplateThemeConfig config) { - super(parent, Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); + super(parent, Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Title"), CONTENT_WIDTH, CONTENT_HEIGHT); this.currentTemplate = template; - this.themeListPane = new TemplateThemeListPane<>(config, null); + this.themeListPane = new TemplateThemeListPane<>(false, config, null); JPanel content = createContent(); UIButton openThemeManagerButton = createOpenThemeManagerButton(); @@ -97,7 +99,7 @@ public class TemplateThemeUsingDialog extends TemplateT JPanel themeListPaneContainer = FRGUIPaneFactory.createBorderLayout_S_Pane(); themeListPaneContainer.setBorder(new CompoundBorder( - BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Select"), 12), + BorderUtils.createTitleBorder(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Select"), 12), BorderFactory.createEmptyBorder(0, 10, 0, 10) )); themeListPaneContainer.add(themeListPane, BorderLayout.CENTER); @@ -107,23 +109,22 @@ public class TemplateThemeUsingDialog extends TemplateT } private UIButton createOpenThemeManagerButton() { - if (DesignModeContext.isAuthorityEditing()) { - // 权限编辑模式下,不显示打开主题管理对话框的按钮 - return null; + if (WorkContext.getCurrent().isRoot()) { + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Manager_Dialog_Title")); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + TemplateThemeManageDialog dialog = new TemplateThemeManageDialog(TemplateThemeUsingDialog.this); + dialog.setVisible(true); + } + }); + return button; } - UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Manager_Dialog_Title")); - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - TemplateThemeManageDialog dialog = new TemplateThemeManageDialog(TemplateThemeUsingDialog.this); - dialog.setVisible(true); - } - }); - return button; + return null; } private UIButton createUsingCurrentThemeButton() { - UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Use")); + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Use")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -134,7 +135,7 @@ public class TemplateThemeUsingDialog extends TemplateT } private UIButton createCompleteButton() { - UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Template_Theme_Using_Dialog_Complete")); + UIButton button = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Using_Dialog_Complete")); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java index 2c2466eaf..ec855962a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java @@ -66,11 +66,13 @@ public class CellStyleListEditPane extends JListControlPane { String[] allNames = nameableList.getAllNames(); allNames[index] = StringUtils.EMPTY; if (StringUtils.isEmpty(newName)) { - showTipDialogAndReset(i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index); + showTipDialogAndReset(i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Cell_Style_Empty_Name_Tip"), index); + nameableList.setNameAt(oldName, index); return; } if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) { - showTipDialogAndReset(i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index); + showTipDialogAndReset(i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Cell_Style_Duplicated_Name_Tip", newName), index); + nameableList.setNameAt(oldName, index); return; } populateSelectedValue(); @@ -249,6 +251,7 @@ public class CellStyleListEditPane extends JListControlPane { super(i18nText("Fine-Design_Predefined_Cell_New_Style"), ThemedCellStyle.class, updatePane); } + @Override public Nameable createNameable(UnrepeatedNameHelper helper) { ThemedCellStyle cellStyle = new ThemedCellStyle(); cellStyle.setName(menuName); @@ -260,6 +263,7 @@ public class CellStyleListEditPane extends JListControlPane { return new NameObject(helper.createUnrepeatedName(this.menuName()), cellStyle); } + @Override public Object acceptObject2Populate(Object ob) { if (ob instanceof NameObject) { ob = ((NameObject) ob).getObject(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java index 9a211ccb6..bb78d2fc0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ComponentStyleEditPane.java @@ -43,9 +43,9 @@ public class ComponentStyleEditPane extends JPanel { JPanel content = new TabbedPane( new String[] { - Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Component_Title"), - Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Component_Body"), - Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Component_Background") + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Title"), + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Body"), + Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Background") }, new JComponent[] { createTabContainer(componentTitleStylePane), createTabContainer(componentBodyStylePane), createTabContainer(componentIntegralStylePane) } ); @@ -119,7 +119,7 @@ public class ComponentStyleEditPane extends JPanel { JPanel tipLabelPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); tipLabelPane.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0)); - UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Template_Theme_Edit_Pane_Component_Style_Tip"), new Color(0XC6C6C6), 8); + UILabel tipLabel = LabelUtils.createLabel(Toolkit.i18nText("Fine-Design_Basic_Template_Theme_Edit_Pane_Component_Style_Tip"), new Color(0XC6C6C6), 10); tipLabelPane.add(tipLabel); container.add(tipLabelPane, BorderLayout.NORTH); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java index 5d12f9498..2b099ed30 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/LabelUtils.java @@ -1,8 +1,10 @@ package com.fr.design.mainframe.theme.edit.ui; import com.fr.design.gui.ilable.UILabel; +import com.fr.general.FRFont; import java.awt.Color; +import java.awt.Font; /** * @author Starryi @@ -20,7 +22,8 @@ public class LabelUtils { public static UILabel createLabel(String title, Color color, int size) { UILabel uiLabel = new UILabel(title); uiLabel.setForeground(color); - uiLabel.setFont(uiLabel.getFont().deriveFont(size)); + Font newFont = FRFont.getInstance(uiLabel.getFont().getFontName(), Font.PLAIN, size); + uiLabel.setFont(newFont); return uiLabel; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java index bca48fac7..0fc194492 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/FormThemePreviewPane.java @@ -12,7 +12,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.TemplateThemePreviewPane; import com.fr.design.mainframe.theme.preview.ecpreview.ECComponentPreviewPane; -import com.fr.design.utils.ComponentUtils; import com.fr.general.Background; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.PiePlot4VanChart; @@ -24,10 +23,10 @@ import com.fr.plugin.chart.type.RadiusType; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.Constants; import com.fr.stable.StringUtils; - -import javax.swing.JComponent; import javax.swing.JPanel; -import java.util.ArrayList; +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Graphics2D; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -44,6 +43,7 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane { private Background background; private ChartComponentPreviewPane columnChartPreviewPane; private ChartComponentPreviewPane pieChartPreviewPane; + private float alpha = 1.0F; public FormThemePreviewPane() { setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -72,9 +72,9 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane { } }; pieChartPanel.setLayout(new BorderLayout()); - pieChartPreviewPane = createChartPreviewPane(initPieChart(), 300, 368); + pieChartPreviewPane = createChartPreviewPane(initPieChart(), 217, 368); pieChartPanel.add(pieChartPreviewPane, BorderLayout.CENTER); - chartContent.add(columnChartPanel, BorderLayout.WEST); + chartContent.add(columnChartPanel, BorderLayout.CENTER); chartContent.add(pieChartPanel, BorderLayout.EAST); return chartContent; } @@ -89,6 +89,7 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane { @Override public void refresh(FormTheme theme) { background = theme.getBodyStyle().getStyle().getBackground(); + alpha = theme.getBodyStyle().getStyle().getAlpha(); elementCasePane.refresh(theme); columnChartPreviewPane.refresh(theme); pieChartPreviewPane.refresh(theme); @@ -96,18 +97,19 @@ public class FormThemePreviewPane extends TemplateThemePreviewPane { } - public void paint(Graphics g) { - // 禁止双缓冲 - ArrayList dbcomponents = new ArrayList(); + @Override + public void paintComponent(Graphics g) { + paintBackground((Graphics2D) g); + } + private void paintBackground(Graphics2D g2d) { if (background == null) { background = ColorBackground.getInstance(Color.WHITE); } - background.paint(g, new Rectangle2D.Double(0, 0, 517, 532)); - paintChildren(g); - // 恢复双缓冲 - ComponentUtils.resetBuffer(dbcomponents); - + Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha)); + background.paint(g2d, new Rectangle2D.Double(0, 0, 517, 532)); + g2d.setComposite(oldComposite); } //柱形图 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java index 71aad36ec..f4e23853d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ReportThemePreviewPane.java @@ -12,7 +12,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.theme.TemplateThemePreviewPane; import com.fr.design.mainframe.theme.preview.ecpreview.ECReportPreviewPane; -import com.fr.design.utils.ComponentUtils; import com.fr.general.Background; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; @@ -21,8 +20,7 @@ import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.column.VanChartColumnPlot; import com.fr.plugin.chart.vanchart.VanChart; -import javax.swing.JComponent; -import java.util.ArrayList; +import java.awt.Graphics2D; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics; @@ -57,19 +55,16 @@ public class ReportThemePreviewPane extends TemplateThemePreviewPane dbcomponents = new ArrayList(); - + private void paintBackground(Graphics2D g2d) { if (background == null) { background = ColorBackground.getInstance(Color.WHITE); } - background.paint(g, new Rectangle2D.Double(0, 0, 517, 532)); - paintChildren(g); - // 恢复双缓冲 - ComponentUtils.resetBuffer(dbcomponents); - + background.paint(g2d, new Rectangle2D.Double(0, 0, 517, 532)); } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/AbstractComponentPopBox.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/AbstractComponentPopBox.java new file mode 100644 index 000000000..ef647f2bd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/AbstractComponentPopBox.java @@ -0,0 +1,243 @@ +package com.fr.design.style.background.gradient; + +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.style.background.BackgroundJComponent; +import com.fr.general.Background; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JWindow; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.util.ArrayList; +import java.util.List; +import java.awt.AWTEvent; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.AWTEventListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2021-08-24 + */ +public abstract class AbstractComponentPopBox extends JComponent { + + protected BackgroundJComponent displayComponent; + + private JWindow selectPopupWindow; + private boolean isWindowEventInit = false; + private static int GAP = 2; + private static int GAP2 = 20; + + private List changeListenerList = new ArrayList(); + + MouseAdapter mouseListener = new MouseAdapter() { + public void mousePressed(MouseEvent evt) { + showPopupMenu(); + } + + + }; + + AWTEventListener awt = new AWTEventListener() { + public void eventDispatched(AWTEvent event) { + if (event instanceof MouseEvent) { + MouseEvent evt = (MouseEvent) event; + if (evt.getClickCount() > 0) { + mouseClick(evt); + } + } + } + }; + + protected void showPopupMenu() { + if (selectPopupWindow != null && selectPopupWindow.isVisible()) { + hidePopupMenu(); + return; + } + + if (!this.isEnabled()) { + return; + } + Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + + selectPopupWindow = this.getControlWindow(); + + Point convertPoint = new Point(0, 0); + + // e: 将点(0,0)从ColorSelectionPane的坐标系统转换到屏幕坐标. + SwingUtilities.convertPointToScreen(convertPoint, this); + int y = convertPoint.y + this.getSize().height; + int x = convertPoint.x; + int h = y + selectPopupWindow.getHeight(); + int width = x + selectPopupWindow.getWidth(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + if (h > screenSize.height) { + y = y - selectPopupWindow.getHeight() - GAP2;// 超过屏幕高度了 + } + + if (width > screenSize.width) { + x = screenSize.width - selectPopupWindow.getWidth(); + } + selectPopupWindow.setLocation(x, y); + + selectPopupWindow.setVisible(true); + + //wei : 为了点击别的地方下拉颜色窗口消失 + MouseAdapter parentMouseListener = new MouseAdapter() { + public void mousePressed(MouseEvent evt) { + mouseClick(evt); + } + }; + if (!this.isWindowEventInit && SwingUtilities.getAncestorOfClass(GradientBackgroundPane.class, this) != null) { + SwingUtilities.getAncestorOfClass(GradientBackgroundPane.class, this).addMouseListener(parentMouseListener); + this.isWindowEventInit = true; + } + } + + private void mouseClick(MouseEvent evt) { + Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY()); + Dimension popBoxD = AbstractComponentPopBox.this.getSize(); + try { + Point popBoxP = AbstractComponentPopBox.this.getLocationOnScreen(); + Dimension popMenuD = this.getControlWindow().getSize(); + Point popMenuP = this.getControlWindow().getLocation(); + Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); + Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); + if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { + this.hidePopupMenu(); + } + } catch (Exception ignore) { + this.hidePopupMenu(); + } + } + + protected void hidePopupMenu() { + if (selectPopupWindow != null) { + selectPopupWindow.setVisible(false); + } + + selectPopupWindow = null; + Toolkit.getDefaultToolkit().removeAWTEventListener(awt); + } + + protected JWindow getControlWindow() { + //find parent. + if (this.selectPopupWindow == null) { + Window parentWindow = SwingUtilities.windowForComponent(this); + if (parentWindow != null) { + this.selectPopupWindow = new AbstractComponentPopBox.SelectControlWindow(parentWindow); + } + + selectPopupWindow.addMouseListener(new MouseAdapter() { + public void mouseExited(MouseEvent evt) { + int x = evt.getLocationOnScreen().x; + int y = evt.getLocationOnScreen().y; + + if (selectPopupWindow != null) { + double desValue = 2; + Rectangle rectangle = selectPopupWindow.getBounds(); + boolean b1 = x < rectangle.x + desValue || x >= rectangle.x + rectangle.width - desValue; + boolean b2 = y > rectangle.y + rectangle.height - desValue;//避免了鼠标下移刚进入selectPopupWindow的过程中弹出框隐藏,上移移出后由AbstractPopBox的mouseListener处理 + if (b1 || b2) { + hidePopupMenu(); + } + } + } + }); + } + + return selectPopupWindow; + } + + /** + * 添加事件 + * + * @param changeListener 事件 + */ + public void addSelectChangeListener(ChangeListener changeListener) { + this.changeListenerList.add(changeListener); + } + + /** + * 删除事件 + * + * @param changeListener 事件 + */ + public void removeSelectChangeListener(ChangeListener changeListener) { + this.changeListenerList.remove(changeListener); + } + + /** + * 响应事件 + */ + public void fireChangeListener() { + if (!changeListenerList.isEmpty()) { + ChangeEvent evt = new ChangeEvent(this); + for (int i = 0; i < changeListenerList.size(); i++) { + this.changeListenerList.get(i).stateChanged(evt); + } + } + } + + /** + * 待说明 + * + * @param background 背景 + */ + public void fireDisplayComponent(Background background) { + if (displayComponent != null) { + displayComponent.setSelfBackground(background); + } + fireChangeListener(); + this.repaint(); + } + + /** + * 初始化弹出框的面板 + * + * @param preWidth 宽度 + * @return 弹出面板 + */ + public abstract JPanel initWindowPane(double preWidth); + + private class SelectControlWindow extends JWindow { + private static final long serialVersionUID = -5776589767069105911L; + + public SelectControlWindow(Window paranet) { + super(paranet); + this.initComponents(); + } + + public void initComponents() { + JPanel defaultPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.setContentPane(defaultPane); + +// defaultPane.setBorder(UIManager.getBorder("PopupMenu.border")); + + if (displayComponent != null) { + defaultPane.add(initWindowPane(displayComponent.getPreferredSize().getWidth())); + } else { + defaultPane.add(initWindowPane(20)); + } + this.pack(); + } + + @Override + public void setVisible(boolean b) { + super.setVisible(b); + AbstractComponentPopBox.this.repaint(); + } + } + + protected boolean isPopupVisible() { + return selectPopupWindow == null ? false : selectPopupWindow.isVisible(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index 269a68be2..e6c2e4dbd 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -5,7 +5,6 @@ import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.style.AbstractPopBox; import com.fr.design.style.color.ColorCell; import com.fr.design.style.color.ColorSelectDetailPane; import com.fr.design.style.color.ColorSelectDialog; @@ -34,7 +33,7 @@ import java.awt.geom.Point2D; /** * TODO:面板缩放的功能没有考虑(就是尾值过大,导致超过界面显示的情况),原来的那个实现完全是个BUG。要缩放的情况也比较少,就干脆以后弄吧 */ -public class GradientBar extends AbstractPopBox implements UIObserver, ColorSelectable { +public class GradientBar extends AbstractComponentPopBox implements UIObserver, ColorSelectable { /** * diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java index e8e1f9f9b..3ec124b13 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectBox.java @@ -52,6 +52,7 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv public JPanel initWindowPane(double preferredWidth) { // 下拉的时候重新生成面板,刷新最近使用颜色 colorPane = getColorSelectPane(); + colorPane.setColor(color); colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { hidePopupMenu(); @@ -59,7 +60,6 @@ public class ColorSelectBox extends AbstractSelectBox implements UIObserv fireDisplayComponent(ColorBackground.getInstance(color)); } }); - colorPane.setColor(color); return colorPane; } diff --git a/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java index ae214d242..367cd6bbb 100644 --- a/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/WorkspaceExceptionHandler.java @@ -68,7 +68,7 @@ public class WorkspaceExceptionHandler { if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) { FineLoggerFactory.getLogger().error(e.getMessage(), e); if (e instanceof ExceptionDescriptor) { - new CommonHandler(true).handle(new RefWrapper(e, StringUtils.EMPTY)); + new CommonHandler(true).handle(new RefWrapper(e, StringUtils.EMPTY)); } else { FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"), diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index ac0bfcb57..e93f0023b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -25,17 +25,19 @@ import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** * 图表 属性表, 类型选择 界面. @@ -99,6 +101,19 @@ public class ChartTypePane extends AbstractChartAttrPane { buttonPane.setEditingChartPane(chartTypeComBox); + buttonPane.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + buttonPane.requestFocus(); + } + }); + + chartTypeComBox.addMouseListener(new MouseAdapter() { + @Override + public void mouseReleased(MouseEvent e) { + content.requestFocus(); + } + }); return content; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java index 584d7fd1d..e8ef8714d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ChartImagePane.java @@ -72,6 +72,7 @@ public class ChartImagePane extends ChartSelectDemoPane { }else{ this.isDoubleClicked = false; } + this.requestFocus(); super.mouseClicked(e); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java index c577a8693..b71def807 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CopyAction.java @@ -1,8 +1,7 @@ package com.fr.design.designer.beans.actions; - import com.fr.design.base.mode.DesignModeContext; -import com.fr.design.designer.beans.actions.behavior.ComponentEnable; +import com.fr.design.designer.beans.actions.behavior.CopyableEnable; import com.fr.design.mainframe.FormDesigner; import javax.swing.KeyStroke; @@ -18,7 +17,7 @@ public class CopyAction extends FormWidgetEditAction { this.setMnemonic('C'); this.setSmallIcon("/com/fr/design/images/m_edit/copy"); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)); - setUpdateBehavior(new ComponentEnable()); + setUpdateBehavior(new CopyableEnable()); this.setEnabled(!DesignModeContext.isBanCopyAndCut()); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java index e93eebd72..94c84a87d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/CutAction.java @@ -3,6 +3,7 @@ package com.fr.design.designer.beans.actions; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.beans.actions.behavior.ComponentEnable; +import com.fr.design.designer.beans.actions.behavior.CutableEnable; import com.fr.design.mainframe.FormDesigner; import javax.swing.KeyStroke; @@ -18,7 +19,7 @@ public class CutAction extends FormWidgetEditAction { this.setMnemonic('T'); this.setSmallIcon("/com/fr/design/images/m_edit/cut"); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)); - this.setUpdateBehavior(new ComponentEnable()); + this.setUpdateBehavior(new CutableEnable()); this.setEnabled(!DesignModeContext.isBanCopyAndCut()); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java index 5f9a59de5..c2fec8f39 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/FormDeleteAction.java @@ -7,9 +7,7 @@ import java.awt.event.KeyEvent; import javax.swing.*; - -import com.fr.design.designer.beans.actions.behavior.ComponentEnable; - +import com.fr.design.designer.beans.actions.behavior.DeletableEnable; import com.fr.design.mainframe.FormDesigner; /** @@ -26,7 +24,7 @@ public class FormDeleteAction extends FormWidgetEditAction { // Richie:删除菜单图标 this.setSmallIcon("/com/fr/design/images/m_report/delete"); this.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0)); - this.setUpdateBehavior(new ComponentEnable()); + this.setUpdateBehavior(new DeletableEnable()); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java new file mode 100644 index 000000000..ce3254ea8 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CopyableEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class CopyableEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentCopyable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java new file mode 100644 index 000000000..7a6320227 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/CutableEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class CutableEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentCutable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java new file mode 100644 index 000000000..669582676 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/beans/actions/behavior/DeletableEnable.java @@ -0,0 +1,16 @@ +package com.fr.design.designer.beans.actions.behavior; + +import com.fr.design.designer.beans.actions.FormWidgetEditAction; +import com.fr.design.mainframe.FormDesigner; + +public class DeletableEnable implements UpdateBehavior { + @Override + public void doUpdate(FormWidgetEditAction action) { + FormDesigner designer = action.getEditingComponent(); + if (designer == null) { + action.setEnabled(false); + return; + } + action.setEnabled(designer.isCurrentComponentDeletable()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index ed90a1c54..3856dde4b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -783,6 +783,12 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo // 不超过可绘制区域 int extraX = Math.min(creatorRightX, formDesignerWidth); int extraY = creatorRightY < 0 ? 0 : Math.min(creatorRightY, formDesignerHeight); + + if (designer.isFormParaDesigner() && extraY + this.getHeight() >= formDesignerHeight) { + popup.setVisible(false); + return; + } + // 放到事件尾部执行 SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index 1d37024d9..f60aa9846 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -103,6 +103,16 @@ public class XWParameterLayout extends XWAbsoluteLayout { return false; } + @Override + public boolean canEnterIntoAbsolutePane() { + return false; + } + + @Override + public boolean canEnterIntoAdaptPane() { + return false; + } + /** * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) * @return 是则返回true diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index 71129bed4..ed59fa9ee 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -219,17 +219,26 @@ public class XWTitleLayout extends DedicateLayoutContainer { public void convert() { isRefreshing = true; WTitleLayout layout = this.toData(); + XBorderStyleWidgetCreator bodyCreator = null; this.removeAll(); for (int i = 0, num = layout.getWidgetCount(); i < num; i++) { BoundsWidget bw = (BoundsWidget) layout.getWidget(i); if (bw != null) { Rectangle bounds = bw.getBounds(); XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget()); - String constraint = bw.getWidget().acceptType(Label.class) ? WTitleLayout.TITLE : WTitleLayout.BODY; + boolean isTitleWidget = bw.getWidget().acceptType(Label.class); + String constraint = isTitleWidget ? WTitleLayout.TITLE : WTitleLayout.BODY; this.add(comp, constraint); comp.setBounds(bounds); + if (!isTitleWidget && comp instanceof XBorderStyleWidgetCreator) { + bodyCreator = (XBorderStyleWidgetCreator) comp; + } } } + // 刷新时重置下样式 + if (bodyCreator != null) { + bodyCreator.initStyle(); + } isRefreshing = false; } diff --git a/designer-form/src/main/java/com/fr/design/fit/JFormType.java b/designer-form/src/main/java/com/fr/design/fit/JFormType.java index 7fe795c6f..f2d1c4ad9 100644 --- a/designer-form/src/main/java/com/fr/design/fit/JFormType.java +++ b/designer-form/src/main/java/com/fr/design/fit/JFormType.java @@ -69,12 +69,12 @@ public enum JFormType { }; private int type; private boolean newType; - private PreviewProvider previewType; + private PreviewProvider defaultPreviewType; - JFormType(int type, PreviewProvider previewType) { + JFormType(int type, PreviewProvider defaultPreviewType) { this.type = type; this.newType = (type == 1); - this.previewType = previewType; + this.defaultPreviewType = defaultPreviewType; } public int getType() { @@ -85,8 +85,8 @@ public enum JFormType { return newType; } - public PreviewProvider getPreviewType() { - return previewType; + public PreviewProvider getDefaultPreviewType() { + return defaultPreviewType; } public abstract void switchUI(); @@ -128,6 +128,14 @@ public enum JFormType { * @date: 2020/12/17 16:17 */ public void updatePreviewType(JTemplate jTemplate) { - jTemplate.setPreviewType(this.getPreviewType()); + if (jTemplate.getPreviewType() != null) { + PreviewProvider[] previewProviders = jTemplate.supportPreview(); + for (PreviewProvider previewProvider : previewProviders) { + if (previewProvider.getClass() == jTemplate.getPreviewType().getClass()) { + return; + } + } + } + jTemplate.setPreviewType(this.getDefaultPreviewType()); } } diff --git a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java index 0d8696ba3..323a28ad0 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/TemplateTool.java @@ -39,6 +39,7 @@ public class TemplateTool { @Override public void on(Event event, JTemplate jTemplate) { if (!(jTemplate instanceof JForm)) { + JFormType.OLD_TYPE.switchUIMode(); return; } JFormType currentType = JFormType.OLD_TYPE; diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index 0ac74e5b5..20f8203ac 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -745,5 +745,13 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP return false; } + @Override + public boolean isCurrentComponentCutable() { + return !isRootSelected(); + } + @Override + public boolean isCurrentComponentCopyable() { + return !isRootSelected(); + } } diff --git a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java index ded4e7c99..4c1f9304b 100644 --- a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java +++ b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java @@ -36,6 +36,9 @@ public class FormDesignerUtils { * @return */ public static boolean isBodyAbsolute(FormDesigner designer) { + if (!designer.getRootComponent().acceptType(XWFitLayout.class)) { + return false; + } WFitLayout root = ((WFitLayout) designer.getRootComponent().toData()); return root.getBodyLayoutType() == com.fr.form.ui.container.WBodyLayoutType.ABSOLUTE; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java index 05cc34dfb..16dc8593e 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormArea.java @@ -175,14 +175,12 @@ public class FormArea extends JComponent implements ScrollRulerComponent { double[] rowSize = {f}; double[] columnSize = {p, f, p, p, p, p, p, f, p}; UILabel tipsPane = new UILabel("form"); - tipsPane.setPreferredSize(new Dimension(265, 0)); widthPane = new UINumberField(); widthPane.setPreferredSize(new Dimension(60, 0)); heightPane = new UINumberField(); heightPane.setPreferredSize(new Dimension(60, 0)); slidePane = JFormSliderPane.getInstance(); - slidePane.setPreferredSize(new Dimension(326, 20)); JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{{tipsPane, new UILabel(), widthPane, diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 4b7fc8eb9..92127c5a8 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -110,6 +110,10 @@ public class FormDesigner extends TargetComponent
implements TreeSelection Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Edit_Delete")}) ); + protected static final ArrayList PARAMETER_TOOLAR_BAN_LIST = new ArrayList( + Arrays.asList(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Cut"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_M_Edit_Copy")}) + ); + private double scale = 1.0D; //底层容器的默认大小 @@ -1267,6 +1271,11 @@ public class FormDesigner extends TargetComponent implements TreeSelection return isForm || isRoot(getSelectionModel().getSelection().getSelectedCreator()); } + public boolean isParameterSelected() { + XCreator xCreator = getSelectionModel().getSelection().getSelectedCreator(); + return xCreator != null && xCreator.acceptType(XWParameterLayout.class); + } + /** * 显示权限编辑界面 */ @@ -1300,6 +1309,10 @@ public class FormDesigner extends TargetComponent implements TreeSelection protected void setToolbarButtons() { //自适应布局和底层都不能删除 DesignerContext.getDesignerFrame().checkCombineUp(!isRootSelected(), NAME_ARRAY_LIST); + + if (isParameterSelected()) { + DesignerContext.getDesignerFrame().checkCombineUp(false, PARAMETER_TOOLAR_BAN_LIST); + } } private void invalidateLayout() { @@ -1385,6 +1398,18 @@ public class FormDesigner extends TargetComponent implements TreeSelection } } + public boolean isCurrentComponentCutable() { + return !(isRootSelected() || isParameterSelected()); + } + + public boolean isCurrentComponentCopyable() { + return !(isRootSelected() || isParameterSelected()); + } + + public boolean isCurrentComponentDeletable() { + return !isRootSelected(); + } + // 当前选中控件可以上移一层吗? public boolean isCurrentComponentMovableUp() { XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java index 2900650aa..84b8f6bf3 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSelectionUtils.java @@ -10,6 +10,7 @@ import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWScaleLayout; import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; @@ -60,6 +61,11 @@ public class FormSelectionUtils { */ public static void paste2Container(FormDesigner designer, XLayoutContainer parent, FormSelection clipboard, int x, int y) { + clipboard = filterFormSelection(clipboard, parent); + if (clipboard.isEmpty()) { + Toolkit.getDefaultToolkit().beep(); + return; + } LayoutAdapter adapter = parent.getLayoutAdapter(); if (parent instanceof XWAbsoluteLayout) { //绝对布局 @@ -77,6 +83,27 @@ public class FormSelectionUtils { Toolkit.getDefaultToolkit().beep(); } + private static FormSelection filterFormSelection(FormSelection clipboard, XLayoutContainer parent) { + FormSelection newSelection = new FormSelection(); + for (XCreator xCreator : clipboard.getSelectedCreators()) { + if (parent.acceptType(XWParameterLayout.class)) { + if (xCreator.canEnterIntoParaPane()) { + newSelection.addSelectedCreator(xCreator); + } + } else if (parent.acceptType(XWAbsoluteLayout.class)) { + if (xCreator.canEnterIntoAbsolutePane()) { + newSelection.addSelectedCreator(xCreator); + } + } else if (parent.acceptType(XWFitLayout.class)) { + if (xCreator.canEnterIntoAdaptPane()) { + newSelection.addSelectedCreator(xCreator); + } + } + + } + return newSelection; + } + private static boolean isExtraContainer(XLayoutContainer parent) { if (parent != null) { Set set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 09808b7bb..f3fbc8cc8 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -140,7 +140,6 @@ public class JForm extends JTemplate implements BaseJForm implements BaseJForm getUsingTemplateThemeConfig() { return getTarget().getUsingTemplateThemeConfig(); @@ -1185,10 +1190,12 @@ public class JForm extends JTemplate implements BaseJForm { // 移动端弹窗 MobilePopupPane mobilePopupPane = new MobilePopupPane(); hyperlinkPane.add(MOBILEPOPUP, mobilePopupPane); - // 导出事件 - if (workbook) { - ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane(); - hyperlinkPane.add(EXPORT, exportJavaScriptPane); - cards.add(exportJavaScriptPane); - } cards.add(javaScriptPane); cards.add(commit2DBJavaScriptPane); cards.add(customActionPane); cards.add(emailPane); cards.add(mobilePopupPane); + // 导出事件 这里要按顺序添加 + if (workbook) { + ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane(); + hyperlinkPane.add(EXPORT, exportJavaScriptPane); + cards.add(exportJavaScriptPane); + } //其他事件 addOtherEvent(); hyperlinkPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Report_JavaScript_Set"))); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index 79b5c8dc5..5cc095cfa 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -5,9 +5,9 @@ import com.fr.design.DesignState; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.cell.CellAttributeAction; import com.fr.design.actions.cell.CellExpandAttrAction; +import com.fr.design.actions.cell.CellStyleAttrAction; import com.fr.design.actions.cell.CellWidgetAttrAction; import com.fr.design.actions.cell.ConditionAttributesAction; -import com.fr.design.actions.cell.GlobalStyleMenuDef; import com.fr.design.actions.columnrow.InsertColumnAction; import com.fr.design.actions.columnrow.InsertRowAction; import com.fr.design.actions.core.ActionFactory; @@ -201,7 +201,7 @@ public class ElementCasePaneDelegate extends ElementCasePane { MenuDef menuDef = new MenuDef(KeySetUtils.CELL.getMenuKeySetName(), KeySetUtils.CELL.getMnemonic()); menuDef.addShortCut(new CellExpandAttrAction()); - menuDef.addShortCut(new GlobalStyleMenuDef(this)); + menuDef.addShortCut(new CellStyleAttrAction()); // 单元格形态 menuDef.addShortCut(DeprecatedActionManager.getPresentMenu(this)); 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 333c7415b..3359513ce 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 @@ -1269,6 +1269,13 @@ public class JWorkBook extends JTemplate { } } + @Override + protected void setUpTheme4NewTemplate() { + super.setUpTheme4NewTemplate(); + getTarget().setTemplateTheme(getTarget().getTemplateTheme()); + } + + @Override public TemplateThemeConfig getUsingTemplateThemeConfig() { return getTarget().getUsingTemplateThemeConfig(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java index 431b401fc..62134c121 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java @@ -45,7 +45,12 @@ class CptApp extends AbstractWorkBookApp { @Override public WorkBook asIOFile(FILE file) { - return asIOFile(file, true); + // 11.beta.1 + // REPORT-51919 主题切换 + // REPORT-57943 【主题切换】10.0自定义的预定义样式,模板放11.0上,配置丢失 + // 11.beta.1 模版主题功能后,预定义单元格样式功能废弃,所有预定义单元格样式将被统一放置到"兼容主题"中, + // 对于本地不存在的预定义单元格样式,将会被设置为兼容主题中默认单元格样式,因此这里不需要再执行检查 + return asIOFile(file, false); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index 049b0111a..bbb63a391 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -70,7 +70,7 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); - if (stylePane.getSelectedIndex() == 1) { + if (stylePane.getSelectedIndex() == 0) { Style s = stylePane.updateBean(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); int cellRectangleCount = cs.getCellRectangleCount(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index 72ee9b221..59bc73d57 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -1,35 +1,155 @@ package com.fr.design.mainframe.cell.settingpane.style; -import java.util.ArrayList; -import java.util.List; +import com.fr.base.NameStyle; +import com.fr.base.Style; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; -import com.fr.base.Style; -import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.gui.frpane.UIComboBoxPane; -import com.fr.general.ComparatorUtils; +public class StylePane extends BasicPane { + public static final String[] FOLLOWING_THEME_STRING_ARRAYS = new String[]{ + Toolkit.i18nText("Fine-Design_Style_Follow_Theme"), + Toolkit.i18nText("Fine-Design_Style_Not_Follow_Theme"), + }; + public static final int DEFAULT_SELECTED_INDEX = 0; -import com.fr.design.mainframe.ElementCasePane; + private final UIButtonGroup followingThemeButtonGroup; + private final CustomStylePane customStylePane; + private final ThemedCellStyleListPane themedCellStyleListPane; + private final CardLayout cardLayout; + private final JComponent[] panes = new JComponent[2]; + + private JPanel contentPane; + + public StylePane() { + followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); + customStylePane = new CustomStylePane(); + themedCellStyleListPane = new ThemedCellStyleListPane(); + panes[0] = createThemedStylePane(); + panes[1] = createCustomStylePane(); + cardLayout = new CardLayout(); + + initializePane(); + } + + private void initializePane() { + setLayout(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + + add(createFollowingThemePane(), BorderLayout.NORTH); + contentPane = createTabbedContentPane(); + add(contentPane, BorderLayout.CENTER); + } + + private JPanel createFollowingThemePane() { + followingThemeButtonGroup.setSelectedIndex(DEFAULT_SELECTED_INDEX); + followingThemeButtonGroup.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); + if (selectedIndex == 1) { + // 对于同一个单元格,跟随主题切换到自定义,若跟随主题面板有选中项,则自定义中的配置与其保持一致,否则自定义中配置保持不变 + NameStyle lastSelectedNameStyle = themedCellStyleListPane.updateBean(); + if (lastSelectedNameStyle != null) { + Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); + try { + lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); + if (lastSelectedRealStyle != null) { + customStylePane.populateBean(lastSelectedRealStyle); + } + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + } + } else { + // 对于同一个单元格,自定义切换到跟随主题,跟随主题应当清除选中项,即没有选中任何主题中的单元格样式, + // 因为还未选中,所以自定义中的配置保持不变,此时若用户切换会自定义,配置应当与之前一样 + themedCellStyleListPane.populateBean(null); + } + } + }); + + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Setting")); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + return TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{ new Component[] { uiLabel, followingThemeButtonGroup} }, + new double[] { p }, new double[] { p, f}, + IntervalConstants.INTERVAL_L1, 0); + } + + protected JPanel createTabbedContentPane() { + JPanel contentPane = new JPanel(cardLayout) { + @Override + public Dimension getPreferredSize() { + int selectedIndex = followingThemeButtonGroup.getSelectedIndex(); + if (selectedIndex < 0) { + return super.getPreferredSize(); + } else { + return panes[selectedIndex].getPreferredSize(); + } + } + }; + for (int i = 0; i < FOLLOWING_THEME_STRING_ARRAYS.length; i++) { + contentPane.add(panes[i], FOLLOWING_THEME_STRING_ARRAYS[i]); + } + cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[DEFAULT_SELECTED_INDEX]); + + return contentPane; + } + + private JPanel createThemedStylePane() { + JPanel container = new JPanel(new BorderLayout(0, IntervalConstants.INTERVAL_L1)); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Style_Selecting")); + uiLabel.setPreferredSize(new Dimension(uiLabel.getPreferredSize().width, 20)); + container.add(uiLabel, BorderLayout.NORTH); + themedCellStyleListPane.setBorder(BorderFactory.createEmptyBorder()); + UIScrollPane scrollPane = new UIScrollPane(themedCellStyleListPane); + container.add(scrollPane, BorderLayout.CENTER); + return container; + } -public class StylePane extends UIComboBoxPane