Browse Source
Merge in DESIGN/design from ~RICHARD.FANG/design:fbp/master to fbp/master * commit '85392ddf1da8be9420e660e6bcf3aad1a6e0a162': REPORT-138177 fix:国际化显示不全增加tooltip REPORT-137840 fix:事件-js参数区域无滚动条修复 REPORT-137614 fix:存储过程报错提示调整为折叠弹窗fbp/master
Richard.Fang-方超
1 month ago
4 changed files with 156 additions and 3 deletions
@ -0,0 +1,145 @@
|
||||
package com.fr.design.dialog; |
||||
|
||||
import com.fine.theme.icon.LazyIcon; |
||||
import com.fine.theme.utils.FineUIScale; |
||||
import com.fine.theme.utils.FineUIStyle; |
||||
import com.formdev.flatlaf.ui.FlatUIUtils; |
||||
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
||||
import com.fr.design.constants.LayoutConstants; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JDialog; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JTextArea; |
||||
|
||||
|
||||
import static com.fine.swing.ui.layout.Layouts.cell; |
||||
import static com.fine.swing.ui.layout.Layouts.row; |
||||
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.fix; |
||||
|
||||
/** |
||||
* 折叠弹窗 |
||||
* |
||||
* @author Richard |
||||
* @since 11.0 |
||||
* Created on 2024/10/22 |
||||
*/ |
||||
public class CollapsibleDetailDialog extends JDialog implements ActionListener { |
||||
|
||||
public JPanel upInTopPanel; |
||||
private JPanel downInTopPanel; |
||||
private JPanel topPanel; |
||||
public JPanel hiddenPanel; |
||||
private JPanel bottomPanel; |
||||
private UILabel directUILabel; |
||||
private UILabel detailLabel; |
||||
// 内容标题
|
||||
private final UILabel messageLabel; |
||||
// 详情
|
||||
private final String detailText; |
||||
private final Dimension collapseDimension = FineUIScale.createScaleDimension(450, 185); |
||||
private final Dimension unfoldDimension = FineUIScale.createScaleDimension(450, 280); |
||||
|
||||
public CollapsibleDetailDialog(Frame parent, UILabel label, String detailText) { |
||||
super(parent, true); |
||||
this.detailText = detailText; |
||||
this.messageLabel = label; |
||||
initComponent(); |
||||
} |
||||
|
||||
private void initComponent() { |
||||
initTopPanel(); |
||||
initHiddenPanel(); |
||||
initBottomPanel(); |
||||
addListeners(); |
||||
this.setResizable(false); |
||||
this.add(topPanel, BorderLayout.NORTH); |
||||
this.add(hiddenPanel, BorderLayout.CENTER); |
||||
this.add(bottomPanel, BorderLayout.SOUTH); |
||||
this.setSize(this.collapseDimension); |
||||
GUICoreUtils.centerWindow(this); |
||||
this.setAlwaysOnTop(true); |
||||
} |
||||
|
||||
private void initTopPanel() { |
||||
initUpInTopPanel(); |
||||
// 查看详情按钮
|
||||
directUILabel = new UILabel(); |
||||
directUILabel.setIcon(new LazyIcon("plus")); |
||||
detailLabel = new UILabel(); |
||||
detailLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||
downInTopPanel = row(fix(30), row(cell(directUILabel), cell(detailLabel), flex())).getComponent(); |
||||
topPanel = column(cell(upInTopPanel), cell(downInTopPanel)).getComponent(); |
||||
} |
||||
|
||||
private void initUpInTopPanel() { |
||||
upInTopPanel = row(LayoutConstants.HORIZONTAL_GAP, |
||||
column(cell(new UILabel(new LazyIcon("error", 20))), flex()), |
||||
column(cell(messageLabel))).getComponent(); |
||||
upInTopPanel.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); |
||||
} |
||||
|
||||
private void initHiddenPanel() { |
||||
hiddenPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
JScrollPane scrollPane = new JScrollPane(); |
||||
JTextArea textArea = new JTextArea(detailText); |
||||
scrollPane.setViewportView(textArea); |
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
||||
scrollPane.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); |
||||
scrollPane.getViewport().setOpaque(false); |
||||
textArea.setOpaque(false); |
||||
textArea.setEditable(false); |
||||
hiddenPanel = row(fix(30), cell(scrollPane).weight(1)).getComponent(); |
||||
hiddenPanel.setVisible(false); |
||||
hiddenPanel.setBorder(new ScaledEmptyBorder(0, 0, 0, 10)); |
||||
} |
||||
|
||||
private void initBottomPanel() { |
||||
//底部的按钮面板
|
||||
UIButton okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK")); |
||||
FineUIStyle.setStyle(okButton, FineUIStyle.STYLE_PRIMARY); |
||||
okButton.addActionListener(this); |
||||
bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); |
||||
bottomPanel.setBorder(new ScaledEmptyBorder(10, 10, 10, 10)); |
||||
bottomPanel.add(okButton, BorderLayout.EAST); |
||||
} |
||||
|
||||
private void addListeners() { |
||||
downInTopPanel.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
toggleHiddenPanel(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void toggleHiddenPanel() { |
||||
if (hiddenPanel.isVisible()) { |
||||
hiddenPanel.setVisible(false); |
||||
setSize(collapseDimension); |
||||
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); |
||||
directUILabel.setIcon(new LazyIcon("plus")); |
||||
} else { |
||||
setSize(unfoldDimension); |
||||
hiddenPanel.setVisible(true); |
||||
detailLabel.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); |
||||
directUILabel.setIcon(new LazyIcon("minus")); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
this.dispose(); |
||||
} |
||||
} |
Loading…
Reference in new issue