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.
87 lines
4.0 KiB
87 lines
4.0 KiB
package com.fr.design.condition; |
|
|
|
import com.fine.theme.light.ui.FineRoundBorder; |
|
import com.fine.theme.utils.FineUIScale; |
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
import com.fr.base.background.ColorBackground; |
|
import com.fr.design.dialog.DialogActionAdapter; |
|
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.style.background.BackgroundPane; |
|
import com.fr.design.style.background.BackgroundPreviewLabel; |
|
|
|
import com.fr.report.cell.cellattr.highlight.BackgroundHighlightAction; |
|
import com.fr.report.cell.cellattr.highlight.HighlightAction; |
|
|
|
import javax.swing.*; |
|
import java.awt.*; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
|
|
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 BackPane extends ConditionAttrSingleConditionPane<HighlightAction> { |
|
private UILabel backgroundLabel; |
|
private BackgroundPreviewLabel backgroundPreviewPane; |
|
private UIComboBox backScopeComboBox; |
|
|
|
public BackPane(final ConditionAttributesPane conditionAttributesPane) { |
|
super(conditionAttributesPane); |
|
backgroundLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Background") + ":"); |
|
this.backgroundPreviewPane = new BackgroundPreviewLabel(); |
|
this.backgroundPreviewPane.setPreferredSize(FineUIScale.scale(new Dimension(80, 20))); |
|
UIButton editBackgroundButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Edit")); |
|
editBackgroundButton.addActionListener(new ActionListener() { |
|
public void actionPerformed(ActionEvent e) { |
|
final BackgroundPane backgroundPane = new BackgroundPane(); |
|
backgroundPane.populate(backgroundPreviewPane.getBackgroundObject()); |
|
backgroundPane.showWindow( |
|
SwingUtilities.getWindowAncestor(conditionAttributesPane), new DialogActionAdapter() { |
|
public void doOk() { |
|
backgroundPreviewPane.setBackgroundObject(backgroundPane.update()); |
|
backgroundPreviewPane.repaint(); |
|
} |
|
}).setVisible(true); |
|
} |
|
}); |
|
this.backgroundPreviewPane.setBorder(new FineRoundBorder()); |
|
|
|
this.backScopeComboBox = new UIComboBox(new String[] { |
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Current_Cell"), |
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Current_Row"), |
|
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Current_Column") }); |
|
this.backScopeComboBox.putClientProperty(COMBO_BOX_TYPE, ADAPTIVE_COMBO_BOX); |
|
this.backgroundPreviewPane.setBackgroundObject(ColorBackground.getInstance(Color.WHITE)); |
|
|
|
this.add(row(10, cell(backgroundLabel).weight(0.2), row( |
|
10, |
|
cell(backgroundPreviewPane), |
|
cell(editBackgroundButton), |
|
cell(backScopeComboBox)).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_Base_Background"); |
|
} |
|
|
|
|
|
public void populate(HighlightAction ha) { |
|
this.backgroundPreviewPane.setBackgroundObject(((BackgroundHighlightAction) ha).getBackground()); |
|
this.backScopeComboBox.setSelectedIndex(((BackgroundHighlightAction) ha).getScope()); |
|
} |
|
|
|
public HighlightAction update() { |
|
return new BackgroundHighlightAction(this.backgroundPreviewPane.getBackgroundObject(), this.backScopeComboBox.getSelectedIndex()); |
|
} |
|
}
|
|
|