diff --git a/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java b/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java index 258f558a71..4c9db5a6a0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java +++ b/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java @@ -1,6 +1,7 @@ package com.fr.design.gui.core; import com.fr.base.BaseUtils; +import com.fr.base.svg.IconUtils; import com.fr.form.ui.Button; import com.fr.form.ui.CheckBox; import com.fr.form.ui.CheckBoxGroup; @@ -14,6 +15,7 @@ import com.fr.form.ui.ListEditor; import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.NumberEditor; import com.fr.form.ui.Password; +import com.fr.form.ui.PictureWidget; import com.fr.form.ui.RadioGroup; import com.fr.form.ui.TextArea; import com.fr.form.ui.TextEditor; @@ -142,7 +144,7 @@ public abstract class WidgetOption implements Serializable { */ public static WidgetOption[] getFormWidgetIntance() { return new WidgetOption[]{TEXTEDITOR, LABEL, FREEBUTTON, COMBOBOX, COMBOCHECKBOX, DATEEDITOR, - NUMBEREDITOR, TREECOMBOBOX, RADIOGROUP, CHECKBOXGROUP, TEXTAREA, PASSWORD, CHECKBOX, TREE, MULTI_FILEEDITOR}; + NUMBEREDITOR, TREECOMBOBOX, RADIOGROUP, CHECKBOXGROUP, TEXTAREA, PASSWORD, CHECKBOX, TREE, MULTI_FILEEDITOR,PICTURE}; } public static final WidgetOption DATEEDITOR = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Type_Date"), @@ -214,4 +216,7 @@ public abstract class WidgetOption implements Serializable { public static final WidgetOption IFRAMEDITOR = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Form_Iframe"), BaseUtils.readIcon("/com/fr/web/images/form/resources/iframe_16.png"), IframeEditor.class); + public static final WidgetOption PICTURE = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Type_Image"), IconUtils.readIcon("/com/fr/web/images/form/resources/picture_widget_16.png"), + PictureWidget.class); + } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java index 525bb5b792..be0d8e8523 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java @@ -8,6 +8,8 @@ import com.fr.design.designer.TargetComponent; */ public interface HyperlinkGroupPaneActionProvider { + String XML_TAG = "HyperlinkGroupPane"; + /** * 刷新面板展示 * diff --git a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java b/designer-base/src/main/java/com/fr/design/report/SelectImagePane.java similarity index 96% rename from designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java rename to designer-base/src/main/java/com/fr/design/report/SelectImagePane.java index bcad15c76c..7781233aac 100644 --- a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java +++ b/designer-base/src/main/java/com/fr/design/report/SelectImagePane.java @@ -13,22 +13,24 @@ import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; 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; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JScrollPane; /** - * 这个类主要用于插入图片时的设置 - */ + *

这个类主要用于插入图片时的设置

+ *

这个类原本在designer-realize包下面,现在表单也可选择图片,所以应该抽为公用的base包。包名不变,应该不影响插件使用

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:22 + **/ public class SelectImagePane extends BasicPane { private ImagePreviewPane previewPane = null; @@ -39,8 +41,31 @@ public class SelectImagePane extends BasicPane { private UIRadioButton adjustRadioButton = null; private Style imageStyle = null; + ActionListener layoutActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + }; private File imageFile; + /** + * 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); + } + } + }; public SelectImagePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -102,23 +127,6 @@ public class SelectImagePane extends BasicPane { 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); @@ -137,15 +145,6 @@ public class SelectImagePane extends BasicPane { } } - 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"); diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/widget/picture_widget_16.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/widget/picture_widget_16.png new file mode 100644 index 0000000000..fbf334ad22 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/widget/picture_widget_16.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png b/designer-base/src/main/resources/com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png new file mode 100644 index 0000000000..9e731c557b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png differ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 5e7807698a..1ebd19ec3d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -19,6 +19,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.fit.common.TemplateTool; import com.fr.design.fun.ChartWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.ParameterWidgetOptionProvider; @@ -39,6 +40,7 @@ import com.fr.form.ui.ComboCheckBox; import com.fr.form.ui.DateEditor; import com.fr.form.ui.EditorHolder; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.FieldEditor; import com.fr.form.ui.FileEditor; import com.fr.form.ui.FreeButton; import com.fr.form.ui.IframeEditor; @@ -47,10 +49,12 @@ import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.NameWidget; import com.fr.form.ui.NumberEditor; import com.fr.form.ui.Password; +import com.fr.form.ui.PictureWidget; import com.fr.form.ui.Radio; import com.fr.form.ui.RadioGroup; import com.fr.form.ui.TextArea; import com.fr.form.ui.TextEditor; +import com.fr.form.ui.ToggleButton; import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; import com.fr.form.ui.Widget; @@ -183,6 +187,7 @@ public class XCreatorUtils { objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); objectMap.put(CardAddButton.class, XCardAddButton.class); objectMap.put(WidgetErrorMarker.class, ErrorCreator.class); + objectMap.put(PictureWidget.class, XPicture.class); } private static void reInitExtra() { @@ -236,14 +241,30 @@ public class XCreatorUtils { } public static XCreator createThemedXCreator(Widget widget) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); TemplateTheme theme = template.getTemplateTheme(); if (theme instanceof FormTheme) { widget = setupTemplateTheme(widget, true, (FormTheme) theme, TemplateThemeCompatible.NONE); } + if (TemplateTool.isCurrentEditingNewJForm()){ + resetWidgetDefaultProperty(widget); + } return createXCreator(widget); } + /** + * 新表单下控件的字体默认都为9pt + * @param widget 控件 + */ + private static void resetWidgetDefaultProperty(Widget widget) { + if (widget.acceptType(FieldEditor.class)) { + ((FieldEditor) widget).setFontSize(Widget.DEFAULT_FONT_PT_SIZE); + } else if (widget.acceptType(ToggleButton.class)) { + ((ToggleButton) widget).setFontSize(Widget.DEFAULT_FONT_PT_SIZE); + } + } + /** * 创建creator * diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XPicture.java b/designer-form/src/main/java/com/fr/design/designer/creator/XPicture.java new file mode 100644 index 0000000000..7dd23bd4ce --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XPicture.java @@ -0,0 +1,74 @@ +package com.fr.design.designer.creator; + +import com.fr.design.designer.ui.ImgPanel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.widget.editors.PictureEditor; +import com.fr.design.mainframe.widget.editors.UrlLinkEditor; +import com.fr.design.mainframe.widget.renderer.PictureRenderer; +import com.fr.design.mainframe.widget.renderer.UrlLinkRenderer; +import com.fr.form.ui.PictureWidget; +import com.fr.general.IOUtils; +import com.fr.stable.ArrayUtils; +import java.awt.Dimension; +import java.awt.Image; +import java.beans.IntrospectionException; +import javax.swing.JComponent; + +/** +* +*

图片控件的creator

+* +* @author Jimmy.Zheng created on 2022/8/11 21:16 +**/ +public class XPicture extends XWidgetCreator { + + public XPicture(PictureWidget widget, Dimension dimension) { + super(widget, dimension); + } + + @Override + protected String getIconName() { + return "picture_widget_16.png"; + } + + @Override + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("picUrl", toData().getClass()) + .setI18NName(Toolkit.i18nText("Fine-Design_Basic_Widget_Type_Image")) + .setEditorClass(PictureEditor.class) + .setRendererClass(PictureRenderer.class) + .putKeyValue("category", "Fine-Design_Basic_Advanced"), + new CRPropertyDescriptor("urlLink", toData().getClass()) + .setI18NName(Toolkit.i18nText("Fine-Design_Basic_Hyperlink")) + .setEditorClass(UrlLinkEditor.class) + .setRendererClass(UrlLinkRenderer.class) + .putKeyValue( + "category", "Fine-Design_Basic_Advanced")}); + } + + @Override + protected JComponent initEditor() { + PictureWidget pictureWidget = (PictureWidget) this.data; + if (this.editor == null) { + this.editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); + Object value = pictureWidget.getPicUrl().getValue(); + ImgPanel imgPanel = new ImgPanel(); + if (value instanceof Image) { + imgPanel.setBackgroundImage((Image) value); + imgPanel.setImageDisplayMode(pictureWidget.getShowType()); + } else { + imgPanel.setBackgroundImage(IOUtils.readImage("com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png")); + imgPanel.setImageDisplayMode(0); + } + this.editor.add(imgPanel, "Center"); + } + return this.editor; + } + + @Override + public boolean canEnterIntoParaPane() { + return false; + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java b/designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java new file mode 100644 index 0000000000..1c17c56c34 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java @@ -0,0 +1,113 @@ +package com.fr.design.designer.ui; + +import com.fr.general.ImageWithSuffix; +import com.fr.stable.Constants; +import java.awt.Graphics; +import java.awt.Image; +import javax.swing.JComponent; + + +/** + *

图片控件中的已选图片展示面板

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:17 + **/ +public class ImgPanel extends JComponent { + private static final long serialVersionUID = 1L; + private Image backgroundImage; + private int imageDisplayMode; + private int modeIndex; + + public ImgPanel() { + this(null, 0); + } + + public ImgPanel(Image image, int modeName) { + setBackgroundImage(image); + setImageDisplayMode(modeName); + } + + public Image getBackgroundImage() { + return this.backgroundImage; + } + + public void setBackgroundImage(Image image) { + this.backgroundImage = image; + repaint(); + } + + public int getImageDisplayMode() { + return this.imageDisplayMode; + } + + public void setImageDisplayMode(int modeName) { + switch (modeName) { + case Constants.IMAGE_CENTER: + this.modeIndex = 0; + break; + case Constants.IMAGE_TILED: + this.imageDisplayMode = 0; + this.modeIndex = 1; + break; + case Constants.IMAGE_EXTEND: + this.imageDisplayMode = 2; + this.modeIndex = 2; + break; + case Constants.IMAGE_ADJUST: + this.imageDisplayMode = 4; + this.modeIndex = 3; + break; + default: + } + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + if (this.backgroundImage != null) { + if (this.backgroundImage instanceof ImageWithSuffix) { + this.backgroundImage = ((ImageWithSuffix) backgroundImage).getImage(); + } + int width = getWidth(); + int height = getHeight(); + int imageWidth = this.backgroundImage.getWidth(this); + int imageHeight = this.backgroundImage.getHeight(this); + + switch (this.modeIndex) { + case 0: + int x = (width - imageWidth) / 2; + int y = (height - imageHeight) / 2; + g.drawImage(this.backgroundImage, x, y, this); + break; + case 1: + for (int ix = 0; ix < width; ix += imageWidth) { + for (int iy = 0; iy < height; iy += imageHeight) { + g.drawImage(this.backgroundImage, ix, iy, this); + } + } + + break; + case 2: + g.drawImage(this.backgroundImage, 0, 0, width, height, this); + break; + case 3: + double sx = 1.0 * width / imageWidth; + double sy = 1.0 * height / imageHeight; + + if (sx > sy) { + sx = sy; + width = (int) (sx * imageWidth); + } else { + sy = sx; + height = (int) (sy * imageHeight); + } + int xx = (getWidth() - width) / 2; + int yy = (getHeight() - height) / 2; + g.drawImage(this.backgroundImage, xx, yy, width, height, this); + default: + } + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessiblePictureModelEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessiblePictureModelEditor.java new file mode 100644 index 0000000000..9e72b5c2ac --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessiblePictureModelEditor.java @@ -0,0 +1,77 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.base.Style; +import com.fr.design.DesignModelAdapter; +import com.fr.design.designer.creator.XPicture; +import com.fr.design.designer.ui.ImgPanel; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.widget.wrappers.PictureModelWrapper; +import com.fr.design.report.SelectImagePane; +import com.fr.form.ui.PictureWidget; +import com.fr.general.ComparatorUtils; +import com.fr.report.cell.FloatElement; +import com.fr.report.cell.cellattr.CellImage; +import javax.swing.JComponent; + + +/** +* +*

图片控件的图片选择、编辑器

+* +* @author Jimmy.Zheng created on 2022/8/11 21:13 +**/ +public class AccessiblePictureModelEditor extends UneditableAccessibleEditor { + protected FloatElement element = new FloatElement(); + private PictureWidget pic; + + public AccessiblePictureModelEditor(PictureWidget pic) { + super(new PictureModelWrapper()); + this.pic = pic; + } + + @Override + public FloatElement getValue() { + return (FloatElement) super.getValue(); + } + + @Override + protected void showEditorPane() { + final SelectImagePane imageEditorPane = new SelectImagePane(); + if (super.getValue() != null) { + this.element = ((FloatElement) super.getValue()); + } + this.element.setStyle(Style.getInstance().deriveImageLayout(this.pic.getShowType())); + imageEditorPane.populate(this.element); + final Object oldValue = this.element.getValue(); + final Style oldStyle = this.element.getStyle(); + final String oldname = this.element.getName(); + imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + CellImage cellImage = imageEditorPane.update(); + if ((!ComparatorUtils.equals(cellImage.getImage(), oldValue)) || (!ComparatorUtils.equals(cellImage.getStyle(), oldStyle))) { + AccessiblePictureModelEditor.this.element.setValue(cellImage.getImage()); + AccessiblePictureModelEditor.this.element.setStyle(cellImage.getStyle()); + AccessiblePictureModelEditor.this.element.setName(imageEditorPane.getSelectedImage() == null ? oldname : imageEditorPane.getSelectedImage().toString()); + AccessiblePictureModelEditor.this.setValue(AccessiblePictureModelEditor.this.element); + AccessiblePictureModelEditor.this.pic.setShowType(cellImage.getStyle().getImageLayout()); + AccessiblePictureModelEditor.this.pic.setPicUrl(element); + ImgPanel p = AccessiblePictureModelEditor.this.getCurrentImgPanel(); + p.setBackgroundImage(cellImage.getBufferImage()); + p.setImageDisplayMode(cellImage.getStyle().getImageLayout()); + AccessiblePictureModelEditor.this.fireStateChanged(); + DesignModelAdapter d = DesignModelAdapter.getCurrentModelAdapter(); + d.fireTargetModified(); + } + } + }).setVisible(true); + } + + private ImgPanel getCurrentImgPanel() { + XPicture xPicture = (XPicture) WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator(); + JComponent editor = (JComponent) xPicture.getComponent(0); + return (ImgPanel) editor.getComponent(0); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleUrlLinkModelEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleUrlLinkModelEditor.java new file mode 100644 index 0000000000..2dd4b54991 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleUrlLinkModelEditor.java @@ -0,0 +1,57 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.DesignModelAdapter; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.xpane.FormHyperlinkGroupPane; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.widget.wrappers.UrlLinkModelWrapper; +import com.fr.js.NameJavaScriptGroup; +import com.fr.stable.bridge.StableFactory; + +/** + *

表单图片控件的链接编辑器

+ * @author Jimmy + */ +public class AccessibleUrlLinkModelEditor extends UneditableAccessibleEditor { + private FormHyperlinkGroupPane hyperlinkPane; + + public AccessibleUrlLinkModelEditor() { + super(new UrlLinkModelWrapper()); + } + /** + * 原插件使用 + *

DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPaneNoPop( + * HyperlinkGroupPaneActionImpl.getInstance()));

获取{@see this.hyperlinkPane} + * 合并插件依赖不到,换种方式 用{@see DesignerActivator将实例注册了} + */ + @Override + protected void showEditorPane() { + if (this.hyperlinkPane == null) { + HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider = StableFactory.getMarkedInstanceObjectFromClass(HyperlinkGroupPaneActionProvider.XML_TAG,HyperlinkGroupPaneActionProvider.class); + this.hyperlinkPane = (FormHyperlinkGroupPane) DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPaneNoPop( + hyperlinkGroupPaneActionProvider); + } + BasicDialog dialog = this.hyperlinkPane.showWindow(DesignerContext.getDesignerFrame()); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + NameJavaScriptGroup hyperlinks = AccessibleUrlLinkModelEditor.this.hyperlinkPane.updateJSGroup(); + AccessibleUrlLinkModelEditor.this.setValue(hyperlinks); + AccessibleUrlLinkModelEditor.this.fireStateChanged(); + DesignModelAdapter d = DesignModelAdapter.getCurrentModelAdapter(); + d.fireTargetModified(); + } + }); + this.hyperlinkPane.populate(getValue()); + + dialog.setVisible(true); + } + + @Override + public NameJavaScriptGroup getValue() { + return (NameJavaScriptGroup) super.getValue(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/PictureEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/PictureEditor.java new file mode 100644 index 0000000000..c7bbff80a3 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/PictureEditor.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe.widget.editors; + +import com.fr.design.mainframe.widget.accessibles.AccessiblePictureModelEditor; +import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; +import com.fr.form.ui.PictureWidget; +/** +* +*

图片控件的图片选择、编辑器

+* +* @author Jimmy.Zheng created on 2022/8/11 21:15 +**/ +public class PictureEditor extends AccessiblePropertyEditor { + + public PictureEditor(Object o) { + super(new AccessiblePictureModelEditor((PictureWidget) o)); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/UrlLinkEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/UrlLinkEditor.java new file mode 100644 index 0000000000..195e8f5250 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/UrlLinkEditor.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe.widget.editors; + +import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; +import com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor; + +/** +* +*

图片控件的链接编辑器

+* +* @author Jimmy.Zheng created on 2022/8/11 21:19 +**/ +public class UrlLinkEditor extends AccessiblePropertyEditor { + + public UrlLinkEditor() { + super(new AccessibleUrlLinkModelEditor()); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/PictureRenderer.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/PictureRenderer.java new file mode 100644 index 0000000000..82fcc85b43 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/PictureRenderer.java @@ -0,0 +1,15 @@ +package com.fr.design.mainframe.widget.renderer; + +import com.fr.design.mainframe.widget.wrappers.PictureModelWrapper; + +/** + *

图片控件的图片编辑器的EncoderCellRenderer

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:29 + **/ +public class PictureRenderer extends EncoderCellRenderer { + + public PictureRenderer() { + super(new PictureModelWrapper()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/UrlLinkRenderer.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/UrlLinkRenderer.java new file mode 100644 index 0000000000..a81187d2d5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/UrlLinkRenderer.java @@ -0,0 +1,16 @@ +package com.fr.design.mainframe.widget.renderer; + + +import com.fr.design.mainframe.widget.wrappers.UrlLinkModelWrapper; + +/** + *

图片控件的链接编辑器的EncoderCellRenderer

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:29 + **/ +public class UrlLinkRenderer extends EncoderCellRenderer { + + public UrlLinkRenderer() { + super(new UrlLinkModelWrapper()); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/PictureModelWrapper.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/PictureModelWrapper.java new file mode 100644 index 0000000000..ed9fd0a4ac --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/PictureModelWrapper.java @@ -0,0 +1,34 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.report.cell.FloatElement; +import com.fr.stable.StringUtils; + +/** + *

图片选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessiblePictureModelEditor}的 Wrapper

+ *

插件中直接移入,未作改动

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:25 + **/ +public class PictureModelWrapper implements Encoder, Decoder { + + @Override + public FloatElement decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + // do nothing + } + + @Override + public String encode(FloatElement v) { + if (v != null) { + return v.getName(); + } + return StringUtils.EMPTY; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/UrlLinkModelWrapper.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/UrlLinkModelWrapper.java new file mode 100644 index 0000000000..a892065ad7 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/UrlLinkModelWrapper.java @@ -0,0 +1,33 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.js.NameJavaScriptGroup; + +/** + *

链接选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor}的 Wrapper

+ *

插件中直接移入,未作改动

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:28 + **/ +public class UrlLinkModelWrapper implements Encoder, Decoder { + + @Override + public NameJavaScriptGroup decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + // do nothing + } + + @Override + public String encode(NameJavaScriptGroup v) { + if (v.size() > 0) { + return v.getNameHyperlink(0).getName(); + } + return null; + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java index fd2367f3be..c3f3c83a1d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.action.content.formula; import com.fr.chart.chartdata.MeterReportDefinition; import com.fr.data.VerifyItem; +import com.fr.data.impl.FormulaDictionary; import com.fr.design.actions.replace.info.DealWithInfoValue; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.base.SearchTag; @@ -9,6 +10,7 @@ import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.general.GeneralUtils; import com.fr.main.impl.WorkBook; import com.fr.plugin.chart.map.data.VanMapReportDefinition; +import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.stable.collections.combination.Pair; import org.jetbrains.annotations.Nullable; @@ -120,6 +122,36 @@ public enum FormulaTag implements DealWithInfoValue { workBook.setReportName(sheetId, ShowValueUtils.replaceAll(name, findStr, replaceStr)); } } + }, + /** + * 单元格属性-其他-内容提示 + */ + CELL_TOOL_TIP(SearchTag.CELL_TOOL_TIP) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof CellGUIAttr) { + CellGUIAttr attr = (CellGUIAttr) info.getContent().getHoldObject(); + attr.setTooltipText(ShowValueUtils.replaceAll(attr.getTooltipText(), findStr, replaceStr)); + } + } + }, + DICT_EXCUTE(SearchTag.DICT_EXCUTE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setExcuteFormula(ShowValueUtils.replaceAll(dictionary.getExcuteFormula(), findStr, replaceStr)); + } + } + }, + DICT_PRODUCE(SearchTag.DICT_PRODUCE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr)); + } + } }; int index; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java index b58008e7bc..39ccf32585 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java @@ -14,18 +14,21 @@ import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; import com.fr.general.data.Condition; import com.fr.js.NameJavaScriptGroup; import com.fr.report.cell.CellElement; import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.report.cell.cellattr.highlight.DefaultHighlight; import com.fr.report.cell.cellattr.highlight.HighlightAction; import com.fr.report.cell.cellattr.highlight.HighlightGroup; import com.fr.report.core.sort.common.CellSortAttr; import com.fr.report.core.sort.sortexpression.FormulaSortExpression; import com.fr.report.core.sort.sortexpression.SortExpression; +import com.fr.stable.CommonUtils; import java.util.List; @@ -69,6 +72,8 @@ public class SearchCellFormulaAction implements SearchCellFormula { searchCellSortAttr4Formula(cellInfo, formulaInfos); //单元格属性-形态 searchCellPresent4Formula(cellInfo, formulaInfos); + //单元格属性-其他-内容提示-自定义 + searchCellToolTip4Formula(cellInfo, formulaInfos); //单元格属性-其他-插入策略 searchCellInsertPolicy4Formula(cellInfo, formulaInfos); //单元格条件属性-参数-公式 @@ -84,6 +89,30 @@ public class SearchCellFormulaAction implements SearchCellFormula { } + private void searchCellToolTip4Formula(CellInfo cellInfo, List formulaInfos) { + if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement) { + TemplateCellElement cellElement = (TemplateCellElement) cellInfo.getContent().getReplaceObject(); + if (isCellGUIAttrValid(cellElement.getCellGUIAttr())) { + CellGUIAttr attr = cellElement.getCellGUIAttr(); + ITContent attrContent = ITContent.copy(cellInfo.getContent()); + attrContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Other"), + Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"), + Toolkit.i18nText("Fine-Design_Basic_Custom") + ); + attrContent.setReplaceObject(attr.getTooltipText()); + attrContent.setHoldObject(attr); + attrContent.setTag(SearchTag.CELL_TOOL_TIP); + formulaInfos.add(new FormulaInfo(attrContent)); + } + } + } + + private boolean isCellGUIAttrValid(CellGUIAttr attr) { + return attr != null && attr.isCustomTooltip() && CommonUtils.canBeFormula(attr.getTooltipText()); + } + private void searchCellHyperLink4Formula(CellInfo cellInfo, List formulaInfos) { NameJavaScriptGroup nameJavaScriptGroup = ((CellElement) cellInfo.getContent().getReplaceObject()).getNameHyperlinkGroup(); if (nameJavaScriptGroup != null) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java index de653dd706..0dd6919558 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java @@ -66,7 +66,10 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { String name = workBook.getReportName(i); if (CommonUtils.canBeFormula(name)) { ITContent sheetContent = ITContent.copy(content); - sheetContent.addOtherPos(Toolkit.i18nText("Fine-Design_Replace_Sheet")); + sheetContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Replace_Sheet"), + name + ); sheetContent.setReplaceObject(name); sheetContent.setHoldObject(workBook); sheetContent.setTag(SearchTag.SHEET_NAME); @@ -104,7 +107,7 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { } //数据校验 - for (int i = 0, len = attr.getValueVerifierCount(); i < len; i++) { + for (int i = 0, len = attr.getVerifierCount(); i < len; i++) { Verifier verifier = attr.getVerifier(i); if (verifier instanceof ValueVerifier) { ITContent content = ITContent.copy(sheetContent); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java index 22d4cb3959..6a55aebf9b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java @@ -6,6 +6,7 @@ import com.fr.data.impl.FormulaDictionary; import com.fr.data.impl.TableDataDictionary; import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.i18n.Toolkit; import org.jetbrains.annotations.Nullable; @@ -32,23 +33,27 @@ public enum DictionaryType implements DictionaryAction { //显示值 if (formulaDictionary.getExcuteFormula() != null) { ITContent excuteContent = ITContent.copy(content); - excuteContent.setReplaceObject(dictionary); + excuteContent.setReplaceObject(formulaDictionary.getExcuteFormula()); excuteContent.addOtherPos( Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), Toolkit.i18nText("Fine-Design_Basic_Formula"), Toolkit.i18nText("Fine-Design_Basic_Display_Value") ); + excuteContent.setHoldObject(dictionary); + excuteContent.setTag(SearchTag.DICT_EXCUTE); formulaInfos.add(new FormulaInfo(excuteContent)); } //实际值 if (formulaDictionary.getProduceFormula() != null) { ITContent produceContent = ITContent.copy(content); - produceContent.setReplaceObject(dictionary); + produceContent.setReplaceObject(formulaDictionary.getProduceFormula()); produceContent.addOtherPos( Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), Toolkit.i18nText("Fine-Design_Basic_Formula"), Toolkit.i18nText("Fine-Design_Basic_Actual_Value") ); + produceContent.setHoldObject(dictionary); + produceContent.setTag(SearchTag.DICT_PRODUCE); formulaInfos.add(new FormulaInfo(produceContent)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java index 0ceec53617..725d1280db 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java @@ -4,6 +4,7 @@ import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; @@ -19,6 +20,7 @@ import com.fr.report.web.util.ReportEngineEventMapping; import com.fr.web.attr.ReportWebAttr; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -86,12 +88,30 @@ public class SearchWebJSAction implements SearchJS { content.setTemplateName(jTemplate.getTemplateName()); content.setJumpAble(false); addWebContent2Array(webAttr); + //处理引用JS + dealImportJS(content,jsInfos,webAttr); for (int i = 0; i < arrayList.size(); i++) { addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i)); } } } + private void dealImportJS(ITContent content, List jsInfos, ReportWebAttr webAttr) { + if (webAttr != null){ + for (String jsStr : webAttr.getJSImport()){ + ITContent jsContent = ITContent.copy(content); + jsContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Report_Web_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Import_JavaScript") + ); + jsContent.setReplaceObject(jsStr); + jsContent.setHoldObject(webAttr); + jsContent.setTag(SearchTag.IMPORT_JS); + jsInfos.add(new JSInfo(jsContent)); + } + } + } + private void addJSInfos2ListFromServerWebAttr(ITContent content, List jsInfos, WebContent webContent) { ITContent newContent = ITContent.copy(content); if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java index 73a0750cb8..ce2ecd36c6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java @@ -40,14 +40,7 @@ public class FormulaInfo implements Info { @Override public Map getValue(Object... o) { Map map = new HashMap<>(); - //这边比较特殊,存的都是FormulaDictionary ,特殊判断一下 - if (this.content.getOtherPos().contains(DISPLAY)) { - map.put("content", ((FormulaDictionary) this.getContent().getReplaceObject()).getExcuteFormula()); - } else if (this.content.getOtherPos().contains(ACTUAL)) { - map.put("content", ((FormulaDictionary) this.getContent().getReplaceObject()).getProduceFormula()); - } else { - map = getCommonValue(); - } + map = getCommonValue(); return map; } @@ -70,11 +63,8 @@ public class FormulaInfo implements Info { @Override public Boolean checkValid() { - FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); - if (formulaReplaceObject != null) { - return formulaReplaceObject.check(this); - } - return false; + //校验二期才完善,目前都给过 + return true; } private Map getCommonValue() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java index 3d615e18a9..48a4dbf644 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -1,15 +1,21 @@ package com.fr.design.actions.replace.info; import com.fr.data.impl.DBTableData; +import com.fr.design.DesignModelAdapter; import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.datapane.TableDataTreePane; import com.fr.form.event.Listener; +import com.fr.general.GeneralUtils; import com.fr.js.JavaScriptImpl; import com.fr.js.NameJavaScript; import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.web.attr.ReportWebAttr; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -184,33 +190,75 @@ public enum ReplaceObject implements DealWithInfoValue { return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); } }, + /** + * 模板Web属性——引用JS + */ + IMPORT_JS("String") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(contentKey, GeneralUtils.objectToString(o[0]), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof ReportWebAttr) { + ReportWebAttr attr = (ReportWebAttr) info.getContent().getHoldObject(); + List jsImports = Arrays.asList(attr.getJSImport()); + String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject()); + for (int i = 0, len = jsImports.size(); i < len; i++) { + if (StringUtils.equals(jsImports.get(i), jsName)) { + jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr)); + } + } + attr.clearJSImportList(); + for (int i = 0, len = jsImports.size(); i < len; i++) { + attr.addJSImport(jsImports.get(i)); + } + } + } + + @Override + public String getInfoShowStr(Info info) { + return GeneralUtils.objectToString(info.getContent().getReplaceObject()); + } + + @Override + boolean check(Info info) { + return true; + } + }, /** * DBTableData——SQL */ DB_TABLE_DATA("DBTableData") { @Override - boolean check(Info info) { + boolean check (Info info){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); } @Override - public Map getValue(Object... o) { + public Map getValue (Object...o){ HashMap map = new HashMap<>(); addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); return map; } @Override - public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + public void setValue (Info info, String findStr, String replaceStr, List < Pair < Integer, Integer >> operatorArray){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); info.updateOldStr(dbTableData.getQuery(), findStr); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); - //todo DesignTableDataManager + //清除缓存 + DesignTableDataManager.removeSelectedColumnNames(dbTableData.getName()); + //收缩菜单 + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); } @Override - public String getInfoShowStr(Info info) { + public String getInfoShowStr (Info info){ return info.getInfoShowStr(info); } }; @@ -256,4 +304,4 @@ public enum ReplaceObject implements DealWithInfoValue { abstract boolean check(Info info); -} + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java index b4163f57bf..b5e202bcb1 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -40,6 +40,22 @@ public class SearchTag { * sheet名称 */ public static final int SHEET_NAME = 7; + /** + * 单元格属性-其他-内容提示 + */ + public static final int CELL_TOOL_TIP = 8; + /** + * 数据字典-公式-显示值 + */ + public static final int DICT_EXCUTE = 9; + /** + * 数据字典-公式-实际值 + */ + public static final int DICT_PRODUCE = 10; + /** + * 引用JS + */ + public static final int IMPORT_JS = 11; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 96ee17b6cd..54e6a3bff4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -9,6 +9,7 @@ import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -22,6 +23,7 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; @@ -46,13 +48,14 @@ public class ITReplaceMainDialog extends UIDialog { private static boolean matched = false; private static volatile ITReplaceMainDialog instance = null; private static String templateID; + private static String templateName; private ITReplaceNorthPanel northPane; private ITReplaceSouthPanel southPanel; private ITReplaceWestPanel westPanel; private boolean searchFlag; private String searchStr; private static final int FIRST_ROW = 0; - public static int selectCount = 0; + public static int selectCount = 0; public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); @@ -117,8 +120,10 @@ public class ITReplaceMainDialog extends UIDialog { JPanel center = new JPanel(new BorderLayout()); + UIComboBox replaceComboBox = northPane.getReplaceInputCombobox(); northPane.getFindInputCombobox().setEditable(true); - northPane.getReplaceInputCombobox().setEditable(false); + replaceComboBox.setEnabled(false); + replaceComboBox.setEditable(true); northPane.getReplaceButton().setEnabled(false); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); @@ -160,8 +165,10 @@ public class ITReplaceMainDialog extends UIDialog { private void replace() { String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); - if (StringUtils.equals(getSearchStr(), searchStr)) { - if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { + //替换内容为空需要触发搜索 + if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { + if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); for (Info info : searchResultList) { if (info.getContent().isSelected()) { info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); @@ -170,29 +177,26 @@ public class ITReplaceMainDialog extends UIDialog { southPanel.getTableEditorPane().update(); northPane.refreshReplaceInputComboBoxItems(); ITTableEditorPane.getEditTable().repaint(); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); setSearchFlag(false); - search(); - } else { - Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; - int optionSelected = FineJOptionPane.showOptionDialog( - ITReplaceMainDialog.this, - Toolkit.i18nText("Fine-Design_Replace_Message"), - Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.ERROR_MESSAGE, - null, - // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) - options, - options[0] - ); - //如果选择了重新查找,则再查找一遍 - if (optionSelected == 0) { - search(); - } } - } else { search(); + } else { + Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; + int optionSelected = FineJOptionPane.showOptionDialog( + ITReplaceMainDialog.this, + Toolkit.i18nText("Fine-Design_Replace_Message"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.ERROR_MESSAGE, + null, + // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) + options, + options[0] + ); + //如果选择了重新查找,则再查找一遍 + if (optionSelected == 0) { + search(); + } } @@ -215,7 +219,8 @@ public class ITReplaceMainDialog extends UIDialog { */ public boolean isITReplaceValid() { if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { - return StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(), templateID); + return StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(), templateID) + && StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName(), templateName); } else { return false; } @@ -283,6 +288,7 @@ public class ITReplaceMainDialog extends UIDialog { if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); + templateName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName(); itTableEditor.clear(); String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); //更新搜索内容 @@ -298,26 +304,26 @@ public class ITReplaceMainDialog extends UIDialog { northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result")); } ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); - renderer.refreshHeader(getEditTable()); + //刷新表头,并且重新勾选中表头全选框 + renderer.refreshHeader(getEditTable(), true); itTableEditor.fireTableDataChanged(); northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); selectCount = searchResultList.size(); //如果有结果,默认选中第一行 - if (searchResultList.size() > 0){ - getEditTable().addRowSelectionInterval(FIRST_ROW,FIRST_ROW); - northPane.getReplaceButton().setEnabled(true); + if (searchResultList.size() > 0) { + getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW); } - - //设置替换输入框的可用性 - if (StringUtils.isNotEmpty(searchStr)) { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); - northPane.getReplaceInputCombobox().setEditable(true); + //更新替换按钮可用性 + if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0) { + northPane.getReplaceButton().setEnabled(false); } else { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(false); - northPane.getReplaceInputCombobox().setEditable(false); + northPane.getReplaceButton().setEnabled(true); } + + //设置替换输入框的可用性 + northPane.getReplaceInputCombobox().setEnabled(StringUtils.isNotEmpty(searchStr)); } else { //todo } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java index 03717a725c..d64946d09d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -6,13 +6,14 @@ import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.ReportComponentComposite; +import com.fr.file.FILEFactory; import com.fr.general.GeneralUtils; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; + import javax.swing.AbstractCellEditor; import javax.swing.JTable; -import javax.swing.SwingUtilities; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; import java.awt.Component; @@ -42,7 +43,9 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6); if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { ITReplaceMainDialog.setITReplaceFlag(true); - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(new TRL(GeneralUtils.objectToString(content.getTrlString()))); + TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); + DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(ProjectConstants.REPORTLETS_NAME + FILEFactory.SEPARATOR + content.getTemplateName())); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); } ITReplaceMainDialog.setITReplaceFlag(false); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java index 4d2f39718d..0a743d34eb 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -72,17 +72,8 @@ public class ITTableEditorPane extends BasicPane { int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint()); if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) { ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); - if (content.isSelected()) { - content.setSelected(false); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount--; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); - } else { - content.setSelected(true); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount++; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); - } + //改变面板的各个状态 + changeComponentStatus(content, row, col); } } @@ -90,10 +81,35 @@ public class ITTableEditorPane extends BasicPane { UIScrollPane scrollPane = new UIScrollPane(editTable); scrollPane.setBorder(new UIRoundedBorder(UIConstants.TITLED_BORDER_COLOR, 1, UIConstants.ARC)); pane.add(scrollPane, BorderLayout.CENTER); + } - + /** + * 改变面板的各个状态(替换按钮、表头勾选框) + * @param content + * @param row + * @param col + */ + public void changeComponentStatus(ITContent content, int row, int col) { + if (content.isSelected()) { + content.setSelected(false); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount--; + //如果没有选中,替换按钮需要置灰 + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); + } else { + content.setSelected(true); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount++; + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); + } + //更新表头的勾选框状态 + if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { + ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); + renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); + } } + public UITableModelAdapter getTableModel() { return tableModel; } @@ -142,8 +158,8 @@ public class ITTableEditorPane extends BasicPane { * * @param table */ - public void refreshHeader(JTable table) { - selectBox.setSelected(true); + public void refreshHeader(JTable table, boolean value) { + selectBox.setSelected(value); int rowHeight = table.getRowHeight(); table.updateUI(); table.setRowHeight(rowHeight); diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java index 19ab2758f3..d7baa0a733 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -28,6 +28,33 @@ public class ShowValueUtils { public static final String ANY_THING_REGEX = "."; public static final String NUMBER_REGEX = "[0-9]"; public static final String ENGLISH_REGEX = "[a-zA-Z]"; + public static final char LEFT_HTML_CHAR = '<'; + public static final char RIGHT_HTML_CHAR = '>'; + public static final String HEAD = ""; + public static final String TAIL = ""; + public static final String FONT_HEAD = ""; + public static final String FONT_TAIL = ""; + public static final String HTML = ""; + public static final String NOBR = ""; + public static final String HTML_TAIL = ""; + public static final String NOBR_TAIL = ""; + public static final int HEAD_LEN = HEAD.length(); + public static final int TAIL_LEN = TAIL.length(); + public static final int FONT_HEAD_LEN = FONT_HEAD.length(); + public static final int FONT_TAIL_LEN = FONT_TAIL.length(); + public static final int HTML_LEN = HTML.length(); + public static final int HTML_TAIL_LEN = HTML_TAIL.length(); + public static final int NOBR_LEN = NOBR.length(); + public static final int NOBR_TAIL_LEN = NOBR_TAIL.length(); + /** + * <转变为<的长度差 + */ + public static final int LEFT_DIFFERENT = 3; + /** + * >转变为>的长度差 + */ + public static final int RIGHT_DIFFERENT = 2; + public static Pattern containPattern; private static List specialCharList = new ArrayList<>(); @@ -135,33 +162,93 @@ public class ShowValueUtils { String result = str; Pattern pattern = containPattern; Matcher matcher = pattern.matcher(str); - String head = ""; - String tail = ""; - int size = head.length() + tail.length(); + int size = FONT_HEAD.length() + FONT_TAIL.length(); int index = 0; StringBuilder builder = new StringBuilder(str); while (matcher.find()) { - builder.replace(matcher.start() + index, matcher.end() + index, head + changeHtmlStr(matcher.group()) + tail); + builder.replace(matcher.start() + index, matcher.end() + index, FONT_HEAD + changeHtmlStr(matcher.group()) + FONT_TAIL); index += size; + index += getIncreaseCount(matcher.group()); } - return "
" + - builder.toString() + - "
"; + + return changeOriginHtmlStr(HEAD + builder.toString() + TAIL); } else { - return "
" + - replaceAll(str, searchStr, "" + changeHtmlStr(searchStr) + "") + - "
"; + String ans = HEAD + replaceAll(str, searchStr, FONT_HEAD + changeHtmlStr(searchStr) + FONT_TAIL) + TAIL; + return changeOriginHtmlStr(ans); } + } + /** + * 用于处理原字符串中的尖括号 + */ + private static String changeOriginHtmlStr(String str) { + int count = 0; + StringBuilder builder = new StringBuilder(str); + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (c == LEFT_HTML_CHAR) { + if (!checkValid(str, i)) { + builder.replace(i + count, i + count + 1, "<"); + count += LEFT_DIFFERENT; + } + } + } + return builder.toString(); + } + + private static boolean checkValid(String str, int i) { + int leftLen = str.length() - (i + 1); + return checkStrValid(str, i, leftLen, HTML_LEN, HTML) || + checkStrValid(str, i, leftLen, HTML_TAIL_LEN, HTML_TAIL) || + checkStrValid(str, i, leftLen, FONT_HEAD_LEN, FONT_HEAD) || + checkStrValid(str, i, leftLen, FONT_TAIL_LEN, FONT_TAIL) || + checkStrValid(str, i, leftLen, NOBR_LEN, NOBR) || + checkStrValid(str, i, leftLen, NOBR_TAIL_LEN, NOBR_TAIL); + } + + /** + * 是否是所指定的字符串 + * + * @param str + * @param i + * @param leftLen + * @return + */ + private static boolean checkStrValid(String str, int i, int leftLen, int len, String checkStr) { + if (leftLen < len - 1) { + return false; + } else { + return StringUtils.equals(str.substring(i, i + len), checkStr); + } } - private static String changeHtmlStr(String searchStr){ + + /** + * 用于处理搜索的字符中的尖括号 + * + * @param searchStr + * @return + */ + private static String changeHtmlStr(String searchStr) { String showStr = searchStr; - showStr = showStr.replace("<","<"); + showStr = showStr.replace("<", "<"); showStr = showStr.replace(">", ">"); return showStr; } + private static int getIncreaseCount(String str) { + int count = 0; + for (int i = 0; i < str.length(); i++) { + if (str.charAt(i) == LEFT_HTML_CHAR) { + count += LEFT_DIFFERENT; + } + if (str.charAt(i) == RIGHT_HTML_CHAR) { + count += RIGHT_DIFFERENT; + } + } + return count; + } + /** * 集合是否不为空 * @@ -193,6 +280,7 @@ public class ShowValueUtils { /** * 支持通配符的contains + * * @param originStr * @param matchStr * @return diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java index 0529cf82a3..629f71b6bb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java @@ -217,9 +217,9 @@ public class WorkSheetDesigner extends ReportComponent