diff --git a/build.gradle b/build.gradle index 5bac80b64..a3892da96 100644 --- a/build.gradle +++ b/build.gradle @@ -69,6 +69,7 @@ allprojects { implementation 'org.swingexplorer:swag:1.0' implementation 'net.java.dev.jna:jna:5.4.0' implementation 'org.apache.tomcat:tomcat-catalina:8.5.72' + implementation 'org.apache.tomcat:tomcat-websocket:8.5.72' implementation 'io.socket:socket.io-client:0.7.0' implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion 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 9d84e25ba..1f39f024d 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -53,7 +53,8 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.third.apache.log4j.FileAppender; +import com.fr.third.apache.logging.log4j.core.appender.FileAppender; +import com.fr.third.apache.logging.log4j.core.layout.PatternLayout; import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -324,18 +325,18 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (!new File(fileName).exists()) { StableUtils.makesureFileExist(new File(fileName)); } - LogHandler handler = new LogHandler() { - final FileAppender appender = new FileAppender( - new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"), - fileName - ); + LogHandler handler = new LogHandler() { + final FileAppender appender = FileAppender.newBuilder(). + setName(FileAppender.class.getSimpleName()). + setLayout(PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n").build()). + withFileName(fileName).build(); @Override public FileAppender getHandler() { return appender; } }; - + handler.getHandler().start(); FineLoggerFactory.getLogger().addLogAppender(handler); } catch (SecurityException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java index bb2de54ba..5365e556b 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/BugAction.java @@ -17,7 +17,7 @@ public class BugAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.bugs", "https://service.fanruan.com/PF/FR/feedback"); + return CloudCenter.getInstance().acquireUrlByKind("bbs.bugs", "https://service.fanruan.com/PF/FR/feedback?type=2"); } public static final MenuKeySet BUG = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java index 4a9b80a9b..62d4b9c95 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/NeedAction.java @@ -18,7 +18,7 @@ public class NeedAction extends AbstractDesignerSSO { @Override public String getJumpUrl() { - return CloudCenter.getInstance().acquireUrlByKind("bbs.needs", "https://service.fanruan.com/PF/FR/feedback"); + return CloudCenter.getInstance().acquireUrlByKind("bbs.needs", "https://service.fanruan.com/PF/FR/feedback?type=1"); } public static final MenuKeySet NEED = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 303d9fd81..c0797e946 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -29,7 +29,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.VerticalFlowLayout; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.os.impl.SupportOSImpl; @@ -45,14 +44,12 @@ import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import com.fr.stable.os.OperatingSystem; -import com.fr.third.apache.log4j.Level; +import com.fr.third.apache.logging.log4j.Level; import com.fr.transaction.Configurations; import com.fr.transaction.Worker; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.git.config.GcConfig; -import com.sun.javafx.tk.FileChooserType; -import javafx.stage.FileChooser; import javax.swing.BorderFactory; import javax.swing.BoxLayout; diff --git a/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java index bde6b1371..f23b5b078 100644 --- a/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java @@ -1,6 +1,6 @@ package com.fr.design.cell; -import com.fr.report.cell.CellElementBorderSourceFlag; +import com.fr.base.CellBorderSourceFlag; import com.fr.base.CellBorderStyle; import com.fr.base.Style; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; @@ -20,34 +20,39 @@ public class CellRectangleStylePreviewPane extends JPanel { private static final int COLUMN_COUNT = 2; private final TemplateCellElement[][] cellElementGrid = new TemplateCellElement[ROW_COUNT][COLUMN_COUNT]; + private final int[][] borderSourceFlags = new int[ROW_COUNT][COLUMN_COUNT]; private final CellStylePreviewPane[][] cellStylePreviewPaneGrid = new CellStylePreviewPane[ROW_COUNT][COLUMN_COUNT]; - public CellRectangleStylePreviewPane() { + public CellRectangleStylePreviewPane(boolean supportInnerBorder) { setLayout(new GridLayout(2, 2)); for (int r = 0; r < ROW_COUNT; r++) { for (int c = 0; c < COLUMN_COUNT; c++) { CellStylePreviewPane pane = new CellStylePreviewPane(); TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r); - int flags = CellElementBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; - if (r != 0) { - flags |= CellElementBorderSourceFlag.TOP_BORDER_SOURCE_INNER; + int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE; + if (supportInnerBorder) { + flags = CellBorderSourceFlag.ALL_BORDER_SOURCE_OUTER; + if (r != 0) { + flags |= CellBorderSourceFlag.TOP_BORDER_SOURCE_INNER; + } + if (r != ROW_COUNT - 1) { + flags |= CellBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; + } + if (c != 0) { + flags |= CellBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; + } + if (c != COLUMN_COUNT - 1) { + flags |= CellBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; + } } - if (r != ROW_COUNT - 1) { - flags |= CellElementBorderSourceFlag.BOTTOM_BORDER_SOURCE_INNER; - } - if (c != 0) { - flags |= CellElementBorderSourceFlag.LEFT_BORDER_SOURCE_INNER; - } - if (c != COLUMN_COUNT - 1) { - flags |= CellElementBorderSourceFlag.RIGHT_BORDER_SOURCE_INNER; - } - cellElement.setBorderSourceFlags(flags); + pane.setStyle(cellElement.getStyle()); add(pane); cellElementGrid[r][c] = cellElement; + borderSourceFlags[r][c] = flags; cellStylePreviewPaneGrid[r][c] = pane; } } @@ -64,7 +69,8 @@ public class CellRectangleStylePreviewPane extends JPanel { for (int j = 0; j < COLUMN_COUNT; j++) { CellStylePreviewPane pane = cellStylePreviewPaneGrid[i][j]; TemplateCellElement cellElement = cellElementGrid[i][j]; - cellElement.setStyle(style, borderStyle); + int flag = borderSourceFlags[i][j]; + cellElement.setStyle(CellBorderSourceFlag.deriveBorderedStyle(style, borderStyle, flag)); pane.setStyle(cellElement.getStyle()); } @@ -73,7 +79,26 @@ public class CellRectangleStylePreviewPane extends JPanel { } @Override - public Dimension getMinimumSize() { - return getPreferredSize(); + public void setPreferredSize(Dimension preferredSize) { + super.setPreferredSize(preferredSize); + int hw = preferredSize.width / 2; + int hh = preferredSize.height / 2; + cellStylePreviewPaneGrid[0][0].setPreferredSize(new Dimension(hw, hh)); + cellStylePreviewPaneGrid[0][1].setPreferredSize(new Dimension(hw, hh)); + cellStylePreviewPaneGrid[1][0].setPreferredSize(new Dimension(hw, hh)); + cellStylePreviewPaneGrid[1][1].setPreferredSize(new Dimension(hw, hh)); + } + + @Override + public Dimension getPreferredSize() { + Dimension d00 = cellStylePreviewPaneGrid[0][0].getPreferredSize(); + Dimension d01 = cellStylePreviewPaneGrid[0][1].getPreferredSize(); + Dimension d10 = cellStylePreviewPaneGrid[1][0].getPreferredSize(); + Dimension d11 = cellStylePreviewPaneGrid[1][1].getPreferredSize(); + + int width = Math.max(d00.width + d01.width, d10.width + d11.width); + int height = Math.max(d00.height + d10.height, d01.height + d11.height); + + return new Dimension(width, height); } } diff --git a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java index 885d3e8e1..8495aa6ec 100644 --- a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java @@ -1,19 +1,26 @@ package com.fr.design.cell; +import com.fr.base.BaseUtils; +import com.fr.base.GraphHelper; import com.fr.base.NameStyle; import com.fr.base.ScreenResolution; import com.fr.base.Style; +import com.fr.general.FRFont; import com.fr.general.IOUtils; +import com.fr.stable.unit.PT; import javax.swing.JPanel; import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Composite; import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; +import java.util.List; /** * @author Starryi @@ -22,6 +29,7 @@ import java.awt.image.BufferedImage; */ public class CellStylePreviewPane extends JPanel { + public static final int MINIMUM_HEIGHT = 40; private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png"); private final float transparentBackgroundWidth; private final float transparentBackgroundHeight; @@ -31,6 +39,7 @@ public class CellStylePreviewPane extends JPanel { public CellStylePreviewPane() { transparentBackgroundWidth = transparentBackgroundImage.getWidth(null); transparentBackgroundHeight = transparentBackgroundImage.getHeight(null); + setPreferredSize(new Dimension(0, 0)); } public void setPaintText(String paintText) { @@ -118,7 +127,39 @@ public class CellStylePreviewPane extends JPanel { } @Override - public Dimension getMinimumSize() { - return getPreferredSize(); + public Dimension getPreferredSize() { + Dimension size = super.getPreferredSize(); + int width = size.width; + int height = size.height; + + if (height != 0) { + // 使用者设置了一个高度 + return size; + } else if (width == 0) { + // 使用者未设置任何尺寸 + return new Dimension(width, MINIMUM_HEIGHT); + } else { + // 使用者设置了宽度,但未设置高度 + return getAutoWrapContentPreferredSize(width, height); + } + } + + private Dimension getAutoWrapContentPreferredSize(int width, int height) { + int resolution = ScreenResolution.getScreenResolution(); + + // 计算文本区域高度 + final FRFont frFont = style.getFRFont(); + final Font rfont = frFont.applyResolutionNP(resolution); + final FontMetrics metrics = GraphHelper.getFontMetrics(rfont); + final int textLineHeight = metrics.getHeight(); + final double textLineSpacing = PT.pt2pix(style.getLineSpacing(), resolution); + + List textLineList = BaseUtils.getLineTextList(paintText, style, rfont, height, width, resolution); + + double textLinesHeight = textLineList.size() * textLineHeight + Math.max(0, textLineList.size() - 1) * textLineSpacing; + + height = (int) Math.max(MINIMUM_HEIGHT, textLinesHeight); + + return new Dimension(width, height); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index f65610526..38d287a20 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -1,12 +1,12 @@ package com.fr.design.data.datapane; import com.fr.base.TableData; -import com.fr.concurrent.NamedThreadFactory; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.Dialect; import com.fr.data.core.db.dialect.DialectFactory; +import com.fr.data.impl.Connection; import com.fr.data.impl.DBTableData; import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; @@ -19,7 +19,7 @@ import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icombobox.FilterableComboBoxModel; -import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox; +import com.fr.design.gui.icombobox.SearchFRTreeComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxRenderer; @@ -40,11 +40,6 @@ import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.server.connection.DBConnectAuth; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.util.Collections; -import java.util.concurrent.CancellationException; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -58,21 +53,20 @@ import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; -import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; import java.util.Collection; -import java.util.Enumeration; +import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.FutureTask; +import java.util.concurrent.CancellationException; /** * @author zhou @@ -97,41 +91,12 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 表名 */ - protected SearchPreTaskTreeComboBox tableNameComboBox; - - private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePane")); + protected SearchFRTreeComboBox tableNameComboBox; private SwingWorker populateWorker; private SwingWorker, Void> initWorker; - private PopupMenuListener popupMenuListener = new PopupMenuListener() { - - @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - FutureTask task = new FutureTask(new Callable() { - @Override - public Void call() throws Exception { - calculateTableDataNames(); - return null; - } - }); - tableNameComboBox.setPreSearchTask(task); - SERVICE.submit(task); - } - - @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - // Do nothing - } - - @Override - public void popupMenuCanceled(PopupMenuEvent e) { - // Do nothing - } - }; - - private PopupMenuListener listener = new PopupMenuListener() { @Override public void popupMenuCanceled(PopupMenuEvent e) { @@ -181,7 +146,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha schemaBox = new StringUIComboBox(); schemaBox.setEditor(new ComboBoxEditor()); - tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); + tableNameComboBox = new SearchFRTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer); tableNameComboBox.setEditable(true); tableNameComboBox.setRenderer(listCellRenderer); registerDSChangeListener(); @@ -198,7 +163,6 @@ public class ChoosePane extends BasicBeanPane implements Refresha }); schemaBox.addPopupMenuListener(listener); addFocusListener(); - this.tableNameComboBox.addPopupMenuListener(popupMenuListener); } protected void addDSBoxListener() { @@ -355,7 +319,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha GUICoreUtils.setSelectedItemQuietly(tableNameComboBox, -1); } - protected com.fr.data.impl.Connection getConnection() { + public Connection getConnection() { String selectedDSName = this.getDSName(); if (StringUtils.isEmpty(selectedDSName)) { return null; // peter:选中了当前的零长度的节点,直接返回. @@ -455,56 +419,6 @@ public class ChoosePane extends BasicBeanPane implements Refresha return "choosepane"; } - protected void calculateTableDataNames() { - JTree tree = tableNameComboBox.getTree(); - if (tree == null) { - return; - } - DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot(); - rootTreeNode.removeAllChildren(); - - String selectedDSName = this.getDSName(); - com.fr.data.impl.Connection selectedDatabase = this.getConnection(); - if (selectedDatabase == null) { - return; - } - try { - String schema = StringUtils.isEmpty(this.schemaBox.getSelectedItem()) ? null : this.schemaBox.getSelectedItem(); - TableProcedure[] sqlTableArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); - if (sqlTableArray.length > 0) { - ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table")); - rootTreeNode.add(tableTreeNode); - for (int i = 0; i < sqlTableArray.length; i++) { - ExpandMutableTreeNode tableChildTreeNode = new ExpandMutableTreeNode(sqlTableArray[i]); - tableTreeNode.add(tableChildTreeNode); - } - } - TableProcedure[] sqlViewArray = DataCoreUtils.getTables(selectedDatabase, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); - if (sqlViewArray.length > 0) { - ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(selectedDSName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View")); - rootTreeNode.add(viewTreeNode); - for (int i = 0; i < sqlViewArray.length; i++) { - ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(sqlViewArray[i]); - viewTreeNode.add(viewChildTreeNode); - } - } - ((DefaultTreeModel) tree.getModel()).reload(); - // daniel 展开所有tree - TreeNode root = (TreeNode) tree.getModel().getRoot(); - TreePath parent = new TreePath(root); - TreeNode node = (TreeNode) parent.getLastPathComponent(); - for (Enumeration e = node.children(); e.hasMoreElements(); ) { - TreeNode n = (TreeNode) e.nextElement(); - TreePath path = parent.pathByAddingChild(n); - tree.expandPath(path); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); - } - } - /** * 创建选中的数据集数据 * @@ -558,10 +472,14 @@ public class ChoosePane extends BasicBeanPane implements Refresha return tableData; } - protected String getDSName() { + public String getDSName() { return this.dsNameComboBox.getSelectedItem(); } + public String getSchema() { + return this.schemaBox.getSelectedItem(); + } + protected void failedToFindTable() { // Do nothing } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java index 14d0431e2..8fc62cd77 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java @@ -83,7 +83,7 @@ public class ChoosePaneSupportFormula extends ChoosePane { * * @return */ - protected String getDSName() { + public String getDSName() { String selectedDSName = null; String item = Utils.objectToString(this.dsNameComboBox.getEditor().getItem()); // 没有选中的列表项 那么看看是不是手输值 diff --git a/designer-base/src/main/java/com/fr/design/event/ComponentChangeListener.java b/designer-base/src/main/java/com/fr/design/event/ComponentChangeListener.java new file mode 100644 index 000000000..d16d49b6a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/ComponentChangeListener.java @@ -0,0 +1,7 @@ +package com.fr.design.event; + +import java.awt.*; + +public interface ComponentChangeListener { + void initListener(Container changedComponent); +} diff --git a/designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java b/designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java new file mode 100644 index 000000000..9ef75d514 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/ComponentChangeObserver.java @@ -0,0 +1,6 @@ +package com.fr.design.event; + + +public interface ComponentChangeObserver { + void registerChangeListener(ComponentChangeListener uiChangeableListener); +} diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java b/designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java index 2fa1ea110..1923a2287 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginInstalledPane.java @@ -60,11 +60,14 @@ public class PluginInstalledPane extends PluginAbstractViewPane { public void actionPerformed(ActionEvent e) { PluginView plugin = controlPane.getSelectedPlugin(); if (plugin != null) { - boolean isActive = plugin.isActive(); - PluginMarker pluginMarker = PluginMarker.create(plugin.getID(), plugin.getVersion()); - final String modifyMessage = isActive ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Actived") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled"); - if (isActive) { - PluginManager.getController().forbid(pluginMarker, new PluginTaskCallback() { + PluginContext pluginContext = getPluginContextByView(plugin); + if (pluginContext == null) { + return; + } + boolean running = pluginContext.isRunning(); + final String modifyMessage = running ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Actived") : com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Been_Disabled"); + if (running) { + PluginManager.getController().forbidPersistently(pluginContext.getMarker(), new PluginTaskCallback() { @Override public void done(PluginTaskResult result) { if (result.isSuccess()) { @@ -75,7 +78,7 @@ public class PluginInstalledPane extends PluginAbstractViewPane { } }); } else { - PluginManager.getController().enable(pluginMarker, new PluginTaskCallback() { + PluginManager.getController().enablePersistently(pluginContext.getMarker(), new PluginTaskCallback() { @Override public void done(PluginTaskResult result) { if (result.isSuccess()) { @@ -145,13 +148,25 @@ public class PluginInstalledPane extends PluginAbstractViewPane { } private void changeTextForButton(PluginView plugin) { - if (plugin.isActive()) { + PluginContext pluginContext = getPluginContextByView(plugin); + if (pluginContext == null) { + return; + } + if (pluginContext.isRunning()) { disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Disable")); } else { disableButton.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Active")); } } + private PluginContext getPluginContextByView(PluginView pluginView) { + if (pluginView != null) { + PluginMarker pluginMarker = PluginMarker.create(pluginView.getID(), pluginView.getVersion()); + return PluginManager.getContext(pluginMarker); + } + return null; + } + @Override protected String title4PopupWindow() { return "Installed"; diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 7dd2097dc..379daab28 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -99,9 +99,9 @@ public class PluginOperateUtils { public void run() { PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); PluginContext plugin = PluginManager.getContext(pluginMarker); - boolean active = plugin.isActive(); - PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(active, jsCallback); - if (active) { + boolean isRunning = plugin.isRunning(); + PluginTaskCallback modifyStatusCallback = new ModifyStatusCallback(isRunning, jsCallback); + if (isRunning) { PluginXmlElement forbidReminder = plugin.getXml().getElement(PluginElementName.ForbidReminder); if (forbidReminder != null && forbidReminder.getContent() != null) { // 禁用前提示 @@ -113,14 +113,14 @@ public class PluginOperateUtils { JOptionPane.WARNING_MESSAGE ); if (rv == JOptionPane.OK_OPTION) { - PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); + PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback); } } else { // 正常禁用 - PluginManager.getController().forbid(pluginMarker, modifyStatusCallback); + PluginManager.getController().forbidPersistently(pluginMarker, modifyStatusCallback); } } else { - PluginManager.getController().enable(pluginMarker, modifyStatusCallback); + PluginManager.getController().enablePersistently(pluginMarker, modifyStatusCallback); } } }); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java index a9321879c..15d50d00c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/AbstractAttrNoScrollPane.java @@ -3,6 +3,8 @@ package com.fr.design.gui.frpane; import com.fr.design.dialog.BasicPane; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; +import com.fr.design.event.ComponentChangeListener; +import com.fr.design.event.ComponentChangeObserver; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.stable.StringUtils; @@ -103,6 +105,15 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { } }); } + if(tmpComp instanceof ComponentChangeObserver){ + ComponentChangeObserver uiChangeableObserver = ((ComponentChangeObserver)tmpComp); + uiChangeableObserver.registerChangeListener(new ComponentChangeListener() { + @Override + public void initListener(Container changedComponent) { + AbstractAttrNoScrollPane.this.initListener(changedComponent); + } + }); + } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index e294d8022..0ddd3e22d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -58,7 +58,7 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser super(locText, b); setUI(new UICheckBoxUI()); initListener(); - this.markMnemonic=markMnemonic; + this.markMnemonic = markMnemonic; } public UICheckBox(String text, Icon icon) { @@ -100,6 +100,10 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser } + public void removeChangeListener() { + uiObserverListener = null; + } + @Override public void setGlobalName(String name) { checkboxName = name; diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index 8fe79d41e..c12239447 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -248,7 +248,7 @@ public class FRTreeComboBox extends UIComboBox { private static TreePopup treePopup; - private static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{ + protected static class FRTreeComboBoxUI extends BasicComboBoxUI implements MouseListener{ private boolean isRollover = false; public FRTreeComboBoxUI() { @@ -535,7 +535,7 @@ public class FRTreeComboBox extends UIComboBox { public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { private volatile boolean setting = false; private FRTreeComboBox comboBox; - private Object item; + protected Object item; public FrTreeSearchComboBoxEditor(FRTreeComboBox comboBox) { super(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java new file mode 100644 index 000000000..06f50e211 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java @@ -0,0 +1,200 @@ +package com.fr.design.gui.icombobox; + +import com.fr.data.core.DataCoreUtils; +import com.fr.data.core.db.TableProcedure; +import com.fr.data.impl.Connection; +import com.fr.design.DesignerEnvManager; +import com.fr.design.data.datapane.ChoosePane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.mainframe.DesignerContext; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; + +import javax.swing.JOptionPane; +import javax.swing.JTree; +import javax.swing.SwingWorker; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeCellRenderer; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +/** + * 实现模糊搜索的FRTreeComboBox + * FRTreeComboBox:搜索后滚动到首个匹配节点 + * SearchFRTreeComboBox:显示所有匹配的节点 + * + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2021/4/14 + */ +public class SearchFRTreeComboBox extends FRTreeComboBox { + + // 持有父容器,需要实时获取其他组件值 + private final ChoosePane parent; + + public SearchFRTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) { + super(tree, renderer); + this.parent = parent; + setUI(new SearchFRTreeComboBoxUI()); + } + + protected UIComboBoxEditor createEditor() { + return new SearchFRComboBoxEditor(this); + } + + /** + * 执行模糊搜索 + */ + private void searchExecute() { + UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor(); + new SwingWorker() { + @Override + protected Void doInBackground() { + processTableDataNames( + parent.getDSName(), + parent.getConnection(), + parent.getSchema(), + createFilter((String) searchEditor.getItem())); + return null; + } + + @Override + protected void done() { + expandTree(); + // 输入框获取焦点 + searchEditor.getEditorComponent().requestFocus(); + } + }.execute(); + } + + private TableNameFilter createFilter(String text) { + return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text); + } + + /** + * 查询数据库表,并构建节点目录 + * + * @param databaseName 数据库名 + * @param connection 数据连接 + * @param schema 模式 + * @param filter 模糊搜索过滤器 + */ + private void processTableDataNames(String databaseName, Connection connection, String schema, TableNameFilter filter) { + if (tree == null) { + return; + } + DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) tree.getModel().getRoot(); + rootTreeNode.removeAllChildren(); + + if (connection == null) { + return; + } + try { + schema = StringUtils.isEmpty(schema) ? null : schema; + TableProcedure[] sqlTableArray = DataCoreUtils.getTables(connection, TableProcedure.TABLE, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); + if (ArrayUtils.isNotEmpty(sqlTableArray)) { + ExpandMutableTreeNode tableTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_Table")); + rootTreeNode.add(tableTreeNode); + addArrayNode(tableTreeNode, sqlTableArray, filter); + } + TableProcedure[] sqlViewArray = DataCoreUtils.getTables(connection, TableProcedure.VIEW, schema, DesignerEnvManager.getEnvManager().isOracleSystemSpace()); + if (ArrayUtils.isNotEmpty(sqlViewArray)) { + ExpandMutableTreeNode viewTreeNode = new ExpandMutableTreeNode(databaseName + "-" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_SQL_View")); + rootTreeNode.add(viewTreeNode); + addArrayNode(viewTreeNode, sqlViewArray, filter); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Failed"), JOptionPane.ERROR_MESSAGE); + } + } + + private void addArrayNode(ExpandMutableTreeNode rootNode, TableProcedure[] sqlArray, TableNameFilter filter) { + if (sqlArray != null) { + for (TableProcedure procedure : sqlArray) { + if (filter.accept(procedure)) { + ExpandMutableTreeNode viewChildTreeNode = new ExpandMutableTreeNode(procedure); + rootNode.add(viewChildTreeNode); + } + } + } + } + + /** + * 展开节点 + */ + private void expandTree() { + ((DefaultTreeModel) tree.getModel()).reload(); + // daniel 展开所有tree + TreeNode root = (TreeNode) tree.getModel().getRoot(); + TreePath parent = new TreePath(root); + TreeNode node = (TreeNode) parent.getLastPathComponent(); + for (Enumeration e = node.children(); e.hasMoreElements(); ) { + TreeNode n = (TreeNode) e.nextElement(); + TreePath path = parent.pathByAddingChild(n); + tree.expandPath(path); + } + } + + /** + * 重写输入框编辑器,实现输入框模糊搜索逻辑 + */ + private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor { + + public SearchFRComboBoxEditor(FRTreeComboBox comboBox) { + super(comboBox); + } + + @Override + protected void changeHandler() { + if (isSetting()) { + return; + } + setPopupVisible(true); + this.item = textField.getText(); + searchExecute(); + } + } + + private static final TableNameFilter EMPTY_FILTER = new TableNameFilter(StringUtils.EMPTY) { + public boolean accept(TableProcedure procedure) { + return true; + } + }; + + /** + * 表名模糊搜索实现 + */ + private static class TableNameFilter { + private final String searchFilter; + + public TableNameFilter(String searchFilter) { + if (StringUtils.isNotEmpty(searchFilter)) { + searchFilter = searchFilter.toLowerCase().trim(); + } + this.searchFilter = searchFilter; + } + + // 字符串匹配 + public boolean accept(TableProcedure procedure) { + return procedure.getName().toLowerCase().contains(searchFilter); + } + } + + /** + * 重写FRTreeComboBoxUI,实现点击下拉时触发模糊搜索 + */ + private class SearchFRTreeComboBoxUI extends FRTreeComboBoxUI { + + @Override + public void mouseClicked(MouseEvent e) { + searchExecute(); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java deleted file mode 100644 index 2d936d896..000000000 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.fr.design.gui.icombobox; - -import com.fr.log.FineLoggerFactory; - -import javax.swing.JTree; -import javax.swing.SwingWorker; -import javax.swing.tree.TreeCellRenderer; -import java.util.concurrent.FutureTask; - -/** - * 模糊搜索前需执行完前置任务的TreeComboBox - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2021/4/14 - */ -public class SearchPreTaskTreeComboBox extends FRTreeComboBox { - - /** - * 模糊搜索前任务 - */ - private FutureTask preSearchTask; - - public SearchPreTaskTreeComboBox(JTree tree, TreeCellRenderer renderer, boolean editable) { - super(tree, renderer, editable); - } - - public FutureTask getPreSearchTask() { - return preSearchTask; - } - - public void setPreSearchTask(FutureTask preSearchTask) { - this.preSearchTask = preSearchTask; - } - - protected UIComboBoxEditor createEditor() { - return new SearchPreTaskComboBoxEditor(this); - } - - private class SearchPreTaskComboBoxEditor extends FrTreeSearchComboBoxEditor { - - public SearchPreTaskComboBoxEditor(FRTreeComboBox comboBox) { - super(comboBox); - } - - protected void changeHandler() { - if (isSetting()) { - return; - } - setPopupVisible(true); - new SwingWorker() { - @Override - protected Void doInBackground() { - FutureTask task = getPreSearchTask(); - try { - // 确保模糊搜索前任务执行完成后,再进行模糊搜索 - if (task != null) { - task.get(); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - if (task != null) { - // 任务执行后置空,否则会被别的操作重复触发 - setPreSearchTask(null); - } - return null; - } - - @Override - protected void done() { - // 模糊搜索 - search(); - } - }.execute(); - } - } -} diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index fe85d5503..9954162da 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java @@ -223,6 +223,9 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse } else if (cellBorderStyle.getHorizontalStyle() != Constants.LINE_NONE) { this.currentLineCombo.setSelectedLineStyle(cellBorderStyle.getHorizontalStyle()); this.currentLineColorPane.setSelectObject(cellBorderStyle.getHorizontalColor()); + } else { + this.currentLineCombo.setSelectedLineStyle(Constants.LINE_NONE); + this.currentLineColorPane.setSelectObject(Color.BLACK); } } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java index 8c96c4c86..7e0db6051 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java @@ -7,7 +7,6 @@ import com.fr.base.TextFormat; import com.fr.data.core.FormatField; import com.fr.data.core.FormatField.FormatContents; import com.fr.design.border.UIRoundedBorder; -import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameObserver; @@ -18,21 +17,18 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; 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.general.ComparatorUtils; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; +import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; -import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.border.Border; import javax.swing.border.TitledBorder; import java.awt.BorderLayout; -import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -43,7 +39,6 @@ import java.awt.event.ItemListener; import java.math.RoundingMode; import java.text.Format; import java.text.SimpleDateFormat; -import java.util.Arrays; /** * @author Starryi @@ -68,69 +63,45 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME}; - private Format format; - - private UIComboBox typeComboBox; - private TextFontComboBox textField; - private UILabel sampleLabel; - private JPanel contentPane; - private JPanel txtCenterPane; - private JPanel centerPane; - private JPanel optionPane; - private UICheckBox roundingBox; - private JPanel formatFontPane; + protected UIComboBox typeComboBox; + protected TextFontComboBox textField; + protected UICheckBox roundingBox; + protected UILabel previewLabel; + private boolean isRightFormat; private boolean isDate = false; private GlobalNameListener globalNameListener = null; - /** - * Constructor. - */ public TextFormatPane() { - this.initComponents(TYPES); - } - protected UIComboBox getTypeComboBox() { - return typeComboBox; + initFormatTypesComboBox(); + initTextFontComboBox4GeneralFormats(); + initRoundingCheckBox4PercentFormat(); + initPreviewLabel4GeneralFormat(); + + initLayout(); + + setTextFieldVisible(false); + setRoundingBoxVisible(false); + setPreviewLabelVisible(false); } - protected void initComponents(Integer[] types) { - this.setLayout(new BorderLayout(0, 4)); - initSampleLabel(); - contentPane = new JPanel(new BorderLayout(0, 4)) { - @Override - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 65); - } - }; - typeComboBox = new UIComboBox(types); - UIComboBoxRenderer render = createComBoxRender(); - typeComboBox.setRenderer(render); + private void initFormatTypesComboBox() { + typeComboBox = new UIComboBox(TextFormatPane.TYPES); + typeComboBox.setRenderer(createComBoxRender()); typeComboBox.addItemListener(itemListener); typeComboBox.setGlobalName("typeComboBox"); - contentPane.add(sampleLabel, BorderLayout.NORTH); + typeComboBox.setPreferredSize(new Dimension(155,20)); + } - txtCenterPane = new JPanel(new BorderLayout()); - textField = new TextFontComboBox(); + private void initTextFontComboBox4GeneralFormats() { + textField = new TextFontComboBox<>(); textField.addItemListener(textFieldItemListener); textField.setEditable(true); textField.setGlobalName("textField"); - txtCenterPane.add(textField, BorderLayout.NORTH); - - contentPane.add(txtCenterPane, BorderLayout.CENTER); - - centerPane = new JPanel(new CardLayout()); - centerPane.add(new JPanel(), "hide"); - centerPane.setPreferredSize(new Dimension(0, 0)); - centerPane.add(contentPane, "show"); - - typeComboBox.setPreferredSize(new Dimension(155,20)); - JPanel typePane = new JPanel(new BorderLayout()); - typePane.add(typeComboBox, BorderLayout.CENTER); - typePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + } - JPanel option = new JPanel(new BorderLayout()); - option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST); + private void initRoundingCheckBox4PercentFormat() { roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up")); roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); roundingBox.addItemListener(new ItemListener() { @@ -139,54 +110,13 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName } }); roundingBox.setGlobalName("roundingBox"); - option.add(roundingBox, BorderLayout.CENTER); - optionPane = new JPanel(new CardLayout()); - optionPane.add(new JPanel(), "hide"); - optionPane.setPreferredSize(new Dimension(0, 0)); - optionPane.add(option, "show"); - - Component[][] components = getComponent(centerPane, typePane); - this.add(createContentPane(components), BorderLayout.CENTER); - } - - protected JPanel createContentPane (Component[][] components) { - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = new double[components.length]; - Arrays.fill(rowSize, p); - double[] columnSize = {p, f}; - int[][] rowCount = new int[components.length][2]; - Arrays.fill(rowCount, new int[] {1, 1}); - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); - } - - - protected Component[][] getComponent (JPanel centerPane, JPanel typePane) { - return new Component[][]{ - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, - new Component[]{centerPane, null}, - new Component[]{optionPane, null}, - }; - } - - protected UIComboBoxRenderer createComBoxRender() { - return new UIComboBoxRenderer() { - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - if (value instanceof Integer) { - label.setText(" " + FormatField.getInstance().getName((Integer) value)); - } - return label; - } - }; } - private void initSampleLabel() { + private void initPreviewLabel4GeneralFormat() { Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR); - sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { + previewLabel = new UILabel(FormatField.getInstance().getFormatValue()) { @Override public void paint(Graphics g) { @@ -198,12 +128,65 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName g.setColor(UIConstants.LINE_COLOR); FontMetrics cellFM = g.getFontMetrics(); int textWidth = cellFM.stringWidth(getText()); - GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); + GraphHelper.drawString(g, getText(), (width - textWidth) / 2F, 26); g.setColor(original); } }; - sampleLabel.setHorizontalAlignment(UILabel.CENTER); - sampleLabel.setBorder(border); + previewLabel.setHorizontalAlignment(UILabel.CENTER); + previewLabel.setBorder(border); + } + + protected void initLayout() { + JPanel labeledFormatTypeComboBoxPane = new JPanel(new BorderLayout(20, 0)); + labeledFormatTypeComboBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format")), BorderLayout.WEST); + labeledFormatTypeComboBoxPane.add(typeComboBox, BorderLayout.CENTER); + + JPanel labeledRoundingCheckboxPane = new JPanel(new BorderLayout(0, 0)); + labeledRoundingCheckboxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option")), BorderLayout.WEST); + labeledRoundingCheckboxPane.add(roundingBox, BorderLayout.CENTER); + + addComponents(4, new JComponent[] { labeledFormatTypeComboBoxPane, textField, labeledRoundingCheckboxPane, previewLabel}); + } + + protected void setTextFieldVisible(boolean visible) { + textField.setVisible(visible); + } + + protected void setRoundingBoxVisible(boolean visible) { + roundingBox.getParent().setVisible(visible); + } + + protected void setPreviewLabelVisible(boolean visible) { + previewLabel.setVisible(visible); + } + + protected void addComponents(int gap, JComponent[] components) { + JPanel container = this; + container.setLayout(new BorderLayout(0, gap)); + for (JComponent component: components) { + if (component != null) { + container.add(component, BorderLayout.NORTH); + JPanel nextContainer = new JPanel(new BorderLayout(0, gap)); + container.add(nextContainer, BorderLayout.CENTER); + container = nextContainer; + } + } + if (container.getComponentCount() == 0) { + container.getParent().remove(container); + } + } + + protected UIComboBoxRenderer createComBoxRender() { + return new UIComboBoxRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof Integer) { + label.setText(" " + FormatField.getInstance().getName((Integer) value)); + } + return label; + } + }; } @@ -231,8 +214,6 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName * Populate */ public void populateBean(Format format) { - this.format = format; - if (format == null) { this.typeComboBox.setSelectedIndex(FormatContents.NULL); } else { @@ -325,17 +306,17 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName * Refresh preview label. */ private void refreshPreviewLabel() { - this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); - this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); + this.previewLabel.setText(FormatField.getInstance().getFormatValue()); + this.previewLabel.setForeground(UIManager.getColor("Label.foreground")); try { isRightFormat = true; if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { return; } - this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem()))); + this.previewLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem()))); } catch (Exception e) { - this.sampleLabel.setForeground(Color.red); - this.sampleLabel.setText(e.getMessage()); + this.previewLabel.setForeground(Color.red); + this.previewLabel.setText(e.getMessage()); isRightFormat = false; } } @@ -354,28 +335,16 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { int contents = getFormatContents(); - String[] items = FormatField.getInstance().getFormatArray(contents, false); - CardLayout cardLayout = (CardLayout) centerPane.getLayout(); - if (isTextOrNull()) { - centerPane.setPreferredSize(new Dimension(0, 0)); - cardLayout.show(centerPane, "hide"); - } else { + if (!isTextOrNull()) { textField.removeAllItems(); + String[] items = FormatField.getInstance().getFormatArray(contents, false); textField.setItemArray(items); textField.setSelectedIndex(0); - centerPane.setPreferredSize(new Dimension(270, 65)); - cardLayout.show(centerPane, "show"); - } - CardLayout optionLayout = ((CardLayout) optionPane.getLayout()); - if (getFormatContents() == FormatContents.PERCENT) { - optionPane.setPreferredSize(new Dimension(100, 20)); - optionLayout.show(optionPane, "show"); - } else { - optionPane.setPreferredSize(new Dimension(0, 0)); - optionLayout.show(optionPane, "hide"); - roundingBox.setSelected(false); } + setTextFieldVisible(!isTextOrNull()); + setPreviewLabelVisible(!isTextOrNull()); + setRoundingBoxVisible(getFormatContents() == FormatContents.PERCENT); } } @@ -403,10 +372,20 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName * update */ public Style update(Style style) { - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField") - || ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox") - || ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) { - return style.deriveFormat(this.update()); + return updateByGlobalNamedSetting(style); + } + + private Style updateByGlobalNamedSetting(Style style) { + if (globalNameListener != null) { + String[] alterSettingNames = new String[] {"typeComboBox", "textField", "roundingBox"}; + String globalSettingName = globalNameListener.getGlobalName(); + if (StringUtils.isNotEmpty(globalSettingName)) { + for (String alterSettingName : alterSettingNames) { + if (ComparatorUtils.equals(alterSettingName, globalSettingName)) { + return style.deriveFormat(this.update()); + } + } + } } return style; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 9e8ffd792..bcda18bb6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -221,10 +221,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (success) { FileNode fileNode = TemplateTreePane.getInstance().getFileNode(); refreshRightToolBarBy(fileNode); - TemplateTreePane.getInstance().refresh(); } else { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Template_Unlock_Failed"), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); FineLoggerFactory.getLogger().error("Unlock {} failed", path); } + TemplateTreePane.getInstance().refresh(); } } }); diff --git a/designer-form/src/main/java/com/fr/design/fit/DesignerUIModeConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java similarity index 65% rename from designer-form/src/main/java/com/fr/design/fit/DesignerUIModeConfig.java rename to designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java index 5e743d383..1e072d956 100644 --- a/designer-form/src/main/java/com/fr/design/fit/DesignerUIModeConfig.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerUIModeConfig.java @@ -1,19 +1,16 @@ -package com.fr.design.fit; +package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.unit.UnitConvertUtil; import com.fr.general.ComparatorUtils; -import com.fr.general.FRScreen; import com.fr.stable.Constants; -import java.awt.Dimension; - /** * Created by kerry on 2020-06-05 */ public class DesignerUIModeConfig { - private DesignerUIMode mode = DesignerUIMode.NEW_UI_MODE; + private DesignerUIMode mode = DesignerUIMode.ABSOLUTE_MEASURE_UI_MODE; private static class DesignerUIModeConfigHolder { private static final DesignerUIModeConfig designerUIModeConfig = new DesignerUIModeConfig(); @@ -33,22 +30,22 @@ public class DesignerUIModeConfig { * * @return boolean */ - public boolean newUIMode() { - return ComparatorUtils.equals(DesignerUIMode.NEW_UI_MODE, mode); + public boolean simulateWebUIMode() { + return ComparatorUtils.equals(DesignerUIMode.SIMULATE_WEB_UI_MODE, mode); } /** * 设置新ui模式 */ - public void setNewUIMode() { - this.mode = DesignerUIMode.NEW_UI_MODE; + public void setSimulateWebUIMode() { + this.mode = DesignerUIMode.SIMULATE_WEB_UI_MODE; } /** * 设置老ui模式 */ - public void setOldUIMode() { - this.mode = DesignerUIMode.OLD_UI_MODE; + public void setAbsoluteMeasureUIMode() { + this.mode = DesignerUIMode.ABSOLUTE_MEASURE_UI_MODE; } /** @@ -70,55 +67,38 @@ public class DesignerUIModeConfig { return mode.getScreenResolution(); } - /** - * 根据屏幕尺寸获取设计时的FRScreen - * - * @param screen 屏幕尺寸 - * @return FRScreen - */ - public FRScreen getDesignScreenByDimension(Dimension screen) { - return mode.getDesignScreenByDimension(screen); - } private enum DesignerUIMode { - OLD_UI_MODE { + ABSOLUTE_MEASURE_UI_MODE { @Override protected ReportLengthUNITProvider parseLengthUNIT(int unitType) { return UnitConvertUtil.parseLengthUNIT(unitType); } - @Override - protected FRScreen getDesignScreenByDimension(Dimension screen) { - return FRScreen.getDesignScreenByDimension(screen); - } - @Override protected int getScreenResolution() { return ScreenResolution.getScreenResolution(); } + }, - NEW_UI_MODE { + SIMULATE_WEB_UI_MODE { @Override protected ReportLengthUNITProvider parseLengthUNIT(int unitType) { return new PXReportLengthUNIT(); } - @Override - protected FRScreen getDesignScreenByDimension(Dimension screen) { - return FRScreen.p1440; - } - @Override protected int getScreenResolution() { return Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION; } + }; protected abstract ReportLengthUNITProvider parseLengthUNIT(int unitType); - protected abstract FRScreen getDesignScreenByDimension(Dimension screen); protected abstract int getScreenResolution(); + } } 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 a08febe68..26a2f64bc 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 @@ -1869,4 +1869,8 @@ public abstract class JTemplate> } + public void setDesignerUIMode(){ + DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); + } + } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/fit/PX.java b/designer-base/src/main/java/com/fr/design/mainframe/PX.java similarity index 94% rename from designer-form/src/main/java/com/fr/design/fit/PX.java rename to designer-base/src/main/java/com/fr/design/mainframe/PX.java index 720268ea6..8fd9ac0ed 100644 --- a/designer-form/src/main/java/com/fr/design/fit/PX.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/PX.java @@ -1,4 +1,4 @@ -package com.fr.design.fit; +package com.fr.design.mainframe; import com.fr.stable.Constants; import com.fr.stable.unit.LEN_UNIT; diff --git a/designer-form/src/main/java/com/fr/design/fit/PXReportLengthUNIT.java b/designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java similarity index 95% rename from designer-form/src/main/java/com/fr/design/fit/PXReportLengthUNIT.java rename to designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java index 8d8f1de16..69d46480e 100644 --- a/designer-form/src/main/java/com/fr/design/fit/PXReportLengthUNIT.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/PXReportLengthUNIT.java @@ -1,4 +1,4 @@ -package com.fr.design.fit; +package com.fr.design.mainframe; import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; import com.fr.stable.unit.UNIT; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java index 88bedf17c..9d9eb0058 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ColorBackgroundQuickPane.java @@ -19,7 +19,17 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { public ColorBackgroundQuickPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - colorSelectBox = new NewColorSelectBox(100); + colorSelectBox = new NewColorSelectBox(100) { + @Override + public boolean shouldResponseChangeListener() { + // ColorBackgroundQuickPane注册监听器ChangeListenerImpl的逻辑不能丢,因为里面有修改字段backgroundChange的逻辑. + // 所以在监听器重复注册以及UndoState重复生成时,应该保留ChangeListenerImpl, 而放弃NewColorSelectBox内部自己注册 + // ChangeListener + // REPORT-63760 【主题切换】撤销以后,样式设置有问题 + // REPORT-64006 【模板主题】单元格自定义样式背景色设置不生效 + return false; + } + }; this.add(colorSelectBox, BorderLayout.NORTH); } @@ -41,14 +51,10 @@ public class ColorBackgroundQuickPane extends BackgroundQuickPane { } @Override - public boolean shouldResponseChangeListener() { - // NewColorSelectBox实现了UIObserver接口,这里就不要重复注册监听器了,以避免产生重复UndoState. - return false; + public void registerChangeListener(final UIObserverListener listener) { + this.colorSelectBox.addSelectChangeListener(new ChangeListenerImpl(listener)); } - @Override - public void registerChangeListener(final UIObserverListener listener) { } - @Override /** * 是否为ColorBackground 类型 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java index 118ea2e32..f965c2172 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogAppender.java @@ -1,41 +1,41 @@ package com.fr.design.mainframe.loghandler; - -import com.fr.third.apache.log4j.AppenderSkeleton; -import com.fr.third.apache.log4j.Level; -import com.fr.third.apache.log4j.spi.LoggingEvent; - +import com.fr.third.apache.logging.log4j.Level; +import com.fr.third.apache.logging.log4j.core.Filter; +import com.fr.third.apache.logging.log4j.core.Layout; +import com.fr.third.apache.logging.log4j.core.LogEvent; +import com.fr.third.apache.logging.log4j.core.appender.AbstractAppender; +import com.fr.third.apache.logging.log4j.core.config.Property; +import com.fr.third.apache.logging.log4j.core.layout.PatternLayout; +import java.io.Serializable; import java.util.Date; /** * Created by Administrator on 2017/7/18 0018. */ -public class DesignerLogAppender extends AppenderSkeleton { +public class DesignerLogAppender extends AbstractAppender { - public DesignerLogAppender() { - this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); + protected DesignerLogAppender(String name, Filter filter, + Layout layout, + boolean ignoreExceptions, + Property[] properties) { + super(name, filter, layout, ignoreExceptions, properties); } - protected void append(LoggingEvent event) { - this.subAppend(event); + public static DesignerLogAppender createDesignerLogAppender() { + return new DesignerLogAppender(DesignerLogAppender.class.getSimpleName(), null, PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n %throwable{0}").build(), false, Property.EMPTY_ARRAY); } - public boolean requiresLayout() { - return true; + @Override + public void append(LogEvent event) { + this.subAppend(event); } - public synchronized void close() { - if (this.closed) { - return; - } - this.closed = true; - - } - public void subAppend(LoggingEvent event) { + public void subAppend(LogEvent event) { synchronized (DesignerLogHandler.getInstance()) { Level level = event.getLevel(); - String msg = this.layout.format(event); + String msg = (String) this.toSerializable(event); DesignerLogHandler.getInstance().printRemoteLog(msg, level, new Date()); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 1d67c47df..1cb8e5d1a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -9,10 +9,9 @@ import com.fr.general.ComparatorUtils; import com.fr.general.log.Log4jConfig; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import com.fr.third.apache.log4j.Level; -import com.fr.third.apache.log4j.spi.LoggingEvent; -import com.fr.third.apache.log4j.spi.ThrowableInformation; +import com.fr.third.apache.logging.log4j.Level; +import com.fr.third.apache.logging.log4j.core.LogEvent; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; @@ -128,7 +127,7 @@ public class DesignerLogHandler { JPopupMenu jPopupMenu = new JPopupMenu(); - int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); + int logLevelInt = Log4jConfig.getInstance().getRootLevel().intLevel(); if (logLevelInt <= DesignerLogger.INFO_INT) { jPopupMenu.add(showInfo); jPopupMenu.add(showError); @@ -240,23 +239,22 @@ public class DesignerLogHandler { return resultPane; } - public void printStackTrace(LoggingEvent event) { + public void printStackTrace(LogEvent event) { - int intLevel = event.getLevel().toInt(); - Date date = new Date(event.getTimeStamp()); - ThrowableInformation information = event.getThrowableInformation(); + int intLevel = event.getLevel().intLevel(); + Date date = new Date(event.getTimeMillis()); if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { - printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); + printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown()); } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { - printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); + printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown()); } else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) { - printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); + printMessage(event.getMessage().getFormattedMessage(), intLevel, date, event.getThrown()); } } public void printStackTrace(String message, Level level, Date date) { - int intLevel = level.toInt(); + int intLevel = level.intLevel(); if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { printMessage(message, intLevel, date); } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java index b2b35da1c..3b6d4bf7a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java @@ -1,26 +1,25 @@ package com.fr.design.mainframe.loghandler; import com.fr.log.FineLoggerFactory; -import com.fr.third.apache.log4j.Level; -import com.fr.third.apache.log4j.spi.LoggingEvent; -import com.fr.third.apache.log4j.spi.ThrowableInformation; +import com.fr.third.apache.logging.log4j.Level; +import com.fr.third.apache.logging.log4j.core.LogEvent; /** * 设计器日志记录 */ public class DesignerLogger { - public static final int INFO_INT = Level.INFO.toInt(); + public static final int INFO_INT = Level.INFO.intLevel(); - public static final int ERROR_INT = Level.ERROR.toInt(); + public static final int ERROR_INT = Level.ERROR.intLevel(); - public static final int WARN_INT = Level.WARN.toInt(); + public static final int WARN_INT = Level.WARN.intLevel(); /** * 记录LoggingEvent对象 * * @param event */ - public static void log(LoggingEvent event) { + public static void log(LogEvent event) { if (event == null) { return; } @@ -30,29 +29,27 @@ public class DesignerLogger { public enum LogParser { DEFAULT(-1) { @Override - public void log(LoggingEvent event) { + public void log(LogEvent event) { } }, - INFO(Level.INFO.toInt()) { + INFO(Level.INFO.intLevel()) { @Override - public void log(LoggingEvent event) { - FineLoggerFactory.getLogger().info(event.getRenderedMessage()); + public void log(LogEvent event) { + FineLoggerFactory.getLogger().info(event.getMessage().getFormattedMessage()); } }, - WARN(Level.WARN.toInt()) { + WARN(Level.WARN.intLevel()) { @Override - public void log(LoggingEvent event) { - ThrowableInformation information = event.getThrowableInformation(); - FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable()); + public void log(LogEvent event) { + FineLoggerFactory.getLogger().warn(event.getMessage().getFormattedMessage(), event.getThrown()); } }, - ERROR(Level.ERROR.toInt()) { + ERROR(Level.ERROR.intLevel()) { @Override - public void log(LoggingEvent event) { - ThrowableInformation information = event.getThrowableInformation(); - FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable()); + public void log(LogEvent event) { + FineLoggerFactory.getLogger().error(event.getMessage().getFormattedMessage(), event.getThrown()); } }; private int level; @@ -65,8 +62,8 @@ public class DesignerLogger { return level; } - public static LogParser parse(LoggingEvent event) { - int intLevel = event.getLevel().toInt(); + public static LogParser parse(LogEvent event) { + int intLevel = event.getLevel().intLevel(); for (LogParser logParser : values()) { if (logParser.getLevel() == intLevel) { return logParser; @@ -76,7 +73,7 @@ public class DesignerLogger { } - public void log(LoggingEvent event) { + public void log(LogEvent event) { } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java new file mode 100644 index 000000000..92995add5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogEventConverter.java @@ -0,0 +1,27 @@ +package com.fr.design.mainframe.loghandler; + +import com.fr.third.apache.log4j.spi.LoggingEvent; +import com.fr.third.apache.logging.log4j.Level; +import com.fr.third.apache.logging.log4j.core.LogEvent; +import com.fr.third.apache.logging.log4j.core.impl.Log4jLogEvent; +import com.fr.third.apache.logging.log4j.message.SimpleMessage; + +/** + * 兼容log4j1和2之间logEvent之间的转换 + * + * @author hades + * @version 11.0 + * Created by hades on 2021/12/9 + */ +public class LogEventConverter { + + public static LogEvent convert(LoggingEvent loggingEvent) { + SimpleMessage message = new SimpleMessage(loggingEvent.getRenderedMessage()); + return Log4jLogEvent.newBuilder(). + setMessage(message). + setLevel(Level.getLevel(loggingEvent.getLevel().toString())). + build(); + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java index 53838d1c7..92e7548b5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/ThemedCellStyleListPane.java @@ -4,7 +4,6 @@ import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.settings.ThemedCellStyle; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.cell.CellRectangleStylePreviewPane; -import com.fr.design.cell.CellStylePreviewPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.i18n.Toolkit; @@ -36,14 +35,10 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane styleList; private ChangeListener changeListener; - public ThemedCellStyleListPane() { - this(false); - } - - public ThemedCellStyleListPane(boolean supportCellRange) { + public ThemedCellStyleListPane(boolean supportInnerBorder) { defaultListModel = new DefaultListModel<>(); styleList = new JList<>(defaultListModel); - styleList.setCellRenderer(supportCellRange ? new RadioButtonListCellRangeRenderer() : new RadioButtonListCellRenderer()); + styleList.setCellRenderer(new RadioButtonListCellRangeRenderer(supportInnerBorder)); styleList.setOpaque(false); styleList.setBackground(null); styleList.addListSelectionListener(new ListSelectionListener() { @@ -115,44 +110,18 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane, Serializable { - - private final UIRadioButton button; - private final CellStylePreviewPane previewArea; - - public RadioButtonListCellRenderer() { - super(); - setLayout(new BorderLayout(20, 0)); - setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - setPreferredSize(new Dimension(getPreferredSize().width, 40)); - button = new UIRadioButton(); - previewArea = new CellStylePreviewPane(); - add(button, BorderLayout.WEST); - add(previewArea, BorderLayout.CENTER); - } - - @Override - public Component getListCellRendererComponent(JList list, ThemedCellStyle value, int index, boolean isSelected, boolean cellHasFocus) { - button.setSelected(isSelected); - previewArea.setPaintText(value.getName()); - previewArea.setStyle(value.getStyle()); - return this; - } - } - private static class RadioButtonListCellRangeRenderer extends JPanel implements ListCellRenderer, Serializable { private final UIRadioButton button; private final CellRectangleStylePreviewPane previewArea; - public RadioButtonListCellRangeRenderer() { + public RadioButtonListCellRangeRenderer(boolean supportInnerBorder) { super(); setLayout(new BorderLayout(5, 0)); setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); - setPreferredSize(new Dimension(getPreferredSize().width, 80)); button = new UIRadioButton(); button.setBorder(BorderFactory.createEmptyBorder()); - previewArea = new CellRectangleStylePreviewPane(); + previewArea = new CellRectangleStylePreviewPane(supportInnerBorder); add(button, BorderLayout.WEST); add(previewArea, BorderLayout.CENTER); } @@ -162,6 +131,12 @@ public class ThemedCellStyleListPane extends FurtherBasicBeanPane { jPanel.setLayout(new BorderLayout(0, 4)); JPanel previewPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - previewArea = new CellRectangleStylePreviewPane(); - previewArea.setPreferredSize(new Dimension(223, 60)); - previewPane.setBorder(BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview"))); + previewArea = new CellRectangleStylePreviewPane(true); + previewArea.setPreferredSize(new Dimension(215, 52)); + previewPane.setBorder(BorderFactory.createCompoundBorder( + BorderUtils.createTitleBorder(i18nText("Fine-Design_Basic_Preview")), + BorderFactory.createEmptyBorder(4, 4, 4, 4))); previewPane.add(previewArea, BorderLayout.CENTER); this.add(previewPane, BorderLayout.NORTH); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java index 5c282033f..ab5d8a4ec 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/ui/ColorListPane.java @@ -139,7 +139,7 @@ public class ColorListPane extends JPanel implements UIObserver { return true; } - private static class ColorButton extends AbstractSelectBox { + public static class ColorButton extends AbstractSelectBox { private Color color; private NewColorSelectPane colorPane; private ChangeListener changeListener; 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 2033e7072..103b6ca6e 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 @@ -45,8 +45,9 @@ public class ReportThemePreviewPane extends TemplateThemePreviewPane> classes = new HashSet>(); classes.add(FineWebApplicationInitializer.class); context.addServletContainerInitializer(initializer, classes); + context.addServletContainerInitializer(new WsSci(), Sets.newHashSet(WebSocketEndpoint.class)); } // tomcat的maxPostSize会影响到post参数获取,默认2M diff --git a/designer-base/src/main/resources/com/fr/design/images/sort/add.png b/designer-base/src/main/resources/com/fr/design/images/sort/add.png new file mode 100644 index 000000000..a14e2a40b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/sort/add.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/sort/asc.svg b/designer-base/src/main/resources/com/fr/design/images/sort/asc.svg new file mode 100644 index 000000000..67dd9e829 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/sort/asc.svg @@ -0,0 +1,19 @@ + + + 升序备份 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/images/sort/des.svg b/designer-base/src/main/resources/com/fr/design/images/sort/des.svg new file mode 100644 index 000000000..2fcef077e --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/sort/des.svg @@ -0,0 +1,17 @@ + + + 降序 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png b/designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png new file mode 100644 index 000000000..84b4909ef Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/sort/down_arrow.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png b/designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png new file mode 100644 index 000000000..9166a9c96 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/sort/left_arrow.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg b/designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg new file mode 100644 index 000000000..ca04928fc --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/images/sort/nosort.svg @@ -0,0 +1,41 @@ + + + 不排序 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java b/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java index 0e692f697..64f9838f9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java +++ b/designer-chart/src/main/java/com/fr/van/chart/config/DefaultStyleConstants.java @@ -18,35 +18,35 @@ import java.awt.Font; * Created by shine on 2021/6/25 */ public class DefaultStyleConstants { - static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 14, new Color(241, 246, 255)); - static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); + static final FRFont TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.BOLD, 19, new Color(241, 246, 255)); + static final FRFont LEGEND = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191)); - static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); - static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(200, 211, 228)); + static final FRFont AXIS_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191)); + static final FRFont AXIS_TITLE = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(200, 211, 228)); static final Color AXIS_LINE = new Color(46, 75, 102); static final Color GRID_LINE = new Color(30, 55, 78); - static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(255, 0, 0)); + static final FRFont ALERT_FONT = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(255, 0, 0)); - static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 9, new Color(159, 173, 191)); + static final FRFont DATA_SHEET = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 12, new Color(159, 173, 191)); static final Color DATA_SHEET_BORDER = new Color(46, 75, 102); static final Color BORDER = Color.BLACK; static final int BORDER_WIDTH = Constants.LINE_NONE; static final int SPECIAL_BORDER_WIDTH = Constants.LINE_THIN; - static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 10, new Color(232, 232, 232)); + static final FRFont PIE_CATEGORY_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 13, new Color(232, 232, 232)); static final Color GAUGE_PANE_BACK_COLOR = null; static final Color GAUGE_HINGE = null; static final Color GAUGE_PANE_BACK_COLOR_4_RING = new Color(72, 73, 79); static final Color GAUGE_SLOT_BACKGROUND_COLOR = new Color(72, 73, 79); private static final String FONT_NAME = ChartBaseUtils.getLocalDefaultFont("verdana"); - static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 9, new Color(232, 232, 232));//试管仪表盘标签的默认样式 - static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 8, new Color(159, 173, 191)); + static final FRFont THERMOMETER_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.BOLD, 12, new Color(232, 232, 232));//试管仪表盘标签的默认样式 + static final FRFont THERMOMETER_AXIS_LABEL = FRFont.getInstance(FONT_NAME, Font.PLAIN, 11, new Color(159, 173, 191)); static final FRFont RING_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//百分比圆环仪表盘值标签的默认样式 static final FRFont POINTER_VALUE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, ChartConstants.AUTO_FONT_SIZE, new Color(232, 232, 232));//多指针仪表盘值标签的默认样式 - static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 10, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式 + static final FRFont POINTER_CATE_LABEL_FONT = FRFont.getInstance(FONT_NAME, Font.PLAIN, 13, new Color(232, 232, 232));//多指针仪表盘分类标签的默认样式 static final Color MAP_NULL_VALUE_COLOR = new Color(168, 168, 168); static final Color MAP_BORDER = Color.BLACK; @@ -56,12 +56,6 @@ public class DefaultStyleConstants { static final Color DRILL_MAP_DRILL_TOOLS_BACK = Color.BLACK; static final float DRILL_MAP_DRILL_TOOLS_BACK_OPACITY = 0.8f; - //todo vancharts - private static final Color GANTT_OUT_LINE = GRID_LINE; - private static final FRFont GANTT_LABEL = FRFont.getInstance(ChartBaseUtils.getLocalDefaultFont("Microsoft YaHei"), Font.PLAIN, 8, new Color(217, 217, 217)); - private static final Color GANTT_BORDER_LINE = new Color(30, 36, 58); - private static final Color GAUGE_TICK = new Color(39, 49, 71); - static final Background BACK = null; //新特新 diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index 12e242b73..bdbdee6a8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -11,6 +11,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; import com.fr.design.ui.ModernUIPane; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.AttrTooltipContent; @@ -21,6 +22,7 @@ import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; +import com.fr.plugin.chart.type.FontAutoType; import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; @@ -315,7 +317,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane xConnectorMap; @@ -73,8 +67,6 @@ public class XWAbsoluteLayout extends XLayoutContainer { connector = widget.getConnectorIndex(i); xConnectorMap.put(connector, new XConnector(connector, this)); } - - initPercent(widget); } /** @@ -87,36 +79,6 @@ public class XWAbsoluteLayout extends XLayoutContainer { return new Dimension(500, 300); } - //根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90% - private void initPercent(WAbsoluteLayout widget) { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue(); - if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) { - this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); - } - } - - /** - * 返回容器大小的百分比 - * - * @return the containerPercent - */ - public double getContainerPercent() { - return containerPercent; - } - - /** - * 设置容器大小的百分比 - * - * @param containerPercent the containerPercent to set - */ - public void setContainerPercent(double containerPercent) { - this.containerPercent = containerPercent; - minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH * containerPercent); - minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT * containerPercent); - } - /** * 返回界面处根据百分比调整后的最小宽度 * @@ -142,30 +104,14 @@ public class XWAbsoluteLayout extends XLayoutContainer { */ public int getAcualInterval() { // adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数 - int interval = (int) (toData().getCompInterval() * containerPercent); + int interval = (int) (toData().getCompInterval() ); int val = interval / 2; return val * 2; } - - /** - * 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 - */ - private Rectangle dealWidgetBound(Rectangle rec) { - if (AssistUtils.equals(1.0, containerPercent)) { - return rec; - } - rec.x = (int) (rec.x / containerPercent); - rec.y = (int) (rec.y / containerPercent); - rec.width = (int) (rec.width / containerPercent); - rec.height = (int) (rec.height / containerPercent); - return rec; - } - /** * 新增删除拉伸后单个组件的BoundsWidget */ public void updateBoundsWidget(XCreator xCreator) { - WAbsoluteLayout layout = this.toData(); if (xCreator.hasTitleStyle()) { xCreator = (XLayoutContainer) xCreator.getParent(); } @@ -223,32 +169,33 @@ public class XWAbsoluteLayout extends XLayoutContainer { } } - /** - * 更新子组件的Bound - * 这边主要用于绝对布局子组件在适应区域选项时 - * 涉及到的不同分辨率下缩放 - * - * @param minHeight 最小高度 - */ - @Override - public void updateChildBound(int minHeight) { - double prevContainerPercent = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; - if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) { - for (int i = 0; i < this.getComponentCount(); i++) { - XCreator creator = getXCreator(i); - Rectangle rec = new Rectangle(creator.getBounds()); - rec.x = (int)Math.round (rec.x / prevContainerPercent * containerPercent); - rec.y = (int)Math.round (rec.y / prevContainerPercent * containerPercent); - rec.height = (int)Math.round (rec.height / prevContainerPercent * containerPercent); - rec.width = (int)Math.round (rec.width / prevContainerPercent * containerPercent); - BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData()); - wgt.setBounds(rec); - creator.setBounds(rec); - creator.updateChildBound(minHeight); + /** + * 更新子组件的Bound + * 这边主要用于绝对布局子组件在适应区域选项时 + * 涉及到的不同分辨率下缩放 + * 兼容方法(老的模板中绝对布局带有分辨率参数的兼容处理) + * + * @param minHeight 最小高度 + */ + @Override + public void updateChildBound(int minHeight) { + double prevContainerPercent = FRScreen.getFRScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; + if (!AssistUtils.equals(DEFAULT_CONTAINER_PERCENT, prevContainerPercent)) { + for (int i = 0; i < this.getComponentCount(); i++) { + XCreator creator = getXCreator(i); + Rectangle rec = new Rectangle(creator.getBounds()); + rec.x = (int) Math.round(rec.x / prevContainerPercent); + rec.y = (int) Math.round(rec.y / prevContainerPercent); + rec.height = (int) Math.round(rec.height / prevContainerPercent); + rec.width = (int) Math.round(rec.width / prevContainerPercent); + BoundsWidget wgt = (BoundsWidget) toData().getBoundsWidget(creator.toData()); + wgt.setBounds(rec); + creator.setBounds(rec); + creator.updateChildBound(minHeight); + } } + toData().setDesigningResolution(FRScreen.p1440.getDimension()); } - toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize()); - } /** * 增加对齐线 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index da4d235f0..ea6170052 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -3,15 +3,12 @@ package com.fr.design.designer.creator; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFixLayoutAdapter; -import com.fr.design.designer.beans.adapters.layout.FRNoFixLayoutAdapter; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.mobile.BodyMobilePropertyUI; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.form.layout.FRFitLayout; import com.fr.design.fun.WidgetPropertyUIProvider; -import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; @@ -24,12 +21,10 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.stable.ArrayUtils; -import com.fr.stable.AssistUtils; import javax.swing.JOptionPane; import java.awt.Component; import java.awt.Dimension; import java.awt.Rectangle; -import java.awt.Toolkit; import java.awt.event.ContainerEvent; import java.util.ArrayList; import java.util.Arrays; @@ -46,9 +41,6 @@ public class XWFitLayout extends XLayoutContainer { private static final long serialVersionUID = 8112908607102660176L; private static final int EACH_ROW_COUNT = 4; - - //由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算 - protected double containerPercent = 1.0; // 布局缩小的时候,考虑最小宽高,若挨着右侧或底侧边框的控件缩小后达到最小宽或高,此时容器大小微调下 private int needAddWidth = 0; private int needAddHeight = 0; @@ -64,20 +56,6 @@ public class XWFitLayout extends XLayoutContainer { public XWFitLayout(WFitLayout widget, Dimension initSize) { super(widget, initSize); - - initPercent(); - - widget.setResolutionScaling(containerPercent); - } - - //根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90% - private void initPercent(){ - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue(); - if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) { - this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); - } } @Override @@ -252,19 +230,16 @@ public class XWFitLayout extends XLayoutContainer { * @return int[] 横坐标数组 */ public int[] getHors(boolean isActualSize) { - double perc = isActualSize ? containerPercent : 1.0; List posX = new ArrayList(); // 保存实际大小时,组件大小已经去除内边距,此处也判断下 - PaddingMargin margin = isActualSize ? new PaddingMargin(0,0,0,0) : toData().getMargin(); + PaddingMargin margin = isActualSize ? new PaddingMargin(0, 0, 0, 0) : toData().getMargin(); posX.add(margin.getLeft()); int width = this.getWidth() - margin.getLeft() - margin.getRight(); - int containW = (int) (width / perc); - posX.add(containW + margin.getLeft()); - for (int i=0, len=this.getComponentCount(); i < len; i++) { + posX.add(width + margin.getLeft()); + for (int i = 0, len = this.getComponentCount(); i < len; i++) { int x = this.getComponent(i).getX(); - int finalX = (int) (x / perc); - if (!posX.contains(finalX)) { - posX.add(finalX); + if (!posX.contains(x)) { + posX.add(x); } } Collections.sort(posX); @@ -278,19 +253,16 @@ public class XWFitLayout extends XLayoutContainer { * */ public int[] getVeris(boolean isActualSize) { - double perc = isActualSize ? containerPercent : 1.0; List posY = new ArrayList(); // 保存实际大小时,组件大小已经去除内边距,此处也判断下 PaddingMargin margin = isActualSize ? new PaddingMargin(0,0,0,0) : toData().getMargin(); posY.add(margin.getTop()); int height = this.getHeight() - margin.getTop() - margin.getBottom(); - int containH = (int) (height / perc); - posY.add(containH + margin.getTop()); + posY.add(height + margin.getTop()); for (int i=0, len=this.getComponentCount(); i < len; i++) { int y = this.getComponent(i).getY(); - int finalY = (int) (y / perc); - if (!posY.contains(finalY)) { - posY.add(finalY); + if (!posY.contains(y)) { + posY.add(y); } } Collections.sort(posY); @@ -721,34 +693,6 @@ public class XWFitLayout extends XLayoutContainer { creator.setBackupParent(this); } - /** - * 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 - */ - private Rectangle dealWidgetBound(Rectangle rec) { - if (AssistUtils.equals(1.0, containerPercent)) { - return rec; - } - rec.x = (int) (rec.x/containerPercent); - rec.y = (int) (rec.y/containerPercent); - rec.width = (int) (rec.width/containerPercent); - rec.height = (int) (rec.height/containerPercent); - return rec; - } - - /** - * 界面容器大小不是默认的时,恢复组件实际大小 - */ - private Rectangle dealWgtBound(Rectangle rec) { - if (AssistUtils.equals(1.0, containerPercent)) { - return rec; - } - rec.x = (int) (rec.x * containerPercent); - rec.y = (int) (rec.y * containerPercent); - rec.width = (int) (rec.width * containerPercent); - rec.height = (int) (rec.height * containerPercent); - return rec; - } - /** * 新增删除拉伸后更新每个组件的BoundsWidget */ @@ -774,7 +718,7 @@ public class XWFitLayout extends XLayoutContainer { XCreator creator = (XCreator) this.getComponent(index); BoundsWidget wgt = (BoundsWidget) layout.getBoundsWidget(creator.toData()); // 用当前的显示大小计算后调正具体位置 - Rectangle wgtBound = dealWidgetBound(creator.getBounds()); + Rectangle wgtBound = creator.getBounds(); Rectangle rec = recalculateWidgetBounds(wgtBound, hors, veris); wgt.setBounds(rec); creator.toData().updateChildBounds(rec); @@ -814,7 +758,7 @@ public class XWFitLayout extends XLayoutContainer { //更新的时候一定要带上backupBound if (creator.getBackupBound() == null && wgt.getBeforeScaleBounds() != null) { - creator.setBackupBound(dealWgtBound(wgt.getBeforeScaleBounds())); + creator.setBackupBound(wgt.getBeforeScaleBounds()); } ((XWAbsoluteLayout) creator).updateBoundsWidget(); creator.setBackupBound(creator.getBounds()); @@ -1170,24 +1114,6 @@ public class XWFitLayout extends XLayoutContainer { return this.getComponentAt(x+w-default_Length, y+h+default_Length+val); } - /** - * 返回容器大小的百分比 - * @return the containerPercent - */ - public double getContainerPercent() { - return containerPercent; - } - - /** - * 设置容器大小的百分比 - * @param containerPercent the containerPercent to set - */ - public void setContainerPercent(double containerPercent) { - this.containerPercent = containerPercent; - minWidth = (int) (XWFitLayout.MIN_WIDTH*containerPercent); - minHeight = (int) (XWFitLayout.MIN_HEIGHT*containerPercent); - } - /** * 该组件是否可以拖拽(表单中参数面板和自适应布局不可以拖拽) * @return 是则返回true @@ -1218,9 +1144,9 @@ public class XWFitLayout extends XLayoutContainer { */ public int getAcualInterval() { // adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数 - int interval = (int) (toData().getCompInterval()*containerPercent); - int val = interval/2; - return val*2; + int interval = toData().getCompInterval(); + int val = interval / 2; + return val * 2; } /** diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java b/designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java index 7e2fd9451..fb0ab8718 100644 --- a/designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java +++ b/designer-form/src/main/java/com/fr/design/designer/properties/FRFitLayoutConstraints.java @@ -92,8 +92,8 @@ public class FRFitLayoutConstraints implements ConstraintsGroupModel { Rectangle bounds = getBounds(); Rectangle rec = ComponentUtils.getRelativeBounds(parent); WFitLayout wFitLayout = parent.toData(); - int minHeight = (int)(MINHEIGHT * wFitLayout.getResolutionScaling()); - int minWidth = (int)(MINWIDTH * wFitLayout.getResolutionScaling()); + int minHeight = MINHEIGHT; + int minWidth = MINWIDTH; PaddingMargin margin= wFitLayout.getMargin(); switch (row) { case 0: 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 f2d1c4ad9..52c8f728c 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 @@ -1,30 +1,10 @@ package com.fr.design.fit; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.fit.common.AdaptiveSwitchUtil; -import com.fr.form.fit.NewFormMarkAttr; import com.fr.form.fit.config.FormFitConfig; -import com.fr.design.fit.menupane.FormFitAttrPane; -import com.fr.design.fun.PreviewProvider; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.preview.FormAdaptivePreview; -import com.fr.design.preview.FormPreview; -import com.fr.design.report.fit.menupane.ReportFitAttrPane; -import com.fr.form.main.Form; import com.fr.report.fit.ReportFitAttr; public enum JFormType { - OLD_TYPE(0, new FormPreview()) { - @Override - public void switchUI() { - AdaptiveSwitchUtil.switch2OldUI(); - } - - @Override - public void switchUIMode() { - AdaptiveSwitchUtil.switch2OldUIMode(); - } - + OLD_TYPE(0) { @Override public ReportFitAttr obtainFitAttr() { return FormFitConfig.getInstance().getOldFitAttr(); @@ -35,23 +15,9 @@ public enum JFormType { FormFitConfig.getInstance().setOldFitAttr(attr); } - @Override - public BasicBeanPane obtainAttrPane(NewJForm newJForm) { - return new ReportFitAttrPane(); - } }, - NEW_TYPE(1, new FormAdaptivePreview()) { - @Override - public void switchUI() { - AdaptiveSwitchUtil.switch2NewUI(); - } - - @Override - public void switchUIMode() { - AdaptiveSwitchUtil.switch2NewUIMode(); - } - + NEW_TYPE(1) { @Override public ReportFitAttr obtainFitAttr() { return FormFitConfig.getInstance().getNewFitAttr(); @@ -62,80 +28,35 @@ public enum JFormType { FormFitConfig.getInstance().setNewFitAttr(attr); } - @Override - public BasicBeanPane obtainAttrPane(NewJForm newJForm) { - return new FormFitAttrPane(newJForm); - } }; - private int type; - private boolean newType; - private PreviewProvider defaultPreviewType; + private final int type; + private final boolean newType; - JFormType(int type, PreviewProvider defaultPreviewType) { + JFormType(int type) { this.type = type; this.newType = (type == 1); - this.defaultPreviewType = defaultPreviewType; } public int getType() { return type; } - public boolean isNewType() { - return newType; - } - public PreviewProvider getDefaultPreviewType() { - return defaultPreviewType; + public static JFormType parseFormType(int type) { + for (JFormType formType : values()) { + if (formType.getType() == type) { + return formType; + } + } + return JFormType.OLD_TYPE; } - public abstract void switchUI(); - - public abstract void switchUIMode(); + public boolean isNewType() { + return newType; + } public abstract ReportFitAttr obtainFitAttr(); public abstract void updateFitAttr(ReportFitAttr attr); - public abstract BasicBeanPane obtainAttrPane(NewJForm newJForm); - - /** - * @Description: 更新模板的标志位 - * @param jTemplate - * @return: - * @Author: Henry.Wang - * @date: 2020/12/17 16:17 - */ - public void updateJFromTemplateType(JTemplate jTemplate) { - if (jTemplate instanceof NewJForm) { - NewJForm newJForm = (NewJForm) jTemplate; - Form form = newJForm.getTarget(); - NewFormMarkAttr newFormMarkAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr == null) { - newFormMarkAttr = new NewFormMarkAttr(this.getType()); - form.addAttrMark(newFormMarkAttr); - } - newFormMarkAttr.setType(this.getType()); - newJForm.setJFormType(this); - } - } - - /** - * @Description: 更新预览方式 - * @param jTemplate - * @return: - * @Author: Henry.Wang - * @date: 2020/12/17 16:17 - */ - public void updatePreviewType(JTemplate jTemplate) { - 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/NewJForm.java b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java index 6859c1231..9df0806de 100644 --- a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java +++ b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java @@ -2,19 +2,18 @@ package com.fr.design.fit; import com.fr.base.DynamicUnitList; import com.fr.base.Parameter; -import com.fr.design.actions.TemplateParameterAction; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRFitLayoutAdapter; import com.fr.design.designer.beans.events.DesignerEditListener; import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.*; -import com.fr.design.fit.common.AdaptiveSwitchUtil; -import com.fr.design.fit.common.LayoutTool; -import com.fr.form.fit.NewFormMarkAttr; -import com.fr.design.fit.common.TemplateTool; -import com.fr.design.actions.NewFormMobileAttrAction; +import com.fr.design.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XElementCase; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWTitleLayout; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.preview.DeveloperPreview; import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.fit.toolbar.SwitchAction; @@ -22,14 +21,13 @@ import com.fr.design.fun.PreviewProvider; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.menu.ShortCut; import com.fr.design.preview.FormPreview; import com.fr.design.preview.MobilePreview; import com.fr.design.utils.ComponentUtils; import com.fr.file.FILE; import com.fr.form.FormElementCaseProvider; +import com.fr.form.fit.NewFormMarkAttr; import com.fr.form.main.Form; -import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.ui.ElementCaseEditor; import com.fr.stable.ArrayUtils; @@ -49,13 +47,13 @@ public class NewJForm extends JForm { public NewJForm() { super(); init(); - changePaneSize(); } public NewJForm(Form form) { super(form); init(); - changePaneSize(); + //新建的模板都要加上新表单标志attr + form.addAttrMark(NewFormMarkAttr.createNewFormAttr()); } public NewJForm(Form form, FILE file, Parameter[] parameters) { @@ -64,51 +62,7 @@ public class NewJForm extends JForm { public NewJForm(Form form, FILE file) { super(form, file); - if (DesignerUIModeConfig.getInstance().newUIMode()) { - init(); - } - changePaneSize(); - } - - /** - * @Description:改变body的大小,主要针对新模式下打开老模板出现截断的情况 - * @param - * @return: - * @Author: Henry.Wang - * @date: 2020/9/13 23:23 - */ - private void changePaneSize() { - NewFormMarkAttr newFormMarkAttr = this.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr.isNotSetOriginSize()) { - newFormMarkAttr.setBodyHeight(LayoutTool.getBodyHeight(this)); - newFormMarkAttr.setBodyWidth(LayoutTool.getBodyWidth(this)); - return; - } - //这种是针对body为绝对布局时,可能出现截断的情况 - if (LayoutTool.absoluteLayoutForm(this)) { - int bodyHeight = newFormMarkAttr.getBodyHeight(); - int bodyWidth = newFormMarkAttr.getBodyWidth(); - Rectangle rectangle = LayoutTool.getAbsoluteBodySize(this); - if (!isNewJFrom() && (rectangle.width != bodyWidth || rectangle.height != bodyHeight)) { - TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, bodyWidth, this); - } else if (isNewJFrom()) { - if (rectangle.width > bodyWidth && rectangle.height > bodyHeight) { - TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, rectangle.width, this); - } else if (rectangle.width > bodyWidth) { - TemplateTool.onlyChangeAbsoluteBodySize(bodyHeight, rectangle.width, this); - } else if (rectangle.height > bodyHeight) { - TemplateTool.onlyChangeAbsoluteBodySize(rectangle.height, bodyWidth, this); - } - } - } else if (AdaptiveSwitchUtil.isSwitchJFromIng()) { - //这种是针对body中有绝对画布块,导致截断的情况 - double scale = LayoutTool.getContainerPercent(); - if (isNewJFrom()) { - LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), 1 / scale); - } else { - LayoutTool.scaleAbsoluteBlockComponentsBounds(this.getFormDesign().getRootComponent(), scale); - } - } + init(); } public JFormType getJFormType() { @@ -119,22 +73,6 @@ public class NewJForm extends JForm { this.jFormType = jFormType; } - - /** - * 模板菜单 - * - * @return 返回菜单 - */ - @Override - public ShortCut[] shortcut4TemplateMenu() { - if (this.index == FORM_TAB) { - return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), getReportFitAttrAction()}, new ShortCut[0]); - } else { - return ArrayUtils.addAll(new ShortCut[]{new TemplateParameterAction(this), new NewFormMobileAttrAction(this), getReportFitAttrAction()}, this.getElementCaseDesign().shortcut4TemplateMenu()); - } - } - - private void init() { this.getFormDesign().addDesignerEditListener(new DesignerEditListener() { private Rectangle oldRec; @@ -247,6 +185,13 @@ public class NewJForm extends JForm { } }); + + Form form = this.getTarget(); + NewFormMarkAttr newFormMarkAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG); + if (newFormMarkAttr == null) { + newFormMarkAttr = new NewFormMarkAttr(); + } + this.setJFormType(JFormType.parseFormType(newFormMarkAttr.getType())); } @@ -270,24 +215,14 @@ public class NewJForm extends JForm { return new PreviewProvider[]{new FormPreview(), new MobilePreview()}; } - public boolean mobileForm() { - FormMobileAttr mobileAttr = this.getTarget().getFormMobileAttr(); - if (mobileAttr.isMobileOnly() && mobileAttr.isAdaptivePropertyAutoMatch()) { - return true; - } - return false; - } - - private SwitchAction switchAction; - public UIButton[] createExtraButtons() { UIButton[] extraButtons = super.createExtraButtons(); return addAdaptiveSwitchButton(extraButtons); } private UIButton[] addAdaptiveSwitchButton(UIButton[] extraButtons) { - switchAction = new SwitchAction(); - return ArrayUtils.addAll(extraButtons, new UIButton[]{switchAction.getToolBarButton()}); + SwitchAction switchAction = new SwitchAction(this); + return ArrayUtils.addAll(extraButtons, switchAction.getToolBarButton()); } public boolean isNewJFrom() { diff --git a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java index a5df5fabd..031d69849 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/AdaptiveSwitchUtil.java @@ -1,15 +1,14 @@ package com.fr.design.fit.common; import com.fr.design.data.DesignTableDataManager; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.design.preview.FormAdaptivePreview; import com.fr.design.preview.FormPreview; import com.fr.file.FILE; import com.fr.file.MemFILE; +import com.fr.form.fit.NewFormMarkAttr; import com.fr.form.main.Form; import com.fr.form.main.WidgetGather; import com.fr.form.ui.Widget; @@ -33,25 +32,10 @@ public class AdaptiveSwitchUtil { } - public static void switch2NewUI() { - switch2NewUIMode(); - reload(); - } - - public static void switch2NewUIMode() { - DesignerUIModeConfig.getInstance().setNewUIMode(); - } - - public static void switch2OldUI() { - switch2OldUIMode(); - reload(); - } - - public static void switch2OldUIMode() { - DesignerUIModeConfig.getInstance().setOldUIMode(); - } - - public static void reload() { + /** + * 新老表单转换的方法 + */ + public static void switchReload() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { @@ -61,15 +45,15 @@ public class AdaptiveSwitchUtil { return; } JTemplate old = TemplateTool.getCurrentEditingTemplate(); - if (old == null || !(old instanceof JForm)) { + if (!(old instanceof NewJForm)) { return; } - JTemplate template = createNewJTemplate(old); + JTemplate template = createNewJTemplate((NewJForm) old); if (template != null) { DesignTableDataManager.closeTemplate(old); TemplateTool.resetTabPaneEditingTemplate(template); TemplateTool.activeAndResizeTemplate(template); - setPreviewType(); + setPreviewType(template); } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); @@ -83,14 +67,12 @@ public class AdaptiveSwitchUtil { /** * @Description: 设置预览方式 - * @return: 新创建的模板 * @Author: Henry.Wang * @date: 2020/10/13 14:08 */ - private static void setPreviewType() { - JTemplate jTemplate = TemplateTool.getCurrentEditingTemplate(); + private static void setPreviewType(JTemplate jTemplate) { if (jTemplate != null) { - if (DesignerUIModeConfig.getInstance().newUIMode()) { + if (TemplateTool.isNewJForm(jTemplate)) { jTemplate.setPreviewType(new FormAdaptivePreview()); } else { jTemplate.setPreviewType(new FormPreview()); @@ -99,29 +81,30 @@ public class AdaptiveSwitchUtil { } /** + * @param oldForm 以前的模板 * @Description: 创建模板 - * @param old 以前的模板 * @return: 新创建的模板 * @Author: Henry.Wang * @date: 2020/9/6 14:08 */ - public static JTemplate createNewJTemplate(JTemplate old) { - JTemplate template; - template = createNewJTemplateInternal(old); - if (template instanceof NewJForm) { - NewJForm jForm = ((NewJForm) template); - //如果是从旧的设计模板转化为新的设计模式,并且不是全局配置的模板。则更新新模板的Pc端自适应属性 - if (DesignerUIModeConfig.getInstance().newUIMode() && jForm.getTarget().getReportFitAttr() != null && isSwitchJFromIng()) { - jForm.getTarget().setReportFitAttr(shiftReportFitAttr(old, jForm.getTarget().getReportFitAttr().isFitFont())); - } - processAbsoluteLayoutCompatible(jForm.getTarget()); - TemplateTool.saveForm(jForm); + public static JTemplate createNewJTemplate(NewJForm oldForm) { + NewJForm newJForm = createNewJTemplateInternal(oldForm); + if (newJForm == null) { + return null; + } + //如果是从旧的设计模板转化为新的设计模式,并且不是全局配置的模板。则更新新模板的Pc端自适应属性 + if (newJForm.getTarget().getReportFitAttr() != null && newJForm.isNewJFrom()) { + //修改自适应属性 + newJForm.getTarget().setReportFitAttr(shiftReportFitAttr(oldForm, newJForm.getTarget().getReportFitAttr().isFitFont())); + //修改绝对布局中的缩放属性 + processAbsoluteLayoutCompatible(newJForm.getTarget()); } - return template; + TemplateTool.saveForm(newJForm); + return newJForm; } - private static void processAbsoluteLayoutCompatible(Form form){ + private static void processAbsoluteLayoutCompatible(Form form) { Form.traversalWidget(form.getContainer(), new WidgetGather() { @Override public void dealWith(Widget widget) { @@ -141,25 +124,28 @@ public class AdaptiveSwitchUtil { } - /** - * @Description: 创建模板核心方法 * @param old 以前的方法 + * @Description: 创建模板核心方法 * @return: 新创建的模板 * @Author: Henry.Wang * @date: 2020/9/6 14:09 */ - private static JTemplate createNewJTemplateInternal(JTemplate old) { + private static NewJForm createNewJTemplateInternal(JTemplate old) { FILE file = old.getEditingFILE(); if ((file instanceof MemFILE) || !old.isSaved()) { - if (old instanceof NewJForm) { - TemplateTool.resetAbsoluteBodySize((NewJForm) old); - } TemplateTool.saveForm(old); } if (old.getTarget() instanceof Form) { try { - return new NewJForm((Form) (old.getTarget()).clone(), old.getEditingFILE()); + //这边进行数据模型中的标志位切换 + Form form = (Form) old.getTarget().clone(); + NewFormMarkAttr oldFormAttr = form.getAttrMark(NewFormMarkAttr.XML_TAG); + if (oldFormAttr == null) { + oldFormAttr = new NewFormMarkAttr(); + } + form.addAttrMark(oldFormAttr.switchAttr()); + return new NewJForm(form, old.getEditingFILE()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); return null; @@ -170,46 +156,43 @@ public class AdaptiveSwitchUtil { } /** - * @Description: 老模板切换到新模板的属性配置转换( - * 1、绝对布局-适应区域--》双向自适应 - * 2、自适应布局-双向自适应--》双向自适应 - * 3、自适应布局-横向自适应--》横向自适应 - * 4、绝对布局-固定大小--》不自适应 - * ) * @param old * @param fitFont 字体是否自适应 + * @Description: 老模板切换到新模板的属性配置转换( + * 1、绝对布局-适应区域--》双向自适应 + * 2、自适应布局-双向自适应--》双向自适应 + * 3、自适应布局-横向自适应--》横向自适应 + * 4、绝对布局-固定大小--》不自适应 + * ) * @return: * @Author: Henry.Wang * @date: 2020/9/6 14:01 */ - private static ReportFitAttr shiftReportFitAttr(JTemplate old, boolean fitFont) { - if (old instanceof JForm && DesignerUIModeConfig.getInstance().newUIMode()) { - JForm jForm = (JForm) old; - try { - int layoutType = LayoutTool.getFormLayoutType(jForm); - int compState = -1; - //自适应布局 - if (layoutType == 0) { - compState = ((WFitLayout) jForm.getFormDesign().getRootComponent().toData()).getCompState(); - if (compState == WFitLayout.STATE_FULL) { - return new ReportFitAttr(2, fitFont); - } else if (compState == WFitLayout.STATE_ORIGIN) { - return new ReportFitAttr(1, fitFont); - } - } else if (layoutType == 1) {//绝对布局 - Widget widget = ((CRBoundsWidget) jForm.getFormDesign().getRootComponent().toData().getWidget(0)).getWidget(); - if (widget instanceof WAbsoluteLayout) { - compState = ((WAbsoluteLayout) widget).getCompState(); - } - if (compState == WAbsoluteLayout.STATE_FIT) { - return new ReportFitAttr(2, fitFont); - } else if (compState == WAbsoluteLayout.STATE_FIXED) { - return new ReportFitAttr(3, fitFont); - } + private static ReportFitAttr shiftReportFitAttr(NewJForm old, boolean fitFont) { + try { + int layoutType = LayoutTool.getFormLayoutType(old); + int compState = -1; + //自适应布局 + if (layoutType == 0) { + compState = ((WFitLayout) old.getFormDesign().getRootComponent().toData()).getCompState(); + if (compState == WFitLayout.STATE_FULL) { + return new ReportFitAttr(2, fitFont); + } else if (compState == WFitLayout.STATE_ORIGIN) { + return new ReportFitAttr(1, fitFont); + } + } else if (layoutType == 1) {//绝对布局 + Widget widget = ((CRBoundsWidget) old.getFormDesign().getRootComponent().toData().getWidget(0)).getWidget(); + if (widget instanceof WAbsoluteLayout) { + compState = ((WAbsoluteLayout) widget).getCompState(); + } + if (compState == WAbsoluteLayout.STATE_FIT) { + return new ReportFitAttr(2, fitFont); + } else if (compState == WAbsoluteLayout.STATE_FIXED) { + return new ReportFitAttr(3, fitFont); } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return null; } diff --git a/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java b/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java index 6bebbbbe8..1d3c85f2c 100644 --- a/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java +++ b/designer-form/src/main/java/com/fr/design/fit/common/LayoutTool.java @@ -7,20 +7,16 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.fit.NewJForm; -import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.JForm; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WLayout; import com.fr.form.ui.widget.CRBoundsWidget; -import com.fr.general.FRScreen; import com.fr.log.FineLoggerFactory; import java.awt.Component; -import java.awt.Dimension; import java.awt.Rectangle; -import java.awt.Toolkit; /** * @description:布局工具类 @@ -163,15 +159,4 @@ public class LayoutTool { } } - /** - * @Description: 获取老预览时的缩放比例 - * @return: - * @Author: Henry.Wang - * @date: 2020/10/26 20:39 - */ - public static double getContainerPercent(){ - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - double screenValue = FRScreen.getFRScreenByDimension(screen).getValue(); - return screenValue / FormArea.DEFAULT_SLIDER; - } } 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 cb415df59..47512348f 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 @@ -1,30 +1,16 @@ package com.fr.design.fit.common; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.fit.JFormType; import com.fr.design.fit.NewJForm; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.FormArea; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.event.Event; import com.fr.event.Listener; import com.fr.file.MemFILE; import com.fr.file.StashedFILE; import com.fr.form.fit.common.LightTool; -import com.fr.form.fit.NewFormMarkAttr; -import com.fr.form.ui.Widget; -import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.ComparatorUtils; - -import java.awt.Rectangle; import java.util.List; /** @@ -33,31 +19,20 @@ import java.util.List; * @create: 2020/09/03 14:19 */ public class TemplateTool { - //和转换有关的所有代码都在这个监听器中 - //在判断新老模式时,统一使用FormUIModeConfig.getInstance().newUIMode()进行判断 - private static Listener switchListener = new Listener() { + private static final Listener switchListener = new Listener() { @Override public void on(Event event, JTemplate jTemplate) { - if (!(jTemplate instanceof JForm)) { - JFormType.OLD_TYPE.switchUIMode(); - return; - } - JFormType currentType = JFormType.OLD_TYPE; - if (AdaptiveSwitchUtil.isSwitchJFromIng()) { - currentType = DesignerUIModeConfig.getInstance().newUIMode() ? JFormType.NEW_TYPE : JFormType.OLD_TYPE; - } else if (isNewJForm(jTemplate)) { - currentType = JFormType.NEW_TYPE; - } - //UI转换 - currentType.switchUIMode(); - //标志位转换 - currentType.updateJFromTemplateType(jTemplate); - //预览方式转换 - currentType.updatePreviewType(jTemplate); + jTemplate.setDesignerUIMode(); } }; - private static boolean isNewJForm(JTemplate jTemplate) { + + public static Listener getSwitchListener() { + return switchListener; + } + + + public static boolean isNewJForm(JTemplate jTemplate) { if (jTemplate instanceof NewJForm) { NewJForm newJForm = (NewJForm) jTemplate; if (LightTool.containNewFormFlag(newJForm.getTarget()) || newJForm.getTarget().getTemplateID() == null) { @@ -67,8 +42,8 @@ public class TemplateTool { return false; } - public static Listener getSwitchListener() { - return switchListener; + public static boolean isCurrentEditingNewJForm(){ + return isNewJForm(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); } /** @@ -79,8 +54,7 @@ public class TemplateTool { * @date: 2020/9/6 14:17 */ public static JTemplate getCurrentEditingTemplate() { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - return jTemplate; + return HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); } /** @@ -168,55 +142,7 @@ public class TemplateTool { jTemplate.requestFocus(); } - /** - * @param height - * @param width - * @param newJForm - * @Description: 只改变绝对布局body的尺寸 - * @return: - * @Author: Henry.Wang - * @date: 2020/9/11 15:14 - */ - public static void onlyChangeAbsoluteBodySize(int height, int width, NewJForm newJForm) { - FormDesigner formDesigner = newJForm.getFormDesign(); - FormArea formArea = formDesigner.getArea(); - XLayoutContainer root = formDesigner.getRootComponent(); - XWAbsoluteBodyLayout xwAbsoluteBodyLayout = LayoutTool.getXWAbsoluteBodyLayout(newJForm); - if (root.acceptType(XWFitLayout.class) && xwAbsoluteBodyLayout != null) { - XWFitLayout layout = (XWFitLayout) root; - if (height == layout.toData().getContainerHeight() && width == layout.toData().getContainerWidth()) - return; - formArea.setWidthPaneValue(width); - formArea.setHeightPaneValue(height); - layout.setSize(width, height); - xwAbsoluteBodyLayout.setSize(width, height); - Widget widget = layout.toData().getWidget(0); - if (widget instanceof CRBoundsWidget) { - ((CRBoundsWidget) widget).setBounds(new Rectangle(0, 0, width, height)); - } - layout.toData().setContainerWidth(width); - layout.toData().setContainerHeight(height); - formArea.doReCalculateRoot(width, height, layout); - } - formDesigner.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); - } - /** - * @param newJForm - * @Description: 因为新老模板切换有截断的问题,所以body的尺寸会在调用onlyChangeAbsoluteBodySize之后发生改变。为了使模板文件中的尺寸不发生,要在模板保存时调用此函数 - * @return: - * @Author: Henry.Wang - * @date: 2020/9/11 15:20 - */ - public static void resetAbsoluteBodySize(NewJForm newJForm) { - if (LayoutTool.absoluteLayoutForm(newJForm)) { - NewFormMarkAttr newFormMarkAttr = newJForm.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - XLayoutContainer root = newJForm.getFormDesign().getRootComponent(); - if (newFormMarkAttr != null && root instanceof XWFitLayout) { - ((XWFitLayout) root).toData().setContainerWidth(newFormMarkAttr.getBodyWidth()); - ((XWFitLayout) root).toData().setContainerHeight(newFormMarkAttr.getBodyHeight()); - } - } - } + } diff --git a/designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java b/designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java index e14d39a68..bf490a720 100644 --- a/designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java +++ b/designer-form/src/main/java/com/fr/design/fit/toolbar/SwitchAction.java @@ -3,7 +3,6 @@ package com.fr.design.fit.toolbar; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.file.TemplateTreePane; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fit.NewJForm; import com.fr.design.fit.common.AdaptiveSwitchUtil; import com.fr.design.fit.common.TemplateTool; @@ -11,6 +10,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; import com.fr.file.FILE; @@ -64,11 +64,11 @@ public class SwitchAction extends UpdateAction { } }; - public SwitchAction() { - initMenuStyle(); + public SwitchAction(JForm jForm) { + initMenuStyle(jForm); } - private void initMenuStyle() { + private void initMenuStyle(JForm jForm) { this.setMenuKeySet(SWITCH_ATTR); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); @@ -80,7 +80,7 @@ public class SwitchAction extends UpdateAction { Font oldFont = switchBtn.getFont(); switchBtn.setFont(new Font(oldFont.getName(),oldFont.getStyle(),12)); switchBtn.setForeground(new Color(0x33, 0x33, 0x34)); - freshSwitchButton(); + freshSwitchButton(jForm); } @Override @@ -92,11 +92,7 @@ public class SwitchAction extends UpdateAction { if (confirmSwitchDialog() && backUpOldModeJTemplate()) { AdaptiveSwitchUtil.setSwitchJFromIng(1); showLoadingJPanel(); - if (DesignerUIModeConfig.getInstance().newUIMode()) { - AdaptiveSwitchUtil.switch2OldUI(); - } else { - AdaptiveSwitchUtil.switch2NewUI(); - } + AdaptiveSwitchUtil.switchReload(); } } @@ -175,7 +171,7 @@ public class SwitchAction extends UpdateAction { */ private boolean backUpOldModeJTemplate() { JTemplate jTemplate = TemplateTool.getCurrentEditingTemplate(); - if (jTemplate != null && !DesignerUIModeConfig.getInstance().newUIMode()) { + if (jTemplate != null && !TemplateTool.isNewJForm(jTemplate)) { FILE editingFILE = jTemplate.getEditingFILE(); if (editingFILE != null && editingFILE.exists()) { try { @@ -237,7 +233,7 @@ public class SwitchAction extends UpdateAction { * @date: 2020/9/18 11:20 */ private boolean confirmSwitchDialog() { - Object message = DesignerUIModeConfig.getInstance().newUIMode() ? Toolkit.i18nText("Fine-Designer_Fit_Confirm_New_Old_Switch") : Toolkit.i18nText("Fine-Designer_Fit_Confirm_Old_New_Switch"); + Object message = TemplateTool.isCurrentEditingNewJForm() ? Toolkit.i18nText("Fine-Designer_Fit_Confirm_New_Old_Switch") : Toolkit.i18nText("Fine-Designer_Fit_Confirm_Old_New_Switch"); int returnVal = FineJOptionPane.showConfirmDialog( DesignerContext.getDesignerFrame(), message, @@ -269,8 +265,8 @@ public class SwitchAction extends UpdateAction { * @Author: Henry.Wang * @date: 2020/8/31 16:39 */ - public UIButton freshSwitchButton() { - if (DesignerUIModeConfig.getInstance().newUIMode()) { + public UIButton freshSwitchButton(JForm jForm) { + if (TemplateTool.isNewJForm(jForm)) { switchBtn.setToolTipText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_UI")); switchBtn.setText(Toolkit.i18nText("Fine-Designer_Fit_Switch_To_Old_Version")); } else { @@ -281,7 +277,7 @@ public class SwitchAction extends UpdateAction { } public UIButton getToolBarButton() { - return freshSwitchButton(); + return switchBtn; } } 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 be001e881..d989aae21 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 @@ -7,7 +7,6 @@ import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.ilable.UILabel; @@ -25,11 +24,11 @@ import com.fr.design.scrollruler.VerticalRuler; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.LayoutUtils; -import com.fr.form.fit.NewFormMarkAttr; import com.fr.form.main.mobile.FormMobileAttr; import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WFitLayout; +import com.fr.general.FRScreen; import com.fr.general.IOUtils; import com.fr.stable.AssistUtils; @@ -66,12 +65,10 @@ import java.awt.event.MouseWheelEvent; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; public class FormArea extends JComponent implements ScrollRulerComponent { - private static final double SLIDER_FLOAT = 400.0; - private static final double SLIDER_MIN = 10.0; private static final String SCALE_PLUS_COMMAND = "scale_plus"; private static final String SCALE_MINUS_COMMAND = "scale_minus"; public static final String FIX_LAYOUT_SWITCH_BUTTON = "fix_layout_switch_button"; - public static final double DEFAULT_SLIDER = 100.0; + public static final double DEFAULT_SLIDER = 100.0D; private static final int ROTATIONS = 50; public static final int SHOWVALMAX = 400; public static final int SHOWVALMIN = 10; @@ -90,21 +87,9 @@ public class FormArea extends JComponent implements ScrollRulerComponent { private UINumberField heightPane; private JFormSliderPane slidePane; private boolean isValid = true; - // 初始时滑块值为100,托动后的值设为START_VALUE; - private double START_VALUE = DEFAULT_SLIDER; - private double screenValue; private UIButton fixLayoutSwitchButton; private boolean isFixLayoutEditState; - - public FormScrollBar getHorScrollBar() { - return horScrollBar; - } - - public void setHorScrollBar(FormScrollBar horScrollBar) { - this.horScrollBar = horScrollBar; - } - public FormArea(FormDesigner designer) { this(designer, true); } @@ -243,7 +228,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { heightPane.setPreferredSize(new Dimension(60, 0)); slidePane = JFormSliderPane.getInstance(); - JPanel resizePane = TableLayoutHelper.createCommonTableLayoutPane( new JComponent[][]{{tipsPane, layoutSwitchPane, widthPane, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Indent_Pixel")), @@ -258,6 +242,7 @@ public class FormArea extends JComponent implements ScrollRulerComponent { slidePane.setVisible(true); initCalculateSize(); slidePane.addValueChangeListener(showValSpinnerChangeListener); + slidePane.setShowValue(FRScreen.getFRScreenByDimension(Toolkit.getDefaultToolkit().getScreenSize()).getValue().intValue()); } public void undoFixLayoutState(boolean isFixLayout) { @@ -309,41 +294,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent { this.designer.repaint(); } - - /** - * 返回当前的屏幕分辨率对应的百分比值 - * - * @return 缩放的百分比值 - */ - public double getScreenValue() { - return screenValue; - } - - /** - * 设置屏幕分辨率对应的百分比值 - * - * @param screenValue 百分比值 - */ - public void setScreenValue(double screenValue) { - this.screenValue = screenValue; - } - private void initCalculateSize() { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Dimension scrnsize = toolkit.getScreenSize(); - this.screenValue = DesignerUIModeConfig.getInstance().getDesignScreenByDimension(scrnsize).getValue(); XLayoutContainer root = FormArea.this.designer.getRootComponent(); - // 7.1.1不放缩放滑块,但表单大小仍按屏幕分辨率调整 -// slidePane.populateBean(screenValue); if (root.acceptType(XWFitLayout.class)) { - XWFitLayout layout = (XWFitLayout) root; - if ( !AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { - reCalculateRoot(screenValue, true); - } else { - // 组件间隔啊 - // REPORT-2585 原有的逻辑导致嵌套的tab中的间隔加不上去,会在后续拖动的过程中出问题 - reCalculateDefaultRoot(screenValue, true); - } + reCalculateDefaultRoot(); } LayoutUtils.layoutContainer(root); updateCreatorsBackupBound(root); @@ -380,18 +334,10 @@ public class FormArea extends JComponent implements ScrollRulerComponent { // 失去焦点时,可以认为输入结束 int width = (int) ((UINumberField) e.getSource()).getValue(); changeWidthPaneValue(width); - changeFormMarkAttrWidth(width); } }); } - private void changeFormMarkAttrWidth(int width) { - NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr != null) { - newFormMarkAttr.setBodyWidth(width); - } - } - private void changeWidthPaneValue(int width) { XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); @@ -407,7 +353,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { public void actionPerformed(ActionEvent evt) { int height = (int) ((UINumberField) evt.getSource()).getValue(); changeHeightPaneValue(height); - changeFormMarkAttrHeight(height); } }); heightPane.addFocusListener( @@ -420,13 +365,6 @@ public class FormArea extends JComponent implements ScrollRulerComponent { }); } - private void changeFormMarkAttrHeight(int height){ - NewFormMarkAttr newFormMarkAttr = designer.getTarget().getAttrMark(NewFormMarkAttr.XML_TAG); - if (newFormMarkAttr != null) { - newFormMarkAttr.setBodyHeight(height); - } - } - private void changeHeightPaneValue(int height) { XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); @@ -497,78 +435,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent { * 修改大小后,再根据屏幕分辨率调整下 */ public void doReCalculateRoot(int width, int height, XWFitLayout layout) { -// double value = slidePane.updateBean(); - //重置滑块的值为默认值100 - START_VALUE = DEFAULT_SLIDER; - if ( AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { - layout.getParent().setSize(width, height + designer.getParaHeight()); - FormArea.this.validate(); - } else { - layout.setBackupGap(screenValue / DEFAULT_SLIDER); - reCalculateRoot(screenValue, false); - } - } - - /** - * 按照界面大小的百分比值调整root大小 - * - * @param needCalculateParaHeight 是否需要调整参数界面高度 - * @param value - */ - private void reCalculateRoot(double value, boolean needCalculateParaHeight) { - if ( AssistUtils.equals(value, START_VALUE) ) { - return; - } - double percent = (value - START_VALUE) / START_VALUE; - XLayoutContainer root = FormArea.this.designer.getRootComponent(); - if (root.acceptType(XWFitLayout.class)) { - XWFitLayout layout = (XWFitLayout) root; - layout.setContainerPercent(value / DEFAULT_SLIDER); - traverAndAdjust(layout, percent); - layout.adjustCreatorsWhileSlide(percent); - - // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 - - Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); - // 自适应布局的父层是border - if (layout.getParent() != null) { - int paraHeight = designer.getParaHeight(); - if (needCalculateParaHeight && paraHeight > 0) { - designer.setParaHeight(paraHeight); - XWBorderLayout parent = (XWBorderLayout) layout.getParent(); - parent.toData().setNorthSize(paraHeight); - parent.removeAll(); - parent.add(designer.getParaComponent(), WBorderLayout.NORTH); - parent.add(designer.getRootComponent(), WBorderLayout.CENTER); - } - layout.getParent().setSize(d.width, d.height + paraHeight); - // 调整自适应布局大小后,同步调整参数界面和border大小,此时刷新下formArea - FormArea.this.validate(); - } - START_VALUE = value; - } + layout.getParent().setSize(width, height + designer.getParaHeight()); + FormArea.this.validate(); } /** * 按照界面大小的百分比值调整root大小 * - * @param needCalculateParaHeight 是否需要调整参数界面高度 - * @param value */ - private void reCalculateDefaultRoot(double value, boolean needCalculateParaHeight) { + private void reCalculateDefaultRoot() { XLayoutContainer root = FormArea.this.designer.getRootComponent(); if (root.acceptType(XWFitLayout.class)) { XWFitLayout layout = (XWFitLayout) root; - layout.setContainerPercent(1.0); traverAndAdjust(layout, 0.0); layout.adjustCreatorsWhileSlide(0.0); // 拖动滑块,先将内部组件百分比大小计算,再计算容器大小 - Dimension d = new Dimension(layout.getWidth(), layout.getHeight()); // 自适应布局的父层是border if (layout.getParent() != null) { int paraHeight = designer.getParaHeight(); - if (needCalculateParaHeight && paraHeight > 0) { + if (paraHeight > 0) { designer.setParaHeight(paraHeight); XWBorderLayout parent = (XWBorderLayout) layout.getParent(); parent.toData().setNorthSize(paraHeight); @@ -885,16 +771,11 @@ public class FormArea extends JComponent implements ScrollRulerComponent { heightPane.setValue(height); reCalculateHeight((int) height); } - if (designer.getRootComponent().acceptType(XWFitLayout.class) && AssistUtils.equals(screenValue, DEFAULT_SLIDER) ) { + if (designer.getRootComponent().acceptType(XWFitLayout.class) ) { XWFitLayout layout = (XWFitLayout) designer.getRootComponent(); // 撤销时先refreshRoot了,此处去掉内边距再增加间隔 layout.moveContainerMargin(); layout.addCompInterval(layout.getAcualInterval()); - } else if (designer.getRootComponent().acceptType(XWFitLayout.class)) { - START_VALUE = DEFAULT_SLIDER; - reCalculateRoot(screenValue, true); -// slidePane.populateBean(slide); - } this.slidePane.setShowValue((int) slide); } 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 3eb40b6a2..adc59581a 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 @@ -43,7 +43,6 @@ import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.RightSelectionHandlerProvider; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; @@ -151,7 +150,6 @@ public class FormDesigner extends TargetComponent
implements TreeSelection // 存储被选择组件和剪切板的model private transient SelectionModel selectionModel; - private int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); // 编辑状态的事件表 private CreatorEventListenerTable edit; protected List designerActions; @@ -1801,14 +1799,6 @@ public class FormDesigner extends TargetComponent implements TreeSelection } - public void setResolution(int resolution) { - this.resolution = resolution; - } - - public int getResolution() { - return this.resolution; - } - public double getScale() { return scale; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 9284554dc..aab1b27b7 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.GraphHelper; +import com.fr.base.ScreenResolution; import com.fr.base.Utils; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.base.vcs.DesignerMode; @@ -132,7 +133,7 @@ public class FormDesignerUI extends ComponentUI { return; } WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(designer.getTarget()); - WatermarkPainter painter = WatermarkPainter.createPainter(watermark, designer.getResolution()); + WatermarkPainter painter = WatermarkPainter.createPainter(watermark, ScreenResolution.getScreenResolution()); painter.paint(g, 0, 0, designer.getArea().getBounds()); } 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 7d3b17f5b..5e5740f03 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 @@ -182,11 +182,10 @@ public class FormSelectionUtils { if (!childrenList.isEmpty()) { for (Object aChildrenList : childrenList) { XWTabFitLayout tabLayout = (XWTabFitLayout) aChildrenList; - double percent = tabLayout.getContainerPercent(); Component[] components = tabLayout.getComponents(); for (Component component : components) { Rectangle show = component.getBounds(); - component.setBounds(new Rectangle((int) (show.x * percent), (int) (show.y * percent), (int) (show.width * percent), (int) (show.height * percent))); + component.setBounds(new Rectangle(show.x, show.y, show.width, show.height)); } } } 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 d61cd5902..8d2748eb3 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 @@ -1235,4 +1235,8 @@ public class JForm extends JTemplate implements BaseJForm { public RootDesignDefinePane(XCreator xCreator) { super(xCreator); - newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().newUIMode(); + newForm = TemplateTool.getCurrentEditingNewJForm() != null && DesignerUIModeConfig.getInstance().simulateWebUIMode(); this.root = (XWParameterLayout) xCreator; initComponent(); } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index f711eb157..85265fa6e 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -150,7 +150,7 @@ public class WidgetBoundPane extends BasicPane { public void limitWidth(WLayout wabs, int w, Rectangle bounds, Rectangle rec) { int difference = 0; - int minWidth = (int) (MINWIDTH * ((WFitLayout) wabs).getResolutionScaling()); + int minWidth = MINWIDTH; PaddingMargin margin = wabs.getMargin(); if (bounds.width != w) { if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) { @@ -172,7 +172,7 @@ public class WidgetBoundPane extends BasicPane { public void limitHeight(WLayout wabs, int h, Rectangle bounds, Rectangle rec) { int difference = 0; PaddingMargin margin = wabs.getMargin(); - int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); + int minHeight = MINHEIGHT; if (bounds.height != h) { if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) { FineJOptionPane.showMessageDialog(null, i18nText("Fine-Design_Form_Beyond_Bounds")); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java index 9507248df..3eb947488 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/ElementEditorDefinePane.java @@ -5,7 +5,7 @@ import com.fr.base.theme.TemplateTheme; import com.fr.base.theme.settings.ThemedComponentStyle; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.*; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.fit.common.TemplateTool; import com.fr.design.fit.attrpane.PcFitExpandablePane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.style.FollowingThemePane; @@ -76,7 +76,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane list = new ArrayList(); @@ -102,7 +102,7 @@ public class ElementEditorDefinePane extends WTitleLayoutDefinePane DSColumnPane.SETTING_DSRELATED) { selectCountPane = new SelectCountPane(); - selectCountPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Results_Filter"), null)); + selectCountPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Results_Filter"))); } valuePane = new ValuePane(); - valuePane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"), null)); + valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"))); formatAttrPane = new FormatAttrPane(); - + JPanel titleBorderedFormatPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format")); + titleBorderedFormatPane.add(formatAttrPane, BorderLayout.NORTH); JPanel extendablePane = null; if (setting > DSColumnPane.SETTING_DSRELATED) { @@ -109,7 +122,7 @@ public class DSColumnAdvancedPane extends BasicPane { {sortPane}, {selectCountPane}, {valuePane}, - {formatAttrPane}, + {titleBorderedFormatPane}, {extendablePane}, {multiNumPane} }; @@ -117,7 +130,7 @@ public class DSColumnAdvancedPane extends BasicPane { components = new Component[][]{ {sortPane}, {valuePane}, - {formatAttrPane} + {titleBorderedFormatPane} }; } @@ -125,7 +138,7 @@ public class DSColumnAdvancedPane extends BasicPane { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] columnSize = {TableLayout.FILL}; - this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); + contentPane.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.CENTER); } @Override @@ -138,7 +151,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } - sortPane.populate(cellElement); + sortPane.populateBean(cellElement); valuePane.populate(cellElement); formatAttrPane.populate(cellElement); @@ -188,7 +201,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } - sortPane.update(cellElement); + sortPane.updateBean(cellElement); valuePane.update(cellElement); formatAttrPane.update(cellElement); @@ -224,66 +237,25 @@ public class DSColumnAdvancedPane extends BasicPane { } } - private static class SortPane extends SortFormulaPane { - private CellElement cellElement; + private static class ScrollPane extends UIScrollPane { + ScrollPane(Component component) { + super(component); + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + } @Override - public void formulaAction() { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - - String[] displayNames = DesignTableDataManager.getSelectedColumnNames( - DesignTableDataManager.getEditingTableDataSource(), ((DSColumn) value).getDSName()); - - showFormulaDialog(displayNames); + public Dimension getPreferredSize() { + return new Dimension(DSColumnPane.DEFAULT_DIMENSION.width - 20, DSColumnPane.DEFAULT_DIMENSION.height - 100); } + } - void populate(CellElement cellElement) { - if (cellElement == null) { - return; - } - this.cellElement = cellElement; - - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) value; - - int sort = dSColumn.getOrder(); - this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); - - String sortFormula = dSColumn.getSortFormula(); - sortFormulaTextField.setText(sortFormula); + private static class SortPane extends CellDSColumnSortPane { + SortPane() { + this.setLayout(new FlowLayout(FlowLayout.LEFT)); } - public void update(CellElement cellElement) { - if (cellElement == null) { - return; - } - Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { - return; - } - DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - - dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); - //lance:sort formula - - String sText = null; - if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { - sText = new String(sortFormulaTextField.getText()); - } - if (!(sText == null || sText.length() < 1)) { - dSColumn.setSortFormula(sText); - } else { - dSColumn.setSortFormula(null); - } + protected boolean needSortHeaderPane() { + return false; } } @@ -538,40 +510,31 @@ public class DSColumnAdvancedPane extends BasicPane { } } - public class FormatAttrPane extends AbstractAttrNoScrollPane { - private TextFormatPane formatPane; + public static class FormatAttrPane extends TextFormatPane { - @Override - protected JPanel createContentPane() { - this.formatPane = new TextFormatPane(); - return this.formatPane; - } + protected void initLayout() { + JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0); + settingPane.add(typeComboBox); + settingPane.add(textField); + settingPane.add(roundingBox); - @Override - public Dimension getPreferredSize() { - if (formatPane == null) { - return super.getPreferredSize(); - } - return formatPane.getPreferredSize(); + addComponents(4, new JComponent[]{settingPane, previewLabel}); } - protected void initContentPane() { - leftContentPane = createContentPane(); - if (leftContentPane != null) { - leftContentPane.setBorder(BorderFactory.createEmptyBorder()); - this.add(leftContentPane, BorderLayout.CENTER); - } + @Override + protected void setRoundingBoxVisible(boolean visible) { + roundingBox.setVisible(visible); } public void populate(CellElement cellElement) { - if (cellElement != null && formatPane != null) { - formatPane.populateBean(cellElement.getStyle()); + if (cellElement != null) { + populateBean(cellElement.getStyle()); } } public void update(CellElement cellElement) { - if (cellElement != null && formatPane != null) { - cellElement.setStyle(formatPane.update(cellElement.getStyle())); + if (cellElement != null) { + cellElement.setStyle(update(cellElement.getStyle())); } } } diff --git a/designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java b/designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java deleted file mode 100644 index bd3c73846..000000000 --- a/designer-realize/src/main/java/com/fr/design/fit/grid/GridHeaderWithBoundMouseHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.fr.design.fit.grid; - -import com.fr.base.DynamicUnitList; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.GridHeader; -import com.fr.grid.AbstractGridHeaderMouseHandler; -import com.fr.report.elementcase.ElementCase; -import com.fr.report.elementcase.TemplateElementCase; - -import java.awt.event.MouseEvent; - -public abstract class GridHeaderWithBoundMouseHandler extends AbstractGridHeaderMouseHandler{ - protected static final int FUZZY_EDGE = 10; - private int limit; - - public GridHeaderWithBoundMouseHandler(GridHeader gHeader, int limit) { - super(gHeader); - this.limit = limit; - } - - public void setLimit(int limit) { - this.limit = limit; - } - - public int getLimit() { - return limit; - } - - public int getDragIndex(MouseEvent evt) { - ElementCase report = this.getEditingElementCase(); - DynamicUnitList sizeList = getSizeList(report); - - int scrollValue = getScrollValue(this.getElementCasePane()); - int scrollExtent = getScrollExtent(this.getElementCasePane()); - int endValue = scrollValue + scrollExtent + 1; - - int beginValue = getBeginValue(this.getElementCasePane()); - - double tmpSize1 = 0; - double tmpSize2; - double tmpIncreaseSize = 0; - - int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); - - for (int index = beginValue; index < endValue; index++) { - if (index == 0) { - index = scrollValue; - } - - tmpSize1 += tmpIncreaseSize; - tmpIncreaseSize = sizeList.get(index).toPixD(resolution); - tmpSize2 = tmpSize1 + Math.max(1, tmpIncreaseSize); - if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) { - return index; - } - } - return -1; - } - - - public ElementCasePane getElementCasePane() { - return this.gHeader.getElementCasePane(); - } - - public TemplateElementCase getEditingElementCase() { - return this.getElementCasePane().getEditingElementCase(); - } - -} diff --git a/designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java b/designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java deleted file mode 100644 index 28185bc38..000000000 --- a/designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitColumnMouseHandler.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.fr.design.fit.grid; - -import com.fr.base.DynamicUnitList; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.gui.imenu.UIPopupMenu; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.GridColumn; -import com.fr.grid.GridHeader; -import com.fr.grid.GridUtils; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.report.ReportHelper; -import com.fr.report.elementcase.ElementCase; -import com.fr.stable.ColumnRow; -import com.fr.stable.unit.FU; -import com.fr.stable.unit.UNIT; - -import javax.swing.SwingUtilities; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.event.MouseEvent; - -/** - * peter:处理对GridColumn的Mouse事件. - */ -public class GridLimitColumnMouseHandler extends GridHeaderWithBoundMouseHandler { - - - public GridLimitColumnMouseHandler(GridColumn gridColumn, int limit) { - super(gridColumn, limit); - this.resolution = gridColumn.getResolution(); - } - - @Override - protected void resetSelectionByRightButton(ColumnRow selectedCellPoint, Selection cs, ElementCasePane ePane) { - int[] selectedColumns = cs.getSelectedColumns(); - if (selectedColumns.length == 0 - || selectedCellPoint.getColumn() < selectedColumns[0] - || selectedCellPoint.getColumn() > selectedColumns[selectedColumns.length - 1]) { - resetGridSelectionBySelect(selectedCellPoint.getColumn(), ePane); - } - } - - - protected int doChooseFrom() { - return CellSelection.CHOOSE_COLUMN; - } - - @Override - protected Rectangle resetSelectedBoundsByShift(Rectangle editRectangle, ColumnRow selectedCellPoint, ElementCasePane reportPane) { - int tempOldSelectedCellX = editRectangle.x;// editRectangle.x; - - // adjust them to got the correct selected bounds. - if (selectedCellPoint.getColumn() >= editRectangle.x) { - selectedCellPoint = ColumnRow.valueOf(selectedCellPoint.getColumn() + 1, selectedCellPoint.getRow()); - } else { - tempOldSelectedCellX++; - } - - int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getRow(); - return new Rectangle(Math.min(tempOldSelectedCellX, selectedCellPoint.getColumn()), 0, Math.max(editRectangle.width, Math.abs(tempOldSelectedCellX - - selectedCellPoint.getColumn())), lastRow); - } - - @Override - protected int[] getGridSelectionIndices(CellSelection cs) { - return cs.getSelectedColumns(); - } - - @Override - protected int getScrollValue(ElementCasePane casePane) { - return casePane.getGrid().getHorizontalValue(); - } - - @Override - protected int getScrollExtent(ElementCasePane casePane) { - return casePane.getGrid().getHorizontalExtent(); - } - - @Override - protected int getBeginValue(ElementCasePane casePane) { - return casePane.getGrid().getHorizontalBeginValue(); - } - - @Override - protected int getColumnOrRowByGridHeader(ColumnRow selectedCellPoint) { - return selectedCellPoint.getColumn(); - } - - - /** - * Checks whether is on zero separator line. - */ - @Override - protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpWidth2, double tmpIncreaseWidth) { - return tmpIncreaseWidth <= 1 && (evt.getX() >= tmpWidth2 + 2 && (evt.getX() <= tmpWidth2 + SEPARATOR_GAP)); - } - - @Override - protected boolean between(MouseEvent evt, double from, double to) { - return evt.getX() > from && evt.getX() <= to; - } - - /** - * Checks whether is on normal separator line. - */ - @Override - protected boolean isOnNormalSeparatorLine(MouseEvent evt, double tmpWidth2) { - return (evt.getX() >= tmpWidth2 - 2) && (evt.getX() <= tmpWidth2 + 2); - } - - @Override - protected int evtOffset(MouseEvent evt, int offset) { - return evt.getX() - offset; - } - - @Override - protected DynamicUnitList getSizeList(ElementCase elementCase) { - return ReportHelper.getColumnWidthList(elementCase); - } - - @Override - protected String methodName() { - return "setColumnWidth"; - } - - @Override - protected String getSelectedHeaderTooltip(int selectedColumnCount) { - return selectedColumnCount + "C"; - } - - @Override - protected Point getTipLocationByMouseEvent(MouseEvent evt, GridHeader gHeader, Dimension tipPreferredSize) { - Point convertPoint = new Point(evt.getX(), 0); - SwingUtilities.convertPointToScreen(convertPoint, gHeader); - - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - convertPoint.x = Math.max(0, Math.min(convertPoint.x - tipPreferredSize.width / 2, screenSize.width - tipPreferredSize.width)); - convertPoint.y = convertPoint.y - tipPreferredSize.height - 2; - - return convertPoint; - } - - @Override - protected void resetGridSelectionBySelect(int column, ElementCasePane ePane) { - int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(ePane).getRow(); - CellSelection cellSelection = new CellSelection(column, 0, 1, lastRow); - cellSelection.setSelectedType(CellSelection.CHOOSE_COLUMN); - ePane.setSelection(cellSelection); - } - - @Override - protected String nameOfMoveCursorGIF() { - return "cursor_hmove"; - } - - @Override - protected String nameOfSelectCursorGIF() { - return "cursor_hselect"; - } - - @Override - protected String nameOfSplitCursorGIF() { - return "cursor_hsplit"; - } - - @Override - protected UIPopupMenu createPopupMenu(ElementCasePane reportPane, - MouseEvent evt, int columnIndex) { - return ElementCasePaneUtil.createColumnPopupMenu(reportPane, evt, columnIndex); - } - - @Override - protected void resetGridSelectionByDrag(CellSelection gridSelection, ElementCasePane reportPane, - int startMultiSelectIndex, int endMultiSelectIndex) { - int lastRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getRow(); - gridSelection.setLastRectangleBounds(Math.min(endMultiSelectIndex, startMultiSelectIndex), 0, Math.abs(startMultiSelectIndex - endMultiSelectIndex) + 1, lastRow); - } - - @Override - public void mouseReleased(MouseEvent e) { - super.mouseReleased(e); - int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); - int dragIndex = getDragIndex(e); - if (Math.abs(e.getX() - getLimit()) < FUZZY_EDGE && dragIndex >= 0) { - UNIT oldValue = this.getEditingElementCase().getColumnWidth(dragIndex); - this.getEditingElementCase().setColumnWidth(dragIndex, FU.valueOfPix(oldValue.toPixI(resolution) + getLimit() - e.getX(), resolution)); - } - this.getElementCasePane().repaint(); - } - -} diff --git a/designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java b/designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java deleted file mode 100644 index ac4a70eab..000000000 --- a/designer-realize/src/main/java/com/fr/design/fit/grid/GridLimitRowMouseHandler.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.fr.design.fit.grid; - -import com.fr.base.DynamicUnitList; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.gui.imenu.UIPopupMenu; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.GridHeader; -import com.fr.grid.GridRow; -import com.fr.grid.GridUtils; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; -import com.fr.report.ReportHelper; -import com.fr.report.elementcase.ElementCase; -import com.fr.stable.ColumnRow; -import com.fr.stable.unit.FU; -import com.fr.stable.unit.UNIT; - -import javax.swing.SwingUtilities; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.MouseEvent; - -/** - * peter:处理对GridRow的Mouse事件. - */ -public class GridLimitRowMouseHandler extends GridHeaderWithBoundMouseHandler { - - public GridLimitRowMouseHandler(GridRow gridRow, int limit) { - super(gridRow, limit); - } - - @Override - protected void resetSelectionByRightButton(ColumnRow selectedCellPoint, Selection cs, ElementCasePane ePane) { - int[] selectedRows = cs.getSelectedRows(); - if (selectedRows.length == 0 - || selectedCellPoint.getRow() < selectedRows[0] - || selectedCellPoint.getRow() > selectedRows[selectedRows.length - 1]) { - resetGridSelectionBySelect(selectedCellPoint.getRow(), ePane); - } - } - - - protected int doChooseFrom() { - return CellSelection.CHOOSE_ROW; - } - - @Override - protected int getScrollValue(ElementCasePane casePane) { - return casePane.getGrid().getVerticalValue(); - } - - @Override - protected int getScrollExtent(ElementCasePane casePane) { - return casePane.getGrid().getVerticalExtent(); - } - - @Override - protected int getBeginValue(ElementCasePane casePane) { - return casePane.getGrid().getVerticalBeginValue(); - } - - @Override - protected Rectangle resetSelectedBoundsByShift(Rectangle editRectangle, ColumnRow selectedCellPoint, ElementCasePane reportPane) { - int tempOldSelectedCellY = editRectangle.y;// editRectangle.x; - - // ajust them to got the correct selected bounds. - if (selectedCellPoint.getRow() >= editRectangle.y) { - selectedCellPoint = ColumnRow.valueOf(selectedCellPoint.getColumn(), selectedCellPoint.getRow() + 1); - } else { - tempOldSelectedCellY++; - } - - int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getColumn(); - return new Rectangle(0, Math.min(tempOldSelectedCellY, selectedCellPoint.getRow()), - lastColumn, Math.max(editRectangle.height, Math.abs(tempOldSelectedCellY - selectedCellPoint.getRow()))); - } - - @Override - protected int[] getGridSelectionIndices(CellSelection cs) { - return cs.getSelectedRows(); - } - - @Override - protected int getColumnOrRowByGridHeader(ColumnRow selectedCellPoint) { - return selectedCellPoint.getRow(); - } - - - @Override - protected void resetGridSelectionBySelect(int row, ElementCasePane ePane) { - int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(ePane).getColumn(); - CellSelection cellSelection = new CellSelection(0, row, lastColumn, 1); - cellSelection.setSelectedType(CellSelection.CHOOSE_ROW); - ePane.setSelection(cellSelection); - } - - /** - * Checks whether is on zero separator line. - */ - @Override - protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpHeight2, double tmpIncreaseHeight) { - return tmpIncreaseHeight <= 1 && (evt.getY() >= tmpHeight2 + 2 && evt.getY() <= tmpHeight2 + SEPARATOR_GAP); - } - - @Override - protected boolean between(MouseEvent evt, double from, double to) { - return evt.getY() > from && evt.getY() <= to; - } - - @Override - protected DynamicUnitList getSizeList(ElementCase elementCase) { - return ReportHelper.getRowHeightList(elementCase); - } - - @Override - protected String methodName() { - return "setRowHeight"; - } - - /** - * Checks whether is on normal separator line. - */ - @Override - protected boolean isOnNormalSeparatorLine(MouseEvent evt, double tmpHeight2) { - return (evt.getY() >= tmpHeight2 - 2) && (evt.getY() <= tmpHeight2 + 2); - } - - @Override - protected int evtOffset(MouseEvent evt, int offset) { - return evt.getY() - offset; - } - - @Override - protected String getSelectedHeaderTooltip(int rowSelectedCount) { - return rowSelectedCount + "R"; - } - - @Override - protected Point getTipLocationByMouseEvent(MouseEvent evt, GridHeader gHeader, Dimension tipPreferredSize) { - Point convertPoint = new Point(0, evt.getY()); - SwingUtilities.convertPointToScreen(convertPoint, gHeader); - - convertPoint.x = convertPoint.x + gHeader.getSize().width + 2; - convertPoint.y = convertPoint.y - tipPreferredSize.height / 2; - - return convertPoint; - } - - @Override - protected String nameOfMoveCursorGIF() { - return "cursor_vmove"; - } - - @Override - protected String nameOfSelectCursorGIF() { - return "cursor_vselect"; - } - - @Override - protected String nameOfSplitCursorGIF() { - return "cursor_vsplit"; - } - - @Override - protected UIPopupMenu createPopupMenu(ElementCasePane reportPane, - MouseEvent evt, int rowIndex) { - return ElementCasePaneUtil.createRowPopupMenu(reportPane, evt, rowIndex); - } - - @Override - protected void resetGridSelectionByDrag(CellSelection gridSelection, ElementCasePane reportPane, - int startMultiSelectIndex, int endMultiSelectIndex) { - int lastColumn = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane).getColumn(); - gridSelection.setLastRectangleBounds(0, Math.min(endMultiSelectIndex, startMultiSelectIndex), lastColumn, Math.abs(startMultiSelectIndex - endMultiSelectIndex) + 1); - - } - - @Override - public void mouseReleased(MouseEvent e) { - super.mouseReleased(e); - int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); - int dragIndex = getDragIndex(e); - if (Math.abs(e.getY() - getLimit()) < FUZZY_EDGE && dragIndex >= 0) { - UNIT oldValue = this.getEditingElementCase().getRowHeight(dragIndex); - this.getEditingElementCase().setRowHeight(dragIndex, FU.valueOfPix(oldValue.toPixI(resolution) + getLimit() - e.getY(), resolution)); - } - this.getElementCasePane().repaint(); - } -} diff --git a/designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java b/designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java deleted file mode 100644 index 9a2601aee..000000000 --- a/designer-realize/src/main/java/com/fr/design/fit/grid/NewFormDesignerGridUI.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.fr.design.fit.grid; - -import com.fr.design.designer.creator.XElementCase; -import com.fr.design.fit.AdaptiveCellElementPainter; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.fit.common.FormDesignerUtil; -import com.fr.design.mainframe.ElementCasePane; -import com.fr.design.mainframe.FormDesigner; -import com.fr.grid.CellElementPainter; -import com.fr.grid.Grid; -import com.fr.grid.GridColumn; -import com.fr.grid.GridRow; -import com.fr.grid.GridUI; -import com.fr.report.elementcase.TemplateElementCase; -import com.fr.report.worksheet.FormElementCase; -import com.fr.stable.Constants; -import com.fr.stable.GraphDrawHelper; - -import javax.swing.JComponent; -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Insets; -import java.awt.Rectangle; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.event.MouseWheelListener; - - -/** - * Created by kerry on 2020-04-14 - */ -public class NewFormDesignerGridUI extends GridUI { - private GridLimitColumnMouseHandler gridColumnMouseHandler; - private GridLimitRowMouseHandler gridRowMouseHandler; - private AdaptiveGridListener adaptiveGridListener; - private FormDesigner designer; - - public NewFormDesignerGridUI(FormDesigner designer, int resolution) { - super(resolution); - this.designer = designer; - this.setCellElementPainter(new AdaptiveCellElementPainter()); - } - - public void setCellElementPainter(CellElementPainter elementPainter) { - this.painter = elementPainter; - } - - public void paint(Graphics g, JComponent c) { - Graphics2D g2d = (Graphics2D) g; - Grid grid = (Grid) c; - // 取得ElementCasePane.ElementCase - ElementCasePane elementCasePane = grid.getElementCasePane(); - final TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - - super.paint(g, c); - - if (!(elementCase instanceof FormElementCase)) { - return; - } - final Rectangle rectangle = getBoundsLineRect(elementCase, grid); - int width = getScaleWidth(rectangle.width) - columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution); - int height = getScaleHeight(rectangle.height) - rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution); - drawBoundsLine(g2d, width, height); - addListener(grid, elementCasePane, width, height, rectangle.width, rectangle.height); - } - - private int getScaleWidth(int width) { - return width * resolution / DesignerUIModeConfig.getInstance().getScreenResolution(); - - } - - private int getScaleHeight(int height) { - return height * resolution / DesignerUIModeConfig.getInstance().getScreenResolution(); - } - - - /** - * 获取需要画线的矩形大小 - */ - private Rectangle getBoundsLineRect(TemplateElementCase elementCase, Grid grid) { - final Rectangle rectangle = new Rectangle(); - XElementCase xElementCase = FormDesignerUtil.getXelementCase(designer.getRootComponent(), (FormElementCase) elementCase); - if (xElementCase != null) { - rectangle.setBounds(xElementCase.getBounds()); - - //减去内边距的宽和高 - Insets insets = xElementCase.getInsets(); - rectangle.width -= insets.left + insets.right; - rectangle.height -= insets.top + insets.bottom; - - } - return rectangle; - } - - - private void addListener(Grid grid, ElementCasePane elementCasePane, int width, int height, int actualWidth, int actualHeight) { - addGridColumnListener(elementCasePane.getGridColumn(), width); - addGridRowListener(elementCasePane.getGridRow(), height); - addMouseListener(grid, width, height, actualWidth, actualHeight); - } - - - private void drawBoundsLine(Graphics2D g2d, int width, int height) { - g2d.setPaint(Color.black); - g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT)); - g2d.drawLine(0, height, width, height); - g2d.drawLine(width, 0, width, height); - } - - private void removeGridColumnListener(GridColumn column) { - MouseMotionListener[] mouseMotionListeners = column.getMouseMotionListeners(); - for (MouseMotionListener mouseMotionListener : mouseMotionListeners) { - if (mouseMotionListener instanceof com.fr.grid.GridColumnMouseHandler || mouseMotionListener instanceof GridLimitColumnMouseHandler) { - column.removeMouseMotionListener(mouseMotionListener); - } - } - MouseListener[] mouseListeners = column.getMouseListeners(); - for (MouseListener motionListener : mouseListeners) { - if (motionListener instanceof com.fr.grid.GridColumnMouseHandler || motionListener instanceof GridLimitColumnMouseHandler) { - column.removeMouseListener(motionListener); - } - } - } - - private void removeGridRowListener(GridRow row) { - MouseMotionListener[] mouseMotionListeners = row.getMouseMotionListeners(); - for (MouseMotionListener mouseMotionListener : mouseMotionListeners) { - if (mouseMotionListener instanceof com.fr.grid.GridRowMouseHandler || mouseMotionListener instanceof GridLimitRowMouseHandler) { - row.removeMouseMotionListener(mouseMotionListener); - } - } - MouseListener[] mouseListeners = row.getMouseListeners(); - for (MouseListener motionListener : mouseListeners) { - if (motionListener instanceof com.fr.grid.GridRowMouseHandler || motionListener instanceof GridLimitRowMouseHandler) { - row.removeMouseListener(motionListener); - } - } - } - - private void removeGridListener(Grid grid) { - MouseMotionListener[] mouseMotionListeners = grid.getMouseMotionListeners(); - for (MouseMotionListener mouseMotionListener : mouseMotionListeners) { - if (mouseMotionListener instanceof AdaptiveGridListener) { - grid.removeMouseMotionListener(mouseMotionListener); - break; - } - } - MouseListener[] mouseListeners = grid.getMouseListeners(); - for (MouseListener motionListener : mouseListeners) { - if (motionListener instanceof AdaptiveGridListener) { - grid.removeMouseListener(motionListener); - break; - } - } - MouseWheelListener[] mouseWheelListeners = grid.getMouseWheelListeners(); - for (MouseWheelListener mouseWheelListener : mouseWheelListeners) { - if (mouseWheelListener instanceof AdaptiveGridListener) { - grid.removeMouseWheelListener(mouseWheelListener); - break; - } - } - } - - private void addGridColumnListener(GridColumn column, int width) { - if (gridColumnMouseHandler != null) { - gridColumnMouseHandler.setLimit(width); - return; - } - removeGridColumnListener(column); - gridColumnMouseHandler = new GridLimitColumnMouseHandler(column, width); - column.addMouseListener(gridColumnMouseHandler); - column.addMouseMotionListener(gridColumnMouseHandler); - } - - - private void addGridRowListener(GridRow row, int height) { - if (gridRowMouseHandler != null) { - gridRowMouseHandler.setLimit(height); - return; - } - removeGridRowListener(row); - gridRowMouseHandler = new GridLimitRowMouseHandler(row, height); - row.addMouseMotionListener(gridRowMouseHandler); - row.addMouseListener(gridRowMouseHandler); - } - - - private void addMouseListener(Grid grid, int width, int height, int actualWidth, int actualHeight) { - if (adaptiveGridListener != null) { - adaptiveGridListener.resetBoundInfo(width, height, actualWidth, actualHeight); - return; - } - removeGridListener(grid); - adaptiveGridListener = new AdaptiveGridListener(grid, width, height, actualWidth, actualHeight); - grid.addMouseMotionListener(adaptiveGridListener); - grid.addMouseListener(adaptiveGridListener); - grid.addMouseWheelListener(adaptiveGridListener); - } - -} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index dbc4269d6..cdfceb3f4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -6,7 +6,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseFormula; import com.fr.base.DynamicUnitList; import com.fr.base.Formula; -import com.fr.base.ScreenResolution; +import com.fr.base.NameStyle; import com.fr.base.Style; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; @@ -67,7 +67,6 @@ import com.fr.design.constants.UIConstants; import com.fr.design.designer.EditingState; import com.fr.design.designer.TargetComponent; import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.fun.ElementUIProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIPopupMenu; @@ -97,6 +96,7 @@ import com.fr.page.PageAttributeGetter; import com.fr.page.ReportPageAttrProvider; import com.fr.poly.creator.PolyElementCasePane; import com.fr.report.ReportHelper; +import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.core.RichText; @@ -133,6 +133,7 @@ import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.lang.reflect.Constructor; +import java.util.Iterator; import java.util.Set; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -157,10 +158,10 @@ public abstract class ElementCasePane extends Tar // alex: private boolean supportDefaultParentCalculate = false; // GUI. - private Grid grid; - private GridRow gridRow; - private GridColumn gridColumn; - private GridCorner gridCorner; + protected Grid grid; + protected GridRow gridRow; + protected GridColumn gridColumn; + protected GridCorner gridCorner; private JScrollBar verScrollBar; private JScrollBar horScrollBar; // Visible @@ -365,7 +366,6 @@ public abstract class ElementCasePane extends Tar } } - public void setResolution(int resolution) { this.resolution = resolution; } @@ -1374,6 +1374,33 @@ public abstract class ElementCasePane extends Tar return cellNeedTOFormat; } + public void traverseSelectedCellElements(TemplateCellElementVisitor visitor) { + Selection selection = getSelection(); + if (!(selection instanceof CellSelection)) { + return; + } + CellSelection cs = (CellSelection) selection; + TemplateElementCase elementCase = getEditingElementCase(); + int cellRectangleCount = cs.getCellRectangleCount(); + + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + visitor.visit(column, row, cellElement); + } + } + } + } + + public interface TemplateCellElementVisitor { + void visit(int column, int row, TemplateCellElement cellElement); + } + private class ElementCaseEditingState implements EditingState { protected Selection selection; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java index 218ee4728..0075ae076 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java @@ -220,7 +220,7 @@ public class DesignerAppUtils { Multimap stringPluginMarkerAdapterMultimap = popPluginInfoMap(key); Collection disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.DISABLE_PLUGIN); for (PluginMarkerAdapter disablePlugin : disablePlugins) { - PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); + PluginManager.getController().enablePersistently(disablePlugin, new ModifyStatusCallback(false)); } Collection uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorContextHolder.NOT_INSTALLED_PLUGIN); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java index 8a3b2ded4..86b93a210 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/AbstractDSCellEditorPane.java @@ -1,17 +1,7 @@ package com.fr.design.mainframe.cell; -import com.fr.design.gui.iscrollbar.UIScrollBar; -import com.fr.design.mainframe.CellElementPropertyPane; -import com.fr.quickeditor.cellquick.layout.CellElementBarLayout; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.event.AdjustmentEvent; -import java.awt.event.AdjustmentListener; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.AbstractAttrPane; /** * 右侧单元格元素面板抽象类 @@ -20,26 +10,8 @@ import java.awt.event.MouseWheelListener; * @version 2017年7月25日 * @since 9.0 */ -public abstract class AbstractDSCellEditorPane extends JPanel { - - /** - * 滚动条相关配置 - */ - private static final int MAXVALUE = 100; - private static final int TITLE_HEIGHT = 95; - private static final int CONTENT_PANE_WIDTH_GAP = 3; - private static final int SCROLLBAR_WIDTH = 7; - private static final int MOUSE_WHEEL_SPEED = 5; - private int maxHeight = 280; - - private JPanel leftContentPane; - private UIScrollBar scrollBar; +public abstract class AbstractDSCellEditorPane extends AbstractAttrPane { - protected abstract JPanel createContentPane(); - - public abstract String getIconPath(); - - public abstract String title4PopupWindow(); /** * 从面板拿数据保存 @@ -51,78 +23,15 @@ public abstract class AbstractDSCellEditorPane extends JPanel { */ public abstract void populate(); - protected void createScrollPane() { - leftContentPane = this.createContentPane(); - this.prepareScrollBar(); - leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); - - this.setLayout(new CellElementBarLayout(leftContentPane) { - @Override - public void layoutContainer(Container parent) { - maxHeight = CellElementPropertyPane.getInstance().getHeight() - TITLE_HEIGHT; - int beginY; - if ((MAXVALUE - scrollBar.getVisibleAmount()) == 0) { - beginY = 0; - } else { - int preferredHeight = leftContentPane.getPreferredSize().height; - int value = scrollBar.getValue(); - beginY = value * (preferredHeight - maxHeight) / (MAXVALUE - scrollBar.getVisibleAmount()); - } - int width = parent.getWidth(); - int height = parent.getHeight(); - if (leftContentPane.getPreferredSize().height > maxHeight) { - leftContentPane.setBounds(0, -beginY, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height + beginY); - scrollBar.setBounds(width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, 0, SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, height); - } else { - leftContentPane.setBounds(0, 0, width - SCROLLBAR_WIDTH - CONTENT_PANE_WIDTH_GAP, height); - } - } - }); - this.add(scrollBar); - this.add(leftContentPane); - } - - - private void prepareScrollBar() { - scrollBar = new UIScrollBar(UIScrollBar.VERTICAL) { - @Override - public int getVisibleAmount() { - int preferredHeight = leftContentPane.getPreferredSize().height; - int e = MAXVALUE * (maxHeight) / preferredHeight; - setVisibleAmount(e); - return e; - } - - @Override - public int getMaximum() { - return MAXVALUE; - } - }; - - scrollBar.addAdjustmentListener(new AdjustmentListener() { - - @Override - public void adjustmentValueChanged(AdjustmentEvent e) { - doLayout(); - } - }); - this.addMouseWheelListener(new MouseWheelListener() { - - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - int value = scrollBar.getValue(); - value += MOUSE_WHEEL_SPEED * e.getWheelRotation(); - scrollBar.setValue(value); - doLayout(); - } - }); - scrollBar.setPreferredSize(new Dimension(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP, this.getHeight())); - scrollBar.setBlockIncrement(SCROLLBAR_WIDTH + CONTENT_PANE_WIDTH_GAP); - scrollBar.setBorder(BorderFactory.createMatteBorder(0, CONTENT_PANE_WIDTH_GAP, 0, 0, this.getBackground())); - } /** * 释放tc */ protected abstract void release(); + + protected abstract AttributeChangeListener getAttributeChangeListener(); + + public void addAttributeChangeListener(){ + this.addAttributeChangeListener(getAttributeChangeListener()); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index cd454660d..9549a3a7e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -4,7 +4,6 @@ import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.expand.ExpandLeftFatherPane; import com.fr.design.expand.ExpandUpFatherPane; -import com.fr.design.expand.SortExpandAttrPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; @@ -13,6 +12,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; +import com.fr.design.sort.cellexpand.CellExpandSortPane; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.report.cell.TemplateCellElement; @@ -38,11 +38,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private ExpandUpFatherPane rightFatherPane; private UICheckBox horizontalExpandableCheckBox; private UICheckBox verticalExpandableCheckBox; - private SortExpandAttrPane sortAfterExpand; private JPanel layoutPane; private JPanel basicPane; private JPanel seniorPane; private CellExpandExtraAttrPane extraPane; + private CellExpandSortPane cellExpandSortPane; /** @@ -62,7 +62,6 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { rightFatherPane = new ExpandUpFatherPane(); horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); - sortAfterExpand = new SortExpandAttrPane(); initAllNames(); return layoutPane(); } @@ -81,8 +80,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { seniorPane = new JPanel(); basicPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane()); seniorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane()); + JPanel sortUIExpandablePane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), + 223, 24, cellExpandSortPane = new CellExpandSortPane(this)); layoutPane.add(basicPane, BorderLayout.NORTH); layoutPane.add(seniorPane, BorderLayout.CENTER); + layoutPane.add(sortUIExpandablePane, BorderLayout.SOUTH); extraPane = CellExpandExtraAttrPane.getInstance(); @@ -119,16 +121,12 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private JPanel seniorPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT); - JPanel expendSortPane = new JPanel(new BorderLayout()); - expendSortPane.add(expendSort, BorderLayout.NORTH); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); verticalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{horizontalExpandableCheckBox, null}, new Component[]{verticalExpandableCheckBox, null}, - new Component[]{expendSortPane, sortAfterExpand}, }; double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; @@ -169,9 +167,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - sortAfterExpand.populate(cellExpandAttr); - extraPane.populate(cellElement); + cellExpandSortPane.populateBean(cellElement); } @@ -217,11 +214,8 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) { - sortAfterExpand.update(cellExpandAttr); - } - extraPane.update(cellElement); + cellExpandSortPane.updateBean(cellElement); } /** 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 c28c00de5..24ea3209d 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 @@ -1,22 +1,23 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.CellBorderStyle; +import com.fr.base.NameStyle; import com.fr.base.Style; import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.constants.UIConstants; -import com.fr.design.gui.style.BorderPane; +import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.cell.settingpane.style.StylePane; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.style.BorderUtils; import com.fr.design.utils.gui.GUICoreUtils; - import com.fr.report.cell.TemplateCellElement; import com.fr.report.elementcase.TemplateElementCase; -import javax.swing.*; +import javax.swing.JFrame; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; /** * @author zhou @@ -71,29 +72,56 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { - Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); + // 因为存在框选多个单元格的情况,跟随主题切换到自定义的行为似乎不太适合由updateBeans完成,它更像是个工具栏上的Action. + // 但它又会触发updateBeans... + boolean isSwitchToCustomStyleAction = stylePane.isFollowingThemeSettingChanged() && !stylePane.isFollowingTheme(); + if (isSwitchToCustomStyleAction) { + switchCellStylesToCustom(); + return; + } + updateCellStylesByPaneSettings(); + } + + private void switchCellStylesToCustom() { TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); - int cellRectangleCount = cs.getCellRectangleCount(); - for (int rect = 0; rect < cellRectangleCount; rect++) { - Rectangle cellRectangle = cs.getCellRectangle(rect); - for (int j = 0; j < cellRectangle.height; j++) { - for (int i = 0; i < cellRectangle.width; i++) { - int column = i + cellRectangle.x; - int row = j + cellRectangle.y; - TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); - if (cellElement == null) { - cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); - elementCase.addCellElement(cellElement); - } - Style style = stylePane.updateBean(); - cellElement.setStyle(style); + elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() { + @Override + public void visit(int column, int row, TemplateCellElement cellElement) { + if (cellElement == null) { + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); + elementCase.addCellElement(cellElement); } + Style style = cellElement.getStyle(); + if (style instanceof NameStyle) { + style = ((NameStyle) style).getRealStyle(); + } + if (style == null) { + style = Style.DEFAULT_STYLE; + } + cellElement.setStyle(style); } - } + }); + } + + private void updateCellStylesByPaneSettings() { + Object[] oldSelectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); + + TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); + elementCasePane.traverseSelectedCellElements(new ElementCasePane.TemplateCellElementVisitor() { + @Override + public void visit(int column, int row, TemplateCellElement cellElement) { + if (cellElement == null) { + cellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); + elementCase.addCellElement(cellElement); + } + Style style = stylePane.updateBean(); + cellElement.setStyle(style); + } + }); // border必须特别处理 - CellBorderStyle cellBorderStyle = stylePane.updateBorderStyle(); - if (cellBorderStyle != null) { - BorderUtils.update(elementCasePane, selectionCellBorderObjects, cellBorderStyle); + CellBorderStyle newCellBorderStyle = stylePane.updateBorderStyle(); + if (newCellBorderStyle != null) { + BorderUtils.update(elementCasePane, oldSelectionCellBorderObjects, newCellBorderStyle); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java index 3e4b3ac71..086392799 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/NameStyleListPane.java @@ -16,11 +16,8 @@ import com.fr.design.mainframe.theme.ThemedCellStyleListPane; */ public class NameStyleListPane extends ThemedCellStyleListPane { - public NameStyleListPane() { - } - - public NameStyleListPane(boolean supportCellRange) { - super(supportCellRange); + public NameStyleListPane(boolean supportInnerBorder) { + super(supportInnerBorder); } public void populateNameStyle(NameStyle style) { 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 c6613befa..7f382ed44 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 @@ -51,6 +51,7 @@ public class StylePane extends BasicPane implements UIObserver { private final List observerListeners = new ArrayList<>(); private Style backupStyleFromPopulating = Style.DEFAULT_STYLE; + private boolean isFollowingThemeSettingChanged = false; public StylePane() { followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); @@ -77,6 +78,7 @@ public class StylePane extends BasicPane implements UIObserver { followingThemeButtonGroup.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + isFollowingThemeSettingChanged = true; AttributeChangeUtils.changeComposedUI(StylePane.this, false, new AttributeChangeUtils.UIChangeAction() { @Override public void changeComposedUI() { @@ -85,6 +87,7 @@ public class StylePane extends BasicPane implements UIObserver { } }); fireStateChanged(); + isFollowingThemeSettingChanged = false; } }); @@ -103,25 +106,33 @@ public class StylePane extends BasicPane implements UIObserver { cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[selectedIndex]); if (!isFollowingTheme) { // 对于同一个单元格,跟随主题切换到自定义,自定义中的配置与其保持一致 - NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle(); - if (lastSelectedNameStyle != null) { - Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); - try { - lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); - if (lastSelectedRealStyle != null) { - customStylePane.populateBean(lastSelectedRealStyle); - customStylePane.dealWithBorder(); - } - } catch (CloneNotSupportedException ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - } + syncCustomStylePaneBySelectedNameStyle(); } else { // 对于同一个单元格,自定义切换到跟随主题,跟随主题选中"默认"样式,并使用默认样式设置选中的单元格 nameStyleListPane.reset(); } } + private void syncCustomStylePaneBySelectedNameStyle() { + NameStyle lastSelectedNameStyle = nameStyleListPane.updateNameStyle(); + if (lastSelectedNameStyle != null) { + Style lastSelectedRealStyle = lastSelectedNameStyle.getRealStyle(); + try { + lastSelectedRealStyle = (Style) lastSelectedRealStyle.clone(); + if (lastSelectedRealStyle != null) { + customStylePane.populateBean(lastSelectedRealStyle); + customStylePane.dealWithBorder(); + } + } catch (CloneNotSupportedException ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + } + } + + public boolean isFollowingThemeSettingChanged() { + return isFollowingThemeSettingChanged; + } + protected JPanel createTabbedContentPane() { JPanel contentPane = new JPanel(cardLayout) { @Override @@ -161,14 +172,22 @@ public class StylePane extends BasicPane implements UIObserver { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); } - public void setSelectedIndex(int index) { + public boolean isFollowingTheme() { + return getSelectedIndex() == 0; + } + + public void setFollowingTheme(boolean followingTheme) { + setSelectedIndex(followingTheme ? 0 : 1); + } + + private void setSelectedIndex(int index) { if (0 <= index && index < FOLLOWING_THEME_STRING_ARRAYS.length) { followingThemeButtonGroup.setSelectedIndex(index); cardLayout.show(contentPane, FOLLOWING_THEME_STRING_ARRAYS[index]); } } - public int getSelectedIndex() { + private int getSelectedIndex() { return followingThemeButtonGroup.getSelectedIndex(); } @@ -185,11 +204,11 @@ public class StylePane extends BasicPane implements UIObserver { } public void setSelctedByName(String id) { - setSelectedIndex(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)? 1 : 0); + setFollowingTheme(!ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom"), id)); } public CellBorderStyle updateBorderStyle() { - if (getSelectedIndex() == 0) { + if (isFollowingTheme()) { return nameStyleListPane.updateBorderStyle(); } else if (customStylePane.isBorderPaneSelected()) { return customStylePane.updateBorderStyle(); @@ -199,7 +218,7 @@ public class StylePane extends BasicPane implements UIObserver { public Style updateBean() { Style finalStyle = null; - if (getSelectedIndex() == 0) { + if (isFollowingTheme()) { finalStyle = nameStyleListPane.updateNameStyle(); } if (finalStyle == null) { @@ -215,7 +234,7 @@ public class StylePane extends BasicPane implements UIObserver { if (style instanceof NameStyle) { NameStyle nameStyle = (NameStyle) style; - setSelectedIndex(0); + setFollowingTheme(true); nameStyleListPane.populateNameStyle(nameStyle); Style realStyle = nameStyle.getRealStyle(); try { @@ -225,7 +244,7 @@ public class StylePane extends BasicPane implements UIObserver { e.printStackTrace(); } } else { - setSelectedIndex(1); + setFollowingTheme(false); customStylePane.populateBean(style); } //单元格配置界面是单例 所以直接在populate的时候把跟随主题的按钮组设置不可见 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java index 2626193a4..7157316c2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoLogAppender.java @@ -4,6 +4,13 @@ import com.fr.base.io.IOFile; import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; import com.fr.design.i18n.Toolkit; +import com.fr.third.apache.logging.log4j.Level; +import com.fr.third.apache.logging.log4j.core.Filter; +import com.fr.third.apache.logging.log4j.core.Layout; +import com.fr.third.apache.logging.log4j.core.LogEvent; +import com.fr.third.apache.logging.log4j.core.appender.AbstractAppender; +import com.fr.third.apache.logging.log4j.core.config.Property; +import com.fr.third.apache.logging.log4j.core.layout.PatternLayout; import com.fr.web.session.SessionLocalManager; import com.fr.stable.StableUtils; @@ -12,22 +19,20 @@ import com.fr.stable.project.ProjectConstants; import com.fr.stable.web.SessionProvider; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import com.fr.third.apache.log4j.AppenderSkeleton; -import com.fr.third.apache.log4j.Level; -import com.fr.third.apache.log4j.spi.LoggingEvent; import com.fr.web.core.SessionPoolManager; import com.fr.web.core.TemplateSessionIDInfo; import com.fr.workspace.WorkContext; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.Serializable; /** * 收集设计器报错信息的appender. *

* Created by Administrator on 2017/7/24 0024. */ -public class ErrorInfoLogAppender extends AppenderSkeleton { +public class ErrorInfoLogAppender extends AbstractAppender { private static final int ERROR_LEN = 8; private static final int ERROR_STACK_TRACE = 15; @@ -38,16 +43,23 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { private String uuid; private String activekey; - public ErrorInfoLogAppender() { - this.layout = new com.fr.third.apache.log4j.PatternLayout("%d{HH:mm:ss} %t %p [%c] %m%n"); - + protected ErrorInfoLogAppender(String name, Filter filter, + Layout layout, + boolean ignoreExceptions, + Property[] properties) { + super(name, filter, layout, ignoreExceptions, properties); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); this.username = envManager.getDesignerLoginUsername(); this.uuid = envManager.getUUID(); this.activekey = envManager.getActivationKey(); } - protected void append(LoggingEvent event) { + public static ErrorInfoLogAppender createErrorLogAppender() { + return new ErrorInfoLogAppender(ErrorInfoLogAppender.class.getSimpleName(), null, PatternLayout.newBuilder().withPattern("%d{HH:mm:ss} %t %p [%c] %m%n %throwable{0}").build(), false, Property.EMPTY_ARRAY); + } + + @Override + public void append(LogEvent event) { this.subAppend(event); } @@ -55,19 +67,12 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { return true; } - public synchronized void close() { - if (this.closed) { - return; - } - this.closed = true; - - } - public void subAppend(LoggingEvent event) { + public void subAppend(LogEvent event) { Level level = event.getLevel(); // 只分析上传记录error以上的. - if (level.isGreaterOrEqual(Level.ERROR)) { - String msg = this.layout.format(event); + if (level.isMoreSpecificThan(Level.ERROR)) { + String msg = (String) this.toSerializable(event); // 这个id并不是一定会有的, 有就记录下, 说明是预览模板出的错. String templateid = readTemplateID(); String logid = readLogID(msg); @@ -80,13 +85,13 @@ public class ErrorInfoLogAppender extends AppenderSkeleton { } } - private String readStackTrace(LoggingEvent event) { - String[] s = event.getThrowableStrRep(); + private String readStackTrace(LogEvent event) { + StackTraceElement[] s = event.getThrown() == null ? null : event.getThrown().getStackTrace(); StringBuilder sb = new StringBuilder(); if (s != null) { int len = Math.min(s.length, ERROR_STACK_TRACE); for (int i = 0; i < len; i++) { - sb.append(s[i]).append("\n"); + sb.append(s[i].toString()).append("\n"); } } return sb.toString(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index 81da86212..73ecf610d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -44,30 +44,35 @@ public class ErrorInfoUploader { //单次发送的错误信息最大条数 private static final int MAX_ITEMS = 200; + private static LogHandler logHandler; + static { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override public void envChanged() { - FineLoggerFactory.getLogger().addLogAppender(new LogHandler() { - private ErrorInfoLogAppender errorInfoLogAppender = new ErrorInfoLogAppender(); - - @Override - public ErrorInfoLogAppender getHandler() { - return errorInfoLogAppender; - } - }); + if (logHandler != null) { + logHandler.getHandler().stop(); + FineLoggerFactory.getLogger().removeLogAppender(logHandler); + logHandler.getHandler().start(); + FineLoggerFactory.getLogger().addLogAppender(logHandler); + } } }); } private ErrorInfoUploader() { - FineLoggerFactory.getLogger().addLogAppender(new LogHandler() { + logHandler = new LogHandler() { + + private final ErrorInfoLogAppender errorInfoLogAppender = ErrorInfoLogAppender.createErrorLogAppender(); + @Override public ErrorInfoLogAppender getHandler() { - return new ErrorInfoLogAppender(); + return errorInfoLogAppender; } - }); + }; + logHandler.getHandler().start(); + FineLoggerFactory.getLogger().addLogAppender(logHandler); } public static ErrorInfoUploader getInstance() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 43c66d8c8..5be6362a4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -13,7 +13,6 @@ import com.fr.design.designer.EditingState; import com.fr.design.designer.TargetComponent; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.fit.DesignerUIModeConfig; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.AuthorityEditPane; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java index 55d11fe7d..750422bc3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java @@ -6,8 +6,10 @@ import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.form.FormECBackgroundAction; import com.fr.design.actions.form.FormECColumnsAction; import com.fr.design.actions.form.FormECFrozenAction; +import com.fr.design.designer.creator.XElementCase; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.fit.common.FormDesignerUtil; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.mainframe.*; import com.fr.design.mainframe.cell.QuickEditorRegion; @@ -18,21 +20,27 @@ import com.fr.design.menu.ToolBarDef; import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.form.main.Form; import com.fr.grid.Grid; +import com.fr.grid.GridColumn; +import com.fr.grid.GridCorner; +import com.fr.grid.GridRow; import com.fr.page.ReportSettingsProvider; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.FormElementCase; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; import javax.swing.JComponent; import javax.swing.JPanel; +import java.awt.Insets; +import java.awt.Rectangle; /** */ public class FormElementCasePaneDelegate extends ElementCasePane{ + public FormElementCasePaneDelegate(FormElementCase sheet, Form form) { super(sheet); - this.getGrid().setPaginateLineShowType(form.getFormMobileAttr().isMobileOnly() ? Grid.SINGLE_HORIZONTAL_PAGINATE_LINE : Grid.NO_PAGINATE_LINE); @@ -55,6 +63,42 @@ public class FormElementCasePaneDelegate extends ElementCasePane tableDataWrapperMap = + DesignTableDataManager.getAllEditingDataSet(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); + TableDataWrapper tableDataWrapper = tableDataWrapperMap.get(dsColumn.getDSName()); + if (tableDataWrapper != null) { + java.util.List columnNameList = tableDataWrapper.calculateColumnNameList(); + String[] columnNames = new String[columnNameList.size()]; + columnNameList.toArray(columnNames); + cellDSColumnSortItemPane.sortAreaUiComboBox.removeAllItems(); + for (String columnName : columnNames) { + cellDSColumnSortItemPane.sortAreaUiComboBox.addItem(columnName); + } + } + cellDSColumnSortItemPane.populateBean(sortExpression); + return cellDSColumnSortItemPane; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortItemPane.java b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortItemPane.java new file mode 100644 index 000000000..044d284a7 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortItemPane.java @@ -0,0 +1,40 @@ +package com.fr.design.sort.celldscolumn; + +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.sort.common.AbstractSortItemPane; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.report.core.sort.sortexpression.SortExpression; + +import javax.swing.*; +import java.awt.*; + + +public class CellDSColumnSortItemPane extends AbstractSortItemPane { + + UIComboBox sortAreaUiComboBox; + + public CellDSColumnSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) { + super(sortItemPaneWidth, sortItemPaneRightWidth); + } + + @Override + public void initMainSortAreaPane(JPanel sortAreaPane) { + sortAreaUiComboBox = new UIComboBox(new String[0]); + sortAreaUiComboBox.setPreferredSize(new Dimension(sortItemPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + sortAreaPane.add(sortAreaUiComboBox); + } + + public void populateBean(SortExpression sortExpression) { + sortAreaUiComboBox.setSelectedItem(sortExpression.getSortArea()); + super.populateBean(sortExpression); + } + + public SortExpression updateBean() { + SortExpression sortExpression = super.updateBean(); + if (sortExpression != null) { + sortExpression.setSortArea(sortAreaUiComboBox.getSelectedItem().toString()); + } + return sortExpression; + } + +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortPane.java b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortPane.java new file mode 100644 index 000000000..aec9c0bcc --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/celldscolumn/CellDSColumnSortPane.java @@ -0,0 +1,59 @@ +package com.fr.design.sort.celldscolumn; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.general.data.TableDataColumn; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.core.sort.common.CellSortAttr; + +import javax.swing.*; + + +public class CellDSColumnSortPane extends AbstractSortPane { + + public CellDSColumnSortPane() { + super(220, 150); + //this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + } + + @Override + protected void initSortGroupPane() { + sortGroupPane = new CellDSColumnSortGroupPane(sortPaneWidth, sortPaneRightWidth); + this.add(sortGroupPane); + } + + @Override + protected CellSortAttr getCellSortAttr(TemplateCellElement cellElement) { + if (cellElement.getValue() instanceof DSColumn) { + DSColumn dsColumn = ((DSColumn) cellElement.getValue()); + if (dsColumn.getCellSortAttr() == null) { + dsColumn.setCellSortAttr(new CellSortAttr()); + } + return dsColumn.getCellSortAttr(); + } + return null; + } + + protected void populateSortArea(TemplateCellElement cellElement) { + super.populateSortArea(cellElement); + if (cellElement.getValue() instanceof DSColumn) { + DSColumn dsColumn = ((DSColumn) cellElement.getValue()); + TableDataColumn tableDataColumn = dsColumn.getColumn(); + if (tableDataColumn instanceof TableDataColumn) { + selfSortArea = TableDataColumn.getColumnName(tableDataColumn); + } + } + } + + public void populateBean(TemplateCellElement cellElement) { + if (cellElement.getValue() instanceof DSColumn) { + DSColumn dsColumn = ((DSColumn) cellElement.getValue()); + if (sortGroupPane != null) { + ((CellDSColumnSortGroupPane) sortGroupPane).populateDsColumn(dsColumn); + } + } + super.populateBean(cellElement); + } + +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortGroupPane.java b/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortGroupPane.java new file mode 100644 index 000000000..62cb37e91 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortGroupPane.java @@ -0,0 +1,19 @@ +package com.fr.design.sort.cellexpand; + +import com.fr.design.sort.common.AbstractSortGroupPane; +import com.fr.design.sort.common.AbstractSortItemPane; +import com.fr.report.core.sort.sortexpression.SortExpression; + +public class CellExpandSortGroupPane extends AbstractSortGroupPane { + + public CellExpandSortGroupPane(int sortGroupPaneWidth, int sortGroupPaneRightWidth) { + super(sortGroupPaneWidth, sortGroupPaneRightWidth); + } + + @Override + protected AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression) { + AbstractSortItemPane abstractSortItemPane = new CellExpandSortItemPane( sortItemPaneWidth, sortItemPaneRightWidth); + abstractSortItemPane.populateBean(sortExpression); + return abstractSortItemPane; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortItemPane.java b/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortItemPane.java new file mode 100644 index 000000000..4b14dc692 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortItemPane.java @@ -0,0 +1,37 @@ +package com.fr.design.sort.cellexpand; + +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.design.sort.common.SortColumnRowPane; +import com.fr.design.sort.common.AbstractSortItemPane; +import com.fr.report.core.sort.sortexpression.SortExpression; +import com.fr.stable.ColumnRow; + +import javax.swing.*; + +public class CellExpandSortItemPane extends AbstractSortItemPane { + SortColumnRowPane columnRowPane; + + public CellExpandSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) { + super(sortItemPaneWidth, sortItemPaneRightWidth); + } + + @Override + public void initMainSortAreaPane(JPanel sortAreaPane) { + columnRowPane = new SortColumnRowPane(sortItemPaneRightWidth + 4, AbstractSortPane.PANE_COMPONENT_HEIGHT); + sortAreaPane.add(columnRowPane); + } + + public void populateBean(SortExpression sortExpression) { + columnRowPane.populateBean(ColumnRow.valueOf(sortExpression.getSortArea())); + super.populateBean(sortExpression); + } + + public SortExpression updateBean() { + SortExpression sortExpression = super.updateBean(); + if (sortExpression != null) { + ColumnRow columnRow = columnRowPane.updateBean(); + sortExpression.setSortArea(columnRow == null ? null : columnRow.toString()); + } + return sortExpression; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortPane.java b/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortPane.java new file mode 100644 index 000000000..5bfc20eea --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/cellexpand/CellExpandSortPane.java @@ -0,0 +1,39 @@ +package com.fr.design.sort.cellexpand; + + +import com.fr.design.mainframe.cell.settingpane.CellExpandAttrPane; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellExpandAttr; +import com.fr.report.core.sort.common.CellSortAttr; + + +import javax.swing.*; + +public class CellExpandSortPane extends AbstractSortPane { + CellExpandAttrPane cellExpandAttrPane; + + public CellExpandSortPane(CellExpandAttrPane cellExpandAttrPane) { + super(227, 155); + this.cellExpandAttrPane = cellExpandAttrPane; + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + } + + @Override + protected void initSortGroupPane() { + sortGroupPane = new CellExpandSortGroupPane(sortPaneWidth, sortPaneRightWidth); + this.add(sortGroupPane); + } + + @Override + protected CellSortAttr getCellSortAttr(TemplateCellElement cellElement) { + CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); + if (cellExpandAttr != null) { + if (cellExpandAttr.getCellSortAttr() == null) { + cellExpandAttr.setCellSortAttr(new CellSortAttr()); + } + return cellExpandAttr.getCellSortAttr(); + } + return null; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java new file mode 100644 index 000000000..6cdde9eb4 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortGroupPane.java @@ -0,0 +1,151 @@ +package com.fr.design.sort.common; + +import com.fr.base.svg.IconUtils; +import com.fr.design.event.ComponentChangeListener; +import com.fr.design.event.ComponentChangeObserver; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.report.core.sort.sortexpression.CellSortExpression; +import com.fr.report.core.sort.sortexpression.SortExpression; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + + +public abstract class AbstractSortGroupPane extends JPanel implements ComponentChangeObserver { + + private static final int SECOND_SORT_LENGTH_REDUCTION = 13; + + protected int sortGroupPaneWidth; + protected int sortGroupPaneRightWidth; + List sortExpressions; + List sortItemPanes = new ArrayList<>(); + AddSortItemBar addSortItemBar; + JPanel sortItemListPane; + UIButton uiButton; + String selfSortArea; + + ComponentChangeListener componentChangeListener; + + public AbstractSortGroupPane(int sortGroupPaneWidth, int sortGroupPaneRightWidth) { + this.sortGroupPaneRightWidth = sortGroupPaneRightWidth; + this.sortGroupPaneWidth = sortGroupPaneWidth; + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + initComponents(); + } + + private void initComponents() { + addSortItemBar = new AddSortItemBar(this); + sortItemListPane = new JPanel(); + sortItemListPane.setLayout(new BoxLayout(sortItemListPane, BoxLayout.Y_AXIS)); + this.add(sortItemListPane); + this.add(addSortItemBar); + } + + public void populateBean(List sortExpressions, String selfSortArea) { + this.sortItemListPane.removeAll(); + this.selfSortArea = selfSortArea; + this.sortExpressions = sortExpressions; + this.sortItemPanes = new ArrayList<>(); + for (int i = 0; i < sortExpressions.size(); i++) { + addSortItem(sortExpressions.get(i), i == 0); + } + refresh(); + } + + protected abstract AbstractSortItemPane refreshSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth, SortExpression sortExpression); + + public List updateBean() { + List sortExpressions = new ArrayList<>(); + for (JPanel sortItemPane : sortItemPanes) { + SortExpression sortExpression = null; + AbstractSortItemPane abstractSortItemPane = null; + if (sortItemPane instanceof AbstractSortItemPane) { + abstractSortItemPane = (AbstractSortItemPane) sortItemPane; + } else if (sortItemPane instanceof SortUIExpandablePane) { + abstractSortItemPane = (AbstractSortItemPane) ((SortUIExpandablePane) sortItemPane).getContentPane(); + } + if (abstractSortItemPane != null) { + sortExpression = abstractSortItemPane.updateBean(); + } + if (sortExpression != null) { + sortExpressions.add(sortExpression); + } + } + return sortExpressions; + } + + + public void removeSortItem(int no) { + if (no < sortExpressions.size()) { + sortItemListPane.remove(sortItemPanes.get(no)); + sortExpressions.remove(no); + sortItemPanes.remove(no); + refresh(); + } + } + + public void registerChangeListener(ComponentChangeListener componentChangeListener) { + this.componentChangeListener = componentChangeListener; + } + + public void addSortItem(SortExpression sortExpression, boolean mainSort) { + int sortItemPaneWidth = sortGroupPaneWidth; + int sortItemPaneRightWidth = sortGroupPaneRightWidth; + if (!mainSort) { + sortItemPaneWidth -= SECOND_SORT_LENGTH_REDUCTION; + sortItemPaneRightWidth -= SECOND_SORT_LENGTH_REDUCTION; + } + if (sortExpression == null) { + sortExpression = new CellSortExpression(selfSortArea); + sortExpressions.add(sortExpression); + } + + AbstractSortItemPane abstractSortItemPane = + refreshSortItemPane(sortItemPaneWidth, sortItemPaneRightWidth, sortExpression); + + JPanel sortItemPane = abstractSortItemPane; + if (!mainSort) { + sortItemPane = new SortUIExpandablePane(abstractSortItemPane, this); + } + sortItemListPane.add(sortItemPane); + sortItemPanes.add(sortItemPane); + + if (componentChangeListener != null) { + componentChangeListener.initListener(sortItemPane); + } + refresh(); + } + + protected void refresh() { + validate(); + repaint(); + revalidate(); + } + + class AddSortItemBar extends JPanel { + AbstractSortGroupPane sortGroupPane; + + AddSortItemBar(AbstractSortGroupPane sortGroupPane) { + init(); + this.sortGroupPane = sortGroupPane; + this.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5)); + } + + void init() { + uiButton = new UIButton(Toolkit.i18nText("Fine-Design_Sort_Add_Second_Sort"), + IconUtils.readIcon("/com/fr/design/images/sort/add.png")); + uiButton.setPreferredSize(new Dimension(sortGroupPaneWidth - 4, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + this.add(uiButton); + uiButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + sortGroupPane.addSortItem(null, false); + } + }); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortItemPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortItemPane.java new file mode 100644 index 000000000..82d14bb7e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortItemPane.java @@ -0,0 +1,153 @@ +package com.fr.design.sort.common; + +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.sort.expressionpane.CellSortExpressionPane; +import com.fr.design.sort.expressionpane.CustomSequenceSortExpressionPane; +import com.fr.design.sort.expressionpane.FormulaSortExpressionPane; +import com.fr.design.sort.expressionpane.SortExpressionPane; +import com.fr.report.core.sort.sortexpression.SortExpression; +import com.fr.report.core.sort.common.SortRule; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +public abstract class AbstractSortItemPane extends JPanel { + protected int sortItemPaneWidth; + protected int sortItemPaneRightWidth; + List sortExpressionPanes = new ArrayList<>(); + SortExpressionPane currentSortExpressionPane = null; + JPanel sortBasisPanel = null; + UIComboBox sortRuleUiComboBox; + UIComboBox sortBasisUiComboBox; + JPanel sortAreaPane; + JPanel sortRulePane; + + public AbstractSortItemPane(int sortItemPaneWidth, int sortItemPaneRightWidth) { + this.sortItemPaneWidth = sortItemPaneWidth; + this.sortItemPaneRightWidth = sortItemPaneRightWidth; + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + registerSortExpressionPanes(); + initComponents(); + } + + private void initComponents() { + initSortAreaPane(); + initSortBasisPanel(); + initSortRulePane(); + } + + private void registerSortExpressionPanes() { + sortExpressionPanes.add(new CellSortExpressionPane(sortItemPaneRightWidth)); + sortExpressionPanes.add(new FormulaSortExpressionPane(sortItemPaneRightWidth)); + sortExpressionPanes.add(new CustomSequenceSortExpressionPane(sortItemPaneWidth, sortItemPaneRightWidth)); + } + + void initSortAreaPane() { + sortAreaPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, AbstractSortPane.PANE_COMPONENT_V_GAP)); + sortAreaPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Sort_Sort_Area"), SwingConstants.LEFT)); + sortAreaPane.add(AbstractSortPane.createIntervalUILabel()); + initMainSortAreaPane(sortAreaPane); + this.add(sortAreaPane); + } + + public abstract void initMainSortAreaPane(JPanel sortAreaPane); + + void initSortRulePane() { + sortRulePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, AbstractSortPane.PANE_COMPONENT_V_GAP)); + sortRuleUiComboBox = new UIComboBox(new String[]{SortRule.ASC.getDescription(), + SortRule.DES.getDescription(), SortRule.NO_SORT.getDescription()}); + sortRuleUiComboBox.setPreferredSize(new Dimension(sortItemPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + sortRulePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Sort_Sort_Rule"), SwingConstants.LEFT)); + sortRulePane.add(AbstractSortPane.createIntervalUILabel()); + sortRulePane.add(sortRuleUiComboBox); + this.add(sortRulePane); + } + + void initSortBasisPanel() { + sortBasisPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, AbstractSortPane.PANE_COMPONENT_V_GAP)); + sortBasisUiComboBox = new UIComboBox(getSortNames()); + sortBasisUiComboBox.setPreferredSize(new Dimension(sortItemPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + sortBasisUiComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + if (sortExpressionPanes.get(sortBasisUiComboBox.getSelectedIndex()) != currentSortExpressionPane) { + if (currentSortExpressionPane != null) { + currentSortExpressionPane.setVisible(false); + } + currentSortExpressionPane = sortExpressionPanes.get(sortBasisUiComboBox.getSelectedIndex()); + refreshCurrentSortExpressionPane(); + } + } + }); + sortBasisPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Sort_Sort_Basis"), SwingConstants.LEFT)); + sortBasisPanel.add(AbstractSortPane.createIntervalUILabel()); + sortBasisPanel.add(sortBasisUiComboBox); + this.add(sortBasisPanel); + for (SortExpressionPane sortExpressionPane : sortExpressionPanes) { + this.add(sortExpressionPane); + sortExpressionPane.setVisible(false); + } + } + + private void refreshCurrentSortExpressionPane() { + currentSortExpressionPane.setVisible(true); + sortAreaPane.setVisible(currentSortExpressionPane.needSortArea()); + sortRulePane.setVisible(currentSortExpressionPane.needSortRule()); + } + + private String[] getSortNames() { + String[] sortNames = new String[sortExpressionPanes.size()]; + for (int i = 0; i < sortExpressionPanes.size(); i++) { + sortNames[i] = sortExpressionPanes.get(i).getSortName(); + } + return sortNames; + } + + public void populateBean(SortExpression sortExpression) { + if (sortExpression.getSortRule() == SortRule.ASC) { + sortRuleUiComboBox.setSelectedIndex(0); + } else if (sortExpression.getSortRule() == SortRule.DES) { + sortRuleUiComboBox.setSelectedIndex(1); + } else if (sortExpression.getSortRule() == SortRule.NO_SORT) { + sortRuleUiComboBox.setSelectedIndex(2); + } + for (int i = 0; i < sortExpressionPanes.size(); i++) { + if (StringUtils.equals(sortExpression.getSortName(), sortExpressionPanes.get(i).getSortName())) { + if (currentSortExpressionPane != null) { + currentSortExpressionPane.setVisible(false); + } + currentSortExpressionPane = sortExpressionPanes.get(i); + currentSortExpressionPane.populateBean(sortExpression); + sortBasisUiComboBox.setSelectedIndex(i); + refreshCurrentSortExpressionPane(); + break; + } + } + refresh(); + } + + public SortExpression updateBean() { + SortExpression sortExpression = currentSortExpressionPane.updateBean(); + if (sortExpression != null) { + String sortRule = sortRuleUiComboBox.getSelectedItem().toString(); + if (StringUtils.isNotBlank(sortRule)) { + sortExpression.setSortRule(SortRule.parse(sortRule)); + } + } + return sortExpression; + } + + protected void refresh() { + validate(); + repaint(); + revalidate(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java new file mode 100644 index 000000000..bfddee38c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/common/AbstractSortPane.java @@ -0,0 +1,113 @@ +package com.fr.design.sort.common; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.sort.header.SortHeaderPane; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.core.sort.common.CellSortAttr; +import com.fr.report.core.sort.sortexpression.CellSortExpression; +import com.fr.report.core.sort.sortexpression.SortExpression; +import com.fr.report.core.sort.header.SortHeader; +import com.fr.stable.ColumnRow; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + + +public abstract class AbstractSortPane extends JPanel { + protected int sortPaneWidth; + protected int sortPaneRightWidth; + public static final int PANE_COMPONENT_HEIGHT = 20; + public static final int PANE_COMPONENT_V_GAP = 4; + public static final int PANE_COMPONENT_H_GAP = 14; + protected AbstractSortGroupPane sortGroupPane; + protected SortHeaderPane sortHeaderPane; + protected String selfSortArea; + protected String defaultHeaderArea; + + public AbstractSortPane(int sortPaneWidth, int sortPaneRightWidth) { + this.sortPaneWidth = sortPaneWidth; + this.sortPaneRightWidth = sortPaneRightWidth; + initComponents(); + } + + private void initComponents() { + initSortGroupPane(); + if (needSortHeaderPane()) { + sortHeaderPane = new SortHeaderPane(sortPaneWidth, sortPaneRightWidth + 5); + this.add(sortHeaderPane); + } + } + + protected abstract void initSortGroupPane(); + + + protected boolean needSortHeaderPane() { + return true; + } + + protected abstract CellSortAttr getCellSortAttr(TemplateCellElement cellElement); + + public void populateBean(TemplateCellElement cellElement) { + populateSortArea(cellElement); + List sortExpressions = null; + CellSortAttr cellSortAttr = getCellSortAttr(cellElement); + if (cellSortAttr != null) { + sortExpressions = cellSortAttr.getSortExpressions(); + } + if (sortExpressions == null || sortExpressions.size() == 0) { + sortExpressions = new ArrayList<>(); + sortExpressions.add(new CellSortExpression(selfSortArea)); + } + sortGroupPane.populateBean(sortExpressions, selfSortArea); + if (needSortHeaderPane()) { + SortHeader sortHeader = null; + if (cellSortAttr != null) { + sortHeader = cellSortAttr.getSortHeader(); + } + sortHeaderPane.populateBean(sortHeader, defaultHeaderArea); + } + refresh(); + } + + protected void populateSortArea(TemplateCellElement cellElement) { + int row = cellElement.getRow(); + int column = cellElement.getColumn(); + selfSortArea = ColumnRow.valueOf(column, row).toString(); + if (row > 1) { + defaultHeaderArea = ColumnRow.valueOf(column, row - 1).toString(); + } else { + defaultHeaderArea = null; + } + } + + public void updateBean(TemplateCellElement cellElement) { + List sortExpressions = sortGroupPane.updateBean(); + CellSortAttr cellSortAttr = getCellSortAttr(cellElement); + cellSortAttr.setSortExpressions(sortExpressions); + if (needSortHeaderPane()) { + SortHeader sortHeader = sortHeaderPane.updateBean(); + if (sortHeader != null) { + sortHeader.setSortArea(selfSortArea); + } + cellSortAttr.setSortHeader(sortHeader); + } + } + + protected void refresh() { + validate(); + repaint(); + revalidate(); + } + + public static UILabel createIntervalUILabel() { + return createIntervalUILabel(PANE_COMPONENT_H_GAP); + } + + public static UILabel createIntervalUILabel(int vGap) { + UILabel uiLabel = new UILabel(); + uiLabel.setPreferredSize(new Dimension(vGap, 10)); + return uiLabel; + } +} 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 new file mode 100644 index 000000000..cc276711a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortColumnRowPane.java @@ -0,0 +1,276 @@ +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.selection.SelectionEvent; +import com.fr.design.selection.SelectionListener; +import com.fr.design.ui.util.UIUtil; +import com.fr.general.Background; +import com.fr.grid.selection.CellSelection; +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; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class SortColumnRowPane extends JPanel implements UIObserver { + int paneWidth; + int paneHeight; + int jTextFieldWidth; + JTextField colJTextField; + JTextField rowJTextField; + UIButton selectButton; + private boolean isAlreadyAddListener = false; + private CellSelection oldSelection; + private SelectionListener gridSelectionChangeListener; + UIObserverListener uiObserverListener; + + public SortColumnRowPane(int paneWidth, int paneHeight) { + this.paneWidth = paneWidth; + this.paneHeight = paneHeight; + initComponents(); + } + + private void initComponents() { + initSize(); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + intUILabel(); + initTextField(); + initSelectButton(); + this.setSize(new Dimension(paneWidth, paneHeight)); + } + + void initSize() { + jTextFieldWidth = (paneWidth - 40) / 2; + } + + void intUILabel() { + UILabel uiLabel = new UILabel(IconUtils.readIcon("/com/fr/design/images/buttonicon/propertiestab/cellelement_normal.png")); + this.add(uiLabel); + } + + public static boolean isAvailableColumnRow(ColumnRow columnRow) { + return columnRow != null && columnRow.getRow() != -1 && columnRow.getColumn() != -1; + } + + void initTextField() { + colJTextField = new JTextField(); + colJTextField.setEditable(false); + rowJTextField = new JTextField(); + rowJTextField.setEditable(false); + colJTextField.setPreferredSize(new Dimension(jTextFieldWidth, paneHeight)); + rowJTextField.setPreferredSize(new Dimension(jTextFieldWidth, paneHeight)); + this.add(colJTextField); + this.add(rowJTextField); + } + + void initSelectButton() { + selectButton = new UIButton(IconUtils.readIcon("/com/fr/design/images/buttonicon/select.png")); + selectButton.addMouseListener(new SelectActionListener(this)); + this.add(selectButton); + } + + public void populateBean(ColumnRow columnRow) { + if (SortColumnRowPane.isAvailableColumnRow(columnRow)) { + colJTextField.setText(EssentialUtils.convertIntToABC(columnRow.column + 1)); + rowJTextField.setText(String.valueOf(columnRow.row + 1)); + } else { + colJTextField.setText(StringUtils.EMPTY); + rowJTextField.setText(StringUtils.EMPTY); + } + refresh(); + } + + public void setColumnRow(ColumnRow columnRow) { + populateBean(columnRow); + uiObserverListener.doChange(); + } + + public ColumnRow updateBean() { + if (StringUtils.isNotBlank(colJTextField.getText()) && StringUtils.isNotBlank(rowJTextField.getText())) { + return ColumnRow.valueOf(colJTextField.getText() + rowJTextField.getText()); + } + return null; + } + + @Override + public void registerChangeListener(UIObserverListener listener) { + this.uiObserverListener = listener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + + class SelectActionListener extends MouseAdapter { + SortColumnRowPane columnRowPane; + + Map disableHeaderCellsStyleMap = new HashMap<>(); + java.util.List tempHeaderCells = new ArrayList<>(); + + SelectActionListener(SortColumnRowPane columnRowPane) { + this.columnRowPane = columnRowPane; + } + + @Override + public void mouseClicked(MouseEvent e) { + ElementCasePane elementCasePane = getCurrentElementCase(); + if (elementCasePane == null || isAlreadyAddListener) { + return; + } + prepareSelectHeader(elementCasePane); + gridSelectionChangeListener = new SelectionListener() { + @Override + public void selectionChanged(SelectionEvent e) { + completeSelectHeader(elementCasePane); + } + }; + elementCasePane.addSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = true; + } + + private void prepareSelectHeader(ElementCasePane elementCasePane) { + ashDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + oldSelection = (CellSelection) elementCasePane.getSelection(); + elementCasePane.getGrid().setNotShowingTableSelectPane(false); + elementCasePane.setEditable(false); + elementCasePane.repaint(10); + } + + private void completeSelectHeader(ElementCasePane elementCasePane) { + Selection selection = elementCasePane.getSelection(); + if (selection instanceof CellSelection) { + CellSelection cellselection = (CellSelection) selection; + ColumnRow columnRow = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); + elementCasePane.setOldSelecton(oldSelection); + oldSelection.getQuickEditor(elementCasePane); + if (!disableHeaderCellsStyleMap.keySet().contains(columnRow)) { + columnRowPane.setColumnRow(columnRow); + } + restoreDisableHeaderCellsStyle(elementCasePane.getEditingElementCase()); + } + elementCasePane.removeSelectionChangeListener(gridSelectionChangeListener); + isAlreadyAddListener = false; + elementCasePane.getGrid().setNotShowingTableSelectPane(true); + elementCasePane.setEditable(true); + elementCasePane.repaint(); + } + + private void ashDisableHeaderCellsStyle(TemplateElementCase elementCase) { + disableHeaderCellsStyleMap = new HashMap<>(); + tempHeaderCells = new ArrayList<>(); + Map disableHeaderCellsMap = getDisableHeaderCellsMap(elementCase); + for (ColumnRow headerColumnRow : disableHeaderCellsMap.keySet()) { + TemplateCellElement headerCell = disableHeaderCellsMap.get(headerColumnRow); + if (headerCell == null) { + headerCell = new DefaultTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + elementCase.addCellElement(headerCell); + tempHeaderCells.add(headerCell); + } + Style style = headerCell.getStyle(); + disableHeaderCellsStyleMap.put(headerColumnRow, style); + style = style.deriveBackground(ColorBackground.getInstance(Color.gray)); + headerCell.setStyle(style); + } + } + + private void restoreDisableHeaderCellsStyle(TemplateElementCase elementCase) { + try { + for (ColumnRow headerColumnRow : disableHeaderCellsStyleMap.keySet()) { + TemplateCellElement headerTemplateCellElement + = elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + headerTemplateCellElement.setStyle(disableHeaderCellsStyleMap.get(headerColumnRow)); + } + for (TemplateCellElement templateCellElement : tempHeaderCells) { + elementCase.removeCellElement(templateCellElement); + } + disableHeaderCellsStyleMap = new HashMap<>(); + tempHeaderCells = new ArrayList<>(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + } + + private Map getDisableHeaderCellsMap(TemplateElementCase elementCase) { + Map headerCellsMap = new HashMap<>(); + Iterator iterator = elementCase.cellIterator(); + while (iterator.hasNext()) { + TemplateCellElement templateCellElement = (TemplateCellElement) iterator.next(); + CellExpandAttr cellExpandAttr = templateCellElement.getCellExpandAttr(); + if (cellExpandAttr != null) { + handleDisableHeaderCell(elementCase, cellExpandAttr, headerCellsMap); + } + Object value = templateCellElement.getValue(); + if (value instanceof DSColumn) { + handleDisableHeaderCell(elementCase, (DSColumn) value, headerCellsMap); + } + } + return headerCellsMap; + } + + private void handleDisableHeaderCell(TemplateElementCase elementCase, CellSortable cellSortable, Map headerCellsMap) { + if (cellSortable.getCellSortAttr() != null) { + SortHeader sortHeader = cellSortable.getCellSortAttr().getSortHeader(); + if (sortHeader != null) { + String headerArea = sortHeader.getHeaderArea(); + if (headerArea != null) { + ColumnRow headerColumnRow = ColumnRow.valueOf(headerArea); + ColumnRow columnRow = columnRowPane.updateBean(); + if (!headerColumnRow.equals(columnRow)) { + TemplateCellElement headerCell + = elementCase.getTemplateCellElement(headerColumnRow.column, headerColumnRow.row); + headerCellsMap.put(headerColumnRow, headerCell); + } + } + } + } + } + + private ElementCasePane getCurrentElementCase() { + try { + TargetComponent targetComponent + = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); + if (targetComponent instanceof ElementCasePane) { + return (ElementCasePane) targetComponent; + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return null; + } + } + + + protected void refresh() { + validate(); + repaint(); + revalidate(); + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java b/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java new file mode 100644 index 000000000..3e9dece09 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/common/SortUIExpandablePane.java @@ -0,0 +1,101 @@ +package com.fr.design.sort.common; + +import com.fr.base.BaseUtils; +import com.fr.base.svg.IconUtils; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + + +public class SortUIExpandablePane extends JPanel { + private static final long serialVersionUID = 1L; + private HeaderPane headerPane; + private AbstractSortItemPane contentPane; + private AbstractSortGroupPane sortGroupPane; + + private JPanel wrapPane; + + public JPanel getContentPane() { + return contentPane; + } + + public SortUIExpandablePane(AbstractSortItemPane contentPane, AbstractSortGroupPane sortGroupPane) { + super(); + this.sortGroupPane = sortGroupPane; + this.contentPane = contentPane; + initComponents(); + wrapPane.setBorder(BorderFactory.createLineBorder(Color.gray, 1)); + wrapPane.setBackground(Color.WHITE); + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5)); + } + + + private void initComponents() { + wrapPane = new JPanel(); + wrapPane.setLayout(new BorderLayout()); + headerPane = new HeaderPane(sortGroupPane); + headerPane.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + setContentPanelShow(!contentPane.isVisible()); + } + }); + headerPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray)); + contentPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + wrapPane.add(headerPane, BorderLayout.NORTH); + wrapPane.add(contentPane, BorderLayout.CENTER); + setContentPanelShow(true); + this.add(wrapPane); + } + + + private void setContentPanelShow(Boolean show) { + contentPane.setVisible(show); + headerPane.setShow(show); + } + + class HeaderPane extends JPanel { + UILabel iconUiLabel; + UILabel closeButton; + AbstractSortGroupPane sortGroupPane; + + HeaderPane(AbstractSortGroupPane sortGroupPane) { + this.sortGroupPane = sortGroupPane; + this.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 3)); + initComponents(); + } + + private void initComponents() { + iconUiLabel = new UILabel(); + this.add(iconUiLabel); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Second_Sort")); + this.add(uiLabel); + this.add(AbstractSortPane.createIntervalUILabel(114)); + + closeButton = new UILabel(IconUtils.readIcon("/com/fr/design/images/control/close.png")); + this.add(closeButton); + closeButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + sortGroupPane.removeSortItem(1); + } + }); + this.setPreferredSize(new Dimension(contentPane.sortItemPaneWidth + 7, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + } + + public void setShow(boolean show) { + if (show) { + iconUiLabel.setIcon(IconUtils.readIcon("/com/fr/design/images/sort/down_arrow.png")); + } else { + iconUiLabel.setIcon(IconUtils.readIcon("/com/fr/design/images/sort/left_arrow.png")); + } + } + + } + +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CellSortExpressionPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CellSortExpressionPane.java new file mode 100644 index 000000000..1381b92cf --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CellSortExpressionPane.java @@ -0,0 +1,32 @@ +package com.fr.design.sort.expressionpane; + +import com.fr.design.i18n.Toolkit; +import com.fr.locale.InterProviderFactory; +import com.fr.report.core.sort.sortexpression.CellSortExpression; + + +import java.awt.*; + + +public class CellSortExpressionPane extends SortExpressionPane { + public CellSortExpressionPane(int with) { + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + } + + @Override + public String getSortName() { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Sort_Cell"); + } + + @Override + public void populateBean(CellSortExpression cellSortExpression) { + + } + + @Override + public CellSortExpression updateBean() { + return new CellSortExpression(); + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceEditPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceEditPane.java new file mode 100644 index 000000000..a62acc413 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceEditPane.java @@ -0,0 +1,160 @@ +package com.fr.design.sort.expressionpane; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ilist.UIList; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.dnd.SerializableTransferable; +import com.fr.design.mainframe.share.ui.base.PlaceholderTextArea; +import com.fr.locale.InterProviderFactory; +import com.fr.report.core.sort.sortexpression.CustomSequenceSortExpression; + +import javax.swing.*; +import java.awt.*; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.util.ArrayList; +import java.util.List; + +public class CustomSequenceEditPane extends BasicPane { + java.util.List customSequence; + JPanel referenceSequencePanel; + JPanel editSequencePanel; + JTextArea jTextArea; + + CustomSequenceEditPane(java.util.List customSequence) { + this.customSequence = customSequence; + initComponents(); + } + + void initComponents() { + this.setLayout(new BorderLayout()); + initReferenceSequencePanel(); + initEditSequencePanel(); + } + + void initReferenceSequencePanel() { + referenceSequencePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Reference_Sequence")); + referenceSequencePanel.add(uiLabel); + UIScrollPane uiScrollPane = new UIScrollPane(getReferenceSequenceList()); + uiScrollPane.setPreferredSize(new Dimension(200, 300)); + referenceSequencePanel.add(uiScrollPane); + referenceSequencePanel.setPreferredSize(new Dimension(200, 400)); + this.add(referenceSequencePanel, BorderLayout.WEST); + } + + private UIList getReferenceSequenceList() { + UIList uiList = new UIList(getReferenceSequenceModel()); + new CustomSequenceEditDragSource(uiList, DnDConstants.ACTION_MOVE); + return uiList; + } + + private String[] getReferenceSequenceModel() { + List> customSequences = CustomSequenceSortExpression.getReferenceCustomSequences(); + String[] listModel = new String[customSequences.size()]; + for (int i = 0; i < customSequences.size(); i++) { + listModel[i] = CustomSequenceSortExpression.customSequenceToString(customSequences.get(i), ","); + } + return listModel; + } + + void initEditSequencePanel() { + editSequencePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Input_Sequence")); + editSequencePanel.add(uiLabel); + UILabel uiLabel2 = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Please_Interlace_Sequence_Elements")); + uiLabel2.setForeground(Color.lightGray); + editSequencePanel.add(uiLabel2); + jTextArea = getTextArea(); + UIScrollPane uiScrollPane = new UIScrollPane(jTextArea); + uiScrollPane.setPreferredSize(new Dimension(475, 300)); + editSequencePanel.add(uiScrollPane); + this.add(editSequencePanel, BorderLayout.CENTER); + + } + + + JTextArea getTextArea() { + PlaceholderTextArea placeholderTextArea = new PlaceholderTextArea(10, 10, getPlaceholderText()); + new CustomSequenceEditDropTarget(placeholderTextArea, CustomSequenceSortExpression.getReferenceCustomSequences()); + placeholderTextArea.setText(CustomSequenceSortExpression.customSequenceToString(customSequence, "\n")); + return placeholderTextArea; + } + + String getPlaceholderText() { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(Toolkit.i18nText("Fine-Design_Sort_Please_Interlace_Sequence_Elements_Such_As") + "\n"); + stringBuilder.append(Toolkit.i18nText("Fine-Design_Sort_Department_One") + "\n"); + stringBuilder.append(Toolkit.i18nText("Fine-Design_Sort_Department_Two") + "\n"); + stringBuilder.append(Toolkit.i18nText("Fine-Design_Sort_Department_Three") + "\n"); + return stringBuilder.toString(); + } + + @Override + protected String title4PopupWindow() { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Sort_Custom_Sequence"); + } + + + class CustomSequenceEditDragSource extends DragSourceAdapter implements DragGestureListener { + private DragSource source; + + public CustomSequenceEditDragSource(UIList uiList, int actions) { + source = new DragSource(); + source.createDefaultDragGestureRecognizer(uiList, actions, this); + } + + public void dragGestureRecognized(DragGestureEvent dge) { + Component comp = dge.getComponent(); + if (comp instanceof UIList) { + UIList uiList = (UIList) comp; + source.startDrag(dge, DragSource.DefaultLinkDrop, new SerializableTransferable(uiList.getSelectedIndex()), this); + } + } + } + + + class CustomSequenceEditDropTarget extends DropTargetAdapter { + java.util.List> customSequences = new ArrayList<>(); + + public CustomSequenceEditDropTarget(PlaceholderTextArea jPanel, java.util.List> customSequences) { + new DropTarget(jPanel, this); + this.customSequences = customSequences; + } + + @Override + public void drop(DropTargetDropEvent dtde) { + try { + Transferable transferable = dtde.getTransferable(); + DataFlavor[] dataFlavors = transferable.getTransferDataFlavors(); + if (dataFlavors.length == 1) { + Integer index = (Integer) transferable.getTransferData(dataFlavors[0]); + String text = ""; + java.util.List customSequence = customSequences.get(index); + for (int i = 0; i < customSequence.size(); i++) { + text += customSequence.get(i) + "\n"; + } + JTextArea jTextArea = (JTextArea) dtde.getDropTargetContext().getComponent(); + jTextArea.setText(text); + } + } catch (Exception e) { + + } + } + } + + public List updateBean() { + return CustomSequenceSortExpression.stringToCustomSequence(jTextArea.getText(), "\n"); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java new file mode 100644 index 000000000..50344f1b6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequencePane.java @@ -0,0 +1,64 @@ +package com.fr.design.sort.expressionpane; + +import com.fr.base.svg.IconUtils; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.report.core.sort.sortexpression.CustomSequenceSortExpression; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + + +public class CustomSequencePane extends JPanel { + protected UITextField textField; + protected UIButton button; + List customSequence; + + public CustomSequencePane(int width) { + this.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + this.initComponents(width); + } + + protected void initComponents(int width) { + textField = new UITextField(); + textField.setEditable(false); + textField.setPreferredSize(new Dimension(width - 20, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + Icon icon = IconUtils.readIcon("/com/fr/design/images/control/refresh.png"); + button = new UIButton(icon); + button.setBackground(Color.RED); + button.setOpaque(false); + button.setCursor(new Cursor(Cursor.HAND_CURSOR)); + button.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + CustomSequenceEditPane customSequenceEditPane = new CustomSequenceEditPane(customSequence); + customSequenceEditPane.showWindowWithCustomSize(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + customSequence = customSequenceEditPane.updateBean(); + textField.setText(CustomSequenceSortExpression.customSequenceToString(customSequence, ",")); + } + }, new Dimension(700, 400)).setVisible(true); + } + }); + button.setPreferredSize(new Dimension(20, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + + this.add(textField); + this.add(button); + } + + + public List updateBean() { + return customSequence; + } + + public void populateBean(List customSequence) { + this.customSequence = customSequence; + textField.setText(CustomSequenceSortExpression.customSequenceToString(customSequence, ",")); + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java new file mode 100644 index 000000000..69dac2a2a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/CustomSequenceSortExpressionPane.java @@ -0,0 +1,37 @@ +package com.fr.design.sort.expressionpane; + +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.locale.InterProviderFactory; +import com.fr.report.core.sort.sortexpression.CustomSequenceSortExpression; + +import javax.swing.*; +import java.awt.*; +import java.util.List; + + +public class CustomSequenceSortExpressionPane extends SortExpressionPane { + CustomSequencePane customSequencePane; + + public CustomSequenceSortExpressionPane(int width, int rightWidth) { + this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0)); + customSequencePane = new CustomSequencePane(rightWidth + 5); + this.add(customSequencePane); + } + + @Override + public String getSortName() { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Sort_Custom_Sequence"); + } + + @Override + public void populateBean(CustomSequenceSortExpression customSequenceSortExpression) { + List customSequence = customSequenceSortExpression.getCustomSequence(); + customSequencePane.populateBean(customSequence); + } + + @Override + public CustomSequenceSortExpression updateBean() { + List customSequence = customSequencePane.updateBean(); + return new CustomSequenceSortExpression(customSequence); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java new file mode 100644 index 000000000..3785a7e97 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/FormulaSortExpressionPane.java @@ -0,0 +1,42 @@ +package com.fr.design.sort.expressionpane; + +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.locale.InterProviderFactory; +import com.fr.report.core.sort.sortexpression.FormulaSortExpression; + +import java.awt.*; + +public class FormulaSortExpressionPane extends SortExpressionPane { + + TinyFormulaPane tinyFormulaPane; + + public FormulaSortExpressionPane(int width) { + this.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 0)); + tinyFormulaPane = new TinyFormulaPane(); + tinyFormulaPane.setPreferredSize(new Dimension(width + 5, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + this.add(tinyFormulaPane); + } + + @Override + public String getSortName() { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Sort_Formula"); + } + + @Override + public void populateBean(FormulaSortExpression formulaSortExpression) { + String formula = formulaSortExpression.getFormula(); + tinyFormulaPane.getUITextField().setText(formula); + } + + @Override + public FormulaSortExpression updateBean() { + String formula = tinyFormulaPane.getUITextField().getText(); + return new FormulaSortExpression(formula); + } + + public boolean needSortArea() { + return false; + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/expressionpane/SortExpressionPane.java b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/SortExpressionPane.java new file mode 100644 index 000000000..69af8464c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/expressionpane/SortExpressionPane.java @@ -0,0 +1,23 @@ +package com.fr.design.sort.expressionpane; + +import com.fr.report.core.sort.sortexpression.SortExpression; + +import javax.swing.*; + + +public abstract class SortExpressionPane extends JPanel { + + public abstract String getSortName(); + + public abstract void populateBean(T sortExpression); + + public abstract T updateBean(); + + public boolean needSortArea() { + return true; + } + + public boolean needSortRule() { + return true; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java new file mode 100644 index 000000000..68824f012 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderAreaPane.java @@ -0,0 +1,125 @@ +package com.fr.design.sort.header; + +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.design.sort.common.SortColumnRowPane; +import com.fr.stable.ColumnRow; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + + +public class HeaderAreaPane extends JPanel { + protected int headerAreaPaneWidth; + protected int headerAreaPaneRightWidth; + + AreaJLayeredPane areaJLayeredPane; + + HeaderAreaPane(int headerAreaPaneWidth, int headerAreaPaneRightWidth) { + this.headerAreaPaneWidth = headerAreaPaneWidth; + this.headerAreaPaneRightWidth = headerAreaPaneRightWidth; + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + initComponents(); + } + + void initComponents() { + initUILabel(); + initLayeredPane(); + } + + void initUILabel() { + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Header_Area"), SwingConstants.LEFT); + this.add(uiLabel); + this.add(AbstractSortPane.createIntervalUILabel()); + } + + void initLayeredPane() { + areaJLayeredPane = new AreaJLayeredPane(); + this.add(areaJLayeredPane); + } + + public void populateBean(ColumnRow columnRow) { + areaJLayeredPane.populateBean(columnRow); + } + + public ColumnRow updateBean() { + return areaJLayeredPane.updateBean(); + } + + class AreaJLayeredPane extends JPanel { + SortColumnRowPane columnRowPane; + JLayeredPane jLayeredPane; + UIComboBox uiComboBox; + + AreaJLayeredPane() { + this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + initComponents(); + } + + private void initComponents() { + initUIComboBox(); + initJLayeredPane(); + } + + + void initUIComboBox() { + uiComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Basic_None"), Toolkit.i18nText("Fine-Design_Basic_Custom")}); + uiComboBox.setSize(new Dimension(headerAreaPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + uiComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + setSortColumnRowPaneShow(uiComboBox.getSelectedIndex() == 1); + } + }); + } + + void setSortColumnRowPaneShow(boolean show) { + if (show) { + jLayeredPane.setLayer(columnRowPane, JLayeredPane.POPUP_LAYER); + jLayeredPane.setLayer(uiComboBox, JLayeredPane.MODAL_LAYER); + } else { + jLayeredPane.setLayer(uiComboBox, JLayeredPane.POPUP_LAYER); + jLayeredPane.setLayer(columnRowPane, JLayeredPane.MODAL_LAYER); + } + refresh(); + } + + void initJLayeredPane() { + jLayeredPane = new JLayeredPane(); + columnRowPane = new SortColumnRowPane(headerAreaPaneRightWidth - 18, AbstractSortPane.PANE_COMPONENT_HEIGHT); + jLayeredPane.setPreferredSize(new Dimension(headerAreaPaneRightWidth, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + jLayeredPane.add(columnRowPane, JLayeredPane.MODAL_LAYER); + jLayeredPane.add(uiComboBox, JLayeredPane.POPUP_LAYER); + this.add(jLayeredPane); + } + + public void populateBean(ColumnRow columnRow) { + if (SortColumnRowPane.isAvailableColumnRow(columnRow)) { + uiComboBox.setSelectedIndex(1); + } else { + uiComboBox.setSelectedIndex(0); + } + columnRowPane.populateBean(columnRow); + setSortColumnRowPaneShow(uiComboBox.getSelectedIndex() == 1); + } + + public ColumnRow updateBean() { + if (uiComboBox.getSelectedIndex() == 0) { + return null; + } else { + return columnRowPane.updateBean(); + } + } + + public void refresh() { + validate(); + repaint(); + revalidate(); + } + + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSettingPane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSettingPane.java new file mode 100644 index 000000000..f31c40929 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSettingPane.java @@ -0,0 +1,81 @@ +package com.fr.design.sort.header; + +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.sort.common.AbstractSortPane; +import com.fr.report.core.sort.header.SortHeader; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; + +public class HeaderSettingPane extends JPanel { + protected int headerSettingPaneWidth; + protected int headerSettingPaneRightWidth; + HeaderSortRulePane headerSortRulePane; + UICheckBox uiCheckBox; + + HeaderSettingPane(int headerSettingPaneWidth, int headerSettingPaneRightWidth) { + this.headerSettingPaneWidth = headerSettingPaneWidth; + this.headerSettingPaneRightWidth = headerSettingPaneRightWidth; + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + initComponents(); + } + + void initComponents() { + initUILabel(); + initHeaderSortRulePane(); + } + + void initUILabel() { + JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 2)); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Header_Setting")); + UILabel emptyUILabel = new UILabel(); + emptyUILabel.setPreferredSize(new Dimension(10, 10)); + + uiCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Sort_Allow_User_Click_Sort_Order")); + uiCheckBox.setPreferredSize(new Dimension(headerSettingPaneRightWidth - 10, AbstractSortPane.PANE_COMPONENT_HEIGHT)); + uiCheckBox.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + headerSortRulePane.setVisible(uiCheckBox.isSelected()); + } + }); + jPanel.add(uiLabel); + jPanel.add(emptyUILabel); + jPanel.add(uiCheckBox); + this.add(jPanel); + } + + void initHeaderSortRulePane() { + headerSortRulePane = new HeaderSortRulePane(); + this.add(headerSortRulePane); + headerSortRulePane.setVisible(false); + } + + protected void refresh() { + validate(); + repaint(); + revalidate(); + } + + public void populateBean(SortHeader.SortItem[] sortItems) { + if (sortItems == null) { + uiCheckBox.setSelected(false); + } else { + uiCheckBox.setSelected(true); + } + headerSortRulePane.populateBean(sortItems); + } + + public SortHeader.SortItem[] updateBean() { + if (uiCheckBox.isSelected()) { + return headerSortRulePane.updateBean(); + } else { + return null; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java new file mode 100644 index 000000000..2dcd3bc48 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/header/HeaderSortRulePane.java @@ -0,0 +1,234 @@ +package com.fr.design.sort.header; + +import com.fr.base.svg.SVGIcon; +import com.fr.base.svg.SVGTranscoder; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.theme.edit.ui.ColorListPane; +import com.fr.general.IOUtils; +import com.fr.report.core.sort.header.SortHeader; +import com.fr.report.core.sort.common.SortRule; +import org.apache.batik.transcoder.TranscoderInput; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; + +public class HeaderSortRulePane extends JPanel { + private static final String ASC_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/asc.svg"; + private static final String DES_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/des.svg"; + private static final String NOSORT_ICON_TEMPLATE_PATH = "/com/fr/design/images/sort/nosort.svg"; + IconButton ascIconButton; + IconButton desIconButton; + IconButton nosortIconButton; + UICheckBox ascUICheckBox; + UICheckBox desUICheckBox; + UICheckBox nosortUICheckBox; + + HeaderSortRulePane() { + initComponents(); + initState(); + this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15)); + } + + void initComponents() { + this.setLayout(new BorderLayout()); + initUILabel(); + initSortRuleItem(); + this.setPreferredSize(new Dimension(160, 160)); + } + + void initUILabel() { + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Sort_Header_Sort_Basis"), SwingConstants.LEFT); + this.add(uiLabel, BorderLayout.NORTH); + } + + void initSortRuleItem() { + Component[][] components = new Component[][]{ + new Component[]{ascUICheckBox = new UICheckBox(SortRule.ASC.getDescription()), ascIconButton = new IconButton(ASC_ICON_TEMPLATE_PATH)}, + new Component[]{desUICheckBox = new UICheckBox(SortRule.DES.getDescription()), desIconButton = new IconButton(DES_ICON_TEMPLATE_PATH)}, + new Component[]{nosortUICheckBox = new UICheckBox(SortRule.NO_SORT.getDescription()), nosortIconButton = new IconButton(NOSORT_ICON_TEMPLATE_PATH)}, + }; + double[] rowSize = {24, 24, 24}; + double[] columnSize = {80, 30}; + JPanel sortRuleItem = TableLayoutHelper.createCommonTableLayoutPane(components, rowSize, columnSize, 0); + this.add(sortRuleItem, BorderLayout.CENTER); + } + + void initState() { + ascUICheckBox.setSelected(false); + desUICheckBox.setSelected(false); + nosortUICheckBox.setSelected(false); + ascIconButton.refreshIconLabelColor(new Color(33, 33, 34)); + desIconButton.refreshIconLabelColor(new Color(33, 33, 34)); + nosortIconButton.refreshIconLabelColor(new Color(33, 33, 34)); + } + + class IconButton extends JPanel implements UIObserver { + JLayeredPane jLayeredPane; + String iconTemplatePath; + UILabel iconLabel; + ColorListPane.ColorButton colorButton; + Color color; + BufferedImage bufferedImage; + UIObserverListener uiObserverListener; + + IconButton(String iconTemplatePath) { + this.iconTemplatePath = iconTemplatePath; + initComponents(); + } + + void initComponents() { + jLayeredPane = new JLayeredPane(); + iconLabel = getIconLabel(iconTemplatePath); + + + UILabel emptyUiLabel = new UILabel(); + emptyUiLabel.setSize(16, 16); + emptyUiLabel.setOpaque(true); + emptyUiLabel.setBackground(Color.WHITE); + iconLabel.setSize(16, 16); + colorButton = new ColorListPane.ColorButton(Color.CYAN); + colorButton.setSize(16, 16); + colorButton.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + color = colorButton.getSelectObject(); + refreshIconLabelColor(color); + uiObserverListener.doChange(); + } + }); + jLayeredPane.setPreferredSize(new Dimension(16, 16)); + + jLayeredPane.add(iconLabel, JLayeredPane.POPUP_LAYER); + jLayeredPane.add(emptyUiLabel, JLayeredPane.MODAL_LAYER); + jLayeredPane.add(colorButton, JLayeredPane.PALETTE_LAYER); + this.add(jLayeredPane); + } + + void refreshIconLabelColor(Color color) { + Icon icon = getIcon(iconTemplatePath, color); + refreshIconLabel(icon); + } + + void refreshIconLabel(Icon icon) { + if (icon != null) { + iconLabel.removeAll(); + iconLabel.setIcon(icon); + iconLabel.repaint(); + } + } + + UILabel getIconLabel(String iconPath) { + return getIconLabel(iconPath, new Color(33, 33, 34)); + } + + UILabel getIconLabel(String iconPath, Color color) { + Icon svgIcon = getIcon(iconPath, color); + return new UILabel(svgIcon); + } + + Icon getIcon(String iconPath, Color color) { + try { + InputStream inputStream = IOUtils.getResourceAsStream(iconPath, HeaderSortRulePane.class); + String svgText = getSvgText(inputStream); + svgText = svgText.replaceAll("\\{fillColor\\}", shiftColor(color)); + InputStream svgInputStream = new ByteArrayInputStream(svgText.getBytes()); + TranscoderInput input = new TranscoderInput(svgInputStream); + bufferedImage = SVGTranscoder.createImage(1.0, input).getImage(); + SVGIcon svgIcon = new SVGIcon(bufferedImage); + return svgIcon; + } catch (Exception e) { + + } + return null; + + } + + String shiftColor(Color color) { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(shiftValue(color.getRed())); + stringBuilder.append(shiftValue(color.getGreen())); + stringBuilder.append(shiftValue(color.getBlue())); + return stringBuilder.toString(); + } + + String shiftValue(int value) { + int resultValue = (int) ((((float) value) / 255) * 99); + if (resultValue < 10) { + return "0" + resultValue; + } else { + return "" + resultValue; + } + } + + private String getSvgText(InputStream inputStream) throws Exception { + StringBuffer stringBuffer = new StringBuffer(); + byte[] b = new byte[1024]; + for (int n; (n = inputStream.read(b)) != -1; ) { + stringBuffer.append(new String(b, 0, n)); + } + return stringBuffer.toString(); + } + + @Override + public void registerChangeListener(UIObserverListener uiObserverListener) { + this.uiObserverListener = uiObserverListener; + } + + @Override + public boolean shouldResponseChangeListener() { + return true; + } + } + + public void populateBean(SortHeader.SortItem[] sortItems) { + initState(); + if (sortItems != null) { + for (SortHeader.SortItem sortItem : sortItems) { + SortRule sortRule = sortItem.getSortRule(); + BufferedImage bufferedImage = sortItem.getBufferedImage(); + Icon icon = null; + if (bufferedImage != null) { + icon = new SVGIcon(bufferedImage); + } + if (sortRule == SortRule.ASC) { + ascIconButton.refreshIconLabel(icon); + ascUICheckBox.setSelected(true); + } else if (sortRule == SortRule.DES) { + desIconButton.refreshIconLabel(icon); + desUICheckBox.setSelected(true); + } else if (sortRule == SortRule.NO_SORT) { + nosortIconButton.refreshIconLabel(icon); + nosortUICheckBox.setSelected(true); + } + + } + } + } + + public SortHeader.SortItem[] updateBean() { + java.util.List items = new ArrayList<>(); + if (ascUICheckBox.isSelected()) { + items.add(new SortHeader.SortItem(SortRule.ASC, ascIconButton.bufferedImage)); + } + if (desUICheckBox.isSelected()) { + items.add(new SortHeader.SortItem(SortRule.DES, desIconButton.bufferedImage)); + } + if (nosortUICheckBox.isSelected()) { + items.add(new SortHeader.SortItem(SortRule.NO_SORT, nosortIconButton.bufferedImage)); + } + SortHeader.SortItem[] resultItems = new SortHeader.SortItem[items.size()]; + return items.toArray(resultItems); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java b/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java new file mode 100644 index 000000000..7aecb3000 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/sort/header/SortHeaderPane.java @@ -0,0 +1,59 @@ +package com.fr.design.sort.header; + +import com.fr.report.core.sort.header.SortHeader; +import com.fr.stable.ColumnRow; + +import javax.swing.*; + +public class SortHeaderPane extends JPanel { + int sortHeaderPaneWidth; + int sortHeaderPaneRightWidth; + SortHeader sortHeader; + HeaderAreaPane headerAreaPane; + HeaderSettingPane headerSettingPane; + + public SortHeaderPane(int sortHeaderPaneWidth, int sortHeaderPaneRightWidth) { + this.sortHeaderPaneWidth = sortHeaderPaneWidth; + this.sortHeaderPaneRightWidth = sortHeaderPaneRightWidth; + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + initHeaderArea(); + initHeaderSetting(); + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + } + + void initHeaderArea() { + this.headerAreaPane = new HeaderAreaPane(sortHeaderPaneWidth, sortHeaderPaneRightWidth); + this.add(headerAreaPane); + } + + void initHeaderSetting() { + this.headerSettingPane = new HeaderSettingPane(sortHeaderPaneWidth, sortHeaderPaneRightWidth); + this.add(headerSettingPane); + } + + public void populateBean(SortHeader sortHeader, String defaultHeaderArea) { + this.sortHeader = sortHeader; + ColumnRow columnRow = null; + SortHeader.SortItem[] sortItems = null; + String headerArea = defaultHeaderArea; + if (sortHeader != null) { + headerArea = sortHeader.getHeaderArea(); + sortItems = sortHeader.getSortItems(); + } + columnRow = ColumnRow.valueOf(headerArea); + + headerAreaPane.populateBean(columnRow); + headerSettingPane.populateBean(sortItems); + } + + public SortHeader updateBean() { + ColumnRow columnRow = headerAreaPane.updateBean(); + SortHeader.SortItem[] items = headerSettingPane.updateBean(); + String headerArea = null; + if (columnRow != null) { + headerArea = columnRow.toString(); + } + SortHeader sortHeader = new SortHeader(headerArea, null, items); + return sortHeader; + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java b/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java index 53145b882..57f4440d0 100644 --- a/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java +++ b/designer-realize/src/main/java/com/fr/design/style/BorderUtils.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import com.fr.report.cell.CellElementBorderSourceFlag; +import com.fr.base.CellBorderSourceFlag; import com.fr.base.CellBorderStyle; import com.fr.base.NameStyle; import com.fr.base.Style; @@ -527,15 +527,20 @@ public abstract class BorderUtils { int cellColumnSpan = tmpCellElement.getColumnSpan(); int cellRow = tmpCellElement.getRow(); int cellRowSpan = tmpCellElement.getRowSpan(); - int borderSourceFlags = CellElementBorderSourceFlag.inspectBorderSourceFlag( + int borderSourceFlags = CellBorderSourceFlag.inspectBorderSourceFlag( column, row, column + columnSpan, row + rowSpan, cellColumn, cellRow, cellColumn + cellColumnSpan, cellRow + cellRowSpan ); - tmpCellElement.setBorderSourceFlags(borderSourceFlags); if (style instanceof NameStyle && !ThemedFeatureController.isCellStyleSupportInnerBorder()) { - tmpCellElement.setBorderSourceFlags(CellElementBorderSourceFlag.INVALID_BORDER_SOURCE); + borderSourceFlags = CellBorderSourceFlag.INVALID_BORDER_SOURCE; } - tmpCellElement.setStyle(style, newCellBorderStyle); + if (style instanceof NameStyle) { + ((NameStyle) style).refreshPassiveBorderStyle(newCellBorderStyle, borderSourceFlags); + } else { + style = CellBorderSourceFlag.deriveBorderedStyle(style, newCellBorderStyle, borderSourceFlags); + } + + tmpCellElement.setStyle(style); } } } diff --git a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java index 772c309c5..d9d5cbe53 100644 --- a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java @@ -4,7 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.ElementCasePane; @@ -36,6 +36,7 @@ import java.lang.reflect.Method; * @since 2012-3-23上午11:54:14 */ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { + protected static final int FUZZY_EDGE = 10; protected static final int SEPARATOR_GAP = 5; protected GridHeader gHeader; @@ -50,16 +51,12 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { private int dragIndex = 0; private JToolTip tip = null; private JWindow tipWindow = null; - protected int resolution = DesignerUIModeConfig.getInstance().getScreenResolution(); + protected int resolution; public AbstractGridHeaderMouseHandler(GridHeader gHeader) { this.gHeader = gHeader; - if (gHeader instanceof GridColumn){ - this.resolution = ((GridColumn)gHeader).getResolution(); - }else { - this.resolution = ((GridRow)gHeader).getResolution(); - } - } + this.resolution = gHeader.getResolution(); + } public void setStartMultiSelectIndex(int index) { this.startMultiSelectIndex = index; @@ -437,6 +434,35 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { tipWindow.repaint(); } + public int getDragIndex(MouseEvent evt) { + ElementCasePane elementCasePane = this.gHeader.getElementCasePane(); + DynamicUnitList sizeList = getSizeList(elementCasePane.getEditingElementCase()); + + int scrollValue = getScrollValue(elementCasePane); + int scrollExtent = getScrollExtent(elementCasePane); + int endValue = scrollValue + scrollExtent + 1; + + int beginValue = getBeginValue(elementCasePane); + + double tmpSize1 = 0; + double tmpSize2; + double tmpIncreaseSize = 0; + + for (int index = beginValue; index < endValue; index++) { + if (index == 0) { + index = scrollValue; + } + + tmpSize1 += tmpIncreaseSize; + tmpIncreaseSize = sizeList.get(index).toPixD(resolution); + tmpSize2 = tmpSize1 + Math.max(1, tmpIncreaseSize); + if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) { + return index; + } + } + return -1; + } + @Override public void mouseMoved(MouseEvent evt) { if (!gHeader.isEnabled()) { diff --git a/designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java b/designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java index 0b4c900e3..7e2d154c2 100644 --- a/designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java +++ b/designer-realize/src/main/java/com/fr/grid/DefaultGridUIProcessor.java @@ -1,10 +1,6 @@ package com.fr.grid; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.fit.grid.NewFormDesignerGridUI; import com.fr.design.fun.impl.AbstractGridUIProcessor; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.WidgetPropertyPane; import javax.swing.plaf.ComponentUI; @@ -15,11 +11,7 @@ public class DefaultGridUIProcessor extends AbstractGridUIProcessor { @Override public ComponentUI appearanceForGrid(int resolution) { - if (DesignerUIModeConfig.getInstance().newUIMode()) { - FormDesigner designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - return new NewFormDesignerGridUI(designer, resolution); - } return new GridUI(resolution); } -} +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/grid/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index dad41264c..e55fa70aa 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -13,6 +13,7 @@ import com.fr.design.cell.editor.GeneralFloatEditor; import com.fr.design.cell.editor.TextCellEditor; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.fit.grid.AdaptiveGridListener; import com.fr.design.fun.GridUIProcessor; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.DesignOperationEvent; @@ -51,6 +52,7 @@ import java.awt.Rectangle; import java.awt.Window; import java.awt.event.MouseEvent; import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; import java.util.Hashtable; import java.util.Iterator; @@ -140,27 +142,36 @@ public class Grid extends BaseGridComponent { // 是否绘制单元格内容区之外的网格线 private boolean showExtraGridLine = true; - public Grid(int resolution) { + protected int adsorbWidth; + + protected int adsorbHeight; + + public Grid(int resolution, int adsorbWidth, int adsorbHeight) { this.resolution = resolution; // 能触发processEvent,不管是否给component增加listener enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); GridKeyAction.initGridInputActionMap(this); - gridMouseAdapter = new GridMouseAdapter(this); + this.adsorbWidth = adsorbWidth; + this.adsorbHeight = adsorbHeight; + gridMouseAdapter = new GridMouseAdapter(this, adsorbWidth, adsorbHeight); this.addMouseListener(gridMouseAdapter); this.addMouseMotionListener(gridMouseAdapter); this.addMouseWheelListener(gridMouseAdapter); - this.addKeyListener(new GridKeyListener(this)); // JDK1.4 this.setFocusTraversalKeysEnabled(false); this.setOpaque(false); - this.updateUI(); } + public Grid(int resolution) { + this(resolution, 0, 0); + } + + public void setResolution(int resolution) { this.resolution = resolution; } @@ -1482,4 +1493,20 @@ public class Grid extends BaseGridComponent { public void setShowExtraGridLine(boolean showExtraGridLine) { this.showExtraGridLine = showExtraGridLine; } + + public int getAdsorbWidth() { + return adsorbWidth; + } + + public void setAdsorbWidth(int adsorbWidth) { + this.adsorbWidth = adsorbWidth; + } + + public int getAdsorbHeight() { + return adsorbHeight; + } + + public void setAdsorbHeight(int adsorbHeight) { + this.adsorbHeight = adsorbHeight; + } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridColumn.java b/designer-realize/src/main/java/com/fr/grid/GridColumn.java index eed4136d4..21355ccc6 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridColumn.java +++ b/designer-realize/src/main/java/com/fr/grid/GridColumn.java @@ -6,7 +6,7 @@ package com.fr.grid; import java.awt.Dimension; import com.fr.base.GraphHelper; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.stable.StableUtils; @@ -19,48 +19,49 @@ import com.fr.stable.StableUtils; public class GridColumn extends GridHeader { - private GridColumnMouseHandler gridColumnMouseHandler; + private GridColumnMouseHandler gridColumnMouseHandler; + private int adsorbWidth; - public GridColumn(int resolution) { - super(resolution); - } + public GridColumn(int resolution) { + this(resolution, 0); + } - @Override - protected void initByConstructor() { - gridColumnMouseHandler = new GridColumnMouseHandler(this); - this.addMouseListener(gridColumnMouseHandler); - this.addMouseMotionListener(gridColumnMouseHandler); - this.updateUI(); - } + public GridColumn(int resolution, int adsorbWidth) { + super(resolution); + this.adsorbWidth = adsorbWidth; + } + @Override + protected void initByConstructor() { + this.updateUI(); + } + @Override + public String getDisplay(int index) { + return StableUtils.convertIntToABC(index + 1); + } - @Override - public String getDisplay(int index) { - return StableUtils.convertIntToABC(index + 1); - } + @Override + public void updateUI() { + this.removeMouseListener(gridColumnMouseHandler); + this.removeMouseMotionListener(gridColumnMouseHandler); + gridColumnMouseHandler = new GridColumnMouseHandler(this, adsorbWidth); + this.addMouseListener(gridColumnMouseHandler); + this.addMouseMotionListener(gridColumnMouseHandler); + this.setUI(new GridColumnUI(resolution)); + } - @Override - public void updateUI() { - this.removeMouseListener(gridColumnMouseHandler); - this.removeMouseMotionListener(gridColumnMouseHandler); - gridColumnMouseHandler = new GridColumnMouseHandler(this); - this.addMouseListener(gridColumnMouseHandler); - this.addMouseMotionListener(gridColumnMouseHandler); - this.setUI(new GridColumnUI(resolution)); - } + /** + * Gets the preferred size. + */ + @Override + public Dimension getPreferredSize() { + ElementCasePane reportPane = this.getElementCasePane(); + float time = (float) reportPane.getResolution() / DesignerUIModeConfig.getInstance().getScreenResolution(); + if (!reportPane.isColumnHeaderVisible()) { + return new Dimension(0, 0); + } - /** - * Gets the preferred size. - */ - @Override - public Dimension getPreferredSize() { - ElementCasePane reportPane = this.getElementCasePane(); - float time = (float)reportPane.getResolution()/ DesignerUIModeConfig.getInstance().getScreenResolution(); - if (!reportPane.isColumnHeaderVisible()) { - return new Dimension(0, 0); - } - - return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST)); - } + return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST)); + } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java index bc5b54c90..a6b38dc81 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/GridColumnMouseHandler.java @@ -9,23 +9,34 @@ import java.awt.event.MouseEvent; import javax.swing.SwingUtilities; import com.fr.base.DynamicUnitList; import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.report.ReportHelper; import com.fr.report.elementcase.ElementCase; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; +import com.fr.stable.unit.FU; +import com.fr.stable.unit.UNIT; /** * peter:处理对GridColumn的Mouse事件. */ public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler { + private final int adsorbWidth; + public GridColumnMouseHandler(GridColumn gridColumn) { - super(gridColumn); - this.resolution = gridColumn.resolution; + this(gridColumn, 0); } + public GridColumnMouseHandler(GridColumn gridColumn, int adsorbWidth) { + super(gridColumn); + this.adsorbWidth = adsorbWidth; + this.resolution = gridColumn.resolution; + } + public void setResolution(int resolution){ this.resolution = resolution; } @@ -40,6 +51,24 @@ public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler { } } + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + if (this.adsorbWidth <= 0) { + return; + } + ElementCasePane elementCasePane = this.gHeader.getElementCasePane(); + TemplateElementCase editingElementCase = elementCasePane.getEditingElementCase(); + double adsorbWidthWithResolution = this.adsorbWidth * (resolution * 1D / DesignerUIModeConfig.getInstance().getScreenResolution()); + + int dragIndex = getDragIndex(e); + if (Math.abs(e.getX() - adsorbWidthWithResolution) < FUZZY_EDGE && dragIndex >= 0) { + UNIT oldValue = editingElementCase.getColumnWidth(dragIndex); + editingElementCase.setColumnWidth(dragIndex, oldValue.add(FU.valueOfPix((int) (adsorbWidthWithResolution- e.getX()), resolution))); + } + elementCasePane.repaint(); + } + protected int doChooseFrom() { return CellSelection.CHOOSE_COLUMN; diff --git a/designer-realize/src/main/java/com/fr/grid/GridColumnUI.java b/designer-realize/src/main/java/com/fr/grid/GridColumnUI.java index 088c8f220..6c401e925 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridColumnUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridColumnUI.java @@ -16,7 +16,7 @@ import com.fr.base.ScreenResolution; import com.fr.base.vcs.DesignerMode; import com.fr.cache.list.IntList; import com.fr.design.constants.UIConstants; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.grid.selection.Selection; diff --git a/designer-realize/src/main/java/com/fr/grid/GridCorner.java b/designer-realize/src/main/java/com/fr/grid/GridCorner.java index 4d1d393b7..2bbe3d9df 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridCorner.java +++ b/designer-realize/src/main/java/com/fr/grid/GridCorner.java @@ -4,9 +4,9 @@ package com.fr.grid; import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; + import com.fr.design.constants.UIConstants; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import javax.swing.event.MouseInputListener; diff --git a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java index c2c186114..45f774823 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java +++ b/designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java @@ -2,11 +2,10 @@ package com.fr.grid; import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; -import com.fr.base.ScreenResolution; import com.fr.base.vcs.DesignerMode; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.constants.UIConstants; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCasePane; @@ -78,8 +77,18 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous private int[] resizingBackupBounds = null; - protected GridMouseAdapter(Grid grid) { + private double adsorbWidth = 0D; + + private double adsorbHeight = 0D; + + private JWindow tipWindow = null; + private JToolTip tip = null; + + + protected GridMouseAdapter(Grid grid, double adsorbWidth, double adsorbHeight) { this.grid = grid; + this.adsorbWidth = adsorbWidth; + this.adsorbHeight = adsorbHeight; } /** @@ -330,8 +339,63 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous } lastMouseMoveTime = systemCurrentTime;// 记录最后一次的时间. mouseMoveOnGrid(evt.getX(), evt.getY()); + dealAdsorb(evt); } + private void dealAdsorb(final MouseEvent e) { + if (adsorbWidth <= 0 || adsorbHeight <= 0) { + return; + } + int verticalValue = grid.getVerticalValue(); + int horizontalValue = grid.getHorizontalValue(); + ElementCasePane reportPane = grid.getElementCasePane(); + TemplateElementCase report = reportPane.getEditingElementCase(); + DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); + DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); + double width = adsorbWidth * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution()) + - columnWidthList.getRangeValue(0, horizontalValue).toPixI(this.grid.getResolution()); + double height = adsorbHeight * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution()) + - rowHeightList.getRangeValue(0, verticalValue).toPixI(this.grid.getResolution()); + if (Math.abs(e.getX() - width) < 5 && e.getY() >= 0 && e.getY() < height) { + Point convertPoint = new Point((int) width, 0); + SwingUtilities.convertPointToScreen(convertPoint, grid); + showToolTip(grid, e, adsorbWidth + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), convertPoint); + return; + } else { + hideToolTip(); + } + if (Math.abs(e.getY() - height) < 5 && e.getX() >= 0 && e.getX() < width) { + Point convertPoint = new Point(0, (int) height); + SwingUtilities.convertPointToScreen(convertPoint, grid); + showToolTip(grid, e, adsorbHeight + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px"), convertPoint); + } else { + hideToolTip(); + } + } + + private void showToolTip(Grid grid, MouseEvent evt, String text, Point tipLocation) { + if (tipWindow == null) { + tipWindow = new JWindow(); + + + tip = grid.createToolTip(); + tip.setBorder(BorderFactory.createEmptyBorder()); + tipWindow.getContentPane().add(tip, BorderLayout.CENTER); + } + tip.setTipText(text); + tip.setForeground(Color.decode("#88ACC6")); + tipWindow.setLocation(tipLocation.x, tipLocation.y); + tipWindow.pack(); + tipWindow.setVisible(true); + } + + private void hideToolTip() { + if (tipWindow != null) { + tipWindow.setVisible(false); + } + } + + /** * @param evt */ @@ -879,7 +943,7 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous * @param e */ public void mouseWheelMoved(MouseWheelEvent e) { - + hideToolTip(); } /** @@ -898,5 +962,6 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous * @param e */ public void mouseExited(MouseEvent e) { + hideToolTip(); } } diff --git a/designer-realize/src/main/java/com/fr/grid/GridRow.java b/designer-realize/src/main/java/com/fr/grid/GridRow.java index a85c3c398..0ec5fdab2 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridRow.java +++ b/designer-realize/src/main/java/com/fr/grid/GridRow.java @@ -6,75 +6,74 @@ package com.fr.grid; import java.awt.Dimension; import com.fr.base.GraphHelper; -import com.fr.base.ScreenResolution; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.fit.DesignerUIModeConfig; -import com.fr.design.fun.GridUIProcessor; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; -import javax.swing.plaf.ComponentUI; - /** * GridRow used to paint and edit grid row. - * + * * @editor zhou * @since 2012-3-22下午6:12:03 */ public class GridRow extends GridHeader { - private static final int MAX = 4; - private GridRowMouseHandler gridRowMouseHandler; + private static final int MAX = 4; + private int adsorbHeight; + private GridRowMouseHandler gridRowMouseHandler; + + public GridRow(int resolution) { + this(resolution, 0); + } + + public GridRow(int resolution, int adsorbHeight) { + super(resolution); + this.adsorbHeight = adsorbHeight; + } - public GridRow(int resolution) { - super(resolution); - } - @Override - protected void initByConstructor() { - gridRowMouseHandler = new GridRowMouseHandler(this); - this.addMouseListener(gridRowMouseHandler); - this.addMouseMotionListener(gridRowMouseHandler); - this.updateUI(); - } + @Override + protected void initByConstructor() { + this.updateUI(); + } - @Override - public Integer getDisplay(int index) { - return new Integer(index + 1); - } + @Override + public Integer getDisplay(int index) { + return new Integer(index + 1); + } - @Override - public void updateUI() { - this.removeMouseListener(gridRowMouseHandler); - this.removeMouseMotionListener(gridRowMouseHandler); - gridRowMouseHandler = new GridRowMouseHandler(this); - this.addMouseListener(gridRowMouseHandler); - this.addMouseMotionListener(gridRowMouseHandler); - this.setUI(new GridRowUI(resolution)); - } + @Override + public void updateUI() { + this.removeMouseListener(gridRowMouseHandler); + this.removeMouseMotionListener(gridRowMouseHandler); + gridRowMouseHandler = new GridRowMouseHandler(this, adsorbHeight); + this.addMouseListener(gridRowMouseHandler); + this.addMouseMotionListener(gridRowMouseHandler); + this.setUI(new GridRowUI(resolution)); + } - /** - * Gets the preferred size. - */ - @Override - public Dimension getPreferredSize() { - ElementCasePane reportPane = this.getElementCasePane(); - float time = (float)reportPane.getResolution()/ DesignerUIModeConfig.getInstance().getScreenResolution(); - if (!(reportPane.isRowHeaderVisible())) { - return new Dimension(0, 0); - } + /** + * Gets the preferred size. + */ + @Override + public Dimension getPreferredSize() { + ElementCasePane reportPane = this.getElementCasePane(); + float time = (float) reportPane.getResolution() / DesignerUIModeConfig.getInstance().getScreenResolution(); + if (!(reportPane.isRowHeaderVisible())) { + return new Dimension(0, 0); + } - int maxCharNumber = this.caculateMaxCharNumber(reportPane); - return new Dimension((int) (maxCharNumber * GraphHelper.getFontMetrics(this.getFont()).charWidth('M') * time), super.getPreferredSize().height); - } + int maxCharNumber = this.caculateMaxCharNumber(reportPane); + return new Dimension((int) (maxCharNumber * GraphHelper.getFontMetrics(this.getFont()).charWidth('M') * time), super.getPreferredSize().height); + } - /** - * Calculates max char number. - */ - private int caculateMaxCharNumber(ElementCasePane reportPane) { - int maxCharNumber = MAX; - maxCharNumber = Math.max(maxCharNumber, ("" + (reportPane.getGrid().getVerticalValue() + reportPane.getGrid().getVerticalExtent())).length() + 1); + /** + * Calculates max char number. + */ + private int caculateMaxCharNumber(ElementCasePane reportPane) { + int maxCharNumber = MAX; + maxCharNumber = Math.max(maxCharNumber, ("" + (reportPane.getGrid().getVerticalValue() + reportPane.getGrid().getVerticalExtent())).length() + 1); - return maxCharNumber; - } + return maxCharNumber; + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/grid/GridRowMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/GridRowMouseHandler.java index b6e229247..e828c2a4a 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridRowMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/GridRowMouseHandler.java @@ -9,20 +9,30 @@ import javax.swing.SwingUtilities; import com.fr.base.DynamicUnitList; import com.fr.design.gui.imenu.UIPopupMenu; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; import com.fr.report.ReportHelper; import com.fr.report.elementcase.ElementCase; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.ColumnRow; +import com.fr.stable.unit.FU; +import com.fr.stable.unit.UNIT; /** * peter:处理对GridRow的Mouse事件. */ public class GridRowMouseHandler extends AbstractGridHeaderMouseHandler { + private final int adsorbHeight; public GridRowMouseHandler(GridRow gridRow) { + this(gridRow, 0); + } + + public GridRowMouseHandler(GridRow gridRow, int adsorbHeight) { super(gridRow); + this.adsorbHeight = adsorbHeight; } @Override @@ -36,6 +46,23 @@ public class GridRowMouseHandler extends AbstractGridHeaderMouseHandler { } + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); + if (this.adsorbHeight <= 0) { + return; + } + ElementCasePane elementCasePane = this.gHeader.getElementCasePane(); + TemplateElementCase editingElementCase = elementCasePane.getEditingElementCase(); + double adsorbHeightWithResolution = this.adsorbHeight * (resolution * 1D / DesignerUIModeConfig.getInstance().getScreenResolution()); + int dragIndex = getDragIndex(e); + if (Math.abs(e.getY() - adsorbHeightWithResolution) < FUZZY_EDGE && dragIndex >= 0) { + UNIT oldValue = editingElementCase.getRowHeight(dragIndex); + editingElementCase.setRowHeight(dragIndex, oldValue.add(FU.valueOfPix((int) (adsorbHeightWithResolution - e.getY()), resolution))); + } + elementCasePane.repaint(); + } + protected int doChooseFrom() { return CellSelection.CHOOSE_ROW; } diff --git a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java index 6c2fed6d0..19f4d76df 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java @@ -8,7 +8,7 @@ import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.stable.AssistUtils; import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 431c6de1e..39e52df54 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -14,6 +14,7 @@ import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; import com.fr.design.roleAuthority.ReportAndFSManagePane; @@ -48,6 +49,7 @@ import com.fr.report.worksheet.WorkSheet; import com.fr.stable.AssistUtils; import com.fr.stable.ColumnRow; import com.fr.stable.Constants; +import com.fr.stable.GraphDrawHelper; import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; import com.fr.stable.unit.UNIT; @@ -1191,9 +1193,37 @@ public class GridUI extends ComponentUI { paintWatermark(g2d, ((WorkSheet) elementCase).getBook()); } + //绘制吸附辅助线 + paintAdsorbLines(g2d, grid); + grid.ajustEditorComponentBounds(); // refresh size } + //绘制吸附辅助线 + private void paintAdsorbLines(Graphics2D g2d, Grid grid) { + int verticalValue = grid.getVerticalValue(); + int horizontalValue = grid.getHorizontalValue(); + if (grid.getAdsorbWidth() <= 0 || grid.getAdsorbHeight() <= 0) { + return; + } + int width = (int) (grid.getAdsorbWidth() * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution()) + - columnWidthList.getRangeValue(0, horizontalValue).toPixI(resolution)); + int height = (int) (grid.getAdsorbHeight() * (resolution * 1.0D / DesignerUIModeConfig.getInstance().getScreenResolution()) + - rowHeightList.getRangeValue(0, verticalValue).toPixI(resolution)); + drawBoundsLine(g2d, width, height); + } + + private void drawBoundsLine(Graphics2D g2d, int width, int height) { + Paint oldPaint = g2d.getPaint(); + Stroke oldStroke = g2d.getStroke(); + g2d.setPaint(Color.black); + g2d.setStroke(GraphDrawHelper.getStroke(Constants.LINE_DASH_DOT)); + g2d.drawLine( 0, height, width, height); + g2d.drawLine( width, 0, width, height); + g2d.setPaint(oldPaint); + g2d.setStroke(oldStroke); + } + // 绘制水印 private void paintWatermark(Graphics2D g2d, FineBook book) { WatermarkAttr watermark = ReportUtils.getWatermarkAttrFromTemplateAndGlobal(book); diff --git a/designer-realize/src/main/java/com/fr/grid/GridUtils.java b/designer-realize/src/main/java/com/fr/grid/GridUtils.java index 31ceacd7a..21b032265 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUtils.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUtils.java @@ -5,7 +5,7 @@ import com.fr.base.ScreenResolution; import com.fr.design.cell.clipboard.CellElementsClip; import com.fr.design.cell.clipboard.ElementsTransferable; import com.fr.design.cell.clipboard.FloatElementsClip; -import com.fr.design.fit.DesignerUIModeConfig; +import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index 0ede5114f..2a4852ee8 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -11,6 +11,7 @@ import com.fr.design.dscolumn.DSColumnAdvancedPane; import com.fr.design.dscolumn.ResultSetGroupDockingPane; import com.fr.design.dscolumn.SelectedDataColumnPane; import com.fr.design.event.UIObserverListener; +import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; @@ -31,6 +32,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.cell.AbstractDSCellEditorPane; +import com.fr.design.sort.celldscolumn.CellDSColumnSortPane; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.IOUtils; @@ -221,62 +223,6 @@ public class CellDSColumnEditor extends CellQuickEditor { */ private UIButton conditionUIButton; - /** - * 分组设置监听器 - */ - private ItemListener groupListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e == null) { - //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 - groupPane.update(); - fireTargetModified(); - return; - } - if (e.getStateChange() == ItemEvent.DESELECTED) { - groupPane.update(); - fireTargetModified(); - } - } - }; - /** - * 数据集列设置监听器 - */ - private ItemListener dataListener = new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - dataPane.update(cellElement); - fireTargetModified(); - } - } - }; - - DSColumnBasicEditorPane() { - dataPane = new SelectedDataColumnPane(true, true); - groupPane = new ResultSetGroupDockingPane(); - dataPane.setListener(dataListener); - groupPane.setListener(groupListener); - - double[] rowSize = {P}, columnSize = {60, F}; - UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); - condition = new DSColumnConditionAction(); - if (tc != null) { - condition.setEditingComponent(tc); - } - //丢掉icon,修改按钮名称为编辑 - condition.setSmallIcon(UIConstants.EMPTY_ICON); - condition.setName(Toolkit.i18nText("Fine-Design_Basic_Edit")); - conditionUIButton = new UIButton(condition); - Component[][] components = new Component[][]{ - new Component[]{uiLabel, UIComponentUtils.wrapWithBorderLayoutPane(conditionUIButton)} - }; - conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.createScrollPane(); - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - - } - @Override public String getIconPath() { @@ -297,11 +243,13 @@ public class CellDSColumnEditor extends CellQuickEditor { @Override public void populate() { + this.removeAttributeChangeListener(); dataPane.populate(DesignTableDataManager.getEditingTableDataSource(), cellElement, tc); groupPane.populate(cellElement); if (tc != null) { condition.setEditingComponent(tc); } + this.addAttributeChangeListener(); } @Override @@ -318,7 +266,7 @@ public class CellDSColumnEditor extends CellQuickEditor { */ @Override protected JPanel createContentPane() { - + initComponents(); double[] columnSize = {F}; double[] rowSize = {P, P, P}; Component[][] components = new Component[][]{ @@ -331,16 +279,43 @@ public class CellDSColumnEditor extends CellQuickEditor { }; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); } + + private void initComponents(){ + dataPane = new SelectedDataColumnPane(true, true); + groupPane = new ResultSetGroupDockingPane(); + + double[] rowSize = {P}, columnSize = {60, F}; + UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); + condition = new DSColumnConditionAction(); + if (tc != null) { + condition.setEditingComponent(tc); + } + //丢掉icon,修改按钮名称为编辑 + condition.setSmallIcon(UIConstants.EMPTY_ICON); + condition.setName(Toolkit.i18nText("Fine-Design_Basic_Edit")); + conditionUIButton = new UIButton(condition); + Component[][] components = new Component[][]{ + new Component[]{uiLabel, UIComponentUtils.wrapWithBorderLayoutPane(conditionUIButton)} + }; + conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + } + @Override + protected AttributeChangeListener getAttributeChangeListener() { + return new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + fireTargetModified(); + } + }; + } } class DSColumnAdvancedEditorPane extends AbstractDSCellEditorPane { /*pane begin*/ - /** - * 排列顺序 - */ - private ResultSetSortConfigPane sortPane; /** * 结果集筛选 */ @@ -373,88 +348,13 @@ public class CellDSColumnEditor extends CellQuickEditor { * 补充空白数据数目面板 可隐藏 */ private JPanel multiPane; - /*pane end*/ - - /*listeners begin*/ - private UIObserverListener sortPaneFormulaChangeListener = new UIObserverListener() { - @Override - public void doChange() { - sortPane.update(cellElement); - fireTargetModified(); - } - }; - - private ChangeListener sortTypeBtnGroupChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - sortPane.update(cellElement); - fireTargetModified(); - } - }; - - private UIObserverListener filterPaneChangeListener = new UIObserverListener() { - @Override - public void doChange() { - filterPane.update(cellElement); - fireTargetModified(); - } - }; - - private UIObserverListener customValuePaneChangeListener = new UIObserverListener() { - @Override - public void doChange() { - valuePane.update(cellElement); - fireTargetModified(); - } - }; - - private AttributeChangeListener formatChangeListener = new AttributeChangeListener() { - @Override - public void attributeChange() { - formatAttrPane.update(cellElement); - fireTargetModified(); - } - }; - - private ChangeListener heCheckBoxChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateExtendConfig(); - fireTargetModified(); - } - }; - - private ChangeListener veCheckBoxChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateExtendConfig(); - fireTargetModified(); - } - }; - - private ActionListener useMultiNumCheckBoxChangeListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkButtonEnabled(); - cellDSColumnAdvancedPane.updateMultipleConfig(); - fireTargetModified(); - } - }; - - private ChangeListener multiNumSpinnerChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - cellDSColumnAdvancedPane.updateMultipleConfig(); - fireTargetModified(); - } - }; - /*listeners end*/ + private CellDSColumnSortPane cellDSColumnSortPane; + /*pane end*/ public DSColumnAdvancedEditorPane() { this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - this.createScrollPane(); } @@ -469,10 +369,10 @@ public class CellDSColumnEditor extends CellQuickEditor { } + @Override public void update() { if (cellElement != null) { - sortPane.update(cellElement); valuePane.update(cellElement); formatAttrPane.update(cellElement); filterPane.update(cellElement); @@ -480,14 +380,14 @@ public class CellDSColumnEditor extends CellQuickEditor { updateExtendConfig(); //更新补充空白设置 updateMultipleConfig(); + cellDSColumnSortPane.updateBean(cellElement); } } @Override public void populate() { if (cellElement != null) { - disableListener(); - sortPane.populate(cellElement); + this.removeAttributeChangeListener(); valuePane.populate(cellElement); formatAttrPane.populate(cellElement); filterPane.populate(cellElement); @@ -524,8 +424,11 @@ public class CellDSColumnEditor extends CellQuickEditor { useMultiNumCheckBox.setSelected(true); multiNumSpinner.setValue(cellExpandAttr.getMultipleNumber()); } + if (cellDSColumnSortPane != null) { + cellDSColumnSortPane.populateBean(cellElement); + } this.checkButtonEnabled(); - enableListener(); + this.addAttributeChangeListener(); } } @@ -534,6 +437,17 @@ public class CellDSColumnEditor extends CellQuickEditor { } + @Override + protected AttributeChangeListener getAttributeChangeListener() { + return new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + fireTargetModified(); + } + }; + } + /** * 更新单元格扩展属性 */ @@ -578,11 +492,8 @@ public class CellDSColumnEditor extends CellQuickEditor { */ @Override protected JPanel createContentPane() { + JPanel contentPane = new JPanel(new BorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - //结果集排序 - sortPane = new ResultSetSortConfigPane(); - //结果筛选 filterPane = new ResultSetFilterConfigPane(); @@ -616,10 +527,7 @@ public class CellDSColumnEditor extends CellQuickEditor { multiPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); multiNumPane.add(multiPane); - enableListener(); - Component[][] components = new Component[][]{ - {sortPane}, {filterPane}, {valuePane}, {formatAttrPane}, @@ -630,32 +538,15 @@ public class CellDSColumnEditor extends CellQuickEditor { double[] rowSize = new double[components.length]; Arrays.fill(rowSize, P); double[] columnSize = {F}; - - return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - } - - public void enableListener() { - sortPane.addListener(sortPaneFormulaChangeListener, sortTypeBtnGroupChangeListener); - filterPane.addListener(filterPaneChangeListener); - valuePane.addListener(customValuePaneChangeListener); - formatAttrPane.addAttributeChangeListener(formatChangeListener); - heCheckBox.addChangeListener(heCheckBoxChangeListener); - veCheckBox.addChangeListener(veCheckBoxChangeListener); - useMultiNumCheckBox.addActionListener(useMultiNumCheckBoxChangeListener); - multiNumSpinner.addChangeListener(multiNumSpinnerChangeListener); - } - - public void disableListener() { - sortPane.removeListener(sortTypeBtnGroupChangeListener); - filterPane.removeListener(); - valuePane.removeListener(); - heCheckBox.removeChangeListener(heCheckBoxChangeListener); - veCheckBox.removeChangeListener(veCheckBoxChangeListener); - useMultiNumCheckBox.removeActionListener(useMultiNumCheckBoxChangeListener); - multiNumSpinner.removeChangeListener(multiNumSpinnerChangeListener); + JPanel advancePropertyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); + contentPane.add(advancePropertyPane, BorderLayout.NORTH); + UIExpandablePane sortUIExpandablePane = + new UIExpandablePane(Toolkit.i18nText("Fine-Design_Sort_Data_Column_Sort"), + 223, 24, cellDSColumnSortPane = new CellDSColumnSortPane()); + contentPane.add(sortUIExpandablePane, BorderLayout.CENTER); + return contentPane; } - private void checkButtonEnabled() { if (useMultiNumCheckBox.isSelected()) { multiNumSpinner.setEnabled(true); @@ -666,136 +557,6 @@ public class CellDSColumnEditor extends CellQuickEditor { } } - /** - * 单元格元素>数据集>高级设置>结果排序设置面板 - * - * @see com.fr.design.expand.SortExpandAttrPane - * @see DSColumnAdvancedPane.SortPane - */ - public class ResultSetSortConfigPane extends JPanel { - private static final String DEFAULT_VALUE = "="; - private JPanel contentPane; - private UIButtonGroup sortTypePane; - private JFormulaField formulaField; - private CardLayout cardLayout; - private JPanel centerPane; - - - public ResultSetSortConfigPane() { - this.setLayout(new BorderLayout()); - Icon[] iconArray = { - IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), - IOUtils.readIcon("/com/fr/design/images/expand/asc.png"), - IOUtils.readIcon("/com/fr/design/images/expand/des.png") - }; - String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_Sort_Original"), Toolkit.i18nText("Fine-Design_Report_Sort_Ascending"), Toolkit.i18nText("Fine-Design_Report_Sort_Descending")}; - sortTypePane = new UIButtonGroup(iconArray); - sortTypePane.setAllToolTips(nameArray); - sortTypePane.setGlobalName(Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand")); - - cardLayout = new CardLayout(); - centerPane = new JPanel(cardLayout); - formulaField = new JFormulaField(DEFAULT_VALUE); - centerPane.add(new JPanel(), "none"); - centerPane.add(formulaField, "content"); - UILabel sortLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")); - sortLabel.setPreferredSize(LABEL_DIMENSION); - sortTypePane.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - boolean noContent = sortTypePane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - } else { - centerPane.setPreferredSize(new Dimension(165, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - } - } - }); - - Component[][] components = new Component[][]{ - new Component[]{sortLabel, sortTypePane}, - new Component[]{null, centerPane} - }; - - double[] rowSize = {P, P}, columnSize = {P, F}; - contentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); - this.add(contentPane, BorderLayout.CENTER); - } - - - /** - * 刷新面板信息 - * - * @param cellElement 单元格 - */ - public void populate(TemplateCellElement cellElement) { - if (cellElement != null) { - Object value = cellElement.getValue(); - if (value instanceof DSColumn) { - this.formulaField.populateElement(cellElement); - DSColumn dSColumn = (DSColumn) value; - int sort = dSColumn.getOrder(); - this.sortTypePane.setSelectedIndex(sort); - boolean noContent = sortTypePane.getSelectedIndex() == 0; - cardLayout.show(centerPane, noContent ? "none" : "content"); - if (noContent) { - centerPane.setPreferredSize(new Dimension(0, 0)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, 0); - } else { - centerPane.setPreferredSize(new Dimension(156, 20)); - TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); - } - String sortFormula = dSColumn.getSortFormula(); - if (sortFormula != null && sortFormula.length() >= 1) { - this.formulaField.populate(sortFormula); - } else { - this.formulaField.populate(DEFAULT_VALUE); - } - } - } - } - - /** - * 保存面板配置信息 - * - * @param cellElement 单元格 - */ - public void update(CellElement cellElement) { - if (cellElement != null) { - Object value = cellElement.getValue(); - if (value instanceof DSColumn) { - DSColumn dSColumn = (DSColumn) value; - dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); - dSColumn.setSortFormula(this.formulaField.getFormulaText()); - } - } - } - - /** - * 添加事件监听器 - * - * @param formulaChangeListener 公式输入框改动事件监听器 - * @param changeListener 排序类型下拉框改动事件监听器 - */ - public void addListener(UIObserverListener formulaChangeListener, ChangeListener changeListener) { - formulaField.addListener(formulaChangeListener); - sortTypePane.addChangeListener(changeListener); - } - - /** - * 去除事件监听器 - * - * @param changeListener 排序类型下拉框改动事件监听器 - */ - public void removeListener(ChangeListener changeListener) { - formulaField.removeListener(); - sortTypePane.removeChangeListener(changeListener); - } - } - /** * 单元格元素>数据集>高级设置>结果集筛选设置面板 * diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 477ac8ae3..56b578578 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -191,18 +191,20 @@ public class DesignerActivator extends Activator implements Prepare { private void loadLogAppender() { logHandler = new LogHandler() { - final DesignerLogAppender logAppender = new DesignerLogAppender(); + final DesignerLogAppender logAppender = DesignerLogAppender.createDesignerLogAppender(); @Override public DesignerLogAppender getHandler() { return logAppender; } }; + logHandler.getHandler().start(); FineLoggerFactory.getLogger().addLogAppender(logHandler); } private void unloadLogAppender() { if (logHandler != null) { + logHandler.getHandler().stop(); FineLoggerFactory.getLogger().removeLogAppender(logHandler); } }