帆软报表设计器源代码。
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.
 
 
 
 

759 lines
32 KiB

package com.fr.design.webattr;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.fun.ExportToolBarProvider;
import com.fr.design.fun.ExtraButtonToolBarProvider;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.javascript.JavaScriptActionPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JWorkBook;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.style.background.BackgroundPane;
import com.fr.design.widget.IconDefinePane;
import com.fr.form.ui.Button;
import com.fr.form.ui.CustomToolBarButton;
import com.fr.general.ColorMode;
import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.general.Background;
import com.fr.log.FineLoggerFactory;
import com.fr.report.web.button.Email;
import com.fr.report.web.button.Export;
import com.fr.report.web.button.write.AppendColumnRow;
import com.fr.report.web.button.write.Submit;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.widgettheme.util.WidgetThemeDesignerUtils;
import com.fr.write.JavaScriptResourceInfo;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingUtilities;
import javax.swing.DefaultListCellRenderer;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.flex;
import static com.fine.swing.ui.layout.Layouts.row;
import static com.fine.theme.utils.FineUIUtils.wrapComponentWithTitle;
public class EditToolBar extends BasicPane {
private static final String EMAIL = "email";
private static final String CUSTOM = "custom";
private static final String EXPORT = "export";
private static final String NONE = "none";
private static final String EDIT_EXCEL = "editexcel";
private static final String APPEND_COUNT = "appendcount";
private static final String SUBMIT = "submit";
private JWorkBook jwb;
private JList list;
private DefaultListModel listModel;
private JPanel right;
private CardLayout card;
private ButtonPane bp;
private ToolBarButton lastButton;
private Background background = null;
private UICheckBox defaultCheckBox;
private UIButtonGroup<String> bgColorButtonGroup;
private ListSelectionListener listSelectionListener = new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
if (lastButton != null) {
lastButton.setWidget(bp.update());
}
if (list.getSelectedValue() instanceof ToolBarButton) {
lastButton = (ToolBarButton) list.getSelectedValue();
if (lastButton.getWidget() instanceof Button) {
card.show(right, "button");
bp.populate(lastButton.getWidget(), lastButton.getIcon());
} else {
bp.populate(lastButton.getWidget(), lastButton.getIcon());
card.show(right, "none");
}
}
}
};
private ActionListener actioner = new ActionListener() {
/**
*
*/
public void actionPerformed(ActionEvent arg0) {
final BackgroundPane backgroundPane = new BackgroundPane();
BasicDialog dialog = backgroundPane.showWindow(DesignerContext.getDesignerFrame());
backgroundPane.populate(EditToolBar.this.background);
dialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
EditToolBar.this.background = backgroundPane.update();
if (EditToolBar.this.background != null) {
EditToolBar.this.defaultCheckBox.setSelected(false);
}
}
});
dialog.setVisible(true);
}
};
public EditToolBar() {
initComponent();
}
/**
* 初始化
*/
public void initComponent() {
this.setLayout(new BorderLayout());
//左侧按钮列表
JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_S_Pane();
listModel = new DefaultListModel();
list = new JList(listModel);
list.setCellRenderer(render);
list.addListSelectionListener(listSelectionListener);
list.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE));
leftPanel.add(new JScrollPane(list), BorderLayout.CENTER);
//添加外边框
leftPanel.setBorder(new FineRoundBorder());
if (listModel.getSize() > 0) {
list.setSelectedIndex(0);
}
//左侧按钮列表上方工具栏,上移-下移-删除
ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(new MoveUpItemAction());
toolbarDef.addShortCut(new MoveDownItemAction());
toolbarDef.addShortCut(new RemoveAction());
UIToolbar toolBar = ToolBarDef.createJToolBar();
toolbarDef.updateToolBar(toolBar);
toolBar.setBackground(FineUIUtils.getUIColor("Center.ZoneBorderColor", "defaultBorderColor"));
leftPanel.add(toolBar, BorderLayout.NORTH);
//右侧表单按钮属性面板
right = FRGUIPaneFactory.createCardLayout_S_Pane();
card = new CardLayout();
right.setLayout(card);
bp = new ButtonPane();
right.add("none", FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane());
right.add("button", bp);
right.setBorder(new ScaledEmptyBorder(0,10,0,0));
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPanel, right);
splitPane.setDividerLocation(150);
//下方样式设置面板
JPanel backgroundPane = new JPanel(new BorderLayout());
UIButton bgButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Background"));
defaultCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default_Background"));
bgButton.addActionListener(actioner);
//添加按钮颜色面板默认不可见,控件显示增强开启才显示
JPanel buttonColorGroupPane = createButtonColorGroup();
buttonColorGroupPane.setVisible(false);
//样式设置面板布局,默认背景-按钮颜色
backgroundPane.add(column(LayoutConstants.VERTICAL_GAP,
row(LayoutConstants.HORIZONTAL_GAP, cell(defaultCheckBox).weight(0.15), cell(bgButton).weight(0.2), flex(0.65)).weight(1),
cell(buttonColorGroupPane).weight(1)
).getComponent());
if(WidgetThemeDesignerUtils.enableWidgetEnhance()) {
buttonColorGroupPane.setVisible(true);
}
//样式设置面板设置标题
JPanel styleSettingPane = new JPanel(new BorderLayout());
styleSettingPane.add(wrapComponentWithTitle(backgroundPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_ToolBar_Style_Setting")));
this.add(column(LayoutConstants.VERTICAL_GAP, cell(splitPane).weight(1), cell(styleSettingPane)).getComponent());
}
ListCellRenderer render = new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof ToolBarButton) {
ToolBarButton button = (ToolBarButton) value;
this.setText(button.getNameOption().optionName());
this.setIcon(button.getNameOption().optionIcon());
}
return this;
}
};
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit");
}
public void populate(FToolBar ftoolbar) {
this.populate(ftoolbar, null);
}
public void populate(FToolBar ftoolbar, ToolBarButton button) {
if (ftoolbar == null) {
return;
}
for (int i = 0; i < ftoolbar.getButtonlist().size(); i++) {
listModel.addElement(ftoolbar.getButtonlist().get(i));
}
this.list.validate();
this.list.repaint();
if (ftoolbar.getButtonlist().size() > 0) {
this.list.setSelectedIndex(0);
}
if (button != null) {
this.list.setSelectedValue(button, true);
}
this.background = ftoolbar.getBackground();
this.defaultCheckBox.setSelected(ftoolbar.isDefault() ? true : false);
if (bgColorButtonGroup != null) {
this.bgColorButtonGroup.setSelectedIndex(ftoolbar.getButtonBgColorMode().getCode());
}
}
public FToolBar update() {
if (this.list.getSelectedIndex() > -1) {
for (int i = 0; i < listModel.getSize(); i++) {
this.list.setSelectedIndex(i);
ToolBarButton toolBarButton = (ToolBarButton) this.list.getSelectedValue();
Widget widget = this.bp.update();
toolBarButton.setWidget(widget);
if (widget instanceof Button) {
String iconname = ((Button) widget).getIconName();
if (StringUtils.isNotBlank(iconname)) {
Image iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname);
if (iconImage != null) {
toolBarButton.setIcon(new ImageIcon(iconImage));
} else {
FineLoggerFactory.getLogger().warn(iconname + " can not find in finedb!");
}
}
}
}
}
List<ToolBarButton> list = new ArrayList<ToolBarButton>();
for (int i = 0; i < listModel.size(); i++) {
list.add((ToolBarButton) listModel.get(i));
}
FToolBar ftoolBar = new FToolBar();
ftoolBar.setButtonlist(list);
ftoolBar.setDefault(this.defaultCheckBox.isSelected());
if (!ftoolBar.isDefault()) {
ftoolBar.setBackground(this.background);
}
if (bgColorButtonGroup != null) {
ftoolBar.setButtonBgColorMode(ColorMode.getModeByCode(bgColorButtonGroup.getSelectedIndex()));
}
return ftoolBar;
}
private class MoveUpItemAction extends UpdateAction {
public MoveUpItemAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Up"));
this.setMnemonic('U');
this.setSmallIcon(new LazyIcon("move_up"));
}
/**
*
*/
public void actionPerformed(ActionEvent evt) {
int selectedIndex = list.getSelectedIndex();
if (selectedIndex == -1) {
return;
}
// 上移
if (selectedIndex > 0) {
DefaultListModel listModel = (DefaultListModel) list.getModel();
Object selecteObj1 = listModel.get(selectedIndex - 1);
listModel.set(selectedIndex - 1, listModel.get(selectedIndex));
listModel.set(selectedIndex, selecteObj1);
list.setSelectedIndex(selectedIndex - 1);
list.ensureIndexIsVisible(selectedIndex - 1);
list.validate();
}
}
}
private class MoveDownItemAction extends UpdateAction {
public MoveDownItemAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Move_Down"));
this.setMnemonic('D');
this.setSmallIcon(new LazyIcon("move_down"));
}
/**
*
*/
public void actionPerformed(ActionEvent evt) {
int selectedIndex = list.getSelectedIndex();
if (selectedIndex == -1) {
return;
}
// 下移
if (selectedIndex == -1) {
return;
}
if (selectedIndex < list.getModel().getSize() - 1) {
DefaultListModel listModel = (DefaultListModel) list.getModel();
Object selecteObj1 = listModel.get(selectedIndex + 1);
listModel.set(selectedIndex + 1, listModel.get(selectedIndex));
listModel.set(selectedIndex, selecteObj1);
list.setSelectedIndex(selectedIndex + 1);
list.ensureIndexIsVisible(selectedIndex + 1);
list.validate();
}
}
}
public class RemoveAction extends UpdateAction {
public RemoveAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Delete"));
this.setSmallIcon(new LazyIcon("clear"));
}
/**
* 动作
*
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
int i = list.getSelectedIndex();
if (i < 0 || !(listModel.getElementAt(i) instanceof ToolBarButton)) {
return;
}
int val = FineJOptionPane.showConfirmDialog(EditToolBar.this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Are_You_Sure_To_Delete_The_Data") + "?",
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Dialog_Prompt"), JOptionPane.YES_NO_OPTION);
if (val != JOptionPane.YES_OPTION) {
return;
}
listModel.removeElementAt(i);
list.validate();
if (listModel.size() > 0) {
list.setSelectedIndex(0);
} else {
card.show(right, "none");
}
}
}
public class ButtonPane extends BasicPane {
private CardLayout card;
private JPanel centerPane;
private UICheckBox icon, text, pdf, excelP, excelO, excelS, image, word,
isPopup, isVerify, failSubmit, isCurSheet, excelImClean,
excelImCover, excelImAppend, excelImCust,
customConsignee, consigneeByDepartment, consigneeByRole;
private UIBasicSpinner count;
private Widget widget;
private UITextField nameField;
private IconDefinePane iconPane;
private UIButton button;
private JavaScriptActionPane javaScriptPane;
private ExportToolBarProvider[] exportToolBarProviders;
private ActionListener actionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (isVerify.isSelected()) {
failSubmit.setVisible(true);
} else {
failSubmit.setVisible(false);
failSubmit.setSelected(false);
}
}
};
public ButtonPane() {
this.initComponents();
}
/**
* 初始化元素
*/
public void initComponents() {
Set<ExportToolBarProvider> set = ExtraDesignClassManager.getInstance().getArray(ExportToolBarProvider.XML_TAG);
exportToolBarProviders = set.toArray(new ExportToolBarProvider[set.size()]);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
//'设置表单按钮属性'面板
JPanel north = FRGUIPaneFactory.createBorderLayout_S_Pane();
icon = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Icon"));
text = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Text"));
nameField = new UITextField();
iconPane = new IconDefinePane();
javaScriptPane = JavaScriptActionPane.createDefault();
JPanel nameIconPane = column(LayoutConstants.VERTICAL_GAP,
//显示按钮图标,显示按钮名称
row(LayoutConstants.HORIZONTAL_GAP, cell(icon), cell(text)),
//控件别名
row(LayoutConstants.HORIZONTAL_GAP, cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Printer_Alias"))),
cell(nameField)),
//控件图标
row(LayoutConstants.HORIZONTAL_GAP, cell(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Icon"))),
cell(iconPane))
).getComponent();
nameIconPane.setBorder(new ScaledEmptyBorder(0, 0, 10, 0));
north.add(wrapComponentWithTitle(nameIconPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property")), BorderLayout.SOUTH);
this.add(north, BorderLayout.NORTH);
//不同图标额外的设置表单按钮属性面板
centerPane = FRGUIPaneFactory.createCardLayout_S_Pane();
card = new CardLayout();
centerPane.setLayout(card);
centerPane.add(CUSTOM, wrapComponentWithTitle(getCustomPane(), com.fr.design.i18n.Toolkit.i18nText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit") + "JS")));
centerPane.add(EXPORT, wrapComponentWithTitle(getExport(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property")));
centerPane.add(EMAIL, wrapComponentWithTitle(getEmail(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property")));
centerPane.add(NONE, FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane());
centerPane.add(APPEND_COUNT, column(LayoutConstants.VERTICAL_GAP,cell(getAppendCountPane())).getComponent());
centerPane.add(SUBMIT, wrapComponentWithTitle(getSubmitPane(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set_Form_Button_Property")));
Set<ExtraButtonToolBarProvider> extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG);
for (ExtraButtonToolBarProvider provider : extraButtonSet) {
provider.updateCenterPane(centerPane);
}
this.add(centerPane, BorderLayout.CENTER);
}
/**
* 自定义按钮Pane
* @return
*/
private JPanel getCustomPane() {
JPanel customPane = new JPanel(new BorderLayout());
button = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_User_Defined_Event"));
customPane.add(row(cell(button).weight(0.2), flex(0.8)).getComponent());
button.addActionListener(l);
return customPane;
}
/**
* 导出Pane
* @return
*/
private JPanel getExport() {
JPanel export = FRGUIPaneFactory.createBorderLayout_S_Pane();
pdf = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_PDF"));
excelP = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Output_Excel_Page"));
excelO = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Simple"));
excelS = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Excel_Sheet"));
word = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Output_Word"));
image = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image"));
export.add(column(10, cell(pdf), cell(excelP), cell(excelO), cell(excelS), cell(word), cell(image)).getComponent());
for (int i = 0; i < ArrayUtils.getLength(exportToolBarProviders); i++) {
export = exportToolBarProviders[i].updateCenterPane(export);
}
return export;
}
/**
* 邮件Pane
* @return
*/
private JPanel getEmail() {
JPanel email = FRGUIPaneFactory.createBorderLayout_S_Pane();
customConsignee = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Custom_Consignee"));
consigneeByDepartment = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Consignee_By_Department"));
consigneeByRole = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Consignee_By_Role"));
email.add(column(LayoutConstants.VERTICAL_GAP,
cell(customConsignee),
cell(consigneeByDepartment),
cell(consigneeByRole)
).getComponent());
return email;
}
/**
* 插入记录Pane
* @return
*/
private JPanel getAppendCountPane() {
JPanel appendCountPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
count = new UIBasicSpinner(new SpinnerNumberModel(1, 0, Integer.MAX_VALUE, 1));
UILabel countLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Add_Row_Column_Numbers"));
appendCountPane.add(row(LayoutConstants.HORIZONTAL_GAP, cell(countLabel), cell(count)).getComponent());
return appendCountPane;
}
/**
* 提交Pane
* @return
*/
private JPanel getSubmitPane() {
isVerify = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Verify_Data_Verify"));
failSubmit = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Verify_Fail_Still_Submit"));
isCurSheet = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Only_Submit_Current_Sheet"));
isVerify.addActionListener(actionListener);
JPanel submitPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
submitPane.add(column(LayoutConstants.VERTICAL_GAP,
cell(isVerify),
cell(failSubmit),
cell(isCurSheet)
).getComponent());
return submitPane;
}
@Override
protected String title4PopupWindow() {
return "Button";
}
ActionListener l = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!(widget instanceof CustomToolBarButton)) {
return;
}
if (javaScriptPane == null || ((CustomToolBarButton) widget).getJSImpl() == null) {
javaScriptPane = JavaScriptActionPane.createDefault();
}
JavaScriptResourceInfo.PathNode pathNode = JavaScriptResourceInfo.PathNode.create(JavaScriptResourceInfo.Type.WIDGET, ((Button) widget).getText());
JavaScriptResourceInfo javaScriptResourceInfo = new JavaScriptResourceInfo().addFirstPathNode(pathNode);
javaScriptPane.setResourceInfo(javaScriptResourceInfo);
javaScriptPane.setPreferredSize(new Dimension(750, 500));
BasicDialog dialog = javaScriptPane.showWindow(SwingUtilities.getWindowAncestor(ButtonPane.this));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doCancel() {
javaScriptPane.populateBean(((CustomToolBarButton) widget).getJSImpl());
}
@Override
public void doOk() {
((CustomToolBarButton) widget).setJSImpl(javaScriptPane.updateBean());
}
});
dialog.setVisible(true);
}
};
/**
* 更新
*
* @param widget 对应组件
*/
public void populate(Widget widget, Icon icon) {
this.widget = widget;
card.show(centerPane, "none");
if (widget instanceof Button) {
populateDefault(icon);
}
if (widget instanceof Export) {
populateExport();
} else if (widget instanceof AppendColumnRow) {
populateAppendColumnRow();
} else if (widget instanceof Submit) {
populateSubmit();
} else if (widget instanceof CustomToolBarButton) {
populateCustomToolBarButton();
} else if (widget instanceof Email) {
populateEmail();
}
Set<ExtraButtonToolBarProvider> extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG);
for (ExtraButtonToolBarProvider provider : extraButtonSet) {
provider.populate(widget, card, centerPane);
}
}
private void populateAppendColumnRow() {
card.show(centerPane, "appendcount");
count.setValue(((AppendColumnRow) widget).getCount());
}
private void populateExport() {
card.show(centerPane, "export");
Export export = (Export) widget;
this.pdf.setSelected(export.isPdfAvailable());
this.excelP.setSelected(export.isExcelPAvailable());
this.excelO.setSelected(export.isExcelOAvailable());
this.excelS.setSelected(export.isExcelSAvailable());
this.word.setSelected(export.isWordAvailable());
this.image.setSelected(export.isImageAvailable());
if (exportToolBarProviders != null) {
for (int i = 0; i < exportToolBarProviders.length; i++) {
exportToolBarProviders[i].populate();
;
}
}
}
private void populateEmail() {
card.show(centerPane, EMAIL);
Email email = (Email) widget;
this.customConsignee.setSelected(email.isCustomConsignee());
this.consigneeByDepartment.setSelected(email.isConsigneeByDepartment());
this.consigneeByRole.setSelected(email.isConsigneeByRole());
}
private void populateCustomToolBarButton() {
card.show(centerPane, "custom");
CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget;
if (customToolBarButton.getJSImpl() != null) {
this.javaScriptPane.populateBean(customToolBarButton.getJSImpl());
}
}
private void populateSubmit() {
card.show(centerPane, "submit");
Submit submit = ((Submit) widget);
this.isVerify.setSelected(submit.isVerify());
if (!submit.isVerify()) {
this.failSubmit.setVisible(false);
}
this.failSubmit.setSelected(submit.isFailVerifySubmit());
this.isCurSheet.setSelected(submit.isOnlySubmitSelect());
}
private void populateDefault(Icon icon) {
Button button = (Button) widget;
this.icon.setSelected(button.isShowIcon());
this.text.setSelected(button.isShowText());
this.nameField.setText(button.getText());
this.iconPane.populateIcon(((Button) widget).getIconName(), icon);
}
/**
* 更新
*
* @return 对应组件
*/
public Widget update() {
if (widget instanceof Export) {
updateExport();
} else if (widget instanceof AppendColumnRow) {
((AppendColumnRow) widget).setCount(((Integer) count.getValue()).intValue());
} else if (widget instanceof Submit) {
updateSubmit();
} else if (widget instanceof CustomToolBarButton) {
updateCustomToolBarButton();
} else if (widget instanceof Email) {
updateEmail();
}
if (widget instanceof Button) {
updateDefault();
}
Set<ExtraButtonToolBarProvider> extraButtonSet = ExtraDesignClassManager.getInstance().getArray(ExtraButtonToolBarProvider.XML_TAG);
for (ExtraButtonToolBarProvider provider : extraButtonSet) {
provider.update(widget);
}
return widget;
}
private void updateDefault() {
((Button) widget).setShowIcon(this.icon.isSelected());
((Button) widget).setShowText(this.text.isSelected());
((Button) widget).setText(this.nameField.getText());
((Button) widget).setIconName(this.iconPane.update());
}
private void updateSubmit() {
Submit submit = ((Submit) widget);
submit.setVerify(this.isVerify.isSelected());
submit.setFailVerifySubmit(this.failSubmit.isSelected());
submit.setOnlySubmitSelect(this.isCurSheet.isSelected());
}
private void updateExport() {
Export export = (Export) widget;
export.setPdfAvailable(this.pdf.isSelected());
export.setExcelPAvailable(this.excelP.isSelected());
export.setExcelOAvailable(this.excelO.isSelected());
export.setExcelSAvailable(this.excelS.isSelected());
export.setWordAvailable(this.word.isSelected());
export.setImageAvailable(this.image.isSelected());
if (exportToolBarProviders != null) {
for (int i = 0; i < exportToolBarProviders.length; i++) {
exportToolBarProviders[i].update();
;
}
}
}
private void updateEmail() {
Email email = ((Email) widget);
email.setCustomConsignee(this.customConsignee.isSelected());
email.setConsigneeByDepartment(this.consigneeByDepartment.isSelected());
email.setConsigneeByRole(this.consigneeByRole.isSelected());
}
private void updateCustomToolBarButton() {
CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget;
if (customToolBarButton.getJSImpl() == null) {
this.javaScriptPane = JavaScriptActionPane.createDefault();
}
JavaScriptResourceInfo.PathNode pathNode = JavaScriptResourceInfo.PathNode.create(JavaScriptResourceInfo.Type.CUSTOM_BUTTON, ((Button) widget).getText());
JavaScriptResourceInfo javaScriptResourceInfo = new JavaScriptResourceInfo().addFirstPathNode(pathNode);
javaScriptPane.setResourceInfo(javaScriptResourceInfo);
customToolBarButton.setJSImpl(this.javaScriptPane.updateBean());
}
}
private JPanel createButtonColorGroup() {
UILabel headLabel = new UILabel(Toolkit.i18nText("Fine-Design_ToolBar_Button_Color"));
String[] titles = new String[]{ Toolkit.i18nText("Fine-Design_ToolBar_Button_Color_Auto"),
Toolkit.i18nText("Fine-Design_ToolBar_Button_Color_Light"),
Toolkit.i18nText("Fine-Design_ToolBar_Button_Color_Dark")};
bgColorButtonGroup = new UIButtonGroup<String>(titles) {
@Override
public void setSelectedIndex(int newSelectedIndex, boolean fireChanged) {
super.setSelectedIndex(newSelectedIndex, fireChanged);
}
};
bgColorButtonGroup.setPreferredSize(new Dimension(FineUIScale.scale(135), bgColorButtonGroup.getPreferredSize().height));
return row(10, cell(headLabel).weight(0.15), cell(bgColorButtonGroup).weight(0.3), flex(0.55)).getComponent();
}
}