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.
121 lines
5.3 KiB
121 lines
5.3 KiB
package com.fr.design.lock; |
|
|
|
import com.fr.design.file.TemplateTreePane; |
|
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.mainframe.DesignerContext; |
|
import com.fr.design.mainframe.DesignerFrameFileDealerPane; |
|
import com.fr.design.utils.TemplateUtils; |
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
import com.fr.file.FileNodeFILE; |
|
import com.fr.file.filetree.FileNode; |
|
import com.fr.general.IOUtils; |
|
import com.fr.stable.StableUtils; |
|
import com.fr.stable.StringUtils; |
|
import com.fr.stable.project.ProjectConstants; |
|
import com.fr.workspace.base.UserInfo; |
|
import java.awt.BorderLayout; |
|
import java.awt.Color; |
|
import java.awt.FlowLayout; |
|
import java.awt.event.ActionEvent; |
|
import java.awt.event.ActionListener; |
|
import java.time.LocalDateTime; |
|
import java.time.format.DateTimeFormatter; |
|
import javax.swing.BorderFactory; |
|
import javax.swing.JDialog; |
|
import javax.swing.JPanel; |
|
|
|
/** |
|
* @author hades |
|
* @version 11.0 |
|
* Created by hades on 2021/12/2 |
|
*/ |
|
public class LockInfoDialog extends JDialog { |
|
|
|
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm"); |
|
|
|
public LockInfoDialog(UserInfo userInfo) { |
|
super(DesignerContext.getDesignerFrame()); |
|
JPanel panel = new JPanel(new BorderLayout()); |
|
panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); |
|
panel.add(createContentPane(userInfo), BorderLayout.CENTER); |
|
panel.add(createControlPane(), BorderLayout.SOUTH); |
|
this.getContentPane().add(panel); |
|
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Title_Hint")); |
|
this.setSize(400, 160); |
|
this.setResizable(false); |
|
this.setModal(true); |
|
GUICoreUtils.centerWindow(this); |
|
this.setVisible(true); |
|
} |
|
|
|
private JPanel createContentPane(UserInfo userInfo) { |
|
JPanel contentPanel = new JPanel(new BorderLayout()); |
|
contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
|
JPanel messagePane = new JPanel(new BorderLayout(13, 0)); |
|
UILabel iconLabel = new UILabel(IOUtils.readIcon("/com/fr/design/images/warnings/warning32.png")); |
|
iconLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
|
messagePane.add(iconLabel, BorderLayout.WEST); |
|
UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Template_Lock_And_SaveAs_Tip")); |
|
tipLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
messagePane.add(tipLabel, BorderLayout.CENTER); |
|
contentPanel.add(messagePane, BorderLayout.NORTH); |
|
JPanel detailInfoPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); |
|
detailInfoPane.setBorder(BorderFactory.createEmptyBorder(0, 45, 0,0)); |
|
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getUserName())) { |
|
UILabel label = createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Holder", userInfo.getUserName())); |
|
label .setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); |
|
detailInfoPane.add(label); |
|
} |
|
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getIp())) { |
|
detailInfoPane.add(createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Holder_Ip", userInfo.getIp()) )); |
|
} |
|
detailInfoPane.add(createLabel(Toolkit.i18nText("Fine-Design_Template_Lock_Get_Time", FORMATTER.format(LocalDateTime.now())))); |
|
contentPanel.add(detailInfoPane, BorderLayout.CENTER); |
|
return contentPanel; |
|
} |
|
|
|
private UILabel createLabel(String text) { |
|
UILabel label = new UILabel(text); |
|
label.setForeground(Color.GRAY); |
|
label.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0)); |
|
return label; |
|
} |
|
|
|
private JPanel createControlPane() { |
|
JPanel controlPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 5)); |
|
controlPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0,5)); |
|
UIButton saveAsButton = new UIButton(Toolkit.i18nText("Fine_Design_Template_Lock_Save_As")); |
|
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")); |
|
saveAsButton.addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
dispose(); |
|
FileNode node = TemplateTreePane.getInstance().getFileNode(); |
|
if (node == null) { |
|
return; |
|
} |
|
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, TemplateTreePane.getInstance().getFilePath()); |
|
TemplateUtils.createAndOpenTemplate(Toolkit.i18nText("Fine_Design_Template_Lock_Copy"), new FileNodeFILE(new FileNode(selectedFilePath, false)), true); |
|
} |
|
}); |
|
cancelButton.addActionListener(new ActionListener() { |
|
@Override |
|
public void actionPerformed(ActionEvent e) { |
|
dispose(); |
|
} |
|
}); |
|
controlPane.add(saveAsButton); |
|
controlPane.add(cancelButton); |
|
return controlPane; |
|
} |
|
|
|
|
|
public static void show(UserInfo userInfo) { |
|
DesignerFrameFileDealerPane.getInstance().refreshRightToolBarBy(TemplateTreePane.getInstance().getFileNode()); |
|
new LockInfoDialog(userInfo); |
|
} |
|
|
|
}
|
|
|