Browse Source

REPORT-8125 水印 设计器配置界面与实时预览=>改为AttrMark

master
plough 7 years ago
parent
commit
2f81f19cbb
  1. 11
      designer-base/src/com/fr/design/report/WatermarkPane.java
  2. 11
      designer-base/src/com/fr/design/report/WatermarkPreviewPane.java
  3. 4
      designer-form/src/com/fr/design/mainframe/widget/accessibles/AccessibleBodyWatermarkEditor.java
  4. 10
      designer-form/src/com/fr/design/mainframe/widget/wrappers/WatermarkWrapper.java
  5. 21
      designer-form/src/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java
  6. 35
      designer-form/src/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java
  7. 42
      designer-realize/src/com/fr/design/actions/report/ReportWatermarkAction.java
  8. 2
      designer-realize/src/com/fr/design/mainframe/JWorkBook.java
  9. 1
      designer-realize/src/com/fr/design/mainframe/ReportComponent.java

11
designer-base/src/com/fr/design/report/WatermarkPane.java

@ -1,6 +1,6 @@
package com.fr.design.report; package com.fr.design.report;
import com.fr.base.Watermark; import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.formula.TinyFormulaPane; import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -69,15 +69,18 @@ public class WatermarkPane extends BasicPane {
rightPane.add(initRightPane(), BorderLayout.CENTER); rightPane.add(initRightPane(), BorderLayout.CENTER);
} }
public void populate(Watermark watermark) { public void populate(WatermarkAttrMark watermark) {
if (watermark == null) {
watermark = new WatermarkAttrMark();
}
populateFourmula(watermark.getText()); populateFourmula(watermark.getText());
populateFontSize(watermark.getFontSize()); populateFontSize(watermark.getFontSize());
populateColor(watermark.getColor()); populateColor(watermark.getColor());
paintPreviewPane(); paintPreviewPane();
} }
public Watermark update() { public WatermarkAttrMark update() {
Watermark watermark = new Watermark(); WatermarkAttrMark watermark = new WatermarkAttrMark();
watermark.setText(formulaPane.getUITextField().getText()); watermark.setText(formulaPane.getUITextField().getText());
watermark.setFontSize((int)fontSizeComboBox.getSelectedItem()); watermark.setFontSize((int)fontSizeComboBox.getSelectedItem());
watermark.setColor(colorPane.getColor()); watermark.setColor(colorPane.getColor());

11
designer-base/src/com/fr/design/report/WatermarkPreviewPane.java

@ -1,16 +1,13 @@
package com.fr.design.report; package com.fr.design.report;
import com.fr.base.Watermark; import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.stable.StringUtils;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.Color;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
/** /**
@ -25,18 +22,18 @@ public class WatermarkPreviewPane extends JPanel {
private int horizontalGap = 20; // 水平间隔(一个中文字符宽度) private int horizontalGap = 20; // 水平间隔(一个中文字符宽度)
private int verticalGap = 40; // 垂直间隔(两个中文字符宽度) private int verticalGap = 40; // 垂直间隔(两个中文字符宽度)
private Watermark watermark; private WatermarkAttrMark watermark;
public WatermarkPreviewPane() { public WatermarkPreviewPane() {
this.watermark = new Watermark(); this.watermark = new WatermarkAttrMark();
repaint(); repaint();
} }
/** /**
* 重新画 * 重新画
*/ */
public void repaint(Watermark watermark){ public void repaint(WatermarkAttrMark watermark){
this.watermark = watermark; this.watermark = watermark;
super.repaint(); super.repaint();
} }

4
designer-form/src/com/fr/design/mainframe/widget/accessibles/AccessibleBodyWatermarkEditor.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.widget.accessibles; package com.fr.design.mainframe.widget.accessibles;
import com.fr.base.Watermark; import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.widget.editors.ITextComponent; import com.fr.design.mainframe.widget.editors.ITextComponent;
@ -42,7 +42,7 @@ public class AccessibleBodyWatermarkEditor extends UneditableAccessibleEditor {
fireStateChanged(); fireStateChanged();
} }
}); });
watermarkPane.populate((Watermark) getValue()); watermarkPane.populate((WatermarkAttrMark) getValue());
dlg.setVisible(true); dlg.setVisible(true);
} }
} }

10
designer-form/src/com/fr/design/mainframe/widget/wrappers/WatermarkWrapper.java

@ -1,9 +1,10 @@
package com.fr.design.mainframe.widget.wrappers; package com.fr.design.mainframe.widget.wrappers;
import com.fr.base.Watermark; import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.Exception.ValidationException; import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder; import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder; import com.fr.design.designer.properties.Encoder;
import com.fr.stable.StringUtils;
/** /**
* Created by plough on 2018/5/15. * Created by plough on 2018/5/15.
@ -11,7 +12,7 @@ import com.fr.design.designer.properties.Encoder;
public class WatermarkWrapper implements Encoder, Decoder { public class WatermarkWrapper implements Encoder, Decoder {
@Override @Override
public Object decode(String txt) { public Object decode(String txt) {
return new Watermark(); return new WatermarkAttrMark();
} }
@Override @Override
@ -21,6 +22,9 @@ public class WatermarkWrapper implements Encoder, Decoder {
@Override @Override
public String encode(Object v) { public String encode(Object v) {
return ((Watermark)v).getText(); if (v == null) {
return StringUtils.EMPTY;
}
return ((WatermarkAttrMark)v).getText();
} }
} }

21
designer-form/src/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java

@ -1,6 +1,7 @@
package com.fr.design.widget.ui.designer.layout; package com.fr.design.widget.ui.designer.layout;
import com.fr.base.Watermark; import com.fr.base.io.IOFile;
import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -24,6 +25,7 @@ import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
@ -99,7 +101,8 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) { public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1); layoutCombox.setSelectedIndex(1);
borderStyleEditor.setValue(ob.getBorderStyle()); borderStyleEditor.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ob.getWatermark()); watermarkEditor.setValue(ReportUtils.getWatermarkFromIOFile(getCurrentIOFile()));
} }
public WAbsoluteBodyLayout updateSubPane() { public WAbsoluteBodyLayout updateSubPane() {
@ -117,10 +120,22 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
} }
} }
layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue()); layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
layout.setWatermark((Watermark) watermarkEditor.getValue()); updateWatermark();
return layout; return layout;
} }
private void updateWatermark() {
WatermarkAttrMark watermark = (WatermarkAttrMark) watermarkEditor.getValue();
if (watermark != null) {
IOFile ioFile = getCurrentIOFile();
ioFile.addAttrMark(watermark);
}
}
private IOFile getCurrentIOFile() {
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
}
@Override @Override
public DataCreatorUI dataUI() { public DataCreatorUI dataUI() {
return null; return null;

35
designer-form/src/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java

@ -1,6 +1,7 @@
package com.fr.design.widget.ui.designer.layout; package com.fr.design.widget.ui.designer.layout;
import com.fr.base.Watermark; import com.fr.base.io.IOFile;
import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.data.DataCreatorUI; import com.fr.design.data.DataCreatorUI;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
@ -18,8 +19,11 @@ import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.mainframe.FormSelectionUtils;
import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.WidgetPropertyPane;
import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleBodyWatermarkEditor;
import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.accessibles.AccessibleWLayoutBorderStyleEditor;
@ -33,9 +37,15 @@ import com.fr.form.ui.container.WBodyLayoutType;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.main.FineBook;
import com.fr.report.core.ReportUtils;
import javax.swing.*; import javax.swing.BorderFactory;
import java.awt.*; import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
/** /**
* Created by ibm on 2017/8/2. * Created by ibm on 2017/8/2.
@ -137,7 +147,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
adaptComboBox.setSelectedIndex(ob.getCompState()); adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval()); componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle()); stylePane.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ob.getWatermark()); watermarkEditor.setValue(ReportUtils.getWatermarkFromIOFile(getCurrentIOFile()));
} }
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) { private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
@ -157,10 +167,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
if(borderStyle != null){ if(borderStyle != null){
layout.setBorderStyle(borderStyle); layout.setBorderStyle(borderStyle);
} }
Watermark watermark = (Watermark) watermarkEditor.getValue(); updateWatermark();
if (watermark != null) {
layout.setWatermark(watermark);
}
Item item = (Item) layoutComboBox.getSelectedItem(); Item item = (Item) layoutComboBox.getSelectedItem();
Object value = item.getValue(); Object value = item.getValue();
int state = 0; int state = 0;
@ -207,6 +214,18 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
return layout; return layout;
} }
private void updateWatermark() {
WatermarkAttrMark watermark = (WatermarkAttrMark) watermarkEditor.getValue();
if (watermark != null) {
IOFile ioFile = getCurrentIOFile();
ioFile.addAttrMark(watermark);
}
}
private IOFile getCurrentIOFile() {
return WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget();
}
private void setLayoutGap(int value) { private void setLayoutGap(int value) {
int interval = wFitLayout.getCompInterval(); int interval = wFitLayout.getCompInterval();
if (value != interval) { if (value != interval) {

42
designer-realize/src/com/fr/design/actions/report/ReportWatermarkAction.java

@ -1,48 +1,54 @@
package com.fr.design.actions.report; package com.fr.design.actions.report;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.IconManager;
import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.actions.JWorkBookAction;
import com.fr.design.actions.ReportComponentAction; import com.fr.design.actions.ReportComponentAction;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.ReportComponent; import com.fr.design.mainframe.ReportComponent;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.report.WatermarkPane; import com.fr.design.report.WatermarkPane;
import com.fr.general.IOUtils;
import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import com.fr.report.stable.ReportSettings; import com.fr.report.stable.ReportSettings;
import java.awt.event.ActionEvent;
/** /**
* Created by plough on 2018/5/15. * Created by plough on 2018/5/15.
*/ */
public class ReportWatermarkAction extends ReportComponentAction<ReportComponent> { public class ReportWatermarkAction extends JWorkBookAction {
public ReportWatermarkAction(JWorkBook jwb) {
public ReportWatermarkAction(ReportComponent rc) { super(jwb);
super(rc);
this.setMenuKeySet(KeySetUtils.REPORT_WATERMARK); this.setMenuKeySet(KeySetUtils.REPORT_WATERMARK);
this.setName(getMenuKeySet().getMenuKeySetName() + "..."); this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic()); this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/watermark.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/watermark.png"));
this.setSearchText(new WatermarkPane());
} }
/** @Override
* 执行动作 public void actionPerformed(ActionEvent e) {
* @return 是否执行成功 final JWorkBook jwb = getEditingComponent();
*/ if (jwb == null) {
public boolean executeActionReturnUndoRecordNeeded() { return;
final ReportComponent reportPane = this.getEditingComponent();
if (reportPane == null) {
return false;
} }
final WorkBook wbTpl = jwb.getTarget();
WatermarkAttrMark watermark = ReportUtils.getWatermarkFromIOFile(wbTpl);
final WatermarkPane watermarkPane = new WatermarkPane(); final WatermarkPane watermarkPane = new WatermarkPane();
ReportSettings reportSettings = (ReportSettings) ReportUtils.getReportSettings(reportPane.getTemplateReport()); watermarkPane.populate(watermark);
watermarkPane.populate(reportSettings.getWatermark());
watermarkPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { watermarkPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
reportSettings.setWatermark(watermarkPane.update()); wbTpl.addAttrMark(watermarkPane.update());
reportPane.fireTargetModified(); jwb.fireTargetModified();
} }
}).setVisible(true); }).setVisible(true);
return false;
} }
} }

2
designer-realize/src/com/fr/design/mainframe/JWorkBook.java

@ -22,6 +22,7 @@ import com.fr.design.actions.file.export.WordExportAction;
import com.fr.design.actions.report.ReportExportAttrAction; import com.fr.design.actions.report.ReportExportAttrAction;
import com.fr.design.actions.report.ReportMobileAttrAction; import com.fr.design.actions.report.ReportMobileAttrAction;
import com.fr.design.actions.report.ReportParameterAction; import com.fr.design.actions.report.ReportParameterAction;
import com.fr.design.actions.report.ReportWatermarkAction;
import com.fr.design.actions.report.ReportWebAttrAction; import com.fr.design.actions.report.ReportWebAttrAction;
import com.fr.design.cell.bar.DynamicScrollBar; import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -694,6 +695,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
new ReportExportAttrAction(this), new ReportExportAttrAction(this),
new ReportParameterAction(this), new ReportParameterAction(this),
new ReportMobileAttrAction(this), new ReportMobileAttrAction(this),
new ReportWatermarkAction(this),
new NameSeparator(Inter.getLocText("Utils-Current_Sheet")), new NameSeparator(Inter.getLocText("Utils-Current_Sheet")),
}, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu());
} }

1
designer-realize/src/com/fr/design/mainframe/ReportComponent.java

@ -57,7 +57,6 @@ public abstract class ReportComponent<T extends TemplateReport, E extends Elemen
new ReportHeaderAction(this), new ReportHeaderAction(this),
new ReportFooterAction(this), new ReportFooterAction(this),
new ReportBackgroundAction(this), new ReportBackgroundAction(this),
new ReportWatermarkAction(this),
}; };
} }

Loading…
Cancel
Save