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 97b4d0f6c..7242b2295 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -192,6 +192,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private static List mapWorkerList = new ArrayList(); private boolean imageCompress = false;//图片压缩 + private boolean showImageCompressMoveTip = true; // 开启内嵌web页面的调试窗口 private boolean openDebug = false; @@ -1637,6 +1638,15 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.imageCompress = imageCompress; } + public boolean isShowImageCompressMoveTip() { + return showImageCompressMoveTip; + } + + public void setShowImageCompressMoveTip(boolean showImageCompressMoveTip) { + this.showImageCompressMoveTip = showImageCompressMoveTip; + } + + public boolean isOpenDebug() { return openDebug; } @@ -1792,6 +1802,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.setCachingTemplateLimit(reader.getAttrAsInt("cachingTemplateLimit", CACHINGTEMPLATE_LIMIT)); this.setJoinProductImprove(reader.getAttrAsBoolean("joinProductImprove", true)); this.setImageCompress(reader.getAttrAsBoolean("imageCompress", true)); + this.setShowImageCompressMoveTip(reader.getAttrAsBoolean("showImageCompressMoveTip", true)); this.setAutoBackUp(reader.getAttrAsBoolean("autoBackUp", true)); this.setTemplateTreePaneExpanded(reader.getAttrAsBoolean("templateTreePaneExpanded", false)); // peter:读取webinfLocation @@ -2072,6 +2083,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (!this.isImageCompress()) { writer.attr("imageCompress", this.isImageCompress()); } + writer.attr("showImageCompressMoveTip", this.isShowImageCompressMoveTip()); if (!this.isAutoBackUp()) { writer.attr("autoBackUp", this.isAutoBackUp()); } 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 133bbb03f..a41f96295 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 @@ -15,6 +15,9 @@ import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iprogressbar.UIProgressBarUI; @@ -47,6 +50,8 @@ 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; @@ -165,6 +170,7 @@ public class PreferencePane extends BasicPane { private UICheckBox joinProductImproveCheckBox; private UICheckBox autoPushUpdateCheckBox; private UICheckBox embedServerLazyStartupCheckBox; + private UICheckBox imageCompressPanelCheckBox; private UICheckBox vcsEnableCheckBox; private UICheckBox saveCommitCheckBox; @@ -256,6 +262,10 @@ public class PreferencePane extends BasicPane { embedServerPanel.add(embedServerLazyStartupCheckBox); advancePane.add(embedServerPanel); + JPanel imageCompressPanel = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Template_Preview_Performance")); + imageCompressPanelCheckBox = new UICheckBox(i18nText("Fine-Design_Image_Compress")); + imageCompressPanel.add(imageCompressPanelCheckBox); + advancePane.add(imageCompressPanel); } private void createVcsSettingPane(JPanel generalPane) { @@ -489,11 +499,13 @@ public class PreferencePane extends BasicPane { chooseDirBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - int saveValue = fileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); + FileChooserProvider fileChooserProvider = + new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.DIR). + build(); + int saveValue = fileChooserProvider.showDialog(null); if (saveValue == JFileChooser.APPROVE_OPTION) { - File selectedFile = fileChooser.getSelectedFile(); + File selectedFile = fileChooserProvider.getSelectedFile(); logExportDirectoryField.setText(selectedFile.getAbsolutePath()); } } @@ -665,7 +677,7 @@ public class PreferencePane extends BasicPane { defaultStringToFormulaBox.setSelected(false); } VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); - if (WorkContext.getCurrent().isCluster()){ + if (WorkContext.getCurrent().isCluster()) { vcsEnableCheckBox.setEnabled(false); gcEnableCheckBox.setEnabled(false); } @@ -717,6 +729,8 @@ public class PreferencePane extends BasicPane { } this.embedServerLazyStartupCheckBox.setSelected(designerEnvManager.isEmbedServerLazyStartup()); + + this.imageCompressPanelCheckBox.setSelected(designerEnvManager.isImageCompress()); } private int chooseCase(int sign) { @@ -775,6 +789,7 @@ public class PreferencePane extends BasicPane { designerEnvManager.setCachingTemplateLimit((int) this.cachingTemplateSpinner.getValue()); designerEnvManager.setJoinProductImprove(this.joinProductImproveCheckBox.isSelected()); designerEnvManager.setEmbedServerLazyStartup(this.embedServerLazyStartupCheckBox.isSelected()); + designerEnvManager.setImageCompress(this.imageCompressPanelCheckBox.isSelected()); VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); vcsConfigManager.setSaveInterval(this.saveIntervalEditor.getValue()); vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); diff --git a/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java b/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java new file mode 100644 index 000000000..870af0be5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardHelper.java @@ -0,0 +1,24 @@ +package com.fr.design.base.clipboard; + +import java.util.List; + +public class ClipboardHelper { + public static String formatExcelString(List> table) { + StringBuffer stringBuffer = new StringBuffer(); + + for (int row = 0; row < table.size(); row++) { + List rowValue = table.get(row); + for (int col = 0; col < rowValue.size(); col++) { + Object cell = rowValue.get(col); + stringBuffer.append(cell); + if (col != rowValue.size() - 1) { + stringBuffer.append("\t"); + } + } + if (row != table.size() - 1) { + stringBuffer.append("\n"); + } + } + return stringBuffer.toString(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java index 9c43f7f50..1352833e6 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignModeContext.java @@ -3,6 +3,7 @@ package com.fr.design.base.mode; import com.fr.design.designer.TargetComponent; import static com.fr.design.base.mode.DesignerMode.AUTHORITY; +import static com.fr.design.base.mode.DesignerMode.DUCHAMP; public class DesignModeContext { @@ -42,6 +43,9 @@ public class DesignModeContext { return mode == AUTHORITY; } + public static boolean isDuchampMode() { + return mode == DUCHAMP; + } public static void doCopy(TargetComponent principal) { if (isBanCopyAndCut() || principal == null) { diff --git a/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java b/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java index b0dd4baaf..d3dc1e5f4 100644 --- a/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java +++ b/designer-base/src/main/java/com/fr/design/base/mode/DesignerMode.java @@ -4,5 +4,6 @@ public enum DesignerMode { NORMAL, BAN_COPY_AND_CUT, VCS, - AUTHORITY + AUTHORITY, + DUCHAMP } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java new file mode 100644 index 000000000..38b5a08e4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java @@ -0,0 +1,203 @@ +package com.fr.design.data.datapane.preview; + +import com.fr.design.base.clipboard.ClipboardHelper; +import com.fr.design.gui.itable.SortableJTable; +import com.fr.design.gui.itable.TableSorter; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.os.OperatingSystem; + +import javax.swing.table.TableCellRenderer; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +public class CopyableJTable extends SortableJTable { + + //区域选中用到的定位数据 + public int startRow = -1; + public int startCol = -1; + public int endRow = -1; + public int endCol = -1; + //单元格不连续多选用到的定位数据 + java.util.List pointList = new ArrayList<>(); + //shift键是否被按下 + public boolean isShiftDown = false; + //control\command键是否被按下 + public boolean isControlDown = false; + //是否可以复制 + public boolean isCopy = true; + int ctrlKeyCode = 17; + int cKeyCode = 67; + int shiftKeyCode = 16; + int commandKeyCode = 157; + //选中单元格的背景色 + Color selectBackGround = new Color(54, 133, 242, 63); + + + public CopyableJTable(TableSorter tableModel) { + super(tableModel); + initListener(); + } + + private void initListener() { + CopyableJTable self = this; + this.addMouseMotionListener(new java.awt.event.MouseAdapter() { + @Override + public void mouseDragged(MouseEvent evt) { + int row = self.rowAtPoint(evt.getPoint()); + int col = self.columnAtPoint(evt.getPoint()); + if (self.updateEndPoint(row, col)) { + self.repaint(); + } + } + }); + this.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + int row = self.rowAtPoint(e.getPoint()); + int col = self.columnAtPoint(e.getPoint()); + if (!self.isControlDown) { + self.clearPoint(); + } + if (self.isShiftDown) { + self.clearPoint(); + } else { + self.updateStartPoint(row, col); + } + self.addPoint(row, col); + self.updateEndPoint(row, col); + + self.repaint(); + } + + }); + this.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (isControlKey(e)) { + isControlDown = true; + } else if (e.getKeyCode() == shiftKeyCode) { + isShiftDown = true; + } else if (e.getKeyCode() == cKeyCode) { + if (isControlDown && isCopy) { + self.copy(); + isCopy = false; + } + } + } + + @Override + public void keyReleased(KeyEvent e) { + if (isControlKey(e)) { + isControlDown = false; + isCopy = true; + } else if (e.getKeyCode() == shiftKeyCode) { + isShiftDown = false; + } + } + + private boolean isControlKey(KeyEvent e) { + if (e.getKeyCode() == ctrlKeyCode) { + return true; + } + if (e.getKeyCode() == commandKeyCode && OperatingSystem.isMacos()) { + return true; + } + return false; + } + }); + } + + + @Override + public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { + Component comp = super.prepareRenderer(renderer, row, column); + if (isChoose(row, column)) { + comp.setBackground(selectBackGround); + } else { + comp.setBackground(this.getBackground()); + } + return comp; + } + + + private boolean updateEndPoint(int row, int col) { + if (endRow != row || endCol != col) { + endRow = row; + endCol = col; + return true; + } + return false; + } + + private boolean updateStartPoint(int row, int col) { + if (startRow != row || startCol != col) { + startRow = row; + startCol = col; + return true; + } + return false; + } + + private void addPoint(int row, int col) { + pointList.add(new Point(row, col)); + } + + private void clearPoint() { + pointList = new ArrayList<>(); + } + + private void copy() { + FineLoggerFactory.getLogger().info("copy cell value"); + java.util.List> table = new ArrayList<>(); + if ((startRow != endRow || startCol != endCol) && + Math.min(startRow, endRow) > -1 && Math.min(startCol, endCol) > -1) { + for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) { + table.add(new ArrayList<>()); + for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) { + Object text = this.getValueAt(i, j); + table.get(i - Math.min(startRow, endRow)).add(text); + } + } + } else if (pointList.size() > 0) { + Collections.sort(pointList, Comparator.comparing(Point::getX).thenComparing(Point::getY)); + int startRow = pointList.get(0).x; + int currentRow = startRow; + table.add(new ArrayList<>()); + for (Point point : pointList) { + while (currentRow < point.x) { + table.add(new ArrayList<>()); + currentRow++; + } + Object text = this.getValueAt(point.x, point.y); + table.get(currentRow - startRow).add(text); + } + } + + Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); + Transferable tText = new StringSelection(ClipboardHelper.formatExcelString(table)); + clip.setContents(tText, null); + } + + private boolean isChoose(int row, int col) { + if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) { + if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) { + return true; + } + } + for (Point point : pointList) { + if (point.x == row && point.y == col) { + return true; + } + } + return false; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java index e95a5999a..409ae7f7f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java @@ -26,7 +26,6 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; -import com.fr.design.utils.gui.GUICoreUtils; import com.fr.function.TIME; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; @@ -162,7 +161,7 @@ public class PreviewTablePane extends BasicPane { } }); - preveiwTable = new SortableJTable(new TableSorter()); + preveiwTable = new CopyableJTable(new TableSorter()); preveiwTable.setRowSelectionAllowed(false); preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java index 930dde76c..d3c592a4e 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java @@ -410,6 +410,4 @@ public abstract class BasicPane extends JPanel { } } - - } diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java new file mode 100644 index 000000000..f7678475f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneActionListener.java @@ -0,0 +1,16 @@ +package com.fr.design.gui.chart; + +import com.fr.chart.chartattr.ChartCollection; + +import java.util.EventListener; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/5/26 + */ +public interface ChartEditPaneActionListener extends EventListener { + + void attributeChange(ChartCollection chartCollection); + +} diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java index 3d4119ab7..300380036 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/ChartEditPaneProvider.java @@ -10,4 +10,10 @@ public interface ChartEditPaneProvider { void fire(); + default void addChartEditPaneActionListener(ChartEditPaneActionListener l) { + } + + default void removeChartEditPaneActionListener(ChartEditPaneActionListener l) { + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java index 0d01ddbda..36e5ea4f3 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java @@ -120,6 +120,7 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S } public void showEditPane() { + // record this.cardLayout.show(cardPane, EDIT); } 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 6af119426..381a9cd76 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 @@ -46,8 +46,10 @@ public abstract class AbstractAttrNoScrollPane extends BasicPane { protected void initContentPane() { leftContentPane = createContentPane(); - leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original)); - this.add(leftContentPane, BorderLayout.CENTER); + if (leftContentPane != null) { + leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, original)); + this.add(leftContentPane, BorderLayout.CENTER); + } } protected abstract JPanel createContentPane(); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java new file mode 100644 index 000000000..0a41aae17 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHead.java @@ -0,0 +1,63 @@ +package com.fr.design.gui.ibutton; + +import com.fr.stable.StringUtils; + +import javax.swing.Icon; + +public class UIHead { + private String text = StringUtils.EMPTY; + private Icon icon = null; + private boolean enable = true; + private int index = 0; + + public UIHead(String text, int index) { + this.text = text; + this.index = index; + } + + public UIHead(String text, int index, boolean enable) { + this(text, index); + this.enable = enable; + } + + public UIHead(Icon icon, int index) { + this.icon = icon; + this.index = index; + } + + public UIHead(Icon icon, int index, boolean enable) { + this(icon, index); + this.enable = enable; + } + + public UIHead(String text, Icon icon, int index) { + this.text = text; + this.icon = icon; + this.index = index; + } + + public UIHead(String text, Icon icon, int index, boolean enable) { + this(text, icon, index); + this.enable = enable; + } + + public boolean isOnlyText() { + return StringUtils.isNotEmpty(text) && icon == null; + } + + public String getText() { + return text; + } + + public Icon getIcon() { + return icon; + } + + public boolean isEnable() { + return enable; + } + + public int getIndex() { + return index; + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java index e21f4c217..0cfe7c390 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIHeadGroup.java @@ -10,7 +10,6 @@ import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; -import java.awt.Graphics; import java.awt.GridLayout; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -18,8 +17,10 @@ import java.awt.event.MouseListener; import java.util.ArrayList; import java.util.List; +// fanglei:不是原作者,只是优化如下问题:代码冗余,无法拓展(例如我想加个enable属性没法加),甚至还有数组越界的问题。 public class UIHeadGroup extends JPanel { private static final int MIN_HEIGHT = 25; + private List uiHeads = new ArrayList<>(); protected List labelButtonList; private boolean isNeedLeftRightOutLine = true; protected int selectedIndex = -1; @@ -29,76 +30,46 @@ public class UIHeadGroup extends JPanel { } public UIHeadGroup(String[] textArray) { - labelButtonList = new ArrayList(textArray.length); - this.setBackground(UIConstants.TREE_BACKGROUND); - this.setLayout(new GridLayout(0, textArray.length, 0, 0)); for (int i = 0; i < textArray.length; i++) { - final int index = i; - String text = textArray[i]; - final UIToggleButton labelButton = new UIToggleButton(text) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; - } - }; - initButton(labelButton); + uiHeads.add(new UIHead(textArray[i], i)); } - setSelectedIndex(0); + initUIHeadGroup(uiHeads); } public UIHeadGroup(Icon[] iconArray) { - labelButtonList = new ArrayList(iconArray.length); - this.setBackground(UIConstants.NORMAL_BACKGROUND); - this.setLayout(new GridLayout(0, iconArray.length, 1, 0)); for (int i = 0; i < iconArray.length; i++) { - final int index = i; - Icon icon = iconArray[i]; - final UIToggleButton labelButton = new UIToggleButton(icon) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; - } - }; - initButton(labelButton); + uiHeads.add(new UIHead(iconArray[i], i)); } - setSelectedIndex(0); + initUIHeadGroup(uiHeads); } public UIHeadGroup(Icon[] iconArray, String[] textArray) { - labelButtonList = new ArrayList(Math.min(textArray.length, iconArray.length)); - this.setBackground(UIConstants.NORMAL_BACKGROUND); - this.setLayout(new GridLayout(0, textArray.length, 1, 0)); - for (int i = 0; i < textArray.length; i++) { - final int index = i; - String text = textArray[i]; - Icon icon = iconArray[i]; - final UIToggleButton labelButton = new UIToggleButton(text, icon) { - @Override - protected MouseListener getMouseListener() { - return new MouseAdapter() { - @Override - public void mousePressed(MouseEvent e) { - setSelectedIndex(index); - UIHeadGroup.this.repaint(); - } - }; + int length = Math.min(textArray.length, iconArray.length); + for (int i = 0; i < length; i++) { + uiHeads.add(new UIHead(textArray[i], iconArray[i], i)); + } + initUIHeadGroup(uiHeads); + } + + public UIHeadGroup(List uiHeads) { + initUIHeadGroup(uiHeads); + } + + public void initUIHeadGroup(List uiHeads) { + if (uiHeads != null) { + labelButtonList = new ArrayList(uiHeads.size()); + this.setLayout(new GridLayout(0, uiHeads.size(), 1, 0)); + + for (UIHead head : uiHeads) { + if (head.isOnlyText()) { + this.setBackground(UIConstants.TREE_BACKGROUND); + } else { + this.setBackground(UIConstants.NORMAL_BACKGROUND); } - }; - initButton(labelButton); + initButton(createUIToggleButton(head)); + } + setSelectedIndex(0); } - setSelectedIndex(0); } @Override @@ -110,32 +81,6 @@ public class UIHeadGroup extends JPanel { return dim; } - @Override - protected void paintBorder(Graphics g) { -// Graphics2D g2d = (Graphics2D)g; -// g2d.setColor(UIConstants.LINE_COLOR); -// -// int width = 0; -// for(int i = 0; i < labelButtonList.size() - 1; i++) { -// int height = labelButtonList.get(i).getHeight(); -// width += labelButtonList.get(i).getWidth() + 1; -// g.drawLine(width, 0, width, height); -// } -// -// width += labelButtonList.get(labelButtonList.size() - 1).getWidth() + 1; -// if(isNeedLeftRightOutLine) { -// g2d.drawRect(0, 0, width, getHeight() - 1); -// } else { -// g2d.drawLine(1, 0, width - 1, 0); -// g2d.drawLine(1, getHeight() - 1, width - 1, getHeight() - 1); -// } -// -// -// g2d.setColor(UIConstants.NORMAL_BACKGROUND); -// UIToggleButton headButton = labelButtonList.get(selectedIndex); -// g2d.drawLine(headButton.getX(), headButton.getHeight() + 1, headButton.getX() + headButton.getWidth() - 1, headButton.getHeight() + 1); - } - private void initButton(UIToggleButton labelButton) { labelButton.setRoundBorder(false); labelButton.setBorderPainted(false); @@ -172,6 +117,26 @@ public class UIHeadGroup extends JPanel { return selectedIndex; } + public UIToggleButton createUIToggleButton(final UIHead head) { + UIToggleButton uiToggleButton = new UIToggleButton(head.getText(), head.getIcon()) { + @Override + protected MouseListener getMouseListener() { + return new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + if (head.isEnable()) { + setSelectedIndex(head.getIndex()); + UIHeadGroup.this.repaint(); + } + } + }; + } + }; + + uiToggleButton.setEnabled(head.isEnable()); + return uiToggleButton; + } + public static void main(String... args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java deleted file mode 100644 index ee61fd81f..000000000 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/AbstractFileChooser.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.fr.design.gui.ifilechooser; - -import javax.swing.filechooser.FileFilter; -import java.awt.*; -import java.io.File; - -/** - * @author hades - * @version 10.0 - * Created by hades on 2020/3/31 - */ -public abstract class AbstractFileChooser { - - /** - * 返回当前目录 - * - */ - public abstract File getCurrentDirectory(); - - /** - * 返回当前的文件选择过滤器 - * - */ - public abstract FileFilter getFileFilter(); - - /** - * 返回选择的文件 - * - */ - public abstract File getSelectedFile(); - - /** - * 多文件选择模式下 返回选择的多个文件 - * - */ - public abstract File[] getSelectedFiles(); - - /** - * 是否可以选择多个文件 - * - */ - public abstract boolean isMultiSelectionEnabled(); - - /** - * 设置当前选择的目录 - * - */ - public abstract void setCurrentDirectory(File dir); - - /** - * 设置左上角标题 - * - */ - public abstract void setDialogTitle(String title); - - /** - * 设置当前的文件过滤器 - * - */ - public abstract void setFileFilter(final FileFilter filter); - - /** - * 设置文件选择器模式 - * - * JFileChooser.FILES_ONLY - * JFileChooser.DIRECTORIES_ONLY - * JFileChooser.FILES_AND_DIRECTORIES - */ - public abstract void setFileSelectionMode(int selectionMode); - - /** - * 设置是否允许选择多个文件 - * - */ - public abstract void setMultiSelectionEnabled(boolean multiple); - - /** - * 设置选择的文件 用于showSaveDialog - * - */ - public abstract void setSelectedFile(File file); - - /** - * 弹出文件选择器 打开文件 - * - */ - public abstract int showOpenDialog(Component parent); - - /** - * 弹出文件选择器 保存文件 - * - */ - public abstract int showSaveDialog(Component parent); - - - /** - * https://bugs.java.com/bugdatabase/view_bug.do?bug_id=4031440 - * - * 设置文件名后缀 起到文件过滤的作用 形如 "*.jpg;*.jpeg" - * - */ - public abstract void setExtensionFilter(String file); -} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java new file mode 100644 index 000000000..aa95fe27b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileChooserProvider.java @@ -0,0 +1,12 @@ +package com.fr.design.gui.ifilechooser; + +import java.awt.*; +import java.io.File; + +public interface FileChooserProvider { + File[] getSelectedFiles(); + + File getSelectedFile(); + + int showDialog(Component parent); +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java new file mode 100644 index 000000000..bee326f6a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/FileSelectionMode.java @@ -0,0 +1,5 @@ +package com.fr.design.gui.ifilechooser; + +public enum FileSelectionMode { + FILE, MULTIPLE_FILE, DIR +} diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java new file mode 100644 index 000000000..b5fce35db --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/JavaFxNativeFileChooser.java @@ -0,0 +1,158 @@ +package com.fr.design.gui.ifilechooser; + + +import com.fr.design.i18n.Toolkit; +import com.fr.design.upm.UpmUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.sun.javafx.application.PlatformImpl; +import javafx.stage.DirectoryChooser; +import javafx.stage.FileChooser; +import javafx.stage.Window; + +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.*; +import java.io.File; +import java.util.List; +import java.util.concurrent.CountDownLatch; + +public class JavaFxNativeFileChooser implements FileChooserProvider { + private File[] selectedFiles = new File[0]; + private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; + private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); + private FileChooser.ExtensionFilter[] filters; + private File currentDirectory; + + @Override + public File[] getSelectedFiles() { + return selectedFiles; + } + + @Override + public File getSelectedFile() { + if (selectedFiles.length > 0) { + return selectedFiles[0]; + } + return null; + } + + @Override + public int showDialog(Component parent) { + final CountDownLatch latch = new CountDownLatch(1); + PlatformImpl.startup(new Runnable() { + @Override + public void run() { + try { + if (fileSelectionMode == FileSelectionMode.FILE || fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle(title); + fileChooser.getExtensionFilters().addAll(filters); + fileChooser.setInitialDirectory(currentDirectory); + if (fileSelectionMode == FileSelectionMode.FILE) { + File file = fileChooser.showOpenDialog(null); + if (file != null) { + selectedFiles = new File[]{file}; + } + } else if (fileSelectionMode == FileSelectionMode.MULTIPLE_FILE) { + List fileList = fileChooser.showOpenMultipleDialog(null); + if (fileList != null) { + selectedFiles = new File[fileList.size()]; + fileList.toArray(selectedFiles); + } + } + } else if (fileSelectionMode == FileSelectionMode.DIR) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setTitle(title); + directoryChooser.setInitialDirectory(currentDirectory); + File folder = directoryChooser.showDialog(null); + if (folder != null) { + selectedFiles = new File[]{folder}; + } + System.out.println(folder); + } + + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } finally { + latch.countDown(); + } + } + }); + + try { + latch.await(); + } catch (InterruptedException ignore) { + } + return selectedFiles.length > 0 ? JFileChooser.APPROVE_OPTION : JFileChooser.CANCEL_OPTION; + } + + public void setSelectionMode(FileSelectionMode fileSelectionMode) { + this.fileSelectionMode = fileSelectionMode; + } + + public void setCurrentDirectory(File currentDirectory) { + this.currentDirectory = currentDirectory; + } + + + public static class Builder { + private FileSelectionMode fileSelectionMode = FileSelectionMode.FILE; + private String title = Toolkit.i18nText("Fine-Design_Basic_Open"); + private FileChooser.ExtensionFilter[] filters = new FileChooser.ExtensionFilter[0]; + private File currentDirectory; + + public Builder fileSelectionMode(FileSelectionMode fileSelectionMode) { + this.fileSelectionMode = fileSelectionMode; + return this; + } + + public Builder title(String title) { + this.title = title; + return this; + } + + public Builder filters(FileChooser.ExtensionFilter[] filters) { + this.filters = filters; + return this; + } + + public Builder filter(String des, String... extensions) { + if (extensions != null) { + this.filters = new FileChooser.ExtensionFilter[]{new FileChooser.ExtensionFilter(des, extensions)}; + } + return this; + } + + + public Builder currentDirectory(File currentDirectory) { + if (currentDirectory != null) { + if (!currentDirectory.isDirectory()) { + currentDirectory = currentDirectory.getParentFile(); + } + if (currentDirectory != null && currentDirectory.isDirectory()) { + this.currentDirectory = currentDirectory; + } + } + return this; + } + + public Builder currentDirectory(String path) { + if (path != null) { + return currentDirectory(new File(path)); + } + return this; + } + + public JavaFxNativeFileChooser build() { + return new JavaFxNativeFileChooser(this); + } + } + + private JavaFxNativeFileChooser(Builder builder) { + this.fileSelectionMode = builder.fileSelectionMode; + this.title = builder.title; + this.filters = builder.filters; + this.currentDirectory = builder.currentDirectory; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java b/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java deleted file mode 100644 index c1418f834..000000000 --- a/designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.fr.design.gui.ifilechooser; - -import com.fr.design.gui.ifilechooser.AbstractFileChooser; -import com.fr.design.mainframe.DesignerContext; -import com.fr.stable.os.OperatingSystem; - -import javax.swing.*; -import javax.swing.filechooser.FileFilter; -import java.awt.*; -import java.io.File; -import java.io.FilenameFilter; - - -/** - * 系统原生风格的文件选择器 - * - * jdk问题: - * https://bugs.openjdk.java.net/browse/JDK-4811090 不支持文件扩展选择 - * https://stackoverflow.com/questions/40713398/filter-not-working-in-filedialog windows下 setFilenameFilter不work - * - * @author hades - * @version 10.0 - * Created by hades on 2020/3/31 - */ -public class UINativeFileChooser extends AbstractFileChooser { - - private final FileDialog fileDialog; - private FileFilter fileFilter; - private int selectionMode; - - public UINativeFileChooser(File file) { - fileDialog = new FileDialog(DesignerContext.getDesignerFrame()); - if (file != null) { - fileDialog.setDirectory(file.getAbsolutePath()); - fileDialog.setFile(file.toString()); - } - } - - public UINativeFileChooser() { - this(null); - } - - @Override - public File getCurrentDirectory() { - return new File(fileDialog.getDirectory()); - } - - @Override - public FileFilter getFileFilter() { - return fileFilter; - } - - @Override - public File getSelectedFile() { - return new File(fileDialog.getDirectory() + fileDialog.getFile()); - } - - @Override - public File[] getSelectedFiles() { - return fileDialog.getFiles(); - } - - @Override - public boolean isMultiSelectionEnabled() { - return fileDialog.isMultipleMode(); - } - - @Override - public void setCurrentDirectory(File f) { - fileDialog.setDirectory(f.toString()); - } - - @Override - public void setDialogTitle(String title) { - fileDialog.setTitle(title); - } - - @Override - public void setFileFilter(final FileFilter cff) { - FilenameFilter filter = new FilenameFilter() { - @Override - public boolean accept(File Directory, String fileName) { - return cff.accept(new File(Directory.getAbsolutePath() + fileName)); - } - }; - fileDialog.setFilenameFilter(filter); - fileFilter = cff; - } - - @Override - public void setFileSelectionMode(int selectionMode) { - this.selectionMode = selectionMode; - } - - @Override - public void setMultiSelectionEnabled(boolean multiple) { - fileDialog.setMultipleMode(multiple); - } - - @Override - public void setSelectedFile(File file) { - fileDialog.setDirectory(file.getAbsolutePath()); - fileDialog.setFile(file.getName()); - } - - @Override - public int showOpenDialog(Component parent) { - boolean appleProperty = OperatingSystem.isMacos() && selectionMode == JFileChooser.DIRECTORIES_ONLY; - if (appleProperty) { - System.setProperty("apple.awt.fileDialogForDirectories", "true"); - } - try { - fileDialog.setLocale(JComponent.getDefaultLocale()); - fileDialog.setMode(FileDialog.LOAD); - fileDialog.setVisible(true); - return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION; - } finally { - if (appleProperty) { - System.setProperty("apple.awt.fileDialogForDirectories", "false"); - } - } - } - - @Override - public int showSaveDialog(Component parent) { - fileDialog.setLocale(JComponent.getDefaultLocale()); - fileDialog.setMode(FileDialog.SAVE); - fileDialog.setVisible(true); - return fileDialog.getFile() == null ? JFileChooser.CANCEL_OPTION : JFileChooser.APPROVE_OPTION; - } - - @Override - public void setExtensionFilter(String file) { - fileDialog.setFile(file); - } - - /** - * 确认本地文件选择器是否支持选择模式 - * @param selectionMode 选择模式 - * @return 是否支持选择模式 - */ - public static boolean supportsSelectionMode(int selectionMode) { - switch (selectionMode) { - case JFileChooser.FILES_AND_DIRECTORIES: - return false; - case JFileChooser.DIRECTORIES_ONLY: - return OperatingSystem.isMacos(); - case JFileChooser.FILES_ONLY: - default: - return true; - } - } - -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java new file mode 100644 index 000000000..36507cf37 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/CenterRegionContainerPane.java @@ -0,0 +1,278 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignState; +import com.fr.design.base.mode.DesignModeContext; +import com.fr.design.constants.UIConstants; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.file.NewTemplatePane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.imenu.UIMenuHighLight; +import com.fr.design.gui.itoolbar.UILargeToolbar; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import org.jetbrains.annotations.Nullable; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.border.MatteBorder; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.util.ArrayList; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/4/6 + */ +public class CenterRegionContainerPane extends JPanel { + + private static volatile CenterRegionContainerPane THIS; + + private static final int LEFT_ALIGN_GAP = -5; + + private DesktopCardPane centerTemplateCardPane; + + private JPanel toolbarPane;//撤销重做 等工具栏 + 模板tab标签 + maybe have cpt 字体 + + private JComponent toolbarComponent;//cpt 字体 等工具栏 + + private JPanel eastPane;//=largeToolbar+eastCenterPane + private UILargeToolbar largeToolbar;//预览 + + private JPanel eastCenterPane;//=combineUp + templateTabPane + + private UIToolbar combineUp;//撤销重做 等工具栏 + + private JPanel templateTabPane;//新建模板 + 模板tab标签 + private NewTemplatePane newWorkBookPane;//新建模板button + + + public static CenterRegionContainerPane getInstance() { + if (THIS == null) { + synchronized (CenterRegionContainerPane.class) { + if (THIS == null) { + THIS = new CenterRegionContainerPane(); + } + } + } + return THIS; + } + + public CenterRegionContainerPane() { + + toolbarPane = new JPanel() { + + @Override + public Dimension getPreferredSize() { + + Dimension dim = super.getPreferredSize(); + // dim.height = TOOLBAR_HEIGHT; + return dim; + } + }; + toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); + eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + eastPane.add(largeToolbar = getToolBarMenuDock().createLargeToolbar(), BorderLayout.WEST); + eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + combineUpTooBar(); + eastCenterPane.add(combineUp, BorderLayout.NORTH); + templateTabPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + templateTabPane.add(newWorkBookPane = getToolBarMenuDock().getNewTemplatePane(), BorderLayout.WEST); + templateTabPane.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); + eastCenterPane.add(templateTabPane, BorderLayout.CENTER); + + eastPane.add(eastCenterPane, BorderLayout.CENTER); + toolbarPane.add(eastPane, BorderLayout.NORTH); + toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); + + this.setLayout(new BorderLayout()); + this.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); + this.add(toolbarPane, BorderLayout.NORTH); + + } + + private ToolBarMenuDock getToolBarMenuDock() { + return DesignerContext.getDesignerFrame().getToolBarMenuDock(); + } + + /** + * 创建上工具栏 + */ + private void combineUpTooBar() { + combineUp = new UIToolbar(FlowLayout.LEFT); + combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); + combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); + setUpUpToolBar(null); + + } + + + /** + * 重置上工具栏 + */ + private void resetCombineUpTooBar(JComponent[] toolbar4Form, ToolBarMenuDockPlus plus) { + combineUp.removeAll(); + setUpUpToolBar(toolbar4Form); + plus.insertToCombineUpToolbar(combineUp); + } + + + /** + * 填充上工具栏的中的工具 + * + * @param toolbar4Form 目标组件 + */ + private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { + UIButton[] fixButtons = getToolBarMenuDock().createUp(); + for (UIButton fixButton : fixButtons) { + combineUp.add(fixButton); + } + if (!DesignModeContext.isAuthorityEditing()) { + combineUp.addSeparator(new Dimension(2, 16)); + if (toolbar4Form != null) { + for (JComponent jComponent : toolbar4Form) { + combineUp.add(jComponent); + } + } + //添加检测按钮 + addCheckButton(); + } + //添加分享按钮 + addShareButton(); + //添加插件中的按钮 + addExtraButtons(); + } + + + private void addExtraButtons() { + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + + UIButton[] extraButtons = jt.createExtraButtons(); + for (UIButton extraButton : extraButtons) { + combineUp.add(extraButton); + } + if (extraButtons.length > 0) { + combineUp.addSeparator(new Dimension(2, 16)); + } + } + + private void addCheckButton() { + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] checkButtons = jt.createCheckButton(); + for (UIButton checkButton : checkButtons) { + combineUp.add(checkButton); + } + } + + private void addShareButton() { + + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt == null) { + return; + } + + combineUp.addSeparator(new Dimension(2, 16)); + UIButton[] shareButtons = jt.createShareButton(); + for (UIButton shareButton : shareButtons) { + combineUp.add(shareButton); + } + } + + /** + * 检查 + * + * @param flag 组件是否可见 + * @param al 组件名称 + */ + protected void checkCombineUp(boolean flag, ArrayList al) { + //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return + if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { + return; + } + combineUp.checkComponentsByNames(flag, al); + } + } + + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + protected void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { + + resetCombineUpTooBar(ad.resetUpToolBar(plus), plus); + + if (toolbarComponent != null) { + toolbarPane.remove(toolbarComponent); + } + + // 颜色,字体那些按钮的工具栏 + toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + + if (plus.hasToolBarPane()) { + this.add(toolbarPane, BorderLayout.NORTH); + } else { + this.remove(toolbarPane); + } + + resetByDesignMode(); + } + + private void resetByDesignMode() { + if (DesignModeContext.isDuchampMode()) { + eastPane.remove(largeToolbar); + eastCenterPane.remove(templateTabPane); + centerTemplateCardPane.refresh(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); + } else { + eastPane.add(largeToolbar, BorderLayout.WEST); + eastCenterPane.add(templateTabPane, BorderLayout.CENTER); + } + + } + + JComponent getToolbarComponent() { + + return this.toolbarComponent; + } + + /** + * 判断是否在权限编辑状态,若是在权限编辑状态,则需要有虚线框和关闭突变 + */ + protected void needToAddAuhtorityPaint() { + newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); + + } + + + protected DesktopCardPane getCenterTemplateCardPane() { + + return centerTemplateCardPane; + } + + protected void refreshUIToolBar() { + if (toolbarComponent instanceof UIToolbar) { + ((UIToolbar ) toolbarComponent).refreshUIToolBar(); + } + combineUp.refreshUIToolBar(); + getToolBarMenuDock().updateEnable(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index b7bc51838..39cdbb930 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -4,9 +4,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.chart.exception.ChartNotFoundException; import com.fr.design.DesignModelAdapter; -import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.core.ActionFactory; @@ -22,24 +20,16 @@ import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.file.NewTemplatePane; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.OemProcessor; -import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.imenu.UIMenuHighLight; import com.fr.design.gui.iprogressbar.ProgressDialog; import com.fr.design.gui.iscrollbar.UIScrollBar; -import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.vcs.common.VcsHelper; -import com.fr.design.menu.MenuManager; import com.fr.design.menu.ShortCut; import com.fr.design.os.impl.MacOsAddListenerAction; import com.fr.design.os.impl.SupportOSImpl; @@ -51,49 +41,32 @@ import com.fr.file.FILE; import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralContext; import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.context.PluginContext; -import com.fr.plugin.injectable.PluginModule; -import com.fr.plugin.manage.PluginFilter; -import com.fr.plugin.observer.PluginEvent; -import com.fr.plugin.observer.PluginEventListener; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.os.OperatingSystem; -import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.project.ProjectConstants; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLayeredPane; -import javax.swing.JMenuBar; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.WindowConstants; -import javax.swing.border.MatteBorder; import java.awt.BorderLayout; -import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Graphics; -import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.datatransfer.DataFlavor; @@ -116,9 +89,12 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; +import java.util.concurrent.CopyOnWriteArrayList; public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { @@ -128,8 +104,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private static final long serialVersionUID = -8732559571067484460L; - private static final int LEFT_ALIGN_GAP = -5; - private static final int MENU_HEIGHT = 26; private static final Integer SECOND_LAYER = 100; @@ -140,22 +114,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private ToolBarMenuDock ad; - private DesktopCardPane centerTemplateCardPane; - - private JPanel toolbarPane; - - private JComponent toolbarComponent; - - private JPanel menuPane; - - private JMenuBar menuBar; - - private JPanel eastCenterPane; - - private UIToolbar combineUp; - - private NewTemplatePane newWorkBookPane; - private Icon closeMode; private JLayeredPane layeredPane = this.getLayeredPane(); @@ -285,37 +243,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // the content pane basePane.setLayout(new BorderLayout()); - toolbarPane = new JPanel() { - @Override - public Dimension getPreferredSize() { - - Dimension dim = super.getPreferredSize(); - // dim.height = TOOLBAR_HEIGHT; - return dim; - } - }; - toolbarPane.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel eastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - eastPane.add(ad.createLargeToolbar(), BorderLayout.WEST); - eastCenterPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - combineUpTooBar(); - eastCenterPane.add(combineUp, BorderLayout.NORTH); - JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.add(newWorkBookPane = ad.getNewTemplatePane(), BorderLayout.WEST); - panel.add(MutilTempalteTabPane.getInstance(), BorderLayout.CENTER); - eastCenterPane.add(panel, BorderLayout.CENTER); - - eastPane.add(eastCenterPane, BorderLayout.CENTER); - toolbarPane.add(eastPane, BorderLayout.NORTH); - toolbarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane.add(centerTemplateCardPane = new DesktopCardPane(), BorderLayout.CENTER); - centerPane.add(toolbarPane, BorderLayout.NORTH); - - - basePane.add(centerPane, BorderLayout.CENTER); + basePane.add(CenterRegionContainerPane.getInstance(), BorderLayout.CENTER); laoyoutWestPane(); basePane.add(EastRegionContainerPane.getInstance(), BorderLayout.EAST); basePane.setBounds(0, 0, contentWidth, contentHeight); @@ -423,7 +352,11 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public DesktopCardPane getCenterTemplateCardPane() { - return centerTemplateCardPane; + return CenterRegionContainerPane.getInstance().getCenterTemplateCardPane(); + } + + public void refreshUIToolBar() { + CenterRegionContainerPane.getInstance().refreshUIToolBar(); } /** @@ -431,80 +364,12 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ protected void initMenuPane() { - menuPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - menuPane.add(new UIMenuHighLight(), BorderLayout.SOUTH); - menuPane.add(initNorthEastPane(ad), BorderLayout.EAST); - basePane.add(menuPane, BorderLayout.NORTH); + basePane.add(NorthRegionContainerPane.getInstance(), BorderLayout.NORTH); this.resetToolkitByPlus(null); } - /** - * @param ad 菜单栏 - * @return panel - */ protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { - //hugh: private修改为protected方便oem的时候修改右上的组件构成 - //顶部日志+登陆按钮 - final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - //优先级为-1,保证最后全面刷新一次 - GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { - - @Override - public void on(PluginEvent event) { - - refreshNorthEastPane(northEastPane, ad); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (DesignerContext.getDesignerFrame() == null) { - return; - } - DesignerContext.getDesignerFrame().refresh(); - DesignerContext.getDesignerFrame().repaint(); - } - }); - } - }, new PluginFilter() { - - @Override - public boolean accept(PluginContext context) { - - return context.contain(PluginModule.ExtraDesign); - } - }); - refreshNorthEastPane(northEastPane, ad); - return northEastPane; - } - - private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { - - northEastPane.removeAll(); - northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); - northEastPane.add(LogMessageBar.getInstance()); - TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); - if (processor != null) { - final Component[] bbsLoginPane = {null}; - OSSupportCenter.buildAction(new OSBasedAction() { - @Override - public void execute(Object... objects) { - bbsLoginPane[0] = ad.createBBSLoginPane(); - } - }, SupportOSImpl.USERINFOPANE); - processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); - } - northEastPane.add(ad.createAlphaFinePane()); - if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { - ad.createAlphaFinePane().setVisible(false); - } - northEastPane.add(ad.createNotificationCenterPane()); - - OSSupportCenter.buildAction(new OSBasedAction() { - @Override - public void execute(Object... objects) { - northEastPane.add(ad.createBBSLoginPane()); - } - }, SupportOSImpl.USERINFOPANE); - + return NorthRegionContainerPane.getInstance().initNorthEastPane(ad); } public void initTitleIcon() { @@ -698,94 +563,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.closeMode = closeMode; } - /** - * 创建上工具栏 - */ - private void combineUpTooBar() { - combineUp = new UIToolbar(FlowLayout.LEFT); - combineUp.setBorder(new MatteBorder(new Insets(0, LEFT_ALIGN_GAP, 1, 0), UIConstants.LINE_COLOR)); - combineUp.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 2)); - setUpUpToolBar(null); - - } - - /** - * 重置上工具栏 - */ - private void resetCombineUpTooBar(JComponent[] toolbar4Form) { - combineUp.removeAll(); - setUpUpToolBar(toolbar4Form); - } - - /** - * 填充上工具栏的中的工具 - * - * @param toolbar4Form 目标组件 - */ - private void setUpUpToolBar(@Nullable JComponent[] toolbar4Form) { - UIButton[] fixButtons = ad.createUp(); - for (UIButton fixButton : fixButtons) { - combineUp.add(fixButton); - } - if (!DesignModeContext.isAuthorityEditing()) { - combineUp.addSeparator(new Dimension(2, 16)); - if (toolbar4Form != null) { - for (JComponent jComponent : toolbar4Form) { - combineUp.add(jComponent); - } - } - //添加检测按钮 - addCheckButton(); - } - //添加分享按钮 - addShareButton(); - //添加插件中的按钮 - addExtraButtons(); - } - - private void addExtraButtons() { - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - - UIButton[] extraButtons = jt.createExtraButtons(); - for (UIButton extraButton : extraButtons) { - combineUp.add(extraButton); - } - if (extraButtons.length > 0) { - combineUp.addSeparator(new Dimension(2, 16)); - } - } - - private void addCheckButton() { - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] checkButtons = jt.createCheckButton(); - for (UIButton checkButton : checkButtons) { - combineUp.add(checkButton); - } - } - - private void addShareButton() { - - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - - combineUp.addSeparator(new Dimension(2, 16)); - UIButton[] shareButtons = jt.createShareButton(); - for (UIButton shareButton : shareButtons) { - combineUp.add(shareButton); - } - } - /** * 检查 * @@ -793,17 +570,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param al 组件名称 */ public void checkCombineUp(boolean flag, ArrayList al) { - //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (jTemplate != null) { - // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return - if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { - return; - } - combineUp.checkComponentsByNames(flag, al); - } + CenterRegionContainerPane.getInstance().checkCombineUp(flag, al); } + /** * 刷新工具条. */ @@ -812,6 +582,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.ad.updateToolBarDef(); } + ToolBarMenuDock getToolBarMenuDock() { + return this.ad; + } + /** * 重置相关的工具条. * @@ -823,39 +597,18 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta plus = ToolBarMenuDock.NULLAVOID; } - DesignState designState = new DesignState(plus); - MenuManager.getInstance().setMenus4Designer(designState); - if (menuBar == null) { - menuPane.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); - } else { - ad.resetJMenuBar(menuBar, plus); - } + NorthRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad); - resetCombineUpTooBar(ad.resetUpToolBar(plus)); - - if (toolbarComponent != null) { - toolbarPane.remove(toolbarComponent); - } - - // 颜色,字体那些按钮的工具栏 - toolbarPane.add(toolbarComponent = ad.resetToolBar(toolbarComponent, plus), BorderLayout.CENTER); + CenterRegionContainerPane.getInstance().resetToolkitByPlus(plus, ad); this.checkToolbarMenuEnable(); this.validate(); layeredPane.repaint(); } - public void refreshUIToolBar() { - if (toolbarComponent instanceof UIToolbar) { - ((UIToolbar ) toolbarComponent).refreshUIToolBar(); - } - combineUp.refreshUIToolBar(); - this.ad.updateEnable(); - } - public JComponent getToolbarComponent() { - return this.toolbarComponent; + return CenterRegionContainerPane.getInstance().getToolbarComponent(); } /** @@ -863,7 +616,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void needToAddAuhtorityPaint() { - newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); + CenterRegionContainerPane.getInstance().needToAddAuhtorityPaint(); // 进入或退出权限编辑模式,通知插件 Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); @@ -981,7 +734,43 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public JTemplate getSelectedJTemplate() { - return this.centerTemplateCardPane.getSelectedJTemplate(); + return getCenterTemplateCardPane().getSelectedJTemplate(); + } + + /** + * 保存当前编辑的模板 + */ + + public void saveCurrentEditingTemplate() { + + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (editingTemplate == null) { + return; + } + if (editingTemplate.isSaved()) {// isSaved == true表示已经保存过,或者新建的一张模板 + if (editingTemplate.getEditingFILE().exists()) {// 表示磁盘上的某一张已经保存过的模板,要添加到历史中 + // HistoryTemplateListPane.getInstance().addHistory(); + } + } else { + editingTemplate.stopEditing(); + if (!editingTemplate.getEditingFILE().exists()) { + int returnVal = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + editingTemplate.getEditingFILE() + + "\" ?", Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + if (returnVal == JOptionPane.YES_OPTION && editingTemplate.saveTemplate()) { + editingTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", + editingTemplate.getEditingFILE().getName())); + } + } else { + if (editingTemplate.saveTemplate()) { + editingTemplate.saveTemplate(); + FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", + editingTemplate.getEditingFILE().getName())); + } + } + } } /** @@ -1010,10 +799,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (jt == null || jt.getEditingFILE() == null) { return; } + if (currentTemplateDeactivateFail()) { + return; + } jt.addJTemplateActionListener(this); jt.addTargetModifiedListener(this); jt.addJTemplateActionListener(VcsHelper.getInstance()); - centerTemplateCardPane.showJTemplate(jt); + getCenterTemplateCardPane().showJTemplate(jt); + refreshBaseContentPane(jt); setTitle(); layeredPane.repaint(); } @@ -1031,11 +824,57 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (jt == null || jt.getEditingFILE() == null) { return; } - centerTemplateCardPane.showJTemplate(jt); + if (currentTemplateDeactivateFail()) { + return; + } + getCenterTemplateCardPane().showJTemplate(jt); + refreshBaseContentPane(jt); setTitle(); layeredPane.repaint(); } + /** + * 当前模板 停用失败 + * + * @return 是否停用失败 + */ + private boolean currentTemplateDeactivateFail() { + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + return currentEditingTemplate != null && !currentEditingTemplate.deactivateTemplate(); + } + + + /** + * 根据模板刷新 设计器整个界面 + * + * @param jTemplate 当前模板 + */ + public void refreshBaseContentPane(JTemplate jTemplate) { + + JComponent north = jTemplate.north4DesignerFrame(), + center = jTemplate.center4DesignerFrame(), + west = jTemplate.west4DesignerFrame(), + east = jTemplate.east4DesignerFrame(); + + basePane.removeAll(); + + if (north != null) { + basePane.add(north, BorderLayout.NORTH); + } + if (center != null) { + basePane.add(center, BorderLayout.CENTER); + } + if (west != null) { + basePane.add(west, BorderLayout.WEST); + } + if (east != null) { + basePane.add(east, BorderLayout.EAST); + } + + layeredPane.repaint(); + layeredPane.revalidate(); + } + /** * 对象侦听 * @@ -1107,16 +946,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta JOptionPane.WARNING_MESSAGE, UIManager.getIcon("OptionPane.errorIcon") ); - if (this.getSelectedJTemplate() == null) { - addAndActivateJTemplate(); - } - } catch (ChartNotFoundException e) { - FineJOptionPane.showMessageDialog(this, - Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"), - Toolkit.i18nText("Fine-Design_Basic_Error"), - JOptionPane.ERROR_MESSAGE, - UIManager.getIcon("OptionPane.errorIcon")); - if (this.getSelectedJTemplate() == null) { addAndActivateJTemplate(); } @@ -1339,4 +1168,4 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta return designerOpened; } -} +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index f3afcacc9..0e26ff3de 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -53,7 +53,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener // 判断是否切换设计器状态到禁止拷贝剪切 if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT); - } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { + } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) { DesignModeContext.switchTo(DesignerMode.NORMAL); } // 切换时 @@ -61,6 +61,11 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener component.fireTabChange(); } DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); + + refresh(jt); + } + + protected void refresh(final JTemplate jt) { if (component != null) { layeredPane.remove(component); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 847a2dcba..84993411e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -16,7 +16,6 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.reuse.ReuseGuideDialog; import com.fr.design.mainframe.reuse.SnapChatKeys; import com.fr.design.mainframe.share.collect.ComponentCollector; -import com.fr.design.menu.SnapChatUtil; import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; import com.fr.design.ui.util.UIUtil; @@ -114,7 +113,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer { POLY_REPORT, // 聚合报表-报表块 POLY_CHART(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings")), // 聚合报表-图表块 AUTHORITY_EDITION, // 权限编辑 - AUTHORITY_EDITION_DISABLED; // 权限编辑 + AUTHORITY_EDITION_DISABLED, // 权限编辑 + DUCHAMP_REPORT; private String title; @@ -280,15 +280,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 单元格元素 PropertyItem cellElement = new PropertyItem(KEY_CELL_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Element"), "cellelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 单元格属性 PropertyItem cellAttr = new PropertyItem(KEY_CELL_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), "cellattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 悬浮元素 PropertyItem floatElement = new PropertyItem(KEY_FLOAT_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Float_Element"), "floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 控件设置 PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"), "widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY}, @@ -296,11 +296,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { // 条件属性 PropertyItem conditionAttr = new PropertyItem(KEY_CONDITION_ATTR, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), "conditionattr", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 超级链接 PropertyItem hyperlink = new PropertyItem(KEY_HYPERLINK, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Hyperlink"), "hyperlink", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_PARA_WIDGET, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, - new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT}); + new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT, PropertyMode.DUCHAMP_REPORT}); // 组件库 widgetLibSnapChat = SnapChatFactory.createSnapChat(false, SnapChatKeys.COMPONENT); PropertyItem widgetLib = new PropertyItem( 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 f1bc2cbaf..8b76b30f4 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 @@ -25,7 +25,6 @@ import com.fr.design.dialog.InformationWarnPane; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateResourceManager; -import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; import com.fr.design.fun.PreviewProvider; @@ -35,7 +34,6 @@ import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.chart.info.ChartInfoCollector; @@ -83,12 +81,8 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JOptionPane; -import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; import java.awt.BorderLayout; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; import java.util.Set; import java.util.concurrent.Callable; @@ -97,6 +91,7 @@ import java.util.concurrent.Callable; */ public abstract class JTemplate> extends TargetComponent implements ToolBarMenuDockPlus, DesignerProxy, JTemplateSave, TabChangeListener { // TODO ALEX_SEP editingFILE这个属性一定要吗?如果非要不可,有没有可能保证不为null + private static final int PREFIX_NUM = 3000; protected FILE editingFILE = null; // alex:初始状态为saved,这样不管是新建模板,还是打开模板,如果未做任何操作直接关闭,不提示保存 @@ -116,7 +111,6 @@ public abstract class JTemplate> protected TemplateProcessInfo processInfo; private JComponent centerPane; - private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private DesignModelAdapter designModel; private PreviewProvider previewType; /** @@ -142,7 +136,7 @@ public abstract class JTemplate> } public JTemplate(T t, String defaultFileName) { - this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); + this(t, new MemFILE(JTemplateNameHelper.newTemplateNameByIndex(defaultFileName)), true); } public JTemplate(T t, FILE file) { @@ -163,7 +157,7 @@ public abstract class JTemplate> // 判断是否切换设计器状态到禁止拷贝剪切 if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT); - } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { + } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing() && !DesignModeContext.isDuchampMode()) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); } this.template = t; @@ -654,8 +648,6 @@ public abstract class JTemplate> /** * 添加图片到格子中 - * - * @return 返回图片URI */ public void setPictureElem(Elem elem, CellImage cellImage) { // 子类实现 @@ -865,7 +857,7 @@ public abstract class JTemplate> return false; } try { - this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); + export(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), "Save Error", JOptionPane.ERROR_MESSAGE); @@ -879,65 +871,9 @@ public abstract class JTemplate> return true; } - private static String newTemplateNameByIndex(String prefix) { - // 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt" - // 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1 - TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree(); - DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot(); - String[] str = new String[gen.getChildCount()]; - - List reportNum = new ArrayList<>(); - for (int j = 0; j < gen.getChildCount(); j++) { - str[j] = gen.getChildAt(j).toString(); - //返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了) - Integer index = getFileNameIndex(prefix, str[j]); - if (index != null) { - reportNum.add(index); - } - } - Collections.sort(reportNum); - int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1; - - idx = idx + currentIndex; - currentIndex++; - return prefix + idx; - } - - /** - * @return java.lang.Integer WorkBook11.cpt则返回11,如果没有找到index返回null - * @Description 返回文件名中的index - * @param: prefix 前缀 - * @param: fileName 文件名称全名 - * @Author Henry.Wang - * @Date 2021/4/9 11:13 - **/ - private static Integer getFileNameIndex(String prefix, String fileName) { - char[] chars = new char[fileName.length()]; - int i = 0; - for (; i < fileName.length(); i++) { - char c = fileName.charAt(i); - //匹配前缀 - if (i < prefix.length()) { - if (c != prefix.charAt(i)) { - return null; - } - } else { - if (c == '.') { - break; - } else { - //匹配0~9 - if (c < 48 || c > 57) { - return null; - } - chars[i - prefix.length()] = c; - } - } - } - String s = new String(chars).substring(0, i - prefix.length()); - if (StringUtils.isBlank(s)) { - return null; - } - return Integer.valueOf(s); + protected boolean export() throws Exception { + return this.getTarget().export(TemplateResourceManager.getResource().saveTemplate(editingFILE)); + } // /////////////////////////////toolbarMenuDock////////////////////////////////// @@ -1192,6 +1128,16 @@ public abstract class JTemplate> DesignerContext.getDesignerFrame().addAndActivateJTemplate(this); } + /** + * 将要激活打开其他模板,使当前模板灭活 + * 默认 do nothing 返回true + * + * @return true:成功停用当前模板 + */ + public boolean deactivateTemplate() { + return true; + } + /** * 返回当前支持的超链界面pane @@ -1304,15 +1250,6 @@ public abstract class JTemplate> */ public abstract Icon getIcon(); - /** - * 导出菜单项 - * - * @return 菜单项 - */ - @Override - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[0]; - } /** * 复制JS代码 @@ -1430,6 +1367,46 @@ public abstract class JTemplate> return StringUtils.EMPTY; } + /** + * 指定 设计器界面 NORTH组件 + * 默认是 菜单区域 + * + * @return NORTH组件 + */ + public JComponent north4DesignerFrame() { + return NorthRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 CENTER组件 + * 默认是 模板对应的工具栏区域+模板设计区域 + * + * @return CENTER组件 + */ + public JComponent center4DesignerFrame() { + return CenterRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 WEST组件 + * 默认是 模板目录树+数据集编辑区域 + * + * @return WEST组件 + */ + public JComponent west4DesignerFrame() { + return WestRegionContainerPane.getInstance(); + } + + /** + * 指定 设计器界面 EAST组件 + * 默认是 属性配置界面 + * + * @return EAST组件 + */ + public JComponent east4DesignerFrame() { + return EastRegionContainerPane.getInstance(); + } + private CallbackSaveWorker save(boolean showLoc) { FILE editingFILE = this.getEditingFILE(); // carl:editingFILE没有,当然不存了,虽然不会有这种情况 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java new file mode 100644 index 000000000..4e201a5ef --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateNameHelper.java @@ -0,0 +1,83 @@ +package com.fr.design.mainframe; + +import com.fr.design.file.TemplateTreePane; +import com.fr.design.gui.itree.filetree.TemplateFileTree; +import com.fr.stable.StringUtils; + +import javax.swing.tree.DefaultMutableTreeNode; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/5/7 + */ +public class JTemplateNameHelper { + + private static final int PREFIX_NUM = 3000; + + private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 + + public static String newTemplateNameByIndex(String prefix) { + // 用于获取左侧模板的文件名,如左侧已包含"WorkBook1.cpt, WorkBook12.cpt, WorkBook177.cpt" + // 那么新建的文件名将被命名为"WorkBook178.cpt",即取最大数+1 + TemplateFileTree tt = TemplateTreePane.getInstance().getTemplateFileTree(); + DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot(); + String[] str = new String[gen.getChildCount()]; + + List reportNum = new ArrayList<>(); + for (int j = 0; j < gen.getChildCount(); j++) { + str[j] = gen.getChildAt(j).toString(); + //返回文件名中的index(算法中没有再匹配文件后缀了,因为DefaultMutableTreeNode中已经匹配过了) + Integer index = getFileNameIndex(prefix, str[j]); + if (index != null) { + reportNum.add(index); + } + } + Collections.sort(reportNum); + int idx = reportNum.size() > 0 ? reportNum.get(reportNum.size() - 1) + 1 : 1; + + idx = idx + currentIndex; + currentIndex++; + return prefix + idx; + } + + /** + * @return java.lang.Integer WorkBook11.cpt则返回11,如果没有找到index返回null + * @Description 返回文件名中的index + * @param: prefix 前缀 + * @param: fileName 文件名称全名 + * @Author Henry.Wang + * @Date 2021/4/9 11:13 + **/ + private static Integer getFileNameIndex(String prefix, String fileName) { + char[] chars = new char[fileName.length()]; + int i = 0; + for (; i < fileName.length(); i++) { + char c = fileName.charAt(i); + //匹配前缀 + if (i < prefix.length()) { + if (c != prefix.charAt(i)) { + return null; + } + } else { + if (c == '.') { + break; + } else { + //匹配0~9 + if (c < 48 || c > 57) { + return null; + } + chars[i - prefix.length()] = c; + } + } + } + String s = new String(chars).substring(0, i - prefix.length()); + if (StringUtils.isBlank(s)) { + return null; + } + return Integer.valueOf(s); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java new file mode 100644 index 000000000..b07071057 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -0,0 +1,144 @@ +package com.fr.design.mainframe; + +import com.fr.design.DesignState; +import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.TitlePlaceProcessor; +import com.fr.design.gui.imenu.UIMenuHighLight; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.loghandler.LogMessageBar; +import com.fr.design.mainframe.toolbar.ToolBarMenuDock; +import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import com.fr.design.menu.MenuManager; +import com.fr.design.os.impl.SupportOSImpl; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.stable.os.support.OSBasedAction; +import com.fr.stable.os.support.OSSupportCenter; + +import javax.swing.JMenuBar; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/4/6 + */ +public class NorthRegionContainerPane extends JPanel { + + private static volatile NorthRegionContainerPane THIS; + + private JMenuBar menuBar; + + public static NorthRegionContainerPane getInstance() { + if (THIS == null) { + synchronized (NorthRegionContainerPane.class) { + if (THIS == null) { + THIS = new NorthRegionContainerPane(); + } + } + } + return THIS; + } + + public NorthRegionContainerPane() { + + ToolBarMenuDock ad = DesignerContext.getDesignerFrame().getToolBarMenuDock(); + + this.setLayout(new BorderLayout()); + this.add(new UIMenuHighLight(), BorderLayout.SOUTH); + this.add(initNorthEastPane(ad), BorderLayout.EAST); + } + + /** + * @param ad 菜单栏 + * @return panel + */ + protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { + //hugh: private修改为protected方便oem的时候修改右上的组件构成 + //顶部日志+登陆按钮 + final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + //优先级为-1,保证最后全面刷新一次 + GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { + + @Override + public void on(PluginEvent event) { + + refreshNorthEastPane(northEastPane, ad); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (DesignerContext.getDesignerFrame() == null) { + return; + } + DesignerContext.getDesignerFrame().refresh(); + DesignerContext.getDesignerFrame().repaint(); + } + }); + } + }, new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign); + } + }); + refreshNorthEastPane(northEastPane, ad); + return northEastPane; + } + + private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { + + northEastPane.removeAll(); + northEastPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0)); + northEastPane.add(LogMessageBar.getInstance()); + TitlePlaceProcessor processor = ExtraDesignClassManager.getInstance().getSingle(TitlePlaceProcessor.MARK_STRING); + if (processor != null) { + final Component[] bbsLoginPane = {null}; + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + bbsLoginPane[0] = ad.createBBSLoginPane(); + } + }, SupportOSImpl.USERINFOPANE); + processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); + } + northEastPane.add(ad.createAlphaFinePane()); + if (!DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isEnabled()) { + ad.createAlphaFinePane().setVisible(false); + } + northEastPane.add(ad.createNotificationCenterPane()); + + OSSupportCenter.buildAction(new OSBasedAction() { + @Override + public void execute(Object... objects) { + northEastPane.add(ad.createBBSLoginPane()); + } + }, SupportOSImpl.USERINFOPANE); + + } + + /** + * 重置相关的工具条. + * + * @param plus 工具条中相关信息 + */ + void resetToolkitByPlus(ToolBarMenuDockPlus plus, ToolBarMenuDock ad) { + DesignState designState = new DesignState(plus); + MenuManager.getInstance().setMenus4Designer(designState); + if (menuBar == null) { + this.add(menuBar = ad.createJMenuBar(plus), BorderLayout.CENTER); + } else { + ad.resetJMenuBar(menuBar, plus); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index a2d0ec83f..d8e5b4a57 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -9,7 +9,19 @@ import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; -import com.fr.design.actions.community.*; +import com.fr.design.actions.community.BBSAction; +import com.fr.design.actions.community.BugAction; +import com.fr.design.actions.community.BugNeedAction; +import com.fr.design.actions.community.CenterAction; +import com.fr.design.actions.community.FacebookFansAction; +import com.fr.design.actions.community.NeedAction; +import com.fr.design.actions.community.QuestionAction; +import com.fr.design.actions.community.SignAction; +import com.fr.design.actions.community.TechSolutionAction; +import com.fr.design.actions.community.TechSupportAction; +import com.fr.design.actions.community.TemplateStoreAction; +import com.fr.design.actions.community.VideoAction; +import com.fr.design.actions.community.WorkOrderCenterAction; import com.fr.design.actions.file.CloseCurrentTemplateAction; import com.fr.design.actions.file.ExitDesignerAction; import com.fr.design.actions.file.OpenRecentReportMenuDef; @@ -64,7 +76,6 @@ import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; import com.fr.stable.bridge.ObjectHolder; -import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; @@ -141,16 +152,6 @@ public abstract class ToolBarMenuDock { return PANLE_HEIGNT; } - /** - * 导出菜单的子菜单 ,目前用于图表设计器 - * - * @return 子菜单 - */ - @Override - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[0]; - } - }; private static final int MENUBAR_HEIGHT = 22; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java index ada075aeb..4de9018ac 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDockPlus.java @@ -1,11 +1,13 @@ package com.fr.design.mainframe.toolbar; -import javax.swing.*; - +import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import javax.swing.JComponent; +import javax.swing.JPanel; + public interface ToolBarMenuDockPlus { /** * 模板的工具 @@ -54,10 +56,19 @@ public interface ToolBarMenuDockPlus { int getToolBarHeight(); /** - * 导出菜单的子菜单 ,目前用于图表设计器 + * 是否含有工具栏 包含:预览按钮 复制粘贴那一行 模板标签页那一行 字体颜色那一行 * - * @return 子菜单 + * @return 默认返回true */ - ShortCut[] shortcut4ExportMenu(); + default boolean hasToolBarPane() { + return true; + } + + /** + * 往 复制粘贴那一行工具栏 插入 工具栏按钮 + */ + default void insertToCombineUpToolbar(UIToolbar combineUp) { + } + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java index 1e5e96ab1..57f0d59d6 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java +++ b/designer-base/src/main/java/com/fr/design/style/background/image/ImageFileChooser.java @@ -3,266 +3,77 @@ */ package com.fr.design.style.background.image; -import com.fr.base.BaseUtils; import com.fr.design.DesignerEnvManager; -import com.fr.design.style.ChooseFileView; - - -import javax.swing.filechooser.FileFilter; -import java.awt.Component; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.share.collect.ComponentCollector; +import com.fr.design.mainframe.toast.DesignerToastMsgUtil; +import javafx.stage.FileChooser; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.io.File; -import java.util.Enumeration; -import java.util.Hashtable; /** * This class used to choose image files. */ -public class ImageFileChooser extends ExpandFileChooser { +public class ImageFileChooser { + + JavaFxNativeFileChooser javaFxNativeFileChooser; public ImageFileChooser() { - super(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Compress"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Open")); - ExampleFileFilter bothFilter = new ExampleFileFilter( - new String[]{"jpg", "gif", "png", "bmp"}, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Image_Files")); - bothFilter.setExtensionListInDescription(true); - this.addChoosableFileFilter(bothFilter); - this.setAcceptAllFileFilterUsed(false); + javaFxNativeFileChooser = + new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.FILE). + title(Toolkit.i18nText("Fine-Design_Basic_Open")). + filters(new FileChooser.ExtensionFilter[]{ + new FileChooser.ExtensionFilter("jpg", "*.jpg"), + new FileChooser.ExtensionFilter("gif", "*.gif"), + new FileChooser.ExtensionFilter("png", "*.png"), + new FileChooser.ExtensionFilter("bmp", "*.bmp")}). + build(); + } - // Create Custom FileView - ChooseFileView fileView = new ChooseFileView(); - fileView.putIcon("jpg", BaseUtils.readIcon("/com/fr/base/images/dialog/file/jpgFile.gif")); - fileView.putIcon("gif", BaseUtils.readIcon("/com/fr/base/images/dialog/file/gifFile.gif")); - fileView.putIcon("png", BaseUtils.readIcon("/com/fr/base/images/dialog/file/pngFile.png")); - fileView.putIcon("bmp", BaseUtils.readIcon("/com/fr/base/images/dialog/file/bmpFile.gif")); - this.setFileView(fileView); + public int showOpenDialog(Component parent, String approveButtonText) { + return showOpenDialog(parent); } - public int showDialog(Component parent, String approveButtonText) { - return super.showDialog(parent, approveButtonText); + public int showOpenDialog(Component parent) { + showImageCompressMoveTip(); + return javaFxNativeFileChooser.showDialog(parent); } - @Override - public ActionListener checkAction() { - return new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - DesignerEnvManager.getEnvManager().setImageCompress(isCheckSelected()); - DesignerEnvManager.getEnvManager().saveXMLFile(); - } - }; - + public void setCurrentDirectory(File file) { + javaFxNativeFileChooser.setCurrentDirectory(file); } - /** - * A convenience implementation of FileFilter that filters out - * all files except for those type extensions that it knows about. - *

D:\finereport\develop\code\test\TestCase\WEB-INF\reportlets\TestCase\01903.cpt - *

- * Extensions are of the type ".foo", which is typically found on - * Windows and Unix boxes, but not on Macinthosh. Case is ignored. - *

- * Example - create a new filter that filerts out all files - * but gif and jpg image files: - *

- * JFileChooser chooser = new JFileChooser(); - * ExampleFileFilter filter = new ExampleFileFilter( - * new String{"gif", "jpg"}, "JPEG & GIF Images") - * chooser.addChoosableFileFilter(filter); - * chooser.showOpenDialog(this); - * - * @author Jeff Dinkins - * @version 1.12 12/03/01 - */ - class ExampleFileFilter extends FileFilter { - private Hashtable filters = null; - private String description = null; - private String fullDescription = null; - private boolean useExtensionsInDescription = true; - - /** - * Creates a file filter. If no filters are added, then all - * files are accepted. - * - * @see #addExtension - */ - public ExampleFileFilter() { - this.filters = new Hashtable(); - } - - /** - * Creates a file filter that accepts files with the given extension. - * Example: new ExampleFileFilter("jpg"); - * - * @see #addExtension - */ - public ExampleFileFilter(String extension) { - this(extension, null); - } - - /** - * Creates a file filter that accepts the given file type. - * Example: new ExampleFileFilter("jpg", "JPEG Image Images"); - *

- * Note that the "." before the extension is not needed. If - * provided, it will be ignored. - * - * @see #addExtension - */ - public ExampleFileFilter(String extension, String description) { - this(); - if (extension != null) addExtension(extension); - if (description != null) setDescription(description); - } - - /** - * Creates a file filter from the given string array. - * Example: new ExampleFileFilter(String {"gif", "jpg"}); - *

- * Note that the "." before the extension is not needed adn - * will be ignored. - * - * @see #addExtension - */ - public ExampleFileFilter(String[] filters) { - this(filters, null); - } - - /** - * Creates a file filter from the given string array and description. - * Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images"); - *

- * Note that the "." before the extension is not needed and will be ignored. - * - * @see #addExtension - */ - public ExampleFileFilter(String[] filters, String description) { - this(); - for (int i = 0; i < filters.length; i++) { - // add filters one by one - addExtension(filters[i]); - } - if (description != null) setDescription(description); - } - - /** - * Return true if this file should be shown in the directory pane, - * false if it shouldn't. - *

- * Files that begin with "." are ignored. - * - * @see #getExtension - */ - public boolean accept(File f) { - if (f != null) { - if (f.isDirectory()) { - return true; - } - String extension = getExtension(f); - if (extension != null && filters.get(getExtension(f)) != null) { - return true; - } - } - return false; - } - - /** - * Return the extension portion of the file's name . - * - * @see #getExtension - * @see javax.swing.filechooser.FileFilter#accept - */ - public String getExtension(File f) { - if (f != null) { - String filename = f.getName(); - int i = filename.lastIndexOf('.'); - if (i > 0 && i < filename.length() - 1) { - return filename.substring(i + 1).toLowerCase(); - } - } - return null; - } - - /** - * Adds a filetype "dot" extension to filter against. - *

- * For example: the following code will create a filter that filters - * out all files except those that end in ".jpg" and ".tif": - *

- * ExampleFileFilter filter = new ExampleFileFilter(); - * filter.addExtension("jpg"); - * filter.addExtension("tif"); - *

- * Note that the "." before the extension is not needed and will be ignored. - */ - public void addExtension(String extension) { - if (filters == null) { - filters = new Hashtable(5); - } - filters.put(extension.toLowerCase(), this); - fullDescription = null; - } - - - /** - * Returns the human readable description of this filter. For - * example: "JPEG and GIF Image Files (*.jpg, *.gif)" - * - * @see javax.swing.filechooser.FileFilter#getDescription - */ - public String getDescription() { - if (fullDescription == null) { - if (description == null || isExtensionListInDescription()) { - fullDescription = description == null ? "(" : description + " ("; - // build the description from the extension list - Enumeration extensions = filters.keys(); - if (extensions != null) { - fullDescription += "." + extensions.nextElement(); - while (extensions.hasMoreElements()) { - fullDescription += ", ." + extensions.nextElement(); - } - } - fullDescription += ")"; - } else { - fullDescription = description; - } - } - return fullDescription; + public void setMultiSelectionEnabled(boolean multiple) { + if (multiple) { + javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.MULTIPLE_FILE); + } else { + javaFxNativeFileChooser.setSelectionMode(FileSelectionMode.FILE); } + } - /** - * Sets the human readable description of this filter. For - * example: filter.setDescription("Gif and JPG Images"); - */ - public void setDescription(String description) { - this.description = description; - fullDescription = null; - } + public File getSelectedFile() { + return javaFxNativeFileChooser.getSelectedFile(); + } - /** - * Determines whether the extension list (.jpg, .gif, etc) should - * show up in the human readable description. - *

- * Only relevent if a description was provided in the constructor - * or using setDescription(); - */ - public void setExtensionListInDescription(boolean b) { - useExtensionsInDescription = b; - fullDescription = null; - } + public boolean isCheckSelected() { + return DesignerEnvManager.getEnvManager().isImageCompress(); + } - /** - * Returns whether the extension list (.jpg, .gif, etc) should - * show up in the human readable description. - *

- * Only relevent if a description was provided in the constructor - * or using setDescription(); - */ - public boolean isExtensionListInDescription() { - return useExtensionsInDescription; + private void showImageCompressMoveTip() { + if (DesignerEnvManager.getEnvManager().isShowImageCompressMoveTip()) { + DesignerToastMsgUtil.toastWarning(Toolkit.i18nText("Fine-Design_Image_Compress_Move_Tip")); + DesignerEnvManager.getEnvManager().setShowImageCompressMoveTip(false); } } } diff --git a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java index 8616b647b..54b115264 100644 --- a/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java @@ -11,10 +11,10 @@ import com.fr.stable.os.OperatingSystem; public class ModernUIPaneFactory { public static ModernUIPane.Builder modernUIPaneBuilder() { - if (OperatingSystem.isWindows()) { - return new NewModernUIPane.Builder<>(); - } else { - return new ModernUIPane.Builder<>(); - } +// if (OperatingSystem.isWindows()) { +// return new NewModernUIPane.Builder<>(); +// } else { +// } + return new ModernUIPane.Builder<>(); } } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java index fb40d5434..fee07ac46 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java @@ -14,6 +14,9 @@ import com.fr.design.extra.exe.GetPluginPrefixExecutor; import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; import com.fr.design.extra.exe.SearchOnlineExecutor; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.i18n.Toolkit; import com.fr.design.locale.impl.BbsRegisterMark; import com.fr.design.locale.impl.BbsResetMark; @@ -36,6 +39,7 @@ import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.JSArray; import com.teamdev.jxbrowser.chromium.JSFunction; import com.teamdev.jxbrowser.chromium.JSObject; +import javafx.stage.FileChooser; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; @@ -95,7 +99,7 @@ public class UpmBridge { @JSBridge public void startDownload(final JSFunction callback) { callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); - new SwingWorker(){ + new SwingWorker() { @Override protected Void doInBackground() throws Exception { UpmResourceLoader.INSTANCE.download(); @@ -308,16 +312,13 @@ public class UpmBridge { RunnableFuture future = new FutureTask<>(new Callable() { @Override public String call() { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - - if (StringUtils.isNotEmpty(filter)) { - fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter))); - } - - int result = fileChooser.showOpenDialog(UpmFinder.getDialog()); + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.FILE). + filter(des, filter). + build(); + int result = fileChooserProvider.showDialog(UpmFinder.getDialog()); if (result == JFileChooser.APPROVE_OPTION) { - return fileChooser.getSelectedFile().getAbsolutePath(); + return fileChooserProvider.getSelectedFile().getAbsolutePath(); } return null; } @@ -345,11 +346,11 @@ public class UpmBridge { public String call() { JFileChooser fileChooser = new JFileChooser(); List filterList = new ArrayList<>(); - if (args instanceof String) { + if (args instanceof String) { filterList.add(GeneralUtils.objectToString(args)); } else if (args instanceof JSArray) { - JSArray array = (JSArray)args; - for (int i = 0, len = array.length(); i < len; i ++) { + JSArray array = (JSArray) args; + for (int i = 0, len = array.length(); i < len; i++) { filterList.add(array.get(i).getStringValue()); } } diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index ef66fc039..9e03dcc9d 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -10,6 +10,8 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.itextarea.DescriptionTextArea; @@ -28,6 +30,7 @@ import com.fr.stable.ListMap; import com.fr.stable.StringUtils; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; +import javafx.stage.FileChooser; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -108,7 +111,7 @@ public class CustomIconPane extends BasicPane { } - protected String createDescriptionText(){ + protected String createDescriptionText() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_Message1"); } @@ -447,13 +450,12 @@ public class CustomIconPane extends BasicPane { } private void onBrowseButtonClicked() { - JFileChooser jf = new JFileChooser(); // carl:不知道是否只要png格式,反正导出时全部都转成png了 - FileNameExtensionFilter fileFilter = new FileNameExtensionFilter("Icon Image File", "jpg", "jpeg", "png", "gif"); - jf.setFileFilter(fileFilter); - - if (JFileChooser.APPROVE_OPTION == jf.showOpenDialog(DesignerContext.getDesignerFrame())) { - String path = jf.getSelectedFile().getAbsolutePath(); + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). + filter("Icon Image File", "*.jpg", "*.jpeg", "*.png", "*.gif"). + build(); + if (JFileChooser.APPROVE_OPTION == fileChooserProvider.showDialog(DesignerContext.getDesignerFrame())) { + String path = fileChooserProvider.getSelectedFile().getAbsolutePath(); // 图片存储有最大值48*48限制,没有超过最大值时,按原图大小存储,超过最大值后,压缩至最大值存储 Image image = BaseUtils.readImage(path); iconImage = ImageUtils.scale((BufferedImage) image, Math.min(image.getWidth(null), IconManager.MAXSTORAGE_ICONWIDTH), Math.min(image.getHeight(null), IconManager.MAXSTORAGE_ICONHEIGHT), true, Image.SCALE_SMOOTH); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index e0a9d8ece..1ea909ccc 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -9,6 +9,9 @@ import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPassWordField; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; @@ -561,11 +564,10 @@ public class RemoteEnvPane extends BasicBeanPane { fileChooserButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - int saveValue = fileChooser.showOpenDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this)); + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().fileSelectionMode(FileSelectionMode.FILE).build(); + int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this)); if (saveValue == JFileChooser.APPROVE_OPTION) { - File selectedFile = fileChooser.getSelectedFile(); + File selectedFile = fileChooserProvider.getSelectedFile(); certPathInput.setText(selectedFile.getAbsolutePath()); } } diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png new file mode 100644 index 000000000..74e79ee24 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png new file mode 100755 index 000000000..238e4735d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_bottom_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png new file mode 100755 index 000000000..a1b89ab78 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png new file mode 100755 index 000000000..2f811f7bf Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png new file mode 100755 index 000000000..d01dab47e Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png new file mode 100755 index 000000000..2fe36d65e Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_left_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png new file mode 100755 index 000000000..d402fb2bd Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_right_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png new file mode 100755 index 000000000..6865975a6 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_top_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png new file mode 100755 index 000000000..20988ce03 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png new file mode 100755 index 000000000..432b2854e Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png new file mode 100755 index 000000000..8b8019beb Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png differ diff --git a/designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java b/designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java new file mode 100644 index 000000000..032e715f6 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/mainframe/JTemplateNameHelperTest.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe; + +import junit.framework.TestCase; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/5/8 + */ +public class JTemplateNameHelperTest extends TestCase { + + public void testNewTemplateNameByIndex() { + + String name = JTemplateNameHelper.newTemplateNameByIndex("TEST"); + + assertEquals("TEST1", name); + + String name1 = JTemplateNameHelper.newTemplateNameByIndex("TEST"); + + assertEquals("TEST2", name1); + + } +} diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index a9dcca2a2..8600a8c14 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -8,7 +8,6 @@ import com.fr.chart.fun.ChartTypeProvider; import com.fr.chartx.attr.ChartProvider; import com.fr.common.annotations.Compatible; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.condition.ConditionAttributesPane; @@ -46,7 +45,6 @@ import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.locale.InterProviderFactory; -import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.box.VanChartBoxPlot; @@ -75,7 +73,6 @@ import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.solution.closeable.CloseableContainedMap; import com.fr.stable.ArrayUtils; -import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.area.AreaIndependentVanChartInterface; @@ -100,17 +97,7 @@ import com.fr.van.chart.treemap.TreeMapIndependentVanChartInterface; import com.fr.van.chart.wordcloud.designer.WordCloudIndependentVanChartInterface; import javax.swing.Icon; -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.awt.event.ActionListener; - -import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY; -import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY; -import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY; /** * Created by eason on 14/12/29. @@ -120,10 +107,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static ChartTypeInterfaceManager classManager = new ChartTypeInterfaceManager(); - private static LinkedHashMap> chartTypeInterfaces = - new LinkedHashMap>(); - - private static Map idAndPriorityMap = new HashMap(); + private static CloseableContainedMap chartTypeUIs = new CloseableContainedMap<>(HashMap.class); public static final String TYPE_PANE_DEFAULT_TITLE = "DEFAULT_NAME"; @@ -186,127 +170,69 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static void readVanChart() { - addChartTypeInterface(VAN_CHART_PRIORITY, PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); - addChartTypeInterface(VAN_CHART_PRIORITY, VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); + addChartTypeInterface(PiePlot4VanChart.VAN_CHART_PIE_PLOT, new PieIndependentVanChartInterface()); + addChartTypeInterface(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID, new VanColumnChartTypeUI()); + addChartTypeInterface(VanChartColumnPlot.VAN_CHART_BAR_PLOT_ID, new BarIndependentVanChartInterface()); + addChartTypeInterface(VanChartLinePlot.VAN_CHART_LINE_PLOT, new LineIndependentVanChartInterface()); + addChartTypeInterface(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID, new AreaIndependentVanChartInterface()); + addChartTypeInterface(VanChartGaugePlot.VAN_CHART_GAUGE_PLOT, new GaugeIndependentVanChartInterface()); + addChartTypeInterface(VanChartRadarPlot.VAN_CHART_RADAR_PLOT, new RadarIndependentVanChartInterface()); + addChartTypeInterface(VanChartScatterPlot.VAN_CHART_SCATTER_PLOT_ID, new ScatterIndependentVanChartInterface()); + addChartTypeInterface(VanChartBubblePlot.VAN_CHART_BUBBLE_PLOT_ID, new BubbleIndependentVanChartInterface()); + addChartTypeInterface(VanChartCustomPlot.VAN_CHART_CUSTOM_PLOT_ID, new CustomIndependentVanChartInterface()); + addChartTypeInterface(VanChartMultiPiePlot.VAN_CHART_MULTILAYER_PLOT_ID, new MultiPieIndependentVanChartInterface()); + addChartTypeInterface(VanChartMapPlot.VAN_CHART_MAP_ID, new VanMapChartTypeUI()); + addChartTypeInterface(VanChartDrillMapPlot.VAN_CHART_DRILL_MAP_ID, new VanDrillMapChartTypeUI()); + addChartTypeInterface(VanChartTreeMapPlot.VAN_CHART_TREE_MAP_PLOT_ID, new TreeMapIndependentVanChartInterface()); + addChartTypeInterface(VanChartFunnelPlot.VAN_CHART_FUNNEL_PLOT_ID, new FunnelIndependentVanChartInterface()); + addChartTypeInterface(VanChartHeatMapPlot.VAN_CHART_HEAT_MAP_ID, new VanHeatMapChartTypeUI()); + addChartTypeInterface(VanChartWordCloudPlot.WORD_CLOUD_PLOT_ID, new WordCloudIndependentVanChartInterface()); + addChartTypeInterface(VanChartGanttPlot.VAN_CHART_GANTT_PLOT_ID, new GanttIndependentVanChartInterface()); + addChartTypeInterface(VanChartStructurePlot.STRUCTURE_PLOT_ID, new VanStructureChartTypeUI()); + addChartTypeInterface(VanChartBoxPlot.VAN_CHART_BOX_PLOT_ID, new BoxIndependentVanChartInterface()); } private static void readDefault() { - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); - addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); - } - - private static void addChartTypeInterface(String priority, String plotID, ChartTypeUIProvider provider) { - - if (chartTypeInterfaces != null) { - if (!chartTypeInterfaces.containsKey(priority)) { - //新建一个具体图表列表 - CloseableContainedMap chartUIList - = new CloseableContainedMap(LinkedHashMap.class); - chartUIList.put(plotID, provider); - chartTypeInterfaces.put(priority, chartUIList); - } else { - Map chartUIList = chartTypeInterfaces.get(priority); - if (!chartUIList.containsKey(plotID)) { - chartUIList.put(plotID, provider); - } - } - idAndPriorityMap.put(plotID, priority); + addChartTypeInterface(ChartConstants.COLUMN_CHART, new ColumnChartTypeUI()); + addChartTypeInterface(ChartConstants.LINE_CHART, new LineChartTypeUI()); + addChartTypeInterface(ChartConstants.BAR_CHART, new BarChartTypeUI()); + addChartTypeInterface(ChartConstants.PIE_CHART, new PieChartTypeUI()); + addChartTypeInterface(ChartConstants.AREA_CHART, new AreaChartTypeUI()); + addChartTypeInterface(ChartConstants.SCATTER_CHART, new XYScatterChartTypeUI()); + addChartTypeInterface(ChartConstants.BUBBLE_CHART, new BubbleChartTypeUI()); + addChartTypeInterface(ChartConstants.RADAR_CHART, new RadarChartTypeUI()); + addChartTypeInterface(ChartConstants.STOCK_CHART, new StockChartTypeUI()); + addChartTypeInterface(ChartConstants.METER_CHART, new MeterChartTypeUI()); + addChartTypeInterface(ChartConstants.RANGE_CHART, new RangeChartTypeUI()); + addChartTypeInterface(ChartConstants.CUSTOM_CHART, new CustomChartTypeUI()); + addChartTypeInterface(ChartConstants.GANTT_CHART, new GanttChartTypeUI()); + addChartTypeInterface(ChartConstants.DONUT_CHART, new DonutChartTypeUI()); + addChartTypeInterface(ChartConstants.MAP_CHART, new MapChartTypeUI()); + addChartTypeInterface(ChartConstants.GIS_CHAER, new GisMapChartTypeUI()); + addChartTypeInterface(ChartConstants.FUNNEL_CHART, new FunnelChartTypeUI()); + } + + private static void addChartTypeInterface(String id, ChartTypeUIProvider provider) { + + if (chartTypeUIs != null) { + chartTypeUIs.put(id, provider); } } - private ChartTypeUIProvider getChartTypeInterface(String plotID) { - if (idAndPriorityMap.containsKey(plotID)) { - String priority = idAndPriorityMap.get(plotID); - if (chartTypeInterfaces.containsKey(priority)) { - return chartTypeInterfaces.get(priority).get(plotID); - } + private ChartTypeUIProvider getChartTypeInterface(String id) { + if (chartTypeUIs.containsKey(id)) { + return chartTypeUIs.get(id); } return null; } - /** - * 把所有的pane加到list里 - * - * @param paneList pane容器 - */ - public void addPlotTypePaneList(List> paneList, - Map>> allChartTypePane, - ActionListener autoButtonListener) { - - List priorityList = getPriorityInOrder(); - for (Integer aPriorityList : priorityList) { - String priority = String.valueOf(aPriorityList); - addPlotTypePaneList(priority, paneList, allChartTypePane, autoButtonListener); - } - } - - - public void addPlotTypePaneList(String priority, List> paneList, - Map>> allChartTypePane, - ActionListener autoButtonListener) { - - if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { - - Map chartUIList = chartTypeInterfaces.get(priority); - - Iterator> iterator = chartUIList.entrySet().iterator(); - while (iterator.hasNext()) { - try { - Map.Entry entry = iterator.next(); - String plotID = entry.getKey(); - - AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); - if (AssistUtils.equals(pane.title4PopupWindow(), TYPE_PANE_DEFAULT_TITLE)) { - continue; - } - pane.reLayout(plotID); - pane.registerButtonListener(autoButtonListener); - paneList.add(pane); - - if (allChartTypePane.get(priority) == null) { - allChartTypePane.put(priority, new LinkedHashMap>()); - } - allChartTypePane.get(priority).put(plotID, pane); - } catch (Throwable e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } + public AbstractChartTypePane getPlotTypePane(String id) { + if (chartTypeUIs.containsKey(id)) { + return chartTypeUIs.get(id).getPlotTypePane(); } + return null; } @Compatible @@ -314,23 +240,9 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr return getName(plotID); } - private List getPriorityInOrder() { - - List priorityList = new ArrayList(); - if (chartTypeInterfaces != null) { - Iterator iterator = chartTypeInterfaces.entrySet().iterator(); - while (iterator.hasNext()) { - Map.Entry entry = (Map.Entry) iterator.next(); - String priority = (String) entry.getKey(); - priorityList.add(Integer.valueOf(priority)); - } - } - return ChartTypeManager.orderInPriority(priorityList); - } - public String getIconPath(String plotID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(plotID); if (provider != null) { return provider.getIconPath(); @@ -341,7 +253,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public String[] getDemoImagePath(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String[] result = null; @@ -397,7 +309,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } public String[] getSubName(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String[] subNames = null; @@ -430,7 +342,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } public String getName(String chartID) { - if (chartTypeInterfaces != null) { + if (chartTypeUIs != null) { ChartTypeUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { String name = null; @@ -575,9 +487,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr if (StringUtils.isEmpty(id)) { id = injection.getAttribute("plotID"); } - String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); ChartTypeUIProvider instance = (ChartTypeUIProvider) injection.getObject(); - addChartTypeInterface(priority, id, instance); + addChartTypeInterface(id, instance); } } @@ -586,22 +497,18 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public void demount(PluginSingleInjection injection) { if (isChartTypeUIProvider(injection)) { - String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); String id = injection.getAttribute("chartID"); if (StringUtils.isEmpty(id)) { id = injection.getAttribute("plotID"); } - removeChartTypeInterface(priority, id); + removeChartTypeInterface(id); } } - private void removeChartTypeInterface(String priority, String plotID) { + private void removeChartTypeInterface(String id) { - if (chartTypeInterfaces != null) { - if (chartTypeInterfaces.containsKey(priority)) { - Map chartUIList = chartTypeInterfaces.get(priority); - chartUIList.remove(plotID); - } + if (chartTypeUIs != null) { + chartTypeUIs.remove(id); } } diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java b/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java index 1843a1886..10ee1bc8a 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/ChartTypeUIProvider.java @@ -90,7 +90,9 @@ public interface ChartTypeUIProvider extends Level { //todo:把下面这些接口删除 @Deprecated - boolean needChartChangePane(); + default boolean needChartChangePane() { + return false; + } /** * 数据集数据源的界面 @@ -98,7 +100,9 @@ public interface ChartTypeUIProvider extends Level { * @return 数据集数据源的界面 */ @Deprecated - AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent); + default AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { + return null; + } /** @@ -107,7 +111,9 @@ public interface ChartTypeUIProvider extends Level { * @return 单元格数据源的界面 */ @Deprecated - AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent); + default AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { + return null; + } /** * 条件属性界面 @@ -115,7 +121,9 @@ public interface ChartTypeUIProvider extends Level { * @return 条件属性界面 */ @Deprecated - ConditionAttributesPane getPlotConditionPane(Plot plot); + default ConditionAttributesPane getPlotConditionPane(Plot plot) { + return null; + } /** * 系列界面 @@ -123,7 +131,9 @@ public interface ChartTypeUIProvider extends Level { * @return 系列界面 */ @Deprecated - BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot); + default BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { + return null; + } /** * 是否使用默认的界面,为了避免界面来回切换 @@ -131,12 +141,18 @@ public interface ChartTypeUIProvider extends Level { * @return 是否使用默认的界面 */ @Deprecated - boolean isUseDefaultPane(); + default boolean isUseDefaultPane() { + return false; + } @Deprecated - ChartEditPane getChartEditPane(String plotID); + default ChartEditPane getChartEditPane(String plotID) { + return new ChartEditPane(); + } @Deprecated - ChartsConfigPane getChartConfigPane(String plotID); + default ChartsConfigPane getChartConfigPane(String plotID) { + return null; + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java b/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java index 88a14c090..d9005788f 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/IndependentChartUIProvider.java @@ -6,6 +6,7 @@ import com.fr.common.annotations.Compatible; * Created by shine on 2019/09/05. */ @Compatible +@Deprecated public interface IndependentChartUIProvider extends ChartTypeUIProvider { } diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java index c37ff939d..445355928 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractChartTypeUI.java @@ -1,19 +1,11 @@ package com.fr.design.chart.fun.impl; -import com.fr.chart.chartattr.Plot; -import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chartx.impl.AbstractDataPane; -import com.fr.design.chartx.impl.AbstractOtherPane; -import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.mainframe.chart.ChartEditPane; -import com.fr.design.mainframe.chart.ChartsConfigPane; -import com.fr.design.mainframe.chart.gui.ChartDataPane; -import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; +import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; @@ -24,13 +16,15 @@ import com.fr.stable.fun.mark.API; public abstract class AbstractChartTypeUI extends AbstractProvider implements ChartTypeUIProvider { @Override - public abstract AbstractChartTypePane getPlotTypePane(); + public AbstractChartTypePane getPlotTypePane() { + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new DefaultChartTypePane(); + } @Override public abstract AbstractDataPane getChartDataPane(AttributeChangeListener listener); @Override - public abstract AbstractOtherPane[] getAttrPaneArray(AttributeChangeListener listener); + public abstract AbstractChartAttrPane[] getAttrPaneArray(AttributeChangeListener listener); @Override public String[] getSubName() { @@ -46,45 +40,4 @@ public abstract class AbstractChartTypeUI extends AbstractProvider implements Ch public String mark4Provider() { return getClass().getName(); } - - @Override - public boolean needChartChangePane() { - return false; - } - - @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { - return null; - } - - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { - return null; - } - - @Override - public boolean isUseDefaultPane() { - return false; - } - - @Override - public ChartEditPane getChartEditPane(String plotID) { - return new ChartEditPane(); - } - - @Override - public ConditionAttributesPane getPlotConditionPane(Plot plot) { - return null; - } - - @Override - public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { - return null; - } - - @Override - public ChartsConfigPane getChartConfigPane(String plotID) { - return null; - } - } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java index f6a1b20fc..8fa0f34dc 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java @@ -17,6 +17,7 @@ import com.fr.stable.StableUtils; /** * Created by Mitisky on 16/3/7. */ +@Deprecated public abstract class AbstractIndependentChartUIWithAPILevel implements ChartTypeUIProvider { //这个不能改,是做兼容用的 //2016.10.14-11.24号的8.0jar因为改了这个为3,不会提示5.26号之前的插件更新 diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java new file mode 100644 index 000000000..9d6b6fdf7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/DefaultChartTypePane.java @@ -0,0 +1,38 @@ +package com.fr.design.chart.fun.impl; + +import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; +import com.fr.design.ChartTypeInterfaceManager; +import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2020/7/8 + */ +public class DefaultChartTypePane extends AbstractChartTypePane { + + @Override + protected String[] getTypeIconPath() { + return ChartTypeInterfaceManager.getInstance().getDemoImagePath(this.getPlotID()); + } + + @Override + protected String[] getTypeTipName() { + return ChartTypeInterfaceManager.getInstance().getSubName(this.getPlotID()); + } + + public ChartProvider getDefaultChart() { + return ChartTypeManager.getInstance().getChartTypes(this.getPlotID())[0]; + } + + public String title4PopupWindow() { + return ChartTypeInterfaceManager.getInstance().getName(this.getPlotID()); + } + + @Override + public void populateBean(T ob) { + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java new file mode 100644 index 000000000..6bc927b17 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/fun/impl/InvisibleChartTypePane.java @@ -0,0 +1,15 @@ +package com.fr.design.chart.fun.impl; + +import com.fr.design.ChartTypeInterfaceManager; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/6/25 + */ +public class InvisibleChartTypePane extends DefaultChartTypePane { + @Override + public String title4PopupWindow() { + return ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java index 8cd0743da..133e2fef7 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapCustomPane.java @@ -9,6 +9,8 @@ import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.FilterComboBox; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.DesignerContext; @@ -40,56 +42,56 @@ import java.awt.event.ItemListener; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-10-15 下午03:38:15 */ -public class MapCustomPane extends BasicBeanPane implements AbstrctMapAttrEditPane{ // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) +public class MapCustomPane extends BasicBeanPane implements AbstrctMapAttrEditPane { // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替) - private FilterComboBox areaString;// 区域字段 - private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮 - private MapImageEditPane imageShowPane; // 图片展示编辑的界面 - private String lastSelectPath; - private boolean isNeedDataSource = true; + private FilterComboBox areaString;// 区域字段 + private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮 + private MapImageEditPane imageShowPane; // 图片展示编辑的界面 + private String lastSelectPath; + private boolean isNeedDataSource = true; - public MapCustomPane() { - initComp(); - } + public MapCustomPane() { + initComp(); + } - public MapCustomPane(boolean isNeedDataSource){ - this.isNeedDataSource = isNeedDataSource; - initComp(); - } + public MapCustomPane(boolean isNeedDataSource) { + this.isNeedDataSource = isNeedDataSource; + initComp(); + } - private void initComp() { - this.setLayout(new BorderLayout(0, 0)); + private void initComp() { + this.setLayout(new BorderLayout(0, 0)); - JPanel pane = new JPanel(); - this.add(pane, BorderLayout.NORTH); + JPanel pane = new JPanel(); + this.add(pane, BorderLayout.NORTH); - pane.setLayout(new BorderLayout()); + pane.setLayout(new BorderLayout()); - pane.add(northPaneCreate(), BorderLayout.NORTH); + pane.add(northPaneCreate(), BorderLayout.NORTH); - imageShowPane = new MapImageEditPane(); + imageShowPane = new MapImageEditPane(); - pane.add(imageShowPane, BorderLayout.CENTER); - } + pane.add(imageShowPane, BorderLayout.CENTER); + } - private JPanel northPaneCreate() { - JPanel northPane = new JPanel(); + private JPanel northPaneCreate() { + JPanel northPane = new JPanel(); - northPane.setLayout(new FlowLayout(FlowLayout.LEFT)); + northPane.setLayout(new FlowLayout(FlowLayout.LEFT)); - UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map")); - loadMap.setPreferredSize(new Dimension(160, 20)); - northPane.add(loadMap); + UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map")); + loadMap.setPreferredSize(new Dimension(160, 20)); + northPane.add(loadMap); - loadMap.addActionListener(selectPictureActionListener); + loadMap.addActionListener(selectPictureActionListener); - if(isNeedDataSource){ - UILabel label =new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT) ; + if (isNeedDataSource) { + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT); tableDataNameBox = new DatabaseTableDataPane(label) { - protected void userEvent() { -refreshAreaNameBox(); -} + protected void userEvent() { + refreshAreaNameBox(); + } }; tableDataNameBox.setPreferredSize(new Dimension(200, 20)); northPane.add(tableDataNameBox); @@ -100,158 +102,156 @@ refreshAreaNameBox(); areaString.setPreferredSize(new Dimension(120, 20)); areaString.addItemListener(areaChange); northPane.add(areaString); - } - - - return northPane; - } - - private ActionListener selectPictureActionListener = new ActionListener() { - - public void actionPerformed(ActionEvent evt) { - JFileChooser svgFileChooser = new JFileChooser(); - svgFileChooser.addChoosableFileFilter(new SVGFileFilter()); - if (StringUtils.isNotBlank(lastSelectPath)) { - svgFileChooser.setSelectedFile(new File(lastSelectPath)); - } - int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = svgFileChooser.getSelectedFile(); - try { - lastSelectPath = selectedFile.getCanonicalPath(); - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - if (selectedFile != null && selectedFile.isFile()) { + } + + + return northPane; + } + + private ActionListener selectPictureActionListener = new ActionListener() { + + public void actionPerformed(ActionEvent evt) { + FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). + filter(".svg, .svgz", "*.svg", "*.svgz"). + currentDirectory(lastSelectPath).build(); + int returnVal = fileChooserProvider.showDialog(DesignerContext.getDesignerFrame()); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = fileChooserProvider.getSelectedFile(); + try { + lastSelectPath = selectedFile.getCanonicalPath(); + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + if (selectedFile != null && selectedFile.isFile()) { imageShowPane.setSvgMap(selectedFile.getPath()); imageShowPane.repaint(); - } - } - } - }; - - private ItemListener areaChange = new ItemListener() { - public void itemStateChanged(ItemEvent e) { - Object select = areaString.getSelectedItem(); - if (select != null) { - String colName = Utils.objectToString(areaString.getSelectedItem()); - - TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); - - imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); - } - } - }; - - public static List getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { - List colValues = new ArrayList<>(); - - EmbeddedTableData embeddedTableData = null; - try { - embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); - } catch (Exception ee) { + } + } + } + }; + + private ItemListener areaChange = new ItemListener() { + public void itemStateChanged(ItemEvent e) { + Object select = areaString.getSelectedItem(); + if (select != null) { + String colName = Utils.objectToString(areaString.getSelectedItem()); + + TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); + + imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); + } + } + }; + + public static List getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { + List colValues = new ArrayList<>(); + + EmbeddedTableData embeddedTableData = null; + try { + embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); + } catch (Exception ee) { FineLoggerFactory.getLogger().error(ee.getMessage(), ee); - } - - if(embeddedTableData == null){ - return colValues; - } - - int columnIndex = getColumnIndex(embeddedTableData, colName); - - if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){ - return colValues; - } - - for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { - String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); - if (!colValues.contains(colValueName)) { - colValues.add(colValueName); - } - } - - return colValues; - } - - private static int getColumnIndex(EmbeddedTableData tableData, String colName) { - for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { - if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { - return columnIndex; - } - } - return DataModel.COLUMN_NAME_NOT_FOUND; - } - - /** - * 选中方式: 区域或者点 - */ - public void setImageSelectType(int selectType) { - if (imageShowPane != null) { - imageShowPane.setEditType(selectType); - } - } - - private void refreshAreaNameBox() {// 刷新区域名称列表 - if(!isNeedDataSource){ - return; - } - TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); - if (tableDataWrappe == null) { - return; - } - List columnNameList = tableDataWrappe.calculateColumnNameList(); - - Object oldSelected = areaString.getSelectedItem(); - areaString.removeAllItems(); - - for(String item : columnNameList) { - areaString.addItem(item); - } - areaString.getModel().setSelectedItem(oldSelected); - } + } + + if (embeddedTableData == null) { + return colValues; + } + + int columnIndex = getColumnIndex(embeddedTableData, colName); + + if (columnIndex == DataModel.COLUMN_NAME_NOT_FOUND) { + return colValues; + } + + for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { + String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); + if (!colValues.contains(colValueName)) { + colValues.add(colValueName); + } + } + + return colValues; + } + + private static int getColumnIndex(EmbeddedTableData tableData, String colName) { + for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { + if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { + return columnIndex; + } + } + return DataModel.COLUMN_NAME_NOT_FOUND; + } + + /** + * 选中方式: 区域或者点 + */ + public void setImageSelectType(int selectType) { + if (imageShowPane != null) { + imageShowPane.setEditType(selectType); + } + } + + private void refreshAreaNameBox() {// 刷新区域名称列表 + if (!isNeedDataSource) { + return; + } + TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); + if (tableDataWrappe == null) { + return; + } + List columnNameList = tableDataWrappe.calculateColumnNameList(); + + Object oldSelected = areaString.getSelectedItem(); + areaString.removeAllItems(); + + for (String item : columnNameList) { + areaString.addItem(item); + } + areaString.getModel().setSelectedItem(oldSelected); + } /** * 当前正在编辑的条目的类别(国家,省市)名和地图名 * @param typeName 类别名 * @param mapName 地图名 */ - public void setTypeNameAndMapName(String typeName, String mapName){ + public void setTypeNameAndMapName(String typeName, String mapName) { imageShowPane.setTypeNameAndMapName(typeName, mapName); } - /** - * 根据地图名称 加载信息 - */ - public void populateBean(String list) { - imageShowPane.populateBean(list); - } - - /** - * 根据地图名称 保存信息 - */ - public String updateBean() { - // 地图类型等 加入Helper - return imageShowPane.updateBean(); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map"); - } - - /** - * 更新界面 - * @param attr 地图属性 - */ - public void populateMapAttr(MapSvgAttr attr) { - imageShowPane.populateMapSvgAttr(attr); - } - - /** - * 更新MapSvgAttr - * @return 返回属性 - */ - public MapSvgAttr updateCurrentAttr() { - return imageShowPane.updateWithOutSave(); - } + /** + * 根据地图名称 加载信息 + */ + public void populateBean(String list) { + imageShowPane.populateBean(list); + } + + /** + * 根据地图名称 保存信息 + */ + public String updateBean() { + // 地图类型等 加入Helper + return imageShowPane.updateBean(); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map"); + } + + /** + * 更新界面 + * @param attr 地图属性 + */ + public void populateMapAttr(MapSvgAttr attr) { + imageShowPane.populateMapSvgAttr(attr); + } + + /** + * 更新MapSvgAttr + * @return 返回属性 + */ + public MapSvgAttr updateCurrentAttr() { + return imageShowPane.updateWithOutSave(); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java index 5d2f2298a..5c692b292 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/LineMapAreaLngLatPaneWithComboBox.java @@ -2,7 +2,7 @@ package com.fr.design.chartx.data.map; import com.fr.chartx.data.field.diff.LineMapColumnFieldCollection; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; -import com.fr.design.chartx.fields.diff.LineMapDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.MapDataSetFieldsPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.i18n.Toolkit; @@ -24,15 +24,15 @@ public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWith private UIComboBox toLng_tab1; private UIComboBox toLat_tab1; - private LineMapDataSetFieldsPane lineMapDataSetFieldsPane; + private MapDataSetFieldsPane mapDataSetFieldsPane; - public LineMapAreaLngLatPaneWithComboBox(LineMapDataSetFieldsPane lineMapDataSetFieldsPane) { - this.lineMapDataSetFieldsPane = lineMapDataSetFieldsPane; + public LineMapAreaLngLatPaneWithComboBox(MapDataSetFieldsPane mapDataSetFieldsPane) { + this.mapDataSetFieldsPane = mapDataSetFieldsPane; initComponents(); } protected void initComponents() { - if (lineMapDataSetFieldsPane == null) { + if (mapDataSetFieldsPane == null) { return; } super.initComponents(); @@ -48,7 +48,7 @@ public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWith return createPane( new String[]{Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")}, - lineMapDataSetFieldsPane.createAreaPanel(fromArea_tab0), lineMapDataSetFieldsPane.createAreaPanel(toArea_tab0) + mapDataSetFieldsPane.createAreaPanel(fromArea_tab0), mapDataSetFieldsPane.createAreaPanel(toArea_tab0) ); } @@ -64,18 +64,19 @@ public class LineMapAreaLngLatPaneWithComboBox extends LineMapAreaLngLatPaneWith } return createPane( new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Start_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Start_Latitude"), - Toolkit.i18nText("Fine-Design_Chart_End_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_End_Longitude"), - Toolkit.i18nText("Fine-Design_Chart_End_Latitude")}, - lineMapDataSetFieldsPane.createAreaPanel(fromArea_tab1), + Toolkit.i18nText("Fine-Design_Chart_End_Latitude"), + Toolkit.i18nText("Fine-Design_Chart_End_Area_Name") + }, fromLng_tab1, fromLat_tab1, - lineMapDataSetFieldsPane.createAreaPanel(toArea_tab1), + fromArea_tab1, toLng_tab1, - toLat_tab1); + toLat_tab1, + toArea_tab1); } protected void populateTab0(LineMapColumnFieldCollection fieldCollection) { diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java index b3b503ddd..bb519cab6 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/map/PointMapAreaLngLatPaneWithComboBox.java @@ -2,7 +2,7 @@ package com.fr.design.chartx.data.map; import com.fr.chartx.data.field.diff.PointMapColumnFieldCollection; import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; -import com.fr.design.chartx.fields.diff.PointMapDataSetFieldsPane; +import com.fr.design.chartx.fields.diff.MapDataSetFieldsPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.i18n.Toolkit; @@ -20,15 +20,15 @@ public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWi private UIComboBox lng_tab1; private UIComboBox lat_tab1; - private PointMapDataSetFieldsPane pointMapDataSetFieldsPane; + private MapDataSetFieldsPane mapDataSetFieldsPane; - public PointMapAreaLngLatPaneWithComboBox(PointMapDataSetFieldsPane pointMapDataSetFieldsPane) { - this.pointMapDataSetFieldsPane = pointMapDataSetFieldsPane; + public PointMapAreaLngLatPaneWithComboBox(MapDataSetFieldsPane pointMapDataSetFieldsPane) { + this.mapDataSetFieldsPane = pointMapDataSetFieldsPane; initComponents(); } protected void initComponents() { - if (pointMapDataSetFieldsPane == null) { + if (mapDataSetFieldsPane == null) { return; } super.initComponents(); @@ -41,7 +41,7 @@ public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWi } return createPane( new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name")}, - pointMapDataSetFieldsPane.createAreaPanel(area_tab0) + mapDataSetFieldsPane.createAreaPanel(area_tab0) ); } @@ -53,8 +53,8 @@ public class PointMapAreaLngLatPaneWithComboBox extends PointMapAreaLngLatPaneWi lat_tab1 = new UIComboBox(); } return createPane( - new String[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Latitude")}, - pointMapDataSetFieldsPane.createAreaPanel(area_tab1), lng_tab1, lat_tab1 + new String[]{Toolkit.i18nText("Fine-Design_Chart_Longitude"), Toolkit.i18nText("Fine-Design_Chart_Latitude"), Toolkit.i18nText("Fine-Design_Chart_Area_Name")}, + lng_tab1, lat_tab1, area_tab1 ); } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java index f6975d3d9..597bac520 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java @@ -21,7 +21,7 @@ public abstract class AbstractCellDataFieldsWithSeriesValuePane extends protected abstract void update(T chart); + public String title4PopupWindow() { + return PaneTitleConstants.CHART_OTHER_TITLE; + } + @Override public void populate(ChartCollection collection) { if (collection == null) { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java index 4efe977ff..90b0e8805 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/ChartPropertyPane.java @@ -16,6 +16,7 @@ import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.AssistUtils; import javax.swing.BorderFactory; import javax.swing.Icon; @@ -35,6 +36,9 @@ public class ChartPropertyPane extends BaseChartPropertyPane { protected ChartEditPane chartEditPane; + //ID一样的话 不用新建chartEditPane + private String currentID; + private ChartPropertyPane() { initComponent(); } @@ -46,9 +50,12 @@ public class ChartPropertyPane extends BaseChartPropertyPane { @Override public void updateChartEditPane(String plotID) { - chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID); - chartEditPane.setContainer(container); - resetChartEditPane(); + if (!AssistUtils.equals(currentID, plotID)) { + chartEditPane = ChartTypeInterfaceManager.getInstance().getChartEditPane(plotID); + chartEditPane.setContainer(container); + currentID = plotID; + resetChartEditPane(); + } } @Override diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java deleted file mode 100644 index 307d457cf..000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/MapEditPane.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.fr.design.mainframe; - -import com.fr.chart.base.MapSvgAttr; -import com.fr.chart.base.MapSvgXMLHelper; -import com.fr.chart.chartglyph.MapShapeValue; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.chart.series.PlotSeries.AbstrctMapAttrEditPane; -import com.fr.design.chart.series.PlotSeries.MapCustomPane; -import com.fr.design.chart.series.PlotSeries.MapDefiAreaNamePane; -import com.fr.design.gui.frpane.UITabbedPane; - -import com.fr.stable.CoreConstants; -import com.fr.stable.StringUtils; - -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 7.1.1 - * Date: 14/12/2 - * Time: 下午7:17 - */ -public class MapEditPane extends BasicBeanPane{ - - private UITabbedPane tabbedPane; - private MapCustomPane areaPane ; -// private MapCustomPane pointPane; - private MapDefiAreaNamePane namedPane; - private String currentMapName; - private AbstrctMapAttrEditPane editingPane; - - private ChangeListener tabbedChangeListener = new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - switch ( tabbedPane.getSelectedIndex()){ - case 1: - namedPane.populateMapAttr(editingPane.updateCurrentAttr()); - editingPane = namedPane; - break; - default: - areaPane.populateMapAttr(editingPane.updateCurrentAttr()); - editingPane = areaPane; - } - } - } ; - - public MapEditPane(){ - initTabbedPane(); - this.setLayout(new BorderLayout()); - this.add(tabbedPane,BorderLayout.CENTER); - } - - private void initTabbedPane(){ - tabbedPane = new UITabbedPane(); - areaPane = new MapCustomPane(false); -// pointPane = new MapCustomPane(false); - namedPane= new MapDefiAreaNamePane(false); - areaPane.setImageSelectType(MapShapeValue.AREA); -// pointPane.setImageSelectType(MapShapeValue.POINT); - tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Image_Area"),areaPane); -// tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("FR-Chart-Map_ImagePoint"),pointPane); - tabbedPane.add(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Corresponding_Fields"),namedPane); - editingPane = areaPane; - } - - @Override - protected String title4PopupWindow() { - return null; - } - - @Override - public void populateBean(MapSvgAttr ob) { - if(!StringUtils.isEmpty(ob.getName()) && !MapSvgXMLHelper.getInstance().containsMapName(ob.getName())){ - MapSvgAttr mapSvgAttr = new MapSvgAttr(); - mapSvgAttr.setFilePath(MapSvgXMLHelper.customMapPath()+ CoreConstants.SEPARATOR+ob.getName()+".svg"); - MapSvgXMLHelper.getInstance().addNewSvgMaps(ob.getName(), mapSvgAttr); - } - - currentMapName = ob.getName(); - if(editingPane == null){ - editingPane = areaPane; - } - editingPane.populateMapAttr(ob); - tabbedPane.addChangeListener(tabbedChangeListener); - } - - public String getCurrentMapName(){ - return currentMapName; - } - - public void setCurrentMapName(String currentMapName){ - this.currentMapName = currentMapName; - - } - - @Override - public MapSvgAttr updateBean() { - MapSvgAttr currentAttr = editingPane.updateCurrentAttr(); - currentMapName =currentAttr != null ? currentAttr.getName() : currentMapName; - MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(currentMapName); - if(attr != null ){ - MapSvgXMLHelper.getInstance().removeNewMapAttr(currentMapName); - MapSvgXMLHelper.getInstance().pushMapAttr(currentMapName,currentAttr); - return currentAttr; - }else{ - return MapSvgXMLHelper.getInstance().getNewMapAttr(currentMapName); - } - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 6cd8ae54a..d6acb929a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -9,6 +9,7 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.chart.ChartEditPaneActionListener; import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIHeadGroup; @@ -19,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartOtherPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartTypePane; +import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.form.main.Form; import com.fr.general.ComparatorUtils; @@ -28,11 +30,11 @@ import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.CardLayout; import java.util.ArrayList; import java.util.Calendar; import java.util.List; -import java.awt.BorderLayout; -import java.awt.CardLayout; public class ChartEditPane extends BasicPane implements AttributeChange, Prepare4DataSourceChange, ChartEditPaneProvider { @@ -102,6 +104,33 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare this.add(center, BorderLayout.CENTER); } + /** + * 增加面板Listener + */ + public void addChartEditPaneActionListener(ChartEditPaneActionListener l) { + this.listenerList.add(ChartEditPaneActionListener.class, l); + } + + /** + * 移除面板Listener + */ + public void removeChartEditPaneActionListener(ChartEditPaneActionListener l) { + this.listenerList.remove(ChartEditPaneActionListener.class, l); + } + + private void fireAttributeChange(ChartCollection chartCollection) { + // Guaranteed to return a non-null array + Object[] listeners = listenerList.getListenerList(); + + // Process the listeners last to first, notifying + // those that are interested in this event + for (int i = listeners.length - 1; i >= 0; i -= 1) { + if (listeners[i] == ChartEditPaneActionListener.class) { + ((ChartEditPaneActionListener) listeners[i + 1]).attributeChange(chartCollection); + } + } + } + AttributeChangeListener listener = new AttributeChangeListener() { @Override public void attributeChange() { @@ -131,6 +160,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare } fire(); + fireAttributeChange(collection); } } }; @@ -147,13 +177,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare */ public void reLayout(ChartProvider currentChart) { if (currentChart != null) { - int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); this.setLayout(new BorderLayout()); paneList = new ArrayList(); - addTypePane(); - String chartID = currentChart.getID(); + + addTypePane(currentChart); + boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); if (isDefault) { @@ -187,8 +217,17 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare return chartDataPane; } - protected void addTypePane() { - paneList.add(typePane); + protected void addTypePane(ChartProvider chart) { + if (visibleTypePane(chart)) { + paneList.add(typePane); + } + } + + private boolean visibleTypePane(ChartProvider chart) { + AbstractChartTypePane pane = ChartTypeInterfaceManager.getInstance().getPlotTypePane(chart.getID()); + return pane != null + && !ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE.equals(pane.title4PopupWindow()) + && pane.visible(chart); } protected void setSelectedTab() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java index bae6e20bc..fdfa6a3c3 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartHyperEditPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.web.ChartHyperPoplink; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPopAttrPane; @@ -48,7 +49,7 @@ public class ChartHyperEditPane extends ChartEditPane { return dataPane; } - protected void addTypePane() { + protected void addTypePane(ChartProvider chart) { paneList.add(attrPane); paneList.add(typePane); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index f2bea5227..1fdd6e9fd 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -27,9 +27,6 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JPanel; import javax.swing.SwingUtilities; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; @@ -46,6 +43,9 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * 图表 类型 增删 控制按钮界面. @@ -252,7 +252,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen public ChartProvider getChangeStateNewChart() { ChartProvider chart = editingCollection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); - String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); + int priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); ChartProvider firstChart = ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); try { return (ChartProvider) firstChart.clone(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 2318fc05f..ac0bfcb57 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -17,23 +17,25 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox; import com.fr.design.mainframe.chart.gui.item.ItemEventType; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.module.DesignModuleFactory; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.JPanel; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; /** * 图表 属性表, 类型选择 界面. @@ -61,7 +63,14 @@ public class ChartTypePane extends AbstractChartAttrPane { if (editingCollection != null) { relayoutChartTypePane(editingCollection); } else { - chartTypeComBox = new ComboBoxPane(); + chartTypeComBox = new ComboBoxPane() { + @Override + protected void initLayout() { + super.initLayout(); + jcb.setVisible(ChartEditContext.normalMode()); + } + }; + } BasicScrollPane scrollPane = new BasicScrollPane() { @@ -140,14 +149,45 @@ public class ChartTypePane extends AbstractChartAttrPane { } } + /** + * 把所有的pane加到list里 + * + * @param paneList pane容器 + */ + private static void addPlotTypePaneList(List> paneList, + Map>> allChartTypePane, + ActionListener autoButtonListener) { + + + String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); + + for (String id : chartIDs) { + + AbstractChartTypePane pane = ChartTypeInterfaceManager.getInstance().getPlotTypePane(id); + if (pane == null || AssistUtils.equals(pane.title4PopupWindow(), ChartTypeInterfaceManager.TYPE_PANE_DEFAULT_TITLE)) { + continue; + } + pane.reLayout(id); + pane.registerButtonListener(autoButtonListener); + paneList.add(pane); + + Integer priority = ChartTypeManager.getInstance().getPriority(id); + if (allChartTypePane.get(priority) == null) { + allChartTypePane.put(priority, new LinkedHashMap>()); + } + allChartTypePane.get(priority).put(id, pane); + } + } + class ComboBoxPane extends UIComboBoxPane { - private Map>> allChartTypePane; + //todo:refactor 图表切换过滤不应该根据优先级priority,应该给旧版本图表和新特性图表的图表类型信息分别增加一个switchID之类的 + private Map>> allChartTypePane; @Override protected List> initPaneList() { List> paneList = new ArrayList>(); - allChartTypePane = new LinkedHashMap>>(); - ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener); + allChartTypePane = new LinkedHashMap>>(); + addPlotTypePaneList(paneList, allChartTypePane, autoButtonListener); return paneList; } @@ -209,18 +249,18 @@ public class ChartTypePane extends AbstractChartAttrPane { } private void addAllCards() { - Iterator iterator = allChartTypePane.keySet().iterator(); + Iterator iterator = allChartTypePane.keySet().iterator(); while (iterator.hasNext()) { addOnePriorityCards(iterator.next(), false); } } - private void addOnePriorityCards(String priority) { + private void addOnePriorityCards(int priority) { addOnePriorityCards(priority, true); } - private void addOnePriorityCards(String priority, boolean ignore) { + private void addOnePriorityCards(int priority, boolean ignore) { Map> map = allChartTypePane.get(priority); @@ -236,7 +276,7 @@ public class ChartTypePane extends AbstractChartAttrPane { } - private void addOnePlotIDCards(String priority, String plotID) { + private void addOnePlotIDCards(int priority, String plotID) { cards.add(allChartTypePane.get(priority).get(plotID)); } @@ -246,7 +286,7 @@ public class ChartTypePane extends AbstractChartAttrPane { //重构需要重构下拉框选项和cardNames ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String chartID = chart.getID(); - String priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); + int priority = ChartTypeManager.getInstanceWithCheck().getPriority(chartID); boolean enabledChart = ChartTypeManager.enabledChart(chartID); String item = ChartTypeInterfaceManager.getInstance().getName(chartID); @@ -360,7 +400,7 @@ public class ChartTypePane extends AbstractChartAttrPane { buttonPane.populateBean(collection); chartTypeComBox.populateBean(chart); - buttonPane.setVisible(ChartTypeInterfaceManager.getInstance().needChartChangePane(chart)); + buttonPane.setVisible(ChartTypeInterfaceManager.getInstance().needChartChangePane(chart) && ChartEditContext.normalMode()); this.initAllListeners(); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java index 42cf782c3..86f7e4da8 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java @@ -7,16 +7,17 @@ import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import javax.swing.BorderFactory; import javax.swing.JPanel; -import java.util.ArrayList; -import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import java.util.ArrayList; +import java.util.List; /** * 一般数据界面 @@ -67,7 +68,9 @@ public class NormalChartDataPane extends DataContentsPane { label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH,ChartDataPane.LABEL_HEIGHT)); northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null})); northPane.setBorder(BorderFactory.createEmptyBorder(0,5,0,8)); - this.add(northPane, BorderLayout.NORTH); + if (ChartEditContext.normalMode()) { + this.add(northPane, BorderLayout.NORTH); + } this.add(cardPane, BorderLayout.CENTER); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 4f3f02510..cde6e8fd6 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -217,6 +217,10 @@ public abstract class AbstractChartTypePane extends Fur return plotID; } + public boolean visible(ChartProvider chart) { + return true; + } + /** * @param ob 对象 * @return diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java new file mode 100644 index 000000000..23616a482 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditContext.java @@ -0,0 +1,26 @@ +package com.fr.design.mainframe.chart.mode; + +import com.fr.common.annotations.Open; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/6/4 + */ +@Open +public class ChartEditContext { + + private static ChartEditMode current = ChartEditMode.NORMAL; + + public static void switchTo(ChartEditMode mode) { + current = mode; + } + + public static boolean duchampMode() { + return current == ChartEditMode.DUCHAMP; + } + + public static boolean normalMode() { + return current == ChartEditMode.NORMAL; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditMode.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditMode.java new file mode 100644 index 000000000..c5cc9da48 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/mode/ChartEditMode.java @@ -0,0 +1,12 @@ +package com.fr.design.mainframe.chart.mode; + +/** + * @author shine + * @version 10.0 + * Created by shine on 2021/6/4 + */ +//todo:refactor 弹出框图表没有单元格数据源,就不用一层层传下去了 +public enum ChartEditMode { + NORMAL, + DUCHAMP +} diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java index 1c4d92752..728ebbe05 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java @@ -3,6 +3,7 @@ package com.fr.design.module; import com.fr.chart.web.ChartHyperPoplink; import com.fr.chart.web.ChartHyperRelateCellLink; import com.fr.chart.web.ChartHyperRelateFloatLink; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane; @@ -58,7 +59,7 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { return false; } - if (template.isJWorkBook()) { + if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) { // 如果是普通报表单元格,那么没有 FormHyperlink 选项 FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); //返回true表示可用,返回false表示不可用 @@ -93,7 +94,7 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { if (template == null) { return false; } - if (template.isJWorkBook()) { + if (template.isJWorkBook() || DesignModeContext.isDuchampMode()) { // 如果是普通报表单元格,那么没有 FormHyperlink 选项 FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); //返回true表示可用,返回false表示不可用 diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java index a1a088020..64b480853 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartUIProvider.java @@ -14,10 +14,14 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +import static com.fr.design.chart.fun.ChartTypeUIProvider.CURRENT_API_LEVEL; /** * Created by shine on 2018/3/2. */ +@API(level = CURRENT_API_LEVEL) public abstract class AbstractExtendedChartUIProvider extends AbstractProvider implements ChartTypeUIProvider { protected abstract AbstractExtendedChartTableDataPane getTableDataSourcePane(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java index 23bd47004..4fe84a35e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/AreaIndependentVanChartInterface.java @@ -2,10 +2,12 @@ package com.fr.van.chart.area; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** @@ -47,7 +49,7 @@ public class AreaIndependentVanChartInterface extends AbstractMultiCategoryVanCh @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartAreaPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartAreaPlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java index 63a8e7640..542be966c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bar/BarIndependentVanChartInterface.java @@ -3,12 +3,14 @@ package com.fr.van.chart.bar; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.column.VanChartColumnConditionPane; import com.fr.van.chart.column.VanChartColumnSeriesPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; @@ -57,7 +59,7 @@ public class BarIndependentVanChartInterface extends AbstractMultiCategoryVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartBarPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartBarPlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java index e4906b625..6e1d3d971 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/BoxIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.box; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,6 +13,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.van.chart.box.data.report.BoxPlotReportDataContentPane; import com.fr.van.chart.box.data.table.BoxPlotTableDataContentPane; @@ -56,7 +58,7 @@ public class BoxIndependentVanChartInterface extends AbstractIndependentVanChart } public AbstractChartTypePane getPlotTypePane() { - return new VanChartBoxPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartBoxPlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java index 985e811ac..cc344d4f4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/BubbleIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.bubble; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -13,6 +14,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.report.BubblePlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.bubble.VanChartBubblePlot; import com.fr.van.chart.bubble.data.VanChartBubblePlotTableDataContentPane; @@ -54,7 +56,7 @@ public class BubbleIndependentVanChartInterface extends AbstractIndependentVanCh */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartBubblePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartBubblePlotPane(); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java index 0d491f904..a971a98a9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanColumnChartTypeUI.java @@ -2,10 +2,12 @@ package com.fr.van.chart.column; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** @@ -48,7 +50,7 @@ public class VanColumnChartTypeUI extends AbstractMultiCategoryVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartColumnPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartColumnPlotPane(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java index 47e6488fd..dc5552740 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java @@ -60,7 +60,9 @@ public class VanChartCustomDataPane extends ChartDataPane { */ public void addAttributeChangeListener(AttributeChangeListener listener) { super.addAttributeChangeListener(listener); - contentsTabPane.addAttributeChangeListener(listener); + if (contentsTabPane != null) { + contentsTabPane.addAttributeChangeListener(listener); + } } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java index ff0147652..c3dcf7390 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java @@ -3,15 +3,19 @@ package com.fr.van.chart.custom; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.data.AbstractDataDefinition; import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.chartx.data.CustomChartDataDefinition; +import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartAttrLine; @@ -28,12 +32,12 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; import javax.swing.JSeparator; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; /** * Created by Mitisky on 16/2/16. @@ -54,11 +58,27 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { //自定义和自动版面的容器,cardLayOut布局 private JPanel contentPane; + @Override + public boolean visible(ChartProvider chart) { + if (ChartEditContext.duchampMode() && chart instanceof VanChart) { + Plot plot = ((VanChart) chart).getPlot(); + + if (plot instanceof VanChartCustomPlot) { + CustomStyle customStyle = ((VanChartCustomPlot) plot).getCustomStyle(); + return customStyle == CustomStyle.CUSTOM; + } + } + return super.visible(chart); + } + protected Component[][] getPaneComponents(JPanel typePane) { initContent(); - return new Component[][]{ + return ChartEditContext.duchampMode() ? new Component[][]{ + new Component[]{contentPane}, + new Component[]{buttonPane}, + }: new Component[][]{ new Component[]{typePane}, new Component[]{stylePane}, new Component[]{contentPane}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java index f399d90e8..8aab51b3f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/other/VanChartCustomInteractivePane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.custom.other; import com.fr.chart.chartattr.Plot; - import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.type.CustomStyle; @@ -37,6 +36,9 @@ public class VanChartCustomInteractivePane extends VanChartInteractivePane { @Override protected void populateHyperlink(Plot plot) { + if (hyperlinkPane == null) { + return; + } hyperlinkPane.populateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index 4a0e7adc5..c97f3a8ec 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -20,6 +20,7 @@ import com.fr.design.gui.ispinner.UnsignedIntUISpinner; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -132,7 +133,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { double[] rowSize = {p, p, p, p, p, p, p}; - Component[][] components = new Component[][]{ + Component[][] components = ChartEditContext.normalMode() ? new Component[][]{ new Component[]{createToolBarPane(getToolBarRowSize(), columnSize), null}, //大数据模式 恢复用注释。取消注释。 //new Component[]{createLargeDataModePane(), null}, @@ -141,6 +142,11 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { new Component[]{createZoomPane(plot), null}, new Component[]{createAutoRefreshPane(plot), null}, new Component[]{createHyperlinkPane(), null} + } : new Component[][]{ + new Component[]{createToolBarPane(getToolBarRowSize(), columnSize), null}, + new Component[]{createAnimationPane(), null}, + new Component[]{createAxisRotationPane(new double[]{p, p}, columnSize, plot), null}, + new Component[]{createZoomPane(plot), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -595,6 +601,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected void populateHyperlink(Plot plot) { + if (superLink == null) { + return; + } superLink.populate(plot); } @@ -634,7 +643,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { } protected void populateAutoRefresh(VanChart chart) { - VanChartPlot plot = chart.getPlot(); + if (autoRefreshPane == null) { + return; + } RefreshMoreLabel refreshMoreLabel = chart.getRefreshMoreLabel(); if (refreshMoreLabel == null) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java index c7386ed0a..c439c4d4d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/other/VanChartDrillMapInteractivePane.java @@ -7,6 +7,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; import com.fr.plugin.chart.vanchart.VanChart; @@ -39,13 +40,18 @@ public class VanChartDrillMapInteractivePane extends VanChartInteractivePaneWith double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; double[] rowSize = {p, p, p, p, p, p, p, p, p, p, p}; - Component[][] components = new Component[][]{ + Component[][] components = ChartEditContext.normalMode() ? new Component[][]{ new Component[]{createToolBarPane(new double[]{p, p, p}, columnSize), null}, new Component[]{createAnimationPane(), null}, new Component[]{createZoomPane(plot), null}, new Component[]{createDrillToolsPane(), null}, new Component[]{createAutoRefreshPane(plot), null}, new Component[]{createHyperlinkPane(), null} + } : new Component[][]{ + new Component[]{createToolBarPane(new double[]{p, p, p}, columnSize), null}, + new Component[]{createAnimationPane(), null}, + new Component[]{createZoomPane(plot), null}, + new Component[]{createDrillToolsPane(), null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java index 2899a9e11..b76f9047d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/FunnelIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.funnel.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -13,6 +14,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.PiePlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.data.OneDimensionalPlotReportDataContentPane; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -45,7 +47,7 @@ public class FunnelIndependentVanChartInterface extends AbstractIndependentVanCh */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartFunnelTypePane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartFunnelTypePane(); } public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java index 9bc3ce123..839e049dd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/GanttIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.gantt.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,6 +13,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.gantt.designer.data.VanChartGanttDataPane; @@ -42,7 +44,7 @@ public class GanttIndependentVanChartInterface extends AbstractIndependentVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartGanttPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartGanttPlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java index 1e7a6fb32..7c424aa55 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gauge/GaugeIndependentVanChartInterface.java @@ -2,6 +2,7 @@ package com.fr.van.chart.gauge; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; @@ -14,6 +15,7 @@ import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.MeterPlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.van.chart.custom.component.CategoryCustomPlotTableDataContentPane; import com.fr.van.chart.custom.component.MeterCustomPlotReportDataContentPane; @@ -61,7 +63,7 @@ public class GaugeIndependentVanChartInterface extends AbstractIndependentVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartGaugePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartGaugePlotPane(); } public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java index 739e87f14..58252a74b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/line/LineIndependentVanChartInterface.java @@ -2,10 +2,12 @@ package com.fr.van.chart.line; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; /** @@ -42,7 +44,7 @@ public class LineIndependentVanChartInterface extends AbstractMultiCategoryVanCh @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartLinePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartLinePlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java index 0f89fed69..a6ede0df7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/other/VanChartMapInteractivePane.java @@ -27,6 +27,9 @@ public class VanChartMapInteractivePane extends VanChartInteractivePaneWithMapZo @Override protected void populateHyperlink(Plot plot) { + if (hyperlinkPane == null) { + return; + } hyperlinkPane.populateBean(plot); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java index 9b5636e40..1bdb8d36c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java @@ -7,6 +7,7 @@ import com.fr.chartx.data.ChartDataDefinitionProvider; import com.fr.chartx.data.MapChartDataDefinition; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -21,9 +22,9 @@ import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; +import java.awt.Component; import java.util.HashSet; import java.util.Set; -import java.awt.Component; /** * Created by Mitisky on 16/5/4. @@ -55,7 +56,9 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - return new Component[][]{ + return ChartEditContext.duchampMode() ? new Component[][]{ + new Component[]{sourceChoosePane} + } : new Component[][]{ new Component[]{typePane}, new Component[]{buttonPane}, new Component[]{sourceChoosePane} diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java index 1cc66a2bf..a5da06312 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java @@ -2,6 +2,7 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; @@ -9,6 +10,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.multilayer.data.MultiPiePlotReportDataContentPane; import com.fr.van.chart.multilayer.data.MultiPiePlotTableDataContentPane; import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane; @@ -21,7 +23,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; public class MultiPieIndependentVanChartInterface extends AbstractIndependentVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartMultiPiePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartMultiPiePlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java index 06841c0c9..7ede0ad46 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/PieIndependentVanChartInterface.java @@ -2,6 +2,7 @@ package com.fr.van.chart.pie; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; @@ -9,6 +10,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.CategoryPlotTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.custom.component.CategoryCustomPlotTableDataContentPane; import com.fr.van.chart.custom.component.VanChartDataPane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -50,7 +52,7 @@ public class PieIndependentVanChartInterface extends AbstractIndependentVanChart @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartPiePlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartPiePlotPane(); } public ConditionAttributesPane getPlotConditionPane(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java index 21784c522..3f13cef0e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/RadarIndependentVanChartInterface.java @@ -2,10 +2,12 @@ package com.fr.van.chart.radar; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; /** @@ -40,7 +42,7 @@ public class RadarIndependentVanChartInterface extends AbstractIndependentVanCha @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartRadarPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartRadarPlotPane(); } public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java index 1b7063af4..444a36ae5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/ScatterIndependentVanChartInterface.java @@ -4,6 +4,7 @@ package com.fr.van.chart.scatter; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -14,6 +15,7 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import com.fr.design.mainframe.chart.gui.data.report.BubblePlotReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.other.zoom.ZoomPane; @@ -33,7 +35,7 @@ public class ScatterIndependentVanChartInterface extends AbstractIndependentVanC */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartScatterPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartScatterPlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java index 8109adeb0..6733b8dbd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/VanStructureChartTypeUI.java @@ -3,6 +3,7 @@ package com.fr.van.chart.structure.desinger; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; @@ -12,6 +13,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -31,7 +33,7 @@ import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; public class VanStructureChartTypeUI extends AbstractIndependentVanChartUI { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartStructureTypePane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartStructureTypePane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java index 2b6589ed8..390a03919 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/treemap/TreeMapIndependentVanChartInterface.java @@ -3,11 +3,13 @@ package com.fr.van.chart.treemap; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -20,7 +22,7 @@ import com.fr.van.chart.treemap.style.VanChartTreeMapSeriesPane; public class TreeMapIndependentVanChartInterface extends MultiPieIndependentVanChartInterface { @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartTreeMapPlotPane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartTreeMapPlotPane(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java index 5ff077a4b..290c6a43f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java @@ -3,6 +3,7 @@ package com.fr.van.chart.wordcloud.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chart.fun.impl.InvisibleChartTypePane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; @@ -13,6 +14,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; @@ -39,7 +41,7 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa */ @Override public AbstractChartTypePane getPlotTypePane() { - return new VanChartWordCloudTypePane(); + return ChartEditContext.duchampMode() ? new InvisibleChartTypePane() : new VanChartWordCloudTypePane(); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index bf1c84990..df645e2df 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -85,13 +85,14 @@ public class SelectionModel { if (e.getButton() == MouseEvent.BUTTON3 || (!InputEventBaseOnOS.isControlDown(e) && !e.isShiftDown())) { // 如果Ctrl或者Shift键盘没有按下,则清除已经选择的组件 XCreator selectXCreator = selection.getSelectedCreator(); - if (selectXCreator != null && comp != null) { + boolean clickOnce = e.getClickCount() == 1; + boolean hasCom = selectXCreator != null && comp != null; + if (clickOnce && hasCom) { if (StringUtils.equals(selectXCreator.toData().getWidgetName(), comp.toData().getWidgetName())) { return; } } selection.reset(); - } else { //按下Ctrl或者shift键时鼠标可以进行多选,两次点击同一控件就取消选中 XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer(comp).getTopLayout(); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 3b991d4a0..8980c09a1 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -862,4 +862,7 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } } + public boolean isParentAbsolute() { + return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class); + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/AbstractFormParallelLine.java b/designer-form/src/main/java/com/fr/design/mainframe/AbstractFormParallelLine.java new file mode 100644 index 000000000..3fe9feded --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/AbstractFormParallelLine.java @@ -0,0 +1,70 @@ +package com.fr.design.mainframe; + +import java.awt.Point; + +public abstract class AbstractFormParallelLine { + protected int parallelValue; + protected int startPosition; + protected int endPosition; + + public AbstractFormParallelLine(int parallelValue, int startPosition, int endPosition) { + this.parallelValue = parallelValue; + this.startPosition = startPosition; + this.endPosition = endPosition; + } + + public int getCenterPosition() { + return (startPosition + endPosition) / 2; + } + + /** + * 获取当前直线的中垂线起点位置 + * @return 中垂线起点位置 + */ + abstract public Point getStartPointOnVerticalCenterLine(); + + /** + * 获取当前直线的中垂线的重点位置,重点位置即为重垂线与另一条平行线相交的点 + * @param parallelValue 平行线 + * @return 中垂线重点位置 + */ + abstract public Point getEndPointOnVerticalCenterLine(int parallelValue); + + public boolean isVerticalCenterLineBeforeTheParallelLine(AbstractFormParallelLine parallelLine) { + return this.getCenterPosition() < parallelLine.getStartPosition(); + } + + public boolean isVerticalCenterLineBehindTheParallelLine(AbstractFormParallelLine parallelLine) { + return this.getCenterPosition() > parallelLine.getEndPosition(); + } + + /** + * 传一个平行线,当 当前直线和平行线中心点位置无平行相交的部分的时候,需要绘制一条延长线,一直延长到平行线边界位置 + * @param parallelLine 平行线 + * @return 延长线的起点位置 + */ + abstract public Point getExtendedLineStartPoint(AbstractFormParallelLine parallelLine); + + /** + * 传一个平行线,当 当前直线和平行线中心点位置无平行相交的部分的时候,需要绘制一条延长线,一直延长到平行线边界位置 + * @param parallelLine 平行线 + * @return 延长线的重点位置 + */ + abstract public Point getExtendedLineEndPoint(AbstractFormParallelLine parallelLine); + + public int getDistanceWithLine(AbstractFormParallelLine parallelLine) { + return Math.abs(this.getParallelValue() - parallelLine.getParallelValue()); + } + + public int getParallelValue() { + return parallelValue; + } + + public int getStartPosition() { + return startPosition; + } + + public int getEndPosition() { + return endPosition; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 4e44e134e..87b55e175 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -36,7 +36,6 @@ import com.fr.design.utils.gui.LayoutUtils; import com.fr.general.ComparatorUtils; import com.fr.stable.Constants; -import java.util.LinkedList; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPopupMenu; @@ -49,6 +48,7 @@ import java.awt.Cursor; import java.awt.Insets; import java.awt.Rectangle; import java.awt.event.MouseEvent; +import java.util.LinkedList; /** * 普通模式下的鼠标点击、位置处理器 @@ -353,6 +353,7 @@ public class EditingMouseListener extends MouseInputAdapter { return; } + designer.getSpacingLineDrawer().updateMouseEvent(e, true); processChartEditorMouseMove(component, e); e.translatePoint(oldX - e.getX(), oldY - e.getY()); designer.repaint(); 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 1a9779a87..9f49de1d8 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 @@ -38,7 +38,6 @@ import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWBorderLayout; import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; -import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; @@ -126,6 +125,7 @@ public class FormDesigner extends TargetComponent

implements TreeSelection private ConnectorHelper connectorHelper; private boolean isReportBlockEditing = false; private TopXCreators topXCreators; + private FormSpacingLineDrawer spacingLineDrawer; //组件重叠 private boolean isWidgetsIntersect = false; @@ -194,6 +194,8 @@ public class FormDesigner extends TargetComponent implements TreeSelection // 必须刷新"参数/控件树"面板,否则,若最近一次打开模版为 cpt,重启设计器,打开 frm,控件树消失 populateParameterPropertyPane(); + + spacingLineDrawer = new FormSpacingLineDrawer(this); } @@ -1764,4 +1766,20 @@ public class FormDesigner extends TargetComponent implements TreeSelection } } + public boolean isMultiSelection() { + XCreator[] creators = this.getSelectionModel().getSelection().getSelectedCreators(); + if (creators != null && creators.length > 1) { + for (int i = 0; i < creators.length - 1; i++) { + if (creators[i].getParent() != creators[i + 1].getParent() || !creators[i].isParentAbsolute()) { + return false; + } + } + return creators[creators.length - 1].isParentAbsolute(); + } + return false; + } + + public FormSpacingLineDrawer getSpacingLineDrawer() { + return spacingLineDrawer; + } } 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 a8ddce03c..776925044 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 @@ -17,15 +17,15 @@ import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.utils.ComponentUtils; - import com.fr.form.main.parameter.FormParameterUI; import com.fr.page.WatermarkPainter; import com.fr.report.core.ReportUtils; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; -import java.awt.dnd.DropTarget; -import javax.swing.*; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.plaf.ComponentUI; import java.awt.AlphaComposite; import java.awt.Color; @@ -33,6 +33,7 @@ import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; +import java.awt.dnd.DropTarget; import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.Rectangle2D; @@ -128,6 +129,8 @@ public class FormDesignerUI extends ComponentUI { // 当前正在添加的组件 paintAddingBean(g, addingModel); } + + designer.getSpacingLineDrawer().draw(g); } // 绘制水印 @@ -518,4 +521,8 @@ public class FormDesignerUI extends ComponentUI { designer.paintTopCreators(g); } + private void paintSpacingLine() { + + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormHorizontalParallelLine.java b/designer-form/src/main/java/com/fr/design/mainframe/FormHorizontalParallelLine.java new file mode 100644 index 000000000..f9acfcc7b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormHorizontalParallelLine.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe; + +import java.awt.Point; + +public class FormHorizontalParallelLine extends AbstractFormParallelLine { + public FormHorizontalParallelLine(int parallelValue, int startPosition, int endPosition) { + super(parallelValue, startPosition, endPosition); + } + + @Override + public Point getStartPointOnVerticalCenterLine() { + Point point = new Point(); + point.setLocation(getCenterPosition(), parallelValue); + return point; + } + + @Override + public Point getEndPointOnVerticalCenterLine(int parallelValue) { + Point point = new Point(); + point.setLocation(getCenterPosition(), parallelValue); + return point; + } + + @Override + public Point getExtendedLineStartPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(getStartPosition(), getParallelValue()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(getEndPosition(), getParallelValue()); + } + return point; + } + + @Override + public Point getExtendedLineEndPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(parallelLine.getStartPosition(), getParallelValue()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(parallelLine.getEndPosition(), getParallelValue()); + } + return point; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java new file mode 100644 index 000000000..a46a59af4 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java @@ -0,0 +1,198 @@ +package com.fr.design.mainframe; + +import com.fr.design.designer.creator.XCreator; +import com.fr.stable.Constants; +import com.fr.stable.GraphDrawHelper; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.geom.RoundRectangle2D; + +public class FormSpacingLineDrawer { + private static final Color LINE_COLOR = new Color(230, 82, 81); + private static final Color TEXT_COLOR = new Color(255, 255, 255); + private static final int TEXT_PADDING_HORIZONTAL = 6; + private static final int TEXT_PADDING_VERTICAL = 1; + private static final int MIN_SPACING = 10; + + private FormDesigner designer; + private XCreator hoverCreator; + private Rectangle selectedRec; + private boolean isMouseMoveEvent = false; + + public FormSpacingLineDrawer(FormDesigner designer) { + this.designer = designer; + } + + public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { + this.hoverCreator = designer.getComponentAt(e); + this.isMouseMoveEvent = isMouseMoveEvent; + } + + public void draw(Graphics g) { + this.selectedRec = designer.getSelectionModel().getSelection().getSelctionBounds(); + if (!isDrawSpacingLine()) { + return; + } + + if (!hoverCreator.isParentAbsolute()) { + return; + } + + drawHorizontalSpacingLine(g); + drawVerticalSpacingLine(g); + } + + private void drawHorizontalSpacingLine(Graphics g) { + AbstractFormParallelLine[] lines = getNearestHorizontalSide(); + drawSpacingLine(g, lines); + } + + private void drawVerticalSpacingLine(Graphics g) { + AbstractFormParallelLine[] lines = getNearestVerticalSide(); + drawSpacingLine(g, lines); + } + + private void drawSpacingLine(Graphics g, int startX, int startY, int endX, int endY) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(LINE_COLOR); + GraphDrawHelper.drawLine(g2d, startX, startY, endX, endY, Constants.LINE_THIN); + } + + private void drawSpacingLine(Graphics g, AbstractFormParallelLine[] nearestSides) { + if (nearestSides.length != 2) { + return; + } + int gap = nearestSides[0].getDistanceWithLine(nearestSides[1]); + if (gap <= MIN_SPACING) { + return; + } + + int startX = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getX(); + int startY = (int) nearestSides[0].getStartPointOnVerticalCenterLine().getY(); + int endX = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getX(); + int endY = (int) nearestSides[0].getEndPointOnVerticalCenterLine(nearestSides[1].getParallelValue()).getY(); + + drawSpacingLine(g, startX, startY, endX, endY); + drawSpacingText(g, String.valueOf(gap), (startX + endX) / 2, (startY + endY) / 2); + drawExtendedLine(g, nearestSides); + } + + private void drawExtendedLine(Graphics g, int startX, int startY, int endX, int endY) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(LINE_COLOR); + GraphDrawHelper.drawLine(g2d, startX, startY, endX, endY, Constants.LINE_DASH); + } + + private void drawExtendedLine(Graphics g, AbstractFormParallelLine[] nearestSides) { + if (isNeedExtendedLine(nearestSides)) { + int startX = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getX(); + int startY = (int) nearestSides[1].getExtendedLineStartPoint(nearestSides[0]).getY(); + int endX = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getX(); + int endY = (int) nearestSides[1].getExtendedLineEndPoint(nearestSides[0]).getY(); + drawExtendedLine(g, startX, startY, endX, endY); + } + } + + private void drawSpacingText(Graphics g, String text, int x, int y) { + Graphics2D g2d = (Graphics2D) g.create(); + g2d.setColor(LINE_COLOR); + Font newFont = g2d.getFont().deriveFont(8F).deriveFont(Font.BOLD); + g2d.setFont(newFont); + FontMetrics metrics = g2d.getFontMetrics(); + int lineHeight = metrics.getAscent(); // 这里由于都是数字,要居中必须忽略掉leading和descent的高度 + int lineWidth = metrics.stringWidth(text); + + int labelPaneX = x - lineWidth / 2 - TEXT_PADDING_HORIZONTAL; + int labelPaneY = y - lineHeight / 2 - TEXT_PADDING_VERTICAL; + int labelPaneWidth = lineWidth + 2 * TEXT_PADDING_HORIZONTAL; + int labelPaneHeight = lineHeight + 2 * TEXT_PADDING_VERTICAL; + int labelPaneArc = Math.min(labelPaneWidth, labelPaneHeight); + GraphDrawHelper.fill(g2d, new RoundRectangle2D.Double(labelPaneX, labelPaneY, labelPaneWidth, labelPaneHeight, labelPaneArc, labelPaneArc)); + + g2d.setColor(TEXT_COLOR); + int labelX = x - lineWidth / 2; + int labelY = y + (lineHeight - 2) / 2; // 由于ascent里面包含了一小段空白,数字又没有大写的情况,相当于五线行第一行是空的,所以往上微调一点来居中 + GraphDrawHelper.drawString(g2d, text, labelX, labelY); + } + + private boolean isSelectedRootComponent() { + return designer.getSelectionModel().getSelection().size() == 1 && + designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); + } + + private boolean isSelectedForm() { + return designer.getSelectionModel().getSelection().size() == 1 && + designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; + } + + private boolean isHoveredRootComponent() { + return designer.isRoot(hoverCreator); + } + + private boolean isHoveredForm() { + return hoverCreator.getParent() == null; + } + + private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { + return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); + } + + private boolean isSelectedRootPane() { + return isSelectedForm() || isSelectedRootComponent(); + } + + private boolean isHoveredRootPane() { + return isHoveredForm() || isHoveredRootComponent(); + } + + private boolean isDrawSpacingLine() { + return !isSelectedRootPane() && !isHoveredRootPane() && isMouseMoveEvent; + } + + private AbstractFormParallelLine[] getNearestHorizontalSide() { + AbstractFormParallelLine[] selectedRecSides = new AbstractFormParallelLine[] { + new FormHorizontalParallelLine(selectedRec.y, selectedRec.x, selectedRec.x + selectedRec.width), + new FormHorizontalParallelLine(selectedRec.y + selectedRec.height, selectedRec.x, selectedRec.x + selectedRec.width) + }; + + AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { + new FormHorizontalParallelLine(hoverCreator.getY(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()), + new FormHorizontalParallelLine(hoverCreator.getY() + hoverCreator.getHeight(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()) + }; + return getNearestSide(selectedRecSides, hoveredCreatorSides); + } + + private AbstractFormParallelLine[] getNearestVerticalSide() { + AbstractFormParallelLine[] selectedRecSides = new AbstractFormParallelLine[] { + new FormVerticalParallelLine(selectedRec.x, selectedRec.y, selectedRec.y + selectedRec.height), + new FormVerticalParallelLine(selectedRec.x + selectedRec.width, selectedRec.y, selectedRec.y + selectedRec.height) + }; + + AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] { + new FormVerticalParallelLine(hoverCreator.getX(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()), + new FormVerticalParallelLine(hoverCreator.getX() + hoverCreator.getWidth(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()) + }; + return getNearestSide(selectedRecSides, hoveredCreatorSides); + } + + private AbstractFormParallelLine[] getNearestSide(AbstractFormParallelLine[] lines1, AbstractFormParallelLine[] lines2) { + AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[2]; + int minDistance = lines1[0].getDistanceWithLine(lines2[0]); + for (int i = 0; i < lines1.length; i++) { + for (int j = 0; j < lines2.length; j++) { + int distance = lines1[i].getDistanceWithLine(lines2[j]); + if (distance <= minDistance) { + nearestSides[0] = lines1[i]; + nearestSides[1] = lines2[j]; + } + } + } + return nearestSides; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormVerticalParallelLine.java b/designer-form/src/main/java/com/fr/design/mainframe/FormVerticalParallelLine.java new file mode 100644 index 000000000..19028bc25 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormVerticalParallelLine.java @@ -0,0 +1,45 @@ +package com.fr.design.mainframe; + +import java.awt.Point; + +public class FormVerticalParallelLine extends AbstractFormParallelLine { + public FormVerticalParallelLine(int parallelValue, int startPosition, int endPosition) { + super(parallelValue, startPosition, endPosition); + } + + @Override + public Point getStartPointOnVerticalCenterLine() { + Point point = new Point(); + point.setLocation(parallelValue, getCenterPosition()); + return point; + } + + @Override + public Point getEndPointOnVerticalCenterLine(int parallelValue) { + Point point = new Point(); + point.setLocation(parallelValue, getCenterPosition()); + return point; + } + + @Override + public Point getExtendedLineStartPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(getParallelValue(), getStartPosition()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(getParallelValue(), getEndPosition()); + } + return point; + } + + @Override + public Point getExtendedLineEndPoint(AbstractFormParallelLine parallelLine) { + Point point = new Point(); + if (parallelLine.isVerticalCenterLineBeforeTheParallelLine(this)) { + point.setLocation(getParallelValue(), parallelLine.getStartPosition()); + } else if (parallelLine.isVerticalCenterLineBehindTheParallelLine(this)) { + point.setLocation(getParallelValue(), parallelLine.getEndPosition()); + } + return point; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java new file mode 100644 index 000000000..1b0962feb --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/MultiSelectionArrangement.java @@ -0,0 +1,218 @@ +package com.fr.design.mainframe; + +import com.fr.design.designer.creator.XCreator; + +import java.awt.Rectangle; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public class MultiSelectionArrangement { + private FormDesigner designer; + private List selectedCreators; + private Rectangle rec; + + public MultiSelectionArrangement(FormDesigner designer) { + this.designer = designer; + update(); + } + + public void leftAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(rec.x, creator.getY()); + } + repaint(); + } + + public void rightAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(rec.x + rec.width - creator.getWidth(), creator.getY()); + } + repaint(); + } + + public void topAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(creator.getX(), rec.y); + } + repaint(); + } + + public void bottomAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(creator.getX(), rec.y + rec.height - creator.getHeight()); + } + repaint(); + } + + public void horizontalCenterAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(rec.x + rec.width / 2 - creator.getWidth() / 2, creator.getY()); + } + repaint(); + } + + public void verticalCenterAlign() { + for (XCreator creator : selectedCreators) { + creator.setLocation(creator.getX(), rec.y + rec.height / 2 - creator.getHeight() / 2); + } + repaint(); + } + + // 水平分布,自动,间距由selectedCreators和border共同计算而来 + public void horizontalAutoDistribution() { + int gap = calculateHorizontalGap(); + horizontalDistribution(gap); + } + + // 水平分布,手动,传入一个间距,排列selectedCreators + public void horizontalManualDistribution(int gap) { + reSizeRecByHorizontal(gap); + horizontalDistribution(gap); + } + + private void horizontalDistribution(int gap) { + sortHorizontal(); + for (int i = 1; i < selectedCreators.size() - 1; i++) { + XCreator creator = selectedCreators.get(i); + XCreator preCreator = selectedCreators.get(i - 1); + creator.setLocation(preCreator.getX() + preCreator.getWidth() + gap, creator.getY()); + } + repaint(); + } + + private void reSizeRecByHorizontal(int gap) { + sortHorizontal(); + int width = 0; + for (XCreator creator : selectedCreators) { + width += creator.getWidth(); + } + width += (selectedCreators.size() - 1) * gap; + rec.x = rec.x + (rec.width - width) / 2; + rec.width = width; + XCreator first = selectedCreators.get(0); + first.setLocation(rec.x, first.getY()); + XCreator last = selectedCreators.get(selectedCreators.size() - 1); + last.setLocation(rec.x + rec.width - last.getWidth(), last.getY()); + } + + private void sortHorizontal() { + Collections.sort(selectedCreators, new Comparator() { + @Override + public int compare(XCreator o1, XCreator o2) { + int diffX = o1.getX() - o2.getX(); + if (diffX > 0) { + return 1; + } else if (diffX < 0) { + return -1; + } else { + int diffY = o1.getY() - o2.getY(); + if (diffY > 0) { + return 1; + } else if (diffY < 0) { + return -1; + } else { + int diffZOrder = o1.getParent().getComponentZOrder(o1) - o2.getParent().getComponentZOrder(o2); + if (diffZOrder > 0) { + return -1; + } else { + return 1; + } + } + } + } + }); + } + + // 计算selectedCreators的均分间距 + private int calculateHorizontalGap() { + int sum = 0; + for (XCreator creator : selectedCreators) { + sum += creator.getWidth(); + } + return (rec.width - sum) / (selectedCreators.size() - 1); + } + + public void verticalAutoDistribution() { + int gap = calculateVerticalGap(); + verticalDistribution(gap); + } + + public void verticalManualDistribution(int gap) { + reSizeRecByVertical(gap); + verticalDistribution(gap); + } + + private void verticalDistribution(int gap) { + sortVertical(); + for (int i = 1; i < selectedCreators.size() - 1; i++) { + XCreator creator = selectedCreators.get(i); + XCreator preCreator = selectedCreators.get(i - 1); + creator.setLocation(creator.getX(), preCreator.getY() + preCreator.getHeight() + gap); + } + repaint(); + } + + private void reSizeRecByVertical(int gap) { + sortVertical(); + int height = 0; + for (XCreator creator : selectedCreators) { + height += creator.getHeight(); + } + height += (selectedCreators.size() - 1) * gap; + rec.y = rec.y + (rec.height - height) / 2; + rec.height = height; + XCreator first = selectedCreators.get(0); + first.setLocation(first.getX(), rec.y); + XCreator last = selectedCreators.get(selectedCreators.size() - 1); + last.setLocation(last.getX(), rec.y + rec.height - last.getHeight()); + } + + private void sortVertical() { + Collections.sort(selectedCreators, new Comparator() { + @Override + public int compare(XCreator o1, XCreator o2) { + int diffY = o1.getY() - o2.getY(); + if (diffY > 0) { + return 1; + } else if (diffY < 0) { + return -1; + } else { + int diffX = o1.getX() - o2.getX(); + if (diffX > 0) { + return 1; + } else if (diffX < 0) { + return -1; + } else { + int diffZOrder = o1.getParent().getComponentZOrder(o1) - o2.getParent().getComponentZOrder(o2); + if (diffZOrder > 0) { + return -1; + } else { + return 1; + } + } + } + } + }); + } + + private int calculateVerticalGap() { + int sum = 0; + for (XCreator creator : selectedCreators) { + sum += creator.getHeight(); + } + return (rec.height - sum) / (selectedCreators.size() - 1); + } + + private void update() { + FormSelection selection = designer.getSelectionModel().getSelection(); + this.selectedCreators = Arrays.asList(selection.getSelectedCreators()); + this.rec = selection.getSelctionBounds(); + } + + private void repaint() { + designer.repaint(); + update(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java index fd64d3aab..b4fc1122b 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/WidgetPropertyPane.java @@ -5,25 +5,37 @@ import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.UIConstants; 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.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.controlpane.EventPropertyPane; +import com.fr.design.gui.ibutton.UIHead; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itable.AbstractPropertyTable; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.widget.ui.FormWidgetCardPane; +import com.fr.design.mainframe.widget.ui.FormWidgetCardPaneFactory; import com.fr.design.widget.ui.designer.mobile.MobileWidgetDefinePane; - import com.fr.stable.ArrayUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.CardLayout; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -130,7 +142,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper * 创建属性表table */ private void createPropertyTable() { - formWidgetCardPane = new FormWidgetCardPane(designer); + formWidgetCardPane = FormWidgetCardPaneFactory.create(designer); designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); psp = new UIScrollPane(formWidgetCardPane); // 用来装载属性表table psp.setBorder(null); @@ -141,6 +153,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper */ private void createEventTable() { eventTable = new EventPropertyPane(designer); + eventTable.setEnabled(false); designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); } @@ -235,6 +248,15 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal") }; + List uiHeads = new ArrayList(){ + private static final long serialVersionUID = -2456634893793575347L; + { + add(new UIHead(tabTitles[0], 0)); + add(new UIHead(tabTitles[1], 1, !designer.isMultiSelection())); + add(new UIHead(tabTitles[2], 2, !designer.isMultiSelection())); + } + + }; final CardLayout tabbedPane = new CardLayout(); final JPanel center = new JPanel(tabbedPane); center.add(formWidgetCardPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties")); @@ -242,7 +264,9 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper center.add(wsp, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal")); this.add(center, BorderLayout.CENTER); - tabsHeaderIconPane = new UIHeadGroup(tabTitles) { + tabsHeaderIconPane = new UIHeadGroup(uiHeads) { + private static final long serialVersionUID = -6739508210752677967L; + @Override public void tabChanged(int index) { //切换的时候再populate diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java b/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java index d3173e36b..fd03dc72a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/action/InstallComponentAction.java @@ -4,7 +4,9 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.gui.ifilechooser.UINativeFileChooser; +import com.fr.design.gui.ifilechooser.FileChooserProvider; +import com.fr.design.gui.ifilechooser.FileSelectionMode; +import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -17,6 +19,8 @@ import com.fr.design.os.impl.SupportOSImpl; import com.fr.form.share.record.ShareWidgetInfoManager; import com.fr.form.share.utils.ReuxUtils; import com.fr.log.FineLoggerFactory; +import com.sun.javafx.tk.FileChooserType; +import javafx.stage.FileChooser; import javax.swing.Action; import javax.swing.JFileChooser; @@ -42,23 +46,16 @@ public class InstallComponentAction extends UpdateAction { @Override public void actionPerformed(ActionEvent e) { - - if (SupportOSImpl.NATIVE_CHOOSER.support()) { - UINativeFileChooser nativeFileChooser = new UINativeFileChooser(); - nativeFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - nativeFileChooser.setMultiSelectionEnabled(true); - nativeFileChooser.setFileFilter(new FileNameExtensionFilter("reu reus", "reu", "reus")); - nativeFileChooser.setDialogTitle(Toolkit.i18nText("Fine-Design_Basic_Select")); - int returnValue = nativeFileChooser.showOpenDialog(new UILabel()); - installComponent(returnValue, nativeFileChooser.getSelectedFiles()); - } else { - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); - fileChooser.setMultiSelectionEnabled(true); - fileChooser.setFileFilter(new FileNameExtensionFilter("reu reus", "reu", "reus")); - int returnValue = fileChooser.showDialog(new UILabel(), Toolkit.i18nText("Fine-Design_Basic_Select")); - installComponent(returnValue, fileChooser.getSelectedFiles()); - } + FileChooserProvider fileChooserProvider = + new JavaFxNativeFileChooser.Builder(). + fileSelectionMode(FileSelectionMode.MULTIPLE_FILE). + title(Toolkit.i18nText("Fine-Design_Basic_Select")). + filters(new FileChooser.ExtensionFilter[]{ + new FileChooser.ExtensionFilter("reu", "*.reu"), + new FileChooser.ExtensionFilter("reus", "*.reus")}). + build(); + int returnValue = fileChooserProvider.showDialog(null); + installComponent(returnValue, fileChooserProvider.getSelectedFiles()); } private void installComponent(int returnValue, File[] selectedFiles) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java new file mode 100644 index 000000000..ac687d425 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/AbstractMultiSelectionArrangementButton.java @@ -0,0 +1,23 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.MultiSelectionArrangement; + +public abstract class AbstractMultiSelectionArrangementButton implements MultiSelectionArrangementButton { + protected MultiSelectionArrangement arrangement; + + public AbstractMultiSelectionArrangementButton(MultiSelectionArrangement arrangement) { + this.arrangement = arrangement; + } + + @Override + public UIButton create() { + UIButton btn = new UIButton(); + btn.setNormalPainted(false); + btn.setBorderPaintedOnlyWhenPressed(true); + btn.setIcon(getIcon()); + btn.setToolTipText(getTipText()); + btn.addActionListener(getActionListener()); + return btn; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java new file mode 100644 index 000000000..41318ff67 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/BottomAlignButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class BottomAlignButton extends AbstractMultiSelectionArrangementButton { + public BottomAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_bottom_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Bottom_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.bottomAlign(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java new file mode 100644 index 000000000..7eface48f --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalCenterButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class HorizontalCenterButton extends AbstractMultiSelectionArrangementButton { + public HorizontalCenterButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_center_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Horizontal_Center_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.horizontalCenterAlign(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java new file mode 100644 index 000000000..678ce895b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/HorizontalDistributionButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class HorizontalDistributionButton extends AbstractMultiSelectionArrangementButton { + public HorizontalDistributionButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_auto_spacing.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Horizontal_Spacing"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.horizontalAutoDistribution(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java new file mode 100644 index 000000000..3f8d685c7 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/LeftAlignButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class LeftAlignButton extends AbstractMultiSelectionArrangementButton { + public LeftAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_left_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Left_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.leftAlign(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java new file mode 100644 index 000000000..06bc2026b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/MultiSelectionArrangementButton.java @@ -0,0 +1,16 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.gui.ibutton.UIButton; + +import javax.swing.Icon; +import java.awt.event.ActionListener; + +public interface MultiSelectionArrangementButton { + Icon getIcon(); + + String getTipText(); + + ActionListener getActionListener(); + + UIButton create(); +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java new file mode 100644 index 000000000..02f20fc45 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/RightAlignButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class RightAlignButton extends AbstractMultiSelectionArrangementButton { + public RightAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_right_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Right_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.rightAlign(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java new file mode 100644 index 000000000..7100b3b96 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/TopAlignButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class TopAlignButton extends AbstractMultiSelectionArrangementButton { + public TopAlignButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_top_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Top_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.topAlign(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java new file mode 100644 index 000000000..81d86d558 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalCenterButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class VerticalCenterButton extends AbstractMultiSelectionArrangementButton { + public VerticalCenterButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_center_align.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Vertical_Center_Align"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.verticalCenterAlign(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java new file mode 100644 index 000000000..538463b6b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/arrangement/buttons/VerticalDistributionButton.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.widget.arrangement.buttons; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.general.IOUtils; + +import javax.swing.Icon; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class VerticalDistributionButton extends AbstractMultiSelectionArrangementButton { + public VerticalDistributionButton(MultiSelectionArrangement arrangement) { + super(arrangement); + } + + @Override + public Icon getIcon() { + return IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_auto_spacing.png"); + } + + @Override + public String getTipText() { + return Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Vertical_Spacing"); + } + + @Override + public ActionListener getActionListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + arrangement.verticalAutoDistribution(); + } + }; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java new file mode 100644 index 000000000..77e6a67d8 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java @@ -0,0 +1,178 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UIIntNumberField; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.MultiSelectionArrangement; +import com.fr.design.mainframe.widget.arrangement.buttons.BottomAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.HorizontalCenterButton; +import com.fr.design.mainframe.widget.arrangement.buttons.HorizontalDistributionButton; +import com.fr.design.mainframe.widget.arrangement.buttons.LeftAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.RightAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.TopAlignButton; +import com.fr.design.mainframe.widget.arrangement.buttons.VerticalCenterButton; +import com.fr.design.mainframe.widget.arrangement.buttons.VerticalDistributionButton; +import com.fr.general.IOUtils; +import com.fr.stable.StableUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; + +public class FormMultiWidgetCardPane extends FormWidgetCardPane { + private MultiSelectionArrangement arrangement; + + public FormMultiWidgetCardPane(FormDesigner designer) { + super(designer); + arrangement = new MultiSelectionArrangement(designer); + } + + public void initPropertyPane() { + content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); + content.add(createArrangementLayoutPane(), BorderLayout.CENTER); + } + + // 整个排列分布面板的layout,可以看成一个三行一列的表格,第一行是分布,第二行是自动间距,第三行是手动间距 + private JPanel createArrangementLayoutPane() { + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] columnSize = {TableLayout.PREFERRED}; + Component[][] components = new Component[][] { + new Component[] { + createAlignmentPane() + }, + new Component[] { + createAutoSpacingPane() + }, + new Component[] { + createManualSpacingPane() + } + }; + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 16); + } + + // 对齐 + private JPanel createAlignmentPane() { + double[] rowSize = {TableLayout.PREFERRED}; + double[] columnSize = { + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED, + TableLayout.PREFERRED + }; + Component[][] components = new Component[][] { + new Component[] { + new LeftAlignButton(arrangement).create(), + new HorizontalCenterButton(arrangement).create(), + new RightAlignButton(arrangement).create(), + new TopAlignButton(arrangement).create(), + new VerticalCenterButton(arrangement).create(), + new BottomAlignButton(arrangement).create() + } + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); + return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Align"), centerPane); + } + + // 自动间距 + private JPanel createAutoSpacingPane() { + double[] rowSize = {TableLayout.PREFERRED}; + double[] columnSize = { + TableLayout.PREFERRED, + TableLayout.PREFERRED + }; + UIButton horizontalAutoSpacingBtn = new HorizontalDistributionButton(arrangement).create(); + UIButton verticalAutoSpacingBtn = new VerticalDistributionButton(arrangement).create(); + if (designer.getSelectionModel().getSelection().size() < 3) { + horizontalAutoSpacingBtn.setEnabled(false); + verticalAutoSpacingBtn.setEnabled(false); + } + Component[][] components = new Component[][] { + new Component[] { + horizontalAutoSpacingBtn, + verticalAutoSpacingBtn + } + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 18, 0); + + + UILabel tip = new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_auto_spacing_tip.png")); + tip.setToolTipText(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing_Tip")); + Component[][] titleComponents = new Component[][] { + new Component[] { + new UILabel(Toolkit.i18nText("Fine-Design_Multi_Selection_Auto_Spacing")), + tip + } + }; + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(titleComponents, rowSize, columnSize, 5, 0); + + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 8)); + jPanel.add(northPane, BorderLayout.NORTH); + jPanel.add(centerPane, BorderLayout.CENTER); + return jPanel; + } + + // 手动间距 + private JPanel createManualSpacingPane() { + double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] columnSize = { + TableLayout.PREFERRED, + TableLayout.FILL + }; + UITextField horizontalSpacingNumberField = new UIIntNumberField(); + horizontalSpacingNumberField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + distributionDoChange(horizontalSpacingNumberField.getText(), false); + } + }); + UITextField verticalSpacingNumberField = new UIIntNumberField(); + verticalSpacingNumberField.addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + distributionDoChange(verticalSpacingNumberField.getText(), true); + } + }); + Component[][] components = new Component[][] { + new Component[] { + new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_horizontal_spacing.png")), + horizontalSpacingNumberField + }, + new Component[] { + new UILabel(IOUtils.readIcon("/com/fr/design/images/buttonicon/multi_selection_vertical_spacing.png")), + verticalSpacingNumberField + } + }; + JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 21, 9); + return createTitleLayout(Toolkit.i18nText("Fine-Design_Multi_Selection_Manual_Spacing"), centerPane); + } + + private void distributionDoChange(String text, boolean isVertical) { + if (StableUtils.isNumber(text)) { + if (isVertical) { + arrangement.verticalManualDistribution(Math.round(Float.parseFloat(text))); + } else { + arrangement.horizontalManualDistribution(Math.round(Float.parseFloat(text))); + } + } + } + + // 创建一个BorderLayout布局,上面是标题,例如“对齐”,下面是个容器 + private JPanel createTitleLayout(String title, JPanel centerPane) { + JPanel jPanel = new JPanel(); + jPanel.setLayout(new BorderLayout(0, 8)); + jPanel.add(new UILabel(title), BorderLayout.NORTH); + jPanel.add(centerPane, BorderLayout.CENTER); + return jPanel; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java new file mode 100644 index 000000000..a9e5e5d98 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormSingleWidgetCardPane.java @@ -0,0 +1,297 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.data.DataCreatorUI; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.XWScaleLayout; +import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.EastRegionContainerPane; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.JForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.widget.DataModify; +import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; +import com.fr.design.widget.Operator; +import com.fr.design.widget.ui.designer.component.WidgetAbsoluteBoundPane; +import com.fr.design.widget.ui.designer.component.WidgetBoundPane; +import com.fr.design.widget.ui.designer.component.WidgetCardTagBoundPane; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import java.awt.BorderLayout; + +public class FormSingleWidgetCardPane extends FormWidgetCardPane { + private AttributeChangeListener listener; + + //当前的编辑器属性定义面板 + private DataModify currentEditorDefinePane; + private FormBasicPropertyPane widgetPropertyPane; + private JPanel attriCardPane; + + private XCreator xCreator; + private WidgetBoundPane widgetBoundPane; + + + public FormSingleWidgetCardPane(FormDesigner designer) { + super(designer); + } + + public void initPropertyPane() { + this.xCreator = findXcreator(designer); + initComponents(); + initDefinePane(); + } + + public XLayoutContainer getParent(XCreator source) { + XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); + if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { + container = null; + } + return container; + } + + public WidgetBoundPane createWidgetBoundPane(XCreator xCreator) { + XLayoutContainer xLayoutContainer = getParent(xCreator); + if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteBodyLayout.class)) { + return null; + } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { + return new WidgetAbsoluteBoundPane(xCreator); + } else if (xCreator.acceptType(XWCardTagLayout.class)) { + return new WidgetCardTagBoundPane(xCreator); + } + return new WidgetBoundPane(xCreator); + } + + public XCreator findXcreator(FormDesigner designer) { + XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); + return creator != null ? creator : designer.getRootComponent(); + } + + /** + * 后台初始化所有事件. + */ + @Override + public void initAllListeners() { + + } + + /** + * 后台初始化所有事件. + */ + public void reinitAllListeners() { + initListener(this); + } + + @Override + protected void initContentPane() { + + } + + private void initComponents() { + XCreator innerCreator = getXCreatorDedicated(); + + attriCardPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + content.add(attriCardPane, BorderLayout.CENTER); + content.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); + + final boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(innerCreator.toData()); + this.listener = new AttributeChangeListener() { + @Override + public void attributeChange() { + if (!isExtraWidget) { + updateCreator(); + } + updateWidgetBound(); + firePropertyEdit(); + } + }; + + freshPropertyMode(innerCreator); + if (isExtraWidget) { + // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 + widgetBoundPane = createWidgetBoundPane(xCreator); + if (widgetBoundPane != null) { + attriCardPane.add(widgetBoundPane, BorderLayout.CENTER); + } + return; + } + + widgetPropertyPane = WidgetBasicPropertyPaneFactory.createBasicPropertyPane(innerCreator); + + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 280, 20, widgetPropertyPane); + + content.add(uiExpandablePane, BorderLayout.NORTH); + + widgetBoundPane = createWidgetBoundPane(xCreator); + if (widgetBoundPane != null) { + attriCardPane.add(widgetBoundPane, BorderLayout.NORTH); + } + } + + private static void freshPropertyMode(XCreator xCreator) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) { + if (xCreator instanceof XWParameterLayout) { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); + } else { + EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA_WIDGET); + } + } + } + + private void initDefinePane() { + currentEditorDefinePane = null; + XCreator creator = getXCreatorDedicated(); + FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, designer, creator.toData(), new Operator() { + @Override + public void did(DataCreatorUI ui, String cardName) { + //todo + } + }); + DataModify definePane = rn.getDefinePane(); + + JComponent definePaneComponent = definePane.toSwingComponent(); + boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(creator.toData()); + + if (isExtraWidget) { + // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 + attriCardPane.add(definePaneComponent, BorderLayout.NORTH); + } else { + // 使用单独的JPane和BorderLayout.North进行包装,避免出现CENTER嵌套CENTER后,内容高度变大的情况 + JPanel definePaneWrapContent = FRGUIPaneFactory.createBorderLayout_S_Pane(); + definePaneWrapContent.add(definePaneComponent, BorderLayout.NORTH); + attriCardPane.add(definePaneWrapContent, BorderLayout.CENTER); + } + currentEditorDefinePane = definePane; + } + + private XCreator getXCreatorDedicated() { + boolean dedicateLayout = xCreator.acceptType(XWScaleLayout.class) && xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator() || xCreator.acceptType(XWTitleLayout.class); + return dedicateLayout ? (XCreator) xCreator.getComponent(0) : xCreator; + } + + @Override + public String title4PopupWindow() { + return "Widget"; + } + + public void populate() { + //populate之前先移除所有的监听 + removeAttributeChangeListener(); + Widget cellWidget = xCreator.toData(); + if (widgetBoundPane != null) { + widgetBoundPane.populate(); + } + Widget innerWidget = cellWidget; + if (cellWidget.acceptType(WScaleLayout.class)) { + Widget crBoundsWidget = ((WScaleLayout) cellWidget).getBoundsWidget(); + innerWidget = ((CRBoundsWidget) crBoundsWidget).getWidget(); + } else if (cellWidget.acceptType(WTitleLayout.class)) { + CRBoundsWidget crBoundsWidget = ((WTitleLayout) cellWidget).getBodyBoundsWidget(); + innerWidget = crBoundsWidget.getWidget(); + } + if (currentEditorDefinePane != null) { + currentEditorDefinePane.populateBean(innerWidget); + } + if (widgetPropertyPane != null) { + widgetPropertyPane.populate(innerWidget); + } + reinitAllListeners(); + this.addAttributeChangeListener(listener); + } + + + public void updateCreator() { + currentEditorDefinePane.setGlobalName(getGlobalName()); + Widget widget = currentEditorDefinePane.updateBean(); + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_Basic")) && widgetPropertyPane != null) { + UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); + String toSetWidgetName = widgetNameField.getText(); + String currentWidgetName = widget.getWidgetName(); + if (toSetWidgetName.isEmpty()) { + widgetNameField.setText(currentWidgetName); + return; + } + + boolean exist = designer.getTarget().isNameExist(toSetWidgetName, widget) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + if (exist) { + widgetNameField.setText(currentWidgetName); + showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure")); + return; + } + + //图表名称的合法性检查 + if (widget instanceof ChartEditor && toSetWidgetName.startsWith("Chart")) { + widgetNameField.setText(currentWidgetName); + showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Chart_Widget_Rename_Failure")); + return; + } + widgetPropertyPane.update(widget); + // 上面一行更新了组件 这里必须重新调用getWidgetName + xCreator.resetCreatorName(widget.getWidgetName()); + xCreator.resetVisible(widget.isVisible()); + designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); + return; + } + fireValueChanged(); + } + + private void showNameInvalidDialog(String message) { + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), message, Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + } + + public void updateWidgetBound() { + if (widgetBoundPane != null && ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"))) { + widgetBoundPane.update(); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); + } + designer.refreshDesignerUI(); + } + + + @Override + /** + *检查 + */ + public void checkValid() throws Exception { + currentEditorDefinePane.checkValid(); + } + + public void fireValueChanged() { + XCreator creator = getXCreatorDedicated(); + creator.firePropertyChange(); + } + + @Override + public String getIconPath() { + return StringUtils.EMPTY; + } + + public void firePropertyEdit() { + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index a76c96902..c2d145983 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -1,49 +1,12 @@ package com.fr.design.mainframe.widget.ui; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteBodyLayout; -import com.fr.design.designer.creator.XWAbsoluteLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.creator.XWScaleLayout; -import com.fr.design.designer.creator.XWTitleLayout; -import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.dialog.AttrScrollPane; import com.fr.design.dialog.BasicScrollPane; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.JForm; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.widget.DataModify; -import com.fr.design.widget.FormWidgetDefinePaneFactoryBase; -import com.fr.design.widget.Operator; -import com.fr.design.widget.ui.designer.component.WidgetAbsoluteBoundPane; -import com.fr.design.widget.ui.designer.component.WidgetBoundPane; -import com.fr.design.widget.ui.designer.component.WidgetCardTagBoundPane; -import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WScaleLayout; -import com.fr.form.ui.container.WTitleLayout; -import com.fr.form.ui.widget.CRBoundsWidget; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.stable.StringUtils; import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -51,43 +14,18 @@ import java.awt.BorderLayout; * Created by ibm on 2017/7/25. */ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { - private AttributeChangeListener listener; - private FormDesigner designer; - //当前的编辑器属性定义面板 - private DataModify currentEditorDefinePane; - private FormBasicPropertyPane widgetPropertyPane; - private JPanel attriCardPane; - - private XCreator xCreator; - private WidgetBoundPane widgetBoundPane; - + protected FormDesigner designer; + protected JPanel content; public FormWidgetCardPane(FormDesigner designer) { - super(); - this.xCreator = findXcreator(designer); this.designer = designer; - initComponents(); - initDefinePane(); + this.initLayout(); + this.initScrollPane(); + this.initPropertyPane(); } - public XLayoutContainer getParent(XCreator source) { - XLayoutContainer container = XCreatorUtils.getParentXLayoutContainer(source); - if (source.acceptType(XWFitLayout.class) || source.acceptType(XWParameterLayout.class)) { - container = null; - } - return container; - } + public void initPropertyPane() { - public WidgetBoundPane createWidgetBoundPane(XCreator xCreator) { - XLayoutContainer xLayoutContainer = getParent(xCreator); - if (xLayoutContainer == null || xCreator.acceptType(XWParameterLayout.class) || xCreator.acceptType(XWAbsoluteBodyLayout.class)) { - return null; - } else if (xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { - return new WidgetAbsoluteBoundPane(xCreator); - } else if (xCreator.acceptType(XWCardTagLayout.class)) { - return new WidgetCardTagBoundPane(xCreator); - } - return new WidgetBoundPane(xCreator); } @Override @@ -95,219 +33,31 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { return null; } - public XCreator findXcreator(FormDesigner designer) { - XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); - return creator != null ? creator : designer.getRootComponent(); - } - - /** - * 后台初始化所有事件. - */ - @Override - public void initAllListeners() { - - } - - /** - * 后台初始化所有事件. - */ - public void reinitAllListeners() { - initListener(this); - } - - @Override - protected void initContentPane() { - } - - private void initComponents() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); - XCreator innerCreator = getXCreatorDedicated(); - - final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + private void initScrollPane() { + final JPanel jPanel = this.createContentPaneInScrollPane(); BasicScrollPane basicScrollPane = new AttrScrollPane() { + private static final long serialVersionUID = 3117877968639659022L; + @Override protected JPanel createContentPane() { return jPanel; } }; this.add(basicScrollPane, BorderLayout.CENTER); - attriCardPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - jPanel.add(attriCardPane, BorderLayout.CENTER); - jPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); - - final boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(innerCreator.toData()); - this.listener = new AttributeChangeListener() { - @Override - public void attributeChange() { - if (!isExtraWidget) { - updateCreator(); - } - updateWidgetBound(); - firePropertyEdit(); - } - }; - - freshPropertyMode(innerCreator); - if (isExtraWidget) { - // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 - widgetBoundPane = createWidgetBoundPane(xCreator); - if (widgetBoundPane != null) { - attriCardPane.add(widgetBoundPane, BorderLayout.CENTER); - } - return; - } - - widgetPropertyPane = WidgetBasicPropertyPaneFactory.createBasicPropertyPane(innerCreator); - - UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 280, 20, widgetPropertyPane); - - jPanel.add(uiExpandablePane, BorderLayout.NORTH); - - widgetBoundPane = createWidgetBoundPane(xCreator); - if (widgetBoundPane != null) { - attriCardPane.add(widgetBoundPane, BorderLayout.NORTH); - } - } - - private static void freshPropertyMode(XCreator xCreator) { - JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (!(jTemplate instanceof JForm) && jTemplate.isUpMode()) { - if (xCreator instanceof XWParameterLayout) { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA); - } else { - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_PARA_WIDGET); - } - } + this.content = jPanel; } - private void initDefinePane() { - currentEditorDefinePane = null; - XCreator creator = getXCreatorDedicated(); - FormWidgetDefinePaneFactoryBase.RN rn = FormWidgetDefinePaneFactoryBase.createWidgetDefinePane(creator, designer, creator.toData(), new Operator() { - @Override - public void did(DataCreatorUI ui, String cardName) { - //todo - } - }); - DataModify definePane = rn.getDefinePane(); - - JComponent definePaneComponent = definePane.toSwingComponent(); - boolean isExtraWidget = FormWidgetDefinePaneFactoryBase.isExtraXWidget(creator.toData()); - - if (isExtraWidget) { - // REPORT-55603: 仅对于插件控件,将尺寸*位置面板放置在definePane下方,其余控件将尺寸*位置面板放置在definePane上方 - attriCardPane.add(definePaneComponent, BorderLayout.NORTH); - } else { - // 使用单独的JPane和BorderLayout.North进行包装,避免出现CENTER嵌套CENTER后,内容高度变大的情况 - JPanel definePaneWrapContent = FRGUIPaneFactory.createBorderLayout_S_Pane(); - definePaneWrapContent.add(definePaneComponent, BorderLayout.NORTH); - attriCardPane.add(definePaneWrapContent, BorderLayout.CENTER); - } - currentEditorDefinePane = definePane; - } - - private XCreator getXCreatorDedicated() { - boolean dedicateLayout = xCreator.acceptType(XWScaleLayout.class) && xCreator.getComponentCount() > 0 && ((XCreator) xCreator.getComponent(0)).shouldScaleCreator() || xCreator.acceptType(XWTitleLayout.class); - return dedicateLayout ? (XCreator) xCreator.getComponent(0) : xCreator; + private void initLayout() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + // 跟上方tab标题“属性”那一栏间距10 + this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); } - @Override - public String title4PopupWindow() { - return "Widget"; + protected JPanel createContentPaneInScrollPane() { + return FRGUIPaneFactory.createBorderLayout_S_Pane(); } public void populate() { - //populate之前先移除所有的监听 - removeAttributeChangeListener(); - Widget cellWidget = xCreator.toData(); - if (widgetBoundPane != null) { - widgetBoundPane.populate(); - } - Widget innerWidget = cellWidget; - if (cellWidget.acceptType(WScaleLayout.class)) { - Widget crBoundsWidget = ((WScaleLayout) cellWidget).getBoundsWidget(); - innerWidget = ((CRBoundsWidget) crBoundsWidget).getWidget(); - } else if (cellWidget.acceptType(WTitleLayout.class)) { - CRBoundsWidget crBoundsWidget = ((WTitleLayout) cellWidget).getBodyBoundsWidget(); - innerWidget = crBoundsWidget.getWidget(); - } - currentEditorDefinePane.populateBean(innerWidget); - if (widgetPropertyPane != null) { - widgetPropertyPane.populate(innerWidget); - } - reinitAllListeners(); - this.addAttributeChangeListener(listener); - } - - - public void updateCreator() { - currentEditorDefinePane.setGlobalName(getGlobalName()); - Widget widget = currentEditorDefinePane.updateBean(); - if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_Basic")) && widgetPropertyPane != null) { - UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); - String toSetWidgetName = widgetNameField.getText(); - String currentWidgetName = widget.getWidgetName(); - if (toSetWidgetName.isEmpty()) { - widgetNameField.setText(currentWidgetName); - return; - } - - boolean exist = designer.getTarget().isNameExist(toSetWidgetName, widget) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); - if (exist) { - widgetNameField.setText(currentWidgetName); - showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure")); - return; - } - - //图表名称的合法性检查 - if (widget instanceof ChartEditor && toSetWidgetName.startsWith("Chart")) { - widgetNameField.setText(currentWidgetName); - showNameInvalidDialog(Toolkit.i18nText("Fine-Design_Form_Chart_Widget_Rename_Failure")); - return; - } - widgetPropertyPane.update(widget); - // 上面一行更新了组件 这里必须重新调用getWidgetName - xCreator.resetCreatorName(widget.getWidgetName()); - xCreator.resetVisible(widget.isVisible()); - designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); - return; - } - fireValueChanged(); - } - - private void showNameInvalidDialog(String message) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), message, Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); - } - - public void updateWidgetBound() { - if (widgetBoundPane != null && ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Coords_And_Size"))) { - widgetBoundPane.update(); - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_RESIZED); - } - designer.refreshDesignerUI(); - } - - - @Override - /** - *检查 - */ - public void checkValid() throws Exception { - currentEditorDefinePane.checkValid(); - } - - public void fireValueChanged() { - XCreator creator = getXCreatorDedicated(); - creator.firePropertyChange(); - } - - @Override - public String getIconPath() { - return StringUtils.EMPTY; - } - public void firePropertyEdit() { - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPaneFactory.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPaneFactory.java new file mode 100644 index 000000000..6c4874536 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPaneFactory.java @@ -0,0 +1,13 @@ +package com.fr.design.mainframe.widget.ui; + +import com.fr.design.mainframe.FormDesigner; + +public class FormWidgetCardPaneFactory { + public static FormWidgetCardPane create(FormDesigner designer) { + if (designer.isMultiSelection()) { + return new FormMultiWidgetCardPane(designer); + } else { + return new FormSingleWidgetCardPane(designer); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/utils/DeprecatedActionManager.java b/designer-realize/src/main/java/com/fr/design/actions/utils/DeprecatedActionManager.java index 47d19a3a7..d12e88cf5 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/utils/DeprecatedActionManager.java +++ b/designer-realize/src/main/java/com/fr/design/actions/utils/DeprecatedActionManager.java @@ -7,24 +7,27 @@ import com.fr.base.present.FormulaPresent; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.cell.NewPresentAction; -import com.fr.design.actions.core.ActionFactory; -import com.fr.design.actions.edit.clear.*; import com.fr.design.actions.columnrow.DeleteColumnAction; import com.fr.design.actions.columnrow.DeleteRowAction; import com.fr.design.actions.columnrow.InsertColumnAction; import com.fr.design.actions.columnrow.InsertRowAction; +import com.fr.design.actions.core.ActionFactory; +import com.fr.design.actions.edit.clear.ClearAction; +import com.fr.design.actions.edit.clear.ClearAllAction; +import com.fr.design.actions.edit.clear.ClearContentsAction; +import com.fr.design.actions.edit.clear.ClearFormatsAction; +import com.fr.design.actions.edit.clear.ClearWidgetAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fun.PresentKindProvider; import com.fr.design.gui.imenu.UIMenu; +import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; - -import com.fr.design.mainframe.ElementCasePane; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.Selection; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; +import com.fr.grid.selection.CellSelection; +import com.fr.grid.selection.Selection; import com.fr.report.cell.cellattr.BarcodePresent; import com.fr.report.cell.cellattr.CurrencyLinePresent; diff --git a/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java b/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java index 2767b1a8e..8bc66e172 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java +++ b/designer-realize/src/main/java/com/fr/design/cell/clipboard/CellElementsClip.java @@ -3,6 +3,7 @@ */ package com.fr.design.cell.clipboard; +import com.fr.design.base.clipboard.ClipboardHelper; import com.fr.grid.selection.CellSelection; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.CellElement; @@ -12,8 +13,10 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.StringUtils; import com.fr.stable.unit.FU; +import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; +import java.util.List; /** * The clip of CellElement. @@ -21,16 +24,16 @@ import java.util.Iterator; public class CellElementsClip implements Cloneable, java.io.Serializable { private int columnSpan = 0; private int rowSpan = 0; - private FU[] columnWidth; - private FU[] rowHeight; + private FU[] columnWidth; + private FU[] rowHeight; private TemplateCellElement[] clips; - public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth , FU[] rowHeight, TemplateCellElement[] clips) { - this.columnSpan = columnSpan; - this.rowSpan = rowSpan; - this.columnWidth = columnWidth ; - this.rowHeight = rowHeight; - this.clips = clips; + public CellElementsClip(int columnSpan, int rowSpan, FU[] columnWidth, FU[] rowHeight, TemplateCellElement[] clips) { + this.columnSpan = columnSpan; + this.rowSpan = rowSpan; + this.columnWidth = columnWidth; + this.rowHeight = rowHeight; + this.clips = clips; } public CellElementsClip(int columnSpan, int rowSpan, TemplateCellElement[] clips) { @@ -39,122 +42,116 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { this.clips = clips; } - public int getColumnSpan() { - return columnSpan; - } + public int getColumnSpan() { + return columnSpan; + } - public void setColumnSpan(int columnSpan) { - this.columnSpan = columnSpan; - } + public void setColumnSpan(int columnSpan) { + this.columnSpan = columnSpan; + } - public int getRowSpan() { - return rowSpan; - } + public int getRowSpan() { + return rowSpan; + } - public void setRowSpan(int rowSpan) { - this.rowSpan = rowSpan; - } + public void setRowSpan(int rowSpan) { + this.rowSpan = rowSpan; + } - public FU[] getColumnWidth() { - return columnWidth; - } + public FU[] getColumnWidth() { + return columnWidth; + } - public void setColumnWidth(FU[] columnWidth) { - this.columnWidth = columnWidth; - } + public void setColumnWidth(FU[] columnWidth) { + this.columnWidth = columnWidth; + } - public FU[] getRowHeight() { - return rowHeight; - } + public FU[] getRowHeight() { + return rowHeight; + } - public void setRowHeight(FU[] rowHeight) { - this.rowHeight = rowHeight; - } + public void setRowHeight(FU[] rowHeight) { + this.rowHeight = rowHeight; + } - public TemplateCellElement[] getClips() { - return clips; - } + public TemplateCellElement[] getClips() { + return clips; + } - public void setClips(TemplateCellElement[] clips) { - this.clips = clips; - } + public void setClips(TemplateCellElement[] clips) { + this.clips = clips; + } - public String compateExcelPaste() { - Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator()); + public String compateExcelPaste() { + Arrays.sort(this.clips, CellElementComparator.getRowFirstComparator()); - // 排序 - StringBuffer sbuf = new StringBuffer(); + // 排序 - int currentRow = -1; - for (int i = 0; i < clips.length; i++) { - CellElement cellElement = clips[i]; - if (currentRow == -1) {// 初始化当前行. - currentRow = cellElement.getRow(); - } + List> table = new ArrayList<>(); + int startRow = -1; + int currentRow = -1; + for (int i = 0; i < clips.length; i++) { + CellElement cellElement = clips[i]; + if (currentRow == -1) {// 初始化当前行. + currentRow = cellElement.getRow(); + startRow = currentRow; + table.add(new ArrayList<>()); + } - if (currentRow < cellElement.getRow()) { - for (int r = currentRow; r < cellElement.getRow(); r++) { - sbuf.append('\n'); - } - currentRow = cellElement.getRow(); - } + while (currentRow < cellElement.getRow()) { + table.add(new ArrayList<>()); + currentRow++; + } - // 添加分隔符号. - if (sbuf.length() > 0 && sbuf.charAt(sbuf.length() - 1) != '\n') { - sbuf.append('\t'); - } - //REPORT-5134:会复制出null - if (cellElement.getValue() == null) { - sbuf.append(StringUtils.EMPTY); - } else { - sbuf.append(cellElement.getValue()); - } - } + Object cellValue = cellElement.getValue() == null ? StringUtils.EMPTY : cellElement.getValue(); + table.get(currentRow - startRow).add(cellValue); + } - return sbuf.toString(); + return ClipboardHelper.formatExcelString(table); } + public CellSelection pasteAt(TemplateElementCase ec, int column, int row) { - Iterator cells = ec.intersect(column, row, columnSpan, rowSpan); - while (cells.hasNext()) { - TemplateCellElement cellElement = (TemplateCellElement)cells.next(); - ec.removeCellElement(cellElement); - } - for (int i = 0; i < clips.length; i++) { - TemplateCellElement cellElement; - try { - cellElement = (TemplateCellElement) clips[i].clone(); - } catch (CloneNotSupportedException e) { + Iterator cells = ec.intersect(column, row, columnSpan, rowSpan); + while (cells.hasNext()) { + TemplateCellElement cellElement = (TemplateCellElement) cells.next(); + ec.removeCellElement(cellElement); + } + for (int i = 0; i < clips.length; i++) { + TemplateCellElement cellElement; + try { + cellElement = (TemplateCellElement) clips[i].clone(); + } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); - return null; - } - - // peter:因为前面已经将这个位置的元素删除了,所以不需要override了. - ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement( - column + cellElement.getColumn(), row + cellElement.getRow() - ), false); - } - //设置单元格的宽高 - if(this.columnWidth != null && this.rowHeight != null){ + return null; + } + + // peter:因为前面已经将这个位置的元素删除了,所以不需要override了. + ec.addCellElement((TemplateCellElement) cellElement.deriveCellElement( + column + cellElement.getColumn(), row + cellElement.getRow() + ), false); + } + //设置单元格的宽高 + if (this.columnWidth != null && this.rowHeight != null) { pasteWidthAndHeight(ec, column, row, columnSpan, rowSpan); } - return new CellSelection(column, row, columnSpan, rowSpan); + return new CellSelection(column, row, columnSpan, rowSpan); } - public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan){ - for(int i = 0; i < columnSpan; i++){ - ec.setColumnWidth(column + i, columnWidth[i]); - } - for(int j = 0; j < rowSpan; j++){ - ec.setRowHeight(row + j, rowHeight[j]); - } - } + public void pasteWidthAndHeight(TemplateElementCase ec, int column, int row, int columnSpan, int rowSpan) { + for (int i = 0; i < columnSpan; i++) { + ec.setColumnWidth(column + i, columnWidth[i]); + } + for (int j = 0; j < rowSpan; j++) { + ec.setRowHeight(row + j, rowHeight[j]); + } + } public void pasteAtRegion(TemplateElementCase ec, - int startColumn, int startRow, - int column, int row, - int columnSpan, int rowSpan) { + int startColumn, int startRow, + int column, int row, + int columnSpan, int rowSpan) { for (int i = 0; i < clips.length; i++) { TemplateCellElement cellElement = clips[i]; @@ -173,14 +170,14 @@ public class CellElementsClip implements Cloneable, java.io.Serializable { * Clone. */ @Override - public Object clone() throws CloneNotSupportedException { + public Object clone() throws CloneNotSupportedException { CellElementsClip cloned = (CellElementsClip) super.clone(); if (this.clips != null) { - cloned.clips = new TemplateCellElement[this.clips.length]; - for (int i = 0; i < this.clips.length; i++) { - cloned.clips[i] = (TemplateCellElement)this.clips[i].clone(); - } + cloned.clips = new TemplateCellElement[this.clips.length]; + for (int i = 0; i < this.clips.length; i++) { + cloned.clips[i] = (TemplateCellElement) this.clips[i].clone(); + } } return cloned; 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 324c21ed4..306aaf4ed 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 @@ -118,8 +118,6 @@ import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollBar; import javax.swing.KeyStroke; -import java.lang.reflect.Constructor; -import java.util.Set; import java.awt.AWTEvent; import java.awt.Adjustable; import java.awt.Dimension; @@ -133,6 +131,8 @@ import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.lang.reflect.Constructor; +import java.util.Set; import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; @@ -181,7 +181,7 @@ public abstract class ElementCasePane extends Tar DesignerContext.setFormatState(DesignerContext.FORMAT_STATE_ONCE); DesignerContext.setReferencedElementCasePane(ElementCasePane.this); DesignerContext.setReferencedIndex( - ((JWorkBook) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingReportIndex()); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingReportIndex()); formatBrush.setSelected(true); formatBrushAction.executeActionReturnUndoRecordNeeded(); } else { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index 44992a84b..79b5c8dc5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -15,6 +15,7 @@ import com.fr.design.actions.edit.HyperlinkAction; import com.fr.design.actions.edit.merge.MergeCellAction; import com.fr.design.actions.edit.merge.UnmergeCellAction; import com.fr.design.actions.utils.DeprecatedActionManager; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; @@ -101,7 +102,9 @@ public class ElementCasePaneDelegate extends ElementCasePane { conditionAttributesGroupPane.populate(ElementCasePaneDelegate.this); EastRegionContainerPane.getInstance().replaceFloatElementPane(ReportFloatPane.getInstance()); - EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT); + EastRegionContainerPane.getInstance().switchMode(DesignModeContext.isDuchampMode() ? + EastRegionContainerPane.PropertyMode.DUCHAMP_REPORT : + EastRegionContainerPane.PropertyMode.REPORT); EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance()); EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance()); EastRegionContainerPane.getInstance().replaceConditionAttrPane(conditionAttributesGroupPane); @@ -201,7 +204,11 @@ public class ElementCasePaneDelegate extends ElementCasePane { menuDef.addShortCut(new GlobalStyleMenuDef(this)); // 单元格形态 menuDef.addShortCut(DeprecatedActionManager.getPresentMenu(this)); - menuDef.addShortCut(new CellWidgetAttrAction()); + + if (!DesignModeContext.isDuchampMode()) { + menuDef.addShortCut(new CellWidgetAttrAction()); + } + menuDef.addShortCut(new ConditionAttributesAction()); menuDef.addShortCut(new HyperlinkAction()); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 95d14be32..11cd14d11 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -193,7 +193,7 @@ public class JWorkBook extends JTemplate { } @Override - protected UIModeControlContainer createCenterPane() { + protected JComponent createCenterPane() { parameterPane = ModuleContext.isModuleStarted(Module.FORM_MODULE) ? new ParameterDefinitePane() : null; centerPane = new UIModeControlContainer(parameterPane, reportComposite = new ReportComponentComposite(this)) { @Override @@ -214,7 +214,7 @@ public class JWorkBook extends JTemplate { reportComposite.addTargetModifiedListener(e -> JWorkBook.this.fireTargetModified()); reportComposite.setParentContainer(centerPane); - return centerPane; + return DesignModeContext.isDuchampMode() ? reportComposite : centerPane; } @Override @@ -313,7 +313,7 @@ public class JWorkBook extends JTemplate { } private boolean hasParameterPane() { - return parameterPane != null; + return parameterPane != null && !DesignModeContext.isDuchampMode(); } /** @@ -580,7 +580,8 @@ public class JWorkBook extends JTemplate { super.setTarget(book); } - private TargetComponent delegate4ToolbarMenuAdapter() { + + public ReportComponent delegate4ToolbarMenuAdapter() { return this.reportComposite.getEditingReportComponent(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 9377c619a..b412d724d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.EditingState; import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; @@ -215,7 +216,9 @@ public class ReportComponentComposite extends JComponent implements RemoveListen jSliderContainer = JFormSliderPane.getInstance(); } southPane.add(hbarContainer, BorderLayout.NORTH); - southPane.add(sheetNameTab, BorderLayout.CENTER); + if (!DesignModeContext.isDuchampMode()) { + southPane.add(sheetNameTab, BorderLayout.CENTER); + } southPane.add(jSliderContainer, BorderLayout.EAST); return southPane; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index cbe37764d..1f0ebd779 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -361,10 +361,11 @@ public class CellOtherSetPane extends AbstractCellAttrPane { cellGUIAttr = CellGUIAttr.DEFAULT_CELLGUIATTR; } - // 是否在编辑表单中的报表块 - boolean isInForm = EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT); + // 支持 跟随页面设置 选项 = 不在编辑表单中的报表块 && 不在大屏模板cpt组件中 + boolean supportFollowTplDefine = !EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.FORM_REPORT) + && !EastRegionContainerPane.getInstance().getCurrentMode().equals(EastRegionContainerPane.PropertyMode.DUCHAMP_REPORT); - defaultAutoRadioButton.setVisible(!isInForm); + defaultAutoRadioButton.setVisible(supportFollowTplDefine); switch (cellGUIAttr.getAdjustMode()) { case CellGUIAttr.ADJUST_MODE_NO_AUTO: noAutoRadioButton.setSelected(true); @@ -376,10 +377,10 @@ public class CellOtherSetPane extends AbstractCellAttrPane { autoWidthRadioButton.setSelected(true); break; case CellGUIAttr.ADJUST_MODE_DEFAULT: - if (isInForm) { - autoHeightRadioButton.setSelected(true); - } else { + if (supportFollowTplDefine) { defaultAutoRadioButton.setSelected(true); + } else { + autoHeightRadioButton.setSelected(true); } break; default: diff --git a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java index fe24109ad..4abab05ef 100644 --- a/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java +++ b/designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java @@ -39,7 +39,6 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; import com.fr.design.report.RowColumnPane; import com.fr.design.selection.QuickEditor; - import com.fr.grid.GridUtils; import com.fr.report.cell.CellElement; import com.fr.report.cell.DefaultTemplateCellElement; diff --git a/designer-realize/src/main/java/com/fr/poly/PolyConstants.java b/designer-realize/src/main/java/com/fr/poly/PolyConstants.java index 50eaa16da..a754bdff3 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyConstants.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyConstants.java @@ -14,5 +14,5 @@ public class PolyConstants { } // 操作聚合报表添加行(列)的组件的高(宽)度 - public static final int OPERATION_SIZE = 15; + public static final int OPERATION_SIZE = 30; } \ No newline at end of file