You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.5 KiB

/*
* Copyright (C), 2018-2022
* Project: starter
* FileName: PdfExportPane
* Author: xx
* Date: 2022/1/4 13:59
*/
package com.fr.plugin.ajhdf.ui;
import com.fanruan.api.design.DesignKit;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.ui.layout.TableLayoutKit;
import com.fanruan.api.i18n.I18nKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.io.BaseBook;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.report.AbstractExportPane;
import com.fr.plugin.ajhdf.provider.PdfExportAttr;
import javax.swing.*;
import java.awt.*;
/**
* <Function Description><br>
* <PdfExportPane>
*
* @author xx
* @since 1.0.0
*/
public class PdfExportPane extends AbstractExportPane {
private static final long serialVersionUID = -3364831983419854602L;
private final UITextField strokeScaleTextField;
public PdfExportPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
UILabel strokeScaleLabel = new UILabel(I18nKit.getLocText("Plugin-ajhdf_Stroke_Scale"));
strokeScaleTextField = new UITextField(10);
double p = TableLayoutKit.PREFERRED;
double f = TableLayoutKit.FILL;
double[] columnSize = new double[]{p, f};
double[] rowSize = new double[]{p, p, p};
Component[][] components = new Component[][]{
new Component[]{strokeScaleLabel, strokeScaleTextField},
};
JPanel propertiesPane = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize);
JPanel customPropertiesPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane();
customPropertiesPane.add(propertiesPane, BorderLayout.CENTER);
JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(DesignKit.i18nText("Plugin-ajhdf_Custom_Properties_Title"));
centerPane.add(customPropertiesPane, BorderLayout.CENTER);
this.add(centerPane, BorderLayout.CENTER);
}
@Override
public void populate(Object attr) {
populateBean(attr);
}
@Override
public void update(Object attr) {
updateBean(attr);
}
@Override
public void populateBean(Object attr) {
BaseBook target = DesignerContext.getDesignerFrame().getSelectedJTemplate().getTarget();
PdfExportAttr pdfExportAttr = target.getAttrMark(PdfExportAttr.XML_TAG);
if (null != pdfExportAttr) {
this.strokeScaleTextField.setText(String.valueOf(pdfExportAttr.getStrokeScale()));
} else {
this.strokeScaleTextField.setText("1.0");
}
}
@Override
public void updateBean(Object attr) {
BaseBook target = DesignerContext.getDesignerFrame().getSelectedJTemplate().getTarget();
PdfExportAttr pdfExportAttr = target.getAttrMark(PdfExportAttr.XML_TAG);
if (null == pdfExportAttr) {
pdfExportAttr = new PdfExportAttr();
target.addAttrMark(pdfExportAttr);
}
float scale = StringKit.isBlank(this.strokeScaleTextField.getText()) ? 1.0F : Float.parseFloat(this.strokeScaleTextField.getText());
pdfExportAttr.setStrokeScale(scale);
}
@Override
protected String title4PopupWindow() {
return DesignKit.i18nText("Plugin-ajhdf_Pdf_Export_Attributes");
}
}