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

130 lines
5.0 KiB

package com.fr.design.condition;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.base.present.Present;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.present.PresentPane;
import com.fr.report.cell.cellattr.PresentConstants;
import com.fr.report.cell.cellattr.highlight.HighlightAction;
import com.fr.report.cell.cellattr.highlight.PresentHighlightAction;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.row;
import static com.fine.theme.utils.FineClientProperties.ADAPTIVE_COMBO_BOX;
import static com.fine.theme.utils.FineClientProperties.COMBO_BOX_TYPE;
/**
* @author richie
* @date 2015-03-26
* @since 8.0
*/
public class PresentHighlightPane extends ConditionAttrSingleConditionPane<HighlightAction> {
private UIComboBox presentComboBox;
private Present present;
private UIButton editButton;
private ValueEditorPane valueEditor;
public PresentHighlightPane(final ConditionAttributesPane conditionAttributesPane) {
super(conditionAttributesPane);
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Present") + ":");
String[] typeArray = {PresentConstants.NORMAL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Other_Present")};
presentComboBox = new UIComboBox(typeArray);
editButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit"));
// this.add(this.valueTextField);
// this.add(editButton);
editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (presentComboBox.getSelectedIndex() != 0) {
final PresentPane presentPane = new PresentPane();
presentPane.populateBean(present);
BasicDialog dialog = presentPane.showWindow(SwingUtilities.getWindowAncestor(conditionAttributesPane));
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
present = presentPane.updateBean();
}
});
dialog.setVisible(true);
}
}
});
// this.valueTextField.setText("");
JPanel type = new JPanel(new BorderLayout());
valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane();
type.add(valueEditor);
presentComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (presentComboBox.getSelectedIndex() == 1){
if (valueEditor.getParent() == type) {
type.remove(valueEditor);
}
type.add(editButton);
PresentHighlightPane.this.validate();
PresentHighlightPane.this.repaint();
} else {
if (editButton.getParent() == type) {
type.remove(editButton);
}
type.add(valueEditor);
PresentHighlightPane.this.validate();
PresentHighlightPane.this.repaint();
}
}
});
presentComboBox.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX);
this.add(row(10, cell(label).weight(0.2), row(
10,
cell(presentComboBox),
cell(type)).weight(0.8)
).with(it -> it.setBorder(new ScaledEmptyBorder(5, 5, 5, 0))).getComponent(), BorderLayout.CENTER);
}
@Override
public String nameForPopupMenuItem() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Present");
}
@Override
protected String title4PopupWindow() {
return nameForPopupMenuItem();
}
public void populate(HighlightAction ha) {
Object obj = ((PresentHighlightAction)ha).getValue();
present = ((PresentHighlightAction)ha).getPresent();
if(null != obj) {
presentComboBox.setSelectedIndex(0);
this.valueEditor.populate(obj);
} else if(null != present) {
presentComboBox.setSelectedIndex(1);
this.valueEditor.populate(present);
}
}
public HighlightAction update() {
if (presentComboBox.getSelectedIndex() == 1) {
return new PresentHighlightAction(present);
}
return new PresentHighlightAction(this.valueEditor.update());
}
}