From 6eabb72ab529ac25af8eaa71297349470ff3d475 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 30 Mar 2020 18:28:37 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-3521=20=E6=B7=BB=E5=8A=A0FineKit?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/concurrent/ConcurrentKit.java | 9 +- .../api/conf/{ => impl}/xml/XmlColConf.java | 2 +- .../api/conf/{ => impl}/xml/XmlConf.java | 2 +- .../fanruan/api/conf/xml/XmlHolderKit.java | 2 + .../com/fanruan/api/design/DesignKit.java | 30 +++ .../mainframe/HyperlinkGroupPaneAction.java | 17 -- .../table/model/DesignModelAdapterKit.java | 15 -- .../fanruan/api/design/util/GUICoreKit.java | 9 + .../api/design/work/SelectImagePane.java | 192 +++++++++++++++++- .../api/design/work/WidgetPropertyPane.java | 12 -- .../work/component/ParameterComboBox.java | 4 +- .../api/conf/xml/XmlHolderKitTest.java | 3 + 12 files changed, 241 insertions(+), 56 deletions(-) rename src/main/java/com/fanruan/api/conf/{ => impl}/xml/XmlColConf.java (95%) rename src/main/java/com/fanruan/api/conf/{ => impl}/xml/XmlConf.java (93%) delete mode 100644 src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java delete mode 100644 src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java diff --git a/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java b/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java index bb0acd6..7dcc423 100644 --- a/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java +++ b/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java @@ -9,7 +9,12 @@ import com.fr.concurrent.NamedThreadFactory; */ public class ConcurrentKit { - public static NamedThreadFactory newNamedThreadFactory(String s) { - return new NamedThreadFactory(s); + /** + * 创建命名的线程工厂 + * @param prefix 线程池名称前缀 + * @return 线程工厂 + */ + public static NamedThreadFactory newNamedThreadFactory(String prefix) { + return new NamedThreadFactory(prefix); } } diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java b/src/main/java/com/fanruan/api/conf/impl/xml/XmlColConf.java similarity index 95% rename from src/main/java/com/fanruan/api/conf/xml/XmlColConf.java rename to src/main/java/com/fanruan/api/conf/impl/xml/XmlColConf.java index caf9405..efcdf89 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java +++ b/src/main/java/com/fanruan/api/conf/impl/xml/XmlColConf.java @@ -1,4 +1,4 @@ -package com.fanruan.api.conf.xml; +package com.fanruan.api.conf.impl.xml; import java.util.Collection; diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlConf.java b/src/main/java/com/fanruan/api/conf/impl/xml/XmlConf.java similarity index 93% rename from src/main/java/com/fanruan/api/conf/xml/XmlConf.java rename to src/main/java/com/fanruan/api/conf/impl/xml/XmlConf.java index 27d83e0..425ea8c 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlConf.java +++ b/src/main/java/com/fanruan/api/conf/impl/xml/XmlConf.java @@ -1,4 +1,4 @@ -package com.fanruan.api.conf.xml; +package com.fanruan.api.conf.impl.xml; import com.fr.stable.xml.XMLable; diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java index f88a363..942864b 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java +++ b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java @@ -1,5 +1,7 @@ package com.fanruan.api.conf.xml; +import com.fanruan.api.conf.impl.xml.XmlColConf; +import com.fanruan.api.conf.impl.xml.XmlConf; import com.fr.config.holder.Conf; import com.fr.stable.xml.XMLable; diff --git a/src/main/java/com/fanruan/api/design/DesignKit.java b/src/main/java/com/fanruan/api/design/DesignKit.java index b4b48d3..60d73d4 100644 --- a/src/main/java/com/fanruan/api/design/DesignKit.java +++ b/src/main/java/com/fanruan/api/design/DesignKit.java @@ -1,14 +1,20 @@ package com.fanruan.api.design; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.base.TableData; +import com.fr.design.DesignModelAdapter; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerBean; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; import com.fr.design.mainframe.JTemplate; +import javax.swing.JComponent; + public class DesignKit { /** * 直接预览数据集,没有实际值及显示值 @@ -67,4 +73,28 @@ public class DesignKit { public static DesignerBean getDesignerBean(String name) { return DesignerContext.getDesignerBean(name); } + + /** + * 超链接面板操作 + * @return 操作对象 + */ + public static HyperlinkGroupPaneActionProvider getHyperlinkGroupPaneAction() { + + return HyperlinkGroupPaneActionImpl.getInstance(); + } + + /** + * 当前的设计模式 FormModel or WorkBookModel + * @return 设计器模式 + */ + public static DesignModelAdapter getCurrentModelAdapter() { + return DesignModelAdapter.getCurrentModelAdapter(); + } + + /** + * 控件属性容器 + */ + public static JComponent getWidgetComponent() { + return (JComponent) (WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator()).getComponent(0); + } } diff --git a/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java b/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java deleted file mode 100644 index 83f82e6..0000000 --- a/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fanruan.api.design.mainframe; - -import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; -import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 - */ -public class HyperlinkGroupPaneAction { - public static HyperlinkGroupPaneActionProvider getInstance() { - - return HyperlinkGroupPaneActionImpl.getInstance(); - } - -} diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java deleted file mode 100644 index 525c9df..0000000 --- a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.design.ui.component.table.model; - -import com.fr.design.DesignModelAdapter; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/27 - */ -public class DesignModelAdapterKit { - - public static DesignModelAdapter getCurrentModelAdapter() { - return DesignModelAdapter.getCurrentModelAdapter(); - } -} diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java index 5d34633..455914c 100644 --- a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -139,6 +139,15 @@ public class GUICoreKit { return FRGUIPaneFactory.createBorderLayout(); } + /** + * 创建一个靠左空边框面板,间隔中等 + * + * @return JPanel对象 + */ + public static JPanel createMediumHGapHighTopFlowInnerContainerPane() { + return FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); + } + /** * 设置一个窗口居中 */ diff --git a/src/main/java/com/fanruan/api/design/work/SelectImagePane.java b/src/main/java/com/fanruan/api/design/work/SelectImagePane.java index 07f1e10..78c1651 100644 --- a/src/main/java/com/fanruan/api/design/work/SelectImagePane.java +++ b/src/main/java/com/fanruan/api/design/work/SelectImagePane.java @@ -1,18 +1,198 @@ package com.fanruan.api.design.work; +import com.fanruan.api.design.ui.component.UIButton; +import com.fanruan.api.design.ui.component.UIRadioButton; +import com.fanruan.api.design.util.GUICoreKit; import com.fanruan.api.report.cell.CellImage; +import com.fr.base.Style; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.report.cell.Elem; +import com.fr.report.cell.painter.CellImagePainter; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; /** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 + * 这个类主要用于插入图片时的设置 */ -public class SelectImagePane extends com.fr.design.report.SelectImagePane { +public class SelectImagePane extends BasicPane { + private ImagePreviewPane previewPane = null; + + private ImageFileChooser imageFileChooser = null; + private UIRadioButton defaultRadioButton = null; + private UIRadioButton tiledRadioButton = null; + private UIRadioButton extendRadioButton = null; + private UIRadioButton adjustRadioButton = null; + + private Style imageStyle = null; + + private File imageFile; + public SelectImagePane() { - super(); + this.setLayout(GUICoreKit.createBorderLayout()); + + // preview pane + JPanel previewContainerPane = GUICoreKit.createBorderLayoutPane(); + this.add(previewContainerPane, BorderLayout.CENTER); + + JPanel previewOwnerPane = GUICoreKit.createBorderLayoutPane(); + previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); + + previewOwnerPane.setBorder(GUICoreKit.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null)); + + previewPane = new ImagePreviewPane(); + previewOwnerPane.add(new JScrollPane(previewPane)); + + JPanel selectFilePane = GUICoreKit.createBorderLayoutPane(); + previewContainerPane.add(selectFilePane, BorderLayout.EAST); + selectFilePane.setBorder(BorderFactory + .createEmptyBorder(8, 2, 4, 0)); + + UIButton selectPictureButton = new UIButton( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Select_Picture")); + selectFilePane.add(selectPictureButton, BorderLayout.NORTH); + selectPictureButton.setMnemonic('S'); + selectPictureButton.addActionListener(selectPictureActionListener); + + JPanel layoutPane = GUICoreKit.createMediumHGapHighTopFlowInnerContainerPane(); + selectFilePane.add(layoutPane, BorderLayout.CENTER); + + //布局 + defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); + tiledRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Titled")); + extendRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Extend")); + adjustRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Adjust")); + + defaultRadioButton.addActionListener(layoutActionListener); + tiledRadioButton.addActionListener(layoutActionListener); + extendRadioButton.addActionListener(layoutActionListener); + adjustRadioButton.addActionListener(layoutActionListener); + + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15)); + jp.add(defaultRadioButton); + jp.add(tiledRadioButton); + jp.add(extendRadioButton); + jp.add(adjustRadioButton); + layoutPane.add(jp); + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(defaultRadioButton); + layoutBG.add(tiledRadioButton); + layoutBG.add(extendRadioButton); + layoutBG.add(adjustRadioButton); + + defaultRadioButton.setSelected(true); + + // init image file chooser. + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser + .showOpenDialog(SelectImagePane.this); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + imageFile = selectedFile; + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal); + } + } + }; + + // 调整图片样式,只有水平和垂直对齐以及拉伸。相对于背景,平铺不予考虑。 + private void changeImageStyle() { + previewPane.setImageStyle(this.imageStyle); + previewPane.repaint(); + } + + private void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } + } + + ActionListener layoutActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + }; + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image"); + } + + public void populate(Elem cell) { + Style style = null; + if (cell != null) { + Object value = cell.getValue(); + if (value instanceof Image) { + setImage((Image) value); + } else if (value instanceof CellImagePainter) { + setImage(((CellImagePainter) value).getImage()); + } + + style = cell.getStyle(); + } + if (style == null) { + return; + } + + if (style.getImageLayout() == Constants.IMAGE_TILED) { + tiledRadioButton.setSelected(true); + } else if (style.getImageLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + } else if (style.getImageLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + } else { + style.deriveImageLayout(Constants.IMAGE_CENTER); + defaultRadioButton.setSelected(true); + } + this.imageStyle = style; + changeImageStyle(); + } + + public void setImage(Image image) { + previewPane.setImage(image); } public CellImage update() { - return (CellImage) super.update(); + CellImage cellImage = new CellImage(); + cellImage.setImage(previewPane.getImageWithSuffix()); + cellImage.setStyle(this.imageStyle); + return cellImage; + } + + public File getSelectedImage() { + return imageFile; } } + diff --git a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java b/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java deleted file mode 100644 index 8621d73..0000000 --- a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fanruan.api.design.work; - -/** - * 控件属性表绘制 - * - */ -public class WidgetPropertyPane { - - public static com.fr.design.mainframe.WidgetPropertyPane getInstance() { - return com.fr.design.mainframe.WidgetPropertyPane.getInstance(); - } -} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java b/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java index 0d66cc1..2b43ebe 100644 --- a/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java +++ b/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java @@ -1,8 +1,8 @@ package com.fanruan.api.design.work.component; import com.fanruan.api.cal.ParameterKit; +import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.component.UIComboBox; -import com.fanruan.api.design.ui.component.table.model.DesignModelAdapterKit; import com.fanruan.api.util.AssistKit; import com.fr.design.DesignModelAdapter; import com.fr.stable.ParameterProvider; @@ -42,7 +42,7 @@ public class ParameterComboBox extends UIComboBox { public void updateParaItems() { - DesignModelAdapter designModel = DesignModelAdapterKit.getCurrentModelAdapter(); + DesignModelAdapter designModel = DesignKit.getCurrentModelAdapter(); this.removeAllItems(); if (designModel != null) { diff --git a/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java b/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java index cf5511d..317c037 100644 --- a/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java +++ b/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java @@ -1,7 +1,10 @@ package com.fanruan.api.conf.xml; + import java.util.ArrayList; import java.util.List; +import com.fanruan.api.conf.impl.xml.XmlColConf; +import com.fanruan.api.conf.impl.xml.XmlConf; import com.fr.stable.xml.XMLable; import org.easymock.EasyMock; import org.junit.Assert;