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 3694c6f83d..7761038b72 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -2220,7 +2220,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writer.attr("layoutTemplateStyle", this.getLayoutTemplateStyle()); writer.attr("showServerDatasetAuthTip", this.isShowServerDatasetAuthTip()); writer.attr("useOptimizedUPM4Adapter", this.isUseOptimizedUPM4Adapter()); - writer.attr("propertiesUsable", false); + writer.attr("propertiesUsable", this.isPropertiesUsable()); writer.end(); } 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 1746330f11..e73f64eb36 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 @@ -66,6 +66,7 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JToolBar; +import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import java.awt.BorderLayout; @@ -303,7 +304,7 @@ public class DBTableDataPane extends AbstractTableDataPane { //显示对应的配置 strategyConfigPane.populateBean(populateStrategyConfig); - BasicDialog dlg = strategyConfigPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + BasicDialog dlg = strategyConfigPane.showMediumWindow(SwingUtilities.getWindowAncestor(DBTableDataPane.this), new DialogActionAdapter() { @Override public void doOk() { super.doOk(); @@ -314,7 +315,7 @@ public class DBTableDataPane extends AbstractTableDataPane { } } }); - dlg.setAlwaysOnTop(true); + //dlg.setAlwaysOnTop(true); dlg.setVisible(true); } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index aacbd2fbfd..d6ceb34177 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1014,7 +1014,7 @@ public abstract class JTemplate> // 过滤掉本地文件 boolean localFile = getEditingFILE() instanceof FileFILE; boolean inconsistent = !localFile && getEditingFILE().exists() - && !WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath()); + && !WorkContext.getCurrent().get(LockInfoOperator.class).isConsistentLock(getEditingFILE().getPath()); if (inconsistent) { throw new InconsistentLockException(); } @@ -1112,6 +1112,20 @@ public abstract class JTemplate> this.listenerList.remove(JTemplateActionListener.class, l); } + /** + * 模板保存前触发 + */ + public void fireJTemplateSaveBefore() { + Object[] listeners = listenerList.getListenerList(); + + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == JTemplateActionListener.class) { + ((JTemplateActionListener) listeners[i + 1]).templateSaveBefore(this); + } + } + this.repaint(30); + } + /** * 触发模板关闭 */ @@ -1622,6 +1636,7 @@ public abstract class JTemplate> } private CallbackSaveWorker save(boolean showLoc) { + fireJTemplateSaveBefore(); FILE editingFILE = this.getEditingFILE(); // carl:editingFILE没有,当然不存了,虽然不会有这种情况 if (editingFILE == null) { @@ -1917,7 +1932,7 @@ public abstract class JTemplate> } - public void setDesignerUIMode(){ + public void setDesignerUIMode() { DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListener.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListener.java index 5e17873695..ecfd52dbe0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListener.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateActionListener.java @@ -4,9 +4,15 @@ import java.util.EventListener; public interface JTemplateActionListener extends EventListener { - public void templateOpened(JTemplate jt); + default void templateOpened(JTemplate jt) { + } - public void templateSaved(JTemplate jt); + default void templateSaved(JTemplate jt) { + } - public void templateClosed(JTemplate jt); + default void templateClosed(JTemplate jt) { + } + + default void templateSaveBefore(JTemplate jt) { + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java b/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java index ec77559856..ea3e72c3f5 100644 --- a/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java +++ b/designer-base/src/main/java/com/fr/exit/ConfigToPropMigrator.java @@ -10,6 +10,8 @@ import com.fr.workspace.WorkContext; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; @@ -62,9 +64,9 @@ public class ConfigToPropMigrator { initDirectory(); try (Connection c = DriverManager.getConnection(url); - FileOutputStream entityOut = new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH); - FileOutputStream classHelperOut = new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH); - FileOutputStream xmlEntityOut = new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH)) { + OutputStreamWriter xmlEntityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.XML_ENTITY_PROP_PATH), StandardCharsets.UTF_8); + OutputStreamWriter entityOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.ENTITY_PROP_PATH), StandardCharsets.UTF_8); + OutputStreamWriter classHelperOut = new OutputStreamWriter(new FileOutputStream(PropertiesConstants.CLASS_NAME_PROP_PATH), StandardCharsets.UTF_8)) { processClassOrEntity(c, new Properties(), SELECT_FOR_ENTITY, entityOut); processClassOrEntity(c, new Properties(), SELECT_FOR_CLASSNAME, classHelperOut); @@ -84,7 +86,7 @@ public class ConfigToPropMigrator { } } - private void processClassOrEntity(Connection c, Properties map, String sql, FileOutputStream outputStream) throws SQLException, IOException { + private void processClassOrEntity(Connection c, Properties map, String sql, OutputStreamWriter writer) throws SQLException, IOException { PreparedStatement query = c.prepareStatement(sql); ResultSet resultSet = query.executeQuery(); while (resultSet.next()) { @@ -94,19 +96,19 @@ public class ConfigToPropMigrator { map.setProperty(id, value); } } - map.store(outputStream, null); + map.store(writer, null); } - private void processXmlEntity(Connection c, Properties map, FileOutputStream outputStream) throws SQLException, IOException { + private void processXmlEntity(Connection c, Properties map, OutputStreamWriter writer) throws SQLException, IOException { PreparedStatement query = c.prepareStatement(SELECT_FOR_XML_ENTITY); ResultSet resultSet = query.executeQuery(); while (resultSet.next()) { String id = resultSet.getString(1); Blob value = resultSet.getBlob(2); byte[] bytes = value.getBytes(1L, (int) value.length()); - map.setProperty(id, new String(bytes)); + map.setProperty(id, new String(bytes, StandardCharsets.UTF_8)); } - map.store(outputStream, null); + map.store(writer, null); } public void deletePropertiesCache() { diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java index e9ebbd882c..19b8ad50ad 100644 --- a/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java @@ -3,13 +3,14 @@ package com.fr.design.sort.common; import com.fr.base.Style; import com.fr.base.background.ColorBackground; import com.fr.base.svg.IconUtils; -import com.fr.design.designer.TargetComponent; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JTemplateActionListener; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; import com.fr.design.sort.header.HeaderAreaPane; @@ -18,10 +19,6 @@ import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; -import com.fr.report.cell.cellattr.CellExpandAttr; -import com.fr.report.cell.cellattr.core.group.DSColumn; -import com.fr.report.core.sort.common.CellSortable; -import com.fr.report.core.sort.header.SortHeader; import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; import com.fr.stable.EssentialUtils; @@ -157,6 +154,7 @@ public class SortColumnRowPane extends JPanel implements UIObserver { class SelectActionListener extends MouseAdapter { SortColumnRowPane columnRowPane; ColumnRow oldColumnRow; + JTemplateActionListener jTemplateActionListener; Map disableHeaderCellsStyleMap = new HashMap<>(); java.util.List tempHeaderCells = new ArrayList<>(); @@ -178,13 +176,44 @@ public class SortColumnRowPane extends JPanel implements UIObserver { @Override public void selectionChanged(SelectionEvent e) { completeSelectHeader(elementCasePane); + removeJTemplateActionListener(); } }; elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); + this.addJTemplateActionListener(); isAlreadyAddListener = true; } } + + private void addJTemplateActionListener() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + removeJTemplateActionListener(); + jTemplateActionListener = new JTemplateActionListener() { + @Override + public void templateSaveBefore(JTemplate jt) { + ElementCasePane elementCasePane = SortUtils.getCurrentElementCase(); + if (elementCasePane != null) { + recoverSelectHeader(elementCasePane); + } + removeJTemplateActionListener(); + } + }; + jTemplate.addJTemplateActionListener(jTemplateActionListener); + } + } + + private void removeJTemplateActionListener() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + if (jTemplateActionListener != null) { + jTemplate.removeJTemplateActionListener(jTemplateActionListener); + } + } + } + + private void prepareSelectHeader(ElementCasePane elementCasePane) { ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); oldSelection = (CellSelection) elementCasePane.getSelection(); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 917de56f0d..4149753f72 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -158,26 +158,26 @@ public class DesignerStartup extends Activator { private void registerDaoSelector() { // 注入设计器db cache 是否可用 - DaoSelectorFactory.registerDaoSelector(() -> false); -// DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo(); -// if (info.getType() == DesignerWorkspaceType.Remote) { -// } else { -// String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath(); -// String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY, -// EncryptionConstants.PROPERTY_NAME); -// String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP); -// String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP); -// String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP); -// // 校验 平台迁移文件/缓存文件 -// boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists(); -// DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable() -// && OptimizeUtil.isOpen() -// && existPropCache -// // demo启动时 前后目录可能会不一致 造成读取缓存失败 -// && !startupArgsValue.getValue().isDemo() -// && !new File(dbConfigPath).exists()); -// -// } + DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo(); + if (info.getType() == DesignerWorkspaceType.Remote) { + DaoSelectorFactory.registerDaoSelector(() -> false); + } else { + String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath(); + String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY, + EncryptionConstants.PROPERTY_NAME); + String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP); + String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP); + String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP); + // 校验 平台迁移文件/缓存文件 + boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists(); + DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable() + && OptimizeUtil.isOpen() + && existPropCache + // demo启动时 前后目录可能会不一致 造成读取缓存失败 + && !startupArgsValue.getValue().isDemo() + && !new File(dbConfigPath).exists()); + + } } private String generatePath(String webInfPath, String name) {