Browse Source
* commit 'aec11ed19de4f8128a24b5a3ca388f06d3e93add': Revert "REPORT-70593 图片控件合并主代码" REPORT-70593 图片控件仅决策报表使用,挪个位置 Revert "REPORT-70593 图片控件仅决策报表使用,挪个位置" REPORT-70593 图片控件仅决策报表使用,挪个位置bugfix/11.0
superman
2 years ago
18 changed files with 37 additions and 499 deletions
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 4.8 KiB |
@ -1,74 +0,0 @@ |
|||||||
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; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* <p>图片控件的creator</p> |
|
||||||
* |
|
||||||
* @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; |
|
||||||
} |
|
||||||
} |
|
@ -1,111 +0,0 @@ |
|||||||
package com.fr.design.designer.ui; |
|
||||||
|
|
||||||
import com.fr.general.ImageWithSuffix; |
|
||||||
import java.awt.Graphics; |
|
||||||
import java.awt.Image; |
|
||||||
import javax.swing.JComponent; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* <p>图片控件中的已选图片展示面板</p> |
|
||||||
* |
|
||||||
* @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 void setBackgroundImage(Image image) { |
|
||||||
this.backgroundImage = image; |
|
||||||
repaint(); |
|
||||||
} |
|
||||||
|
|
||||||
public Image getBackgroundImage() { |
|
||||||
return this.backgroundImage; |
|
||||||
} |
|
||||||
|
|
||||||
public void setImageDisplayMode(int modeName) { |
|
||||||
if (modeName == 1) { |
|
||||||
this.modeIndex = 0; |
|
||||||
} |
|
||||||
|
|
||||||
if (modeName == 0) { |
|
||||||
this.imageDisplayMode = 0; |
|
||||||
this.modeIndex = 1; |
|
||||||
} |
|
||||||
|
|
||||||
if (modeName == 2) { |
|
||||||
this.imageDisplayMode = 2; |
|
||||||
this.modeIndex = 2; |
|
||||||
} |
|
||||||
if (modeName == 4) { |
|
||||||
this.imageDisplayMode = 4; |
|
||||||
this.modeIndex = 3; |
|
||||||
} |
|
||||||
repaint(); |
|
||||||
} |
|
||||||
|
|
||||||
public int getImageDisplayMode() { |
|
||||||
return this.imageDisplayMode; |
|
||||||
} |
|
||||||
|
|
||||||
@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); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,77 +0,0 @@ |
|||||||
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; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* <p>图片控件的图片选择、编辑器</p> |
|
||||||
* |
|
||||||
* @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); |
|
||||||
} |
|
||||||
} |
|
@ -1,57 +0,0 @@ |
|||||||
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; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>表单图片控件的链接编辑器</p> |
|
||||||
* @author Jimmy |
|
||||||
*/ |
|
||||||
public class AccessibleUrlLinkModelEditor extends UneditableAccessibleEditor { |
|
||||||
private FormHyperlinkGroupPane hyperlinkPane; |
|
||||||
|
|
||||||
public AccessibleUrlLinkModelEditor() { |
|
||||||
super(new UrlLinkModelWrapper()); |
|
||||||
} |
|
||||||
/** |
|
||||||
* 原插件使用 |
|
||||||
* <p>DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPaneNoPop( |
|
||||||
* HyperlinkGroupPaneActionImpl.getInstance()));</p>获取{@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(); |
|
||||||
} |
|
||||||
} |
|
@ -1,17 +0,0 @@ |
|||||||
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; |
|
||||||
/** |
|
||||||
* |
|
||||||
* <p>图片控件的图片选择、编辑器</p> |
|
||||||
* |
|
||||||
* @author Jimmy.Zheng created on 2022/8/11 21:15 |
|
||||||
**/ |
|
||||||
public class PictureEditor extends AccessiblePropertyEditor { |
|
||||||
|
|
||||||
public PictureEditor(Object o) { |
|
||||||
super(new AccessiblePictureModelEditor((PictureWidget) o)); |
|
||||||
} |
|
||||||
} |
|
@ -1,17 +0,0 @@ |
|||||||
package com.fr.design.mainframe.widget.editors; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
|
||||||
import com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor; |
|
||||||
|
|
||||||
/** |
|
||||||
* |
|
||||||
* <p><p>图片控件的链接编辑器</p></p> |
|
||||||
* |
|
||||||
* @author Jimmy.Zheng created on 2022/8/11 21:19 |
|
||||||
**/ |
|
||||||
public class UrlLinkEditor extends AccessiblePropertyEditor { |
|
||||||
|
|
||||||
public UrlLinkEditor() { |
|
||||||
super(new AccessibleUrlLinkModelEditor()); |
|
||||||
} |
|
||||||
} |
|
@ -1,15 +0,0 @@ |
|||||||
package com.fr.design.mainframe.widget.renderer; |
|
||||||
|
|
||||||
import com.fr.design.mainframe.widget.wrappers.PictureModelWrapper; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>图片控件的图片编辑器的EncoderCellRenderer</p> |
|
||||||
* |
|
||||||
* @author Jimmy.Zheng created on 2022/8/11 21:29 |
|
||||||
**/ |
|
||||||
public class PictureRenderer extends EncoderCellRenderer { |
|
||||||
|
|
||||||
public PictureRenderer() { |
|
||||||
super(new PictureModelWrapper()); |
|
||||||
} |
|
||||||
} |
|
@ -1,16 +0,0 @@ |
|||||||
package com.fr.design.mainframe.widget.renderer; |
|
||||||
|
|
||||||
|
|
||||||
import com.fr.design.mainframe.widget.wrappers.UrlLinkModelWrapper; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>图片控件的链接编辑器的EncoderCellRenderer</p> |
|
||||||
* |
|
||||||
* @author Jimmy.Zheng created on 2022/8/11 21:29 |
|
||||||
**/ |
|
||||||
public class UrlLinkRenderer extends EncoderCellRenderer { |
|
||||||
|
|
||||||
public UrlLinkRenderer() { |
|
||||||
super(new UrlLinkModelWrapper()); |
|
||||||
} |
|
||||||
} |
|
@ -1,34 +0,0 @@ |
|||||||
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; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>图片选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessiblePictureModelEditor}的 Wrapper</p> |
|
||||||
* <p>插件中直接移入,未作改动</p> |
|
||||||
* |
|
||||||
* @author Jimmy.Zheng created on 2022/8/11 21:25 |
|
||||||
**/ |
|
||||||
public class PictureModelWrapper implements Encoder<FloatElement>, Decoder<FloatElement> { |
|
||||||
|
|
||||||
@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; |
|
||||||
} |
|
||||||
} |
|
@ -1,33 +0,0 @@ |
|||||||
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; |
|
||||||
|
|
||||||
/** |
|
||||||
* <p>链接选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor}的 Wrapper</p> |
|
||||||
* <p>插件中直接移入,未作改动</p> |
|
||||||
* |
|
||||||
* @author Jimmy.Zheng created on 2022/8/11 21:28 |
|
||||||
**/ |
|
||||||
public class UrlLinkModelWrapper implements Encoder<NameJavaScriptGroup>, Decoder<NameJavaScriptGroup> { |
|
||||||
|
|
||||||
@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; |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue