Browse Source

Merge pull request #41 in DESIGN/design from ~PLOUGH/10-design:feature/10.0 to feature/10.0

* commit 'b17f56af4c2e059fa923e874d316988c02ed9d5f':
  REPORT-8125 水印 设计器配置界面与实时预览=>改为AttrMark
master
superman 7 years ago
parent
commit
c07ed9a7a7
  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;
import com.fr.base.Watermark;
import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.dialog.BasicPane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icombobox.UIComboBox;
@ -69,15 +69,18 @@ public class WatermarkPane extends BasicPane {
rightPane.add(initRightPane(), BorderLayout.CENTER);
}
public void populate(Watermark watermark) {
public void populate(WatermarkAttrMark watermark) {
if (watermark == null) {
watermark = new WatermarkAttrMark();
}
populateFourmula(watermark.getText());
populateFontSize(watermark.getFontSize());
populateColor(watermark.getColor());
paintPreviewPane();
}
public Watermark update() {
Watermark watermark = new Watermark();
public WatermarkAttrMark update() {
WatermarkAttrMark watermark = new WatermarkAttrMark();
watermark.setText(formulaPane.getUITextField().getText());
watermark.setFontSize((int)fontSizeComboBox.getSelectedItem());
watermark.setColor(colorPane.getColor());

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

@ -1,16 +1,13 @@
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.general.FRFont;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
/**
@ -25,18 +22,18 @@ public class WatermarkPreviewPane extends JPanel {
private int horizontalGap = 20; // 水平间隔(一个中文字符宽度)
private int verticalGap = 40; // 垂直间隔(两个中文字符宽度)
private Watermark watermark;
private WatermarkAttrMark watermark;
public WatermarkPreviewPane() {
this.watermark = new Watermark();
this.watermark = new WatermarkAttrMark();
repaint();
}
/**
* 重新画
*/
public void repaint(Watermark watermark){
public void repaint(WatermarkAttrMark watermark){
this.watermark = watermark;
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;
import com.fr.base.Watermark;
import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.widget.editors.ITextComponent;
@ -42,7 +42,7 @@ public class AccessibleBodyWatermarkEditor extends UneditableAccessibleEditor {
fireStateChanged();
}
});
watermarkPane.populate((Watermark) getValue());
watermarkPane.populate((WatermarkAttrMark) getValue());
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;
import com.fr.base.Watermark;
import com.fr.base.iofileattr.WatermarkAttrMark;
import com.fr.design.Exception.ValidationException;
import com.fr.design.designer.properties.Decoder;
import com.fr.design.designer.properties.Encoder;
import com.fr.stable.StringUtils;
/**
* Created by plough on 2018/5/15.
@ -11,7 +12,7 @@ import com.fr.design.designer.properties.Encoder;
public class WatermarkWrapper implements Encoder, Decoder {
@Override
public Object decode(String txt) {
return new Watermark();
return new WatermarkAttrMark();
}
@Override
@ -21,6 +22,9 @@ public class WatermarkWrapper implements Encoder, Decoder {
@Override
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;
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.designer.IntervalConstants;
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.general.FRLogger;
import com.fr.general.Inter;
import com.fr.report.core.ReportUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultComboBoxModel;
@ -99,7 +101,8 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
public void populateSubPane(WAbsoluteLayout ob) {
layoutCombox.setSelectedIndex(1);
borderStyleEditor.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ob.getWatermark());
watermarkEditor.setValue(ReportUtils.getWatermarkFromIOFile(getCurrentIOFile()));
}
public WAbsoluteBodyLayout updateSubPane() {
@ -117,10 +120,22 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane {
}
}
layout.setBorderStyle((LayoutBorderStyle) borderStyleEditor.getValue());
layout.setWatermark((Watermark) watermarkEditor.getValue());
updateWatermark();
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
public DataCreatorUI dataUI() {
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;
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.designer.IntervalConstants;
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.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.FormDesigner;
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.widget.accessibles.AccessibleBodyWatermarkEditor;
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.general.FRLogger;
import com.fr.general.Inter;
import com.fr.main.FineBook;
import com.fr.report.core.ReportUtils;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
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.
@ -137,7 +147,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
adaptComboBox.setSelectedIndex(ob.getCompState());
componentIntervel.setValue(ob.getCompInterval());
stylePane.setValue(ob.getBorderStyle());
watermarkEditor.setValue(ob.getWatermark());
watermarkEditor.setValue(ReportUtils.getWatermarkFromIOFile(getCurrentIOFile()));
}
private XLayoutContainer selectedBodyLayout(FormDesigner formDesigner) {
@ -157,10 +167,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
if(borderStyle != null){
layout.setBorderStyle(borderStyle);
}
Watermark watermark = (Watermark) watermarkEditor.getValue();
if (watermark != null) {
layout.setWatermark(watermark);
}
updateWatermark();
Item item = (Item) layoutComboBox.getSelectedItem();
Object value = item.getValue();
int state = 0;
@ -207,6 +214,18 @@ public class FRFitLayoutDefinePane extends AbstractDataModify<WFitLayout> {
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) {
int interval = wFitLayout.getCompInterval();
if (value != interval) {

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

@ -1,48 +1,54 @@
package com.fr.design.actions.report;
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.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.mainframe.ReportComponent;
import com.fr.design.menu.KeySetUtils;
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.stable.ReportSettings;
import java.awt.event.ActionEvent;
/**
* Created by plough on 2018/5/15.
*/
public class ReportWatermarkAction extends ReportComponentAction<ReportComponent> {
public ReportWatermarkAction(ReportComponent rc) {
super(rc);
public class ReportWatermarkAction extends JWorkBookAction {
public ReportWatermarkAction(JWorkBook jwb) {
super(jwb);
this.setMenuKeySet(KeySetUtils.REPORT_WATERMARK);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_report/watermark.png"));
this.setSearchText(new WatermarkPane());
}
/**
* 执行动作
* @return 是否执行成功
*/
public boolean executeActionReturnUndoRecordNeeded() {
final ReportComponent reportPane = this.getEditingComponent();
if (reportPane == null) {
return false;
@Override
public void actionPerformed(ActionEvent e) {
final JWorkBook jwb = getEditingComponent();
if (jwb == null) {
return;
}
final WorkBook wbTpl = jwb.getTarget();
WatermarkAttrMark watermark = ReportUtils.getWatermarkFromIOFile(wbTpl);
final WatermarkPane watermarkPane = new WatermarkPane();
ReportSettings reportSettings = (ReportSettings) ReportUtils.getReportSettings(reportPane.getTemplateReport());
watermarkPane.populate(reportSettings.getWatermark());
watermarkPane.populate(watermark);
watermarkPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() {
reportSettings.setWatermark(watermarkPane.update());
reportPane.fireTargetModified();
wbTpl.addAttrMark(watermarkPane.update());
jwb.fireTargetModified();
}
}).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.ReportMobileAttrAction;
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.cell.bar.DynamicScrollBar;
import com.fr.design.constants.UIConstants;
@ -694,6 +695,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
new ReportExportAttrAction(this),
new ReportParameterAction(this),
new ReportMobileAttrAction(this),
new ReportWatermarkAction(this),
new NameSeparator(Inter.getLocText("Utils-Current_Sheet")),
}, 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 ReportFooterAction(this),
new ReportBackgroundAction(this),
new ReportWatermarkAction(this),
};
}

Loading…
Cancel
Save