package com.fr.plugin.file.submit.oss.ui; import com.fr.design.beans.BasicBeanPane; import com.fanruan.api.design.ui.editor.ValueEditorPane; import com.fanruan.api.design.ui.component.UIComboBox; import com.fanruan.api.design.ui.component.UILabel; import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.layout.TableLayoutKit; import com.fanruan.api.util.GeneralKit; import com.fr.plugin.file.submit.oss.fun.OssVariableValue; import com.fr.plugin.file.submit.oss.script.OssDownloadHyperlink; import com.fr.plugin.oss.universal.config.OssUniversalConfig; import javax.swing.*; import java.awt.*; public class OssHyperlink4DownloadPane extends BasicBeanPane { private UIComboBox bucketComboBox; private ValueEditorPane directoryValuePane; private ValueEditorPane fileNameValuePane; public OssHyperlink4DownloadPane() { initComponents(); } private void initComponents() { this.setLayout(new BorderLayout()); this.bucketComboBox = new UIComboBox(OssUniversalConfig.getInstance().getArrayBuckets()); this.directoryValuePane = Editors.createValueEditorPane(); this.fileNameValuePane = Editors.createValueEditorPane(); double p = TableLayoutKit.PREFERRED; double f = TableLayoutKit.FILL; double[] rowSize = {p, p, p}; double[] columnSize = {p, f}; JPanel centerPane = TableLayoutKit.createTableLayoutPane( new Component[][] { {new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Bucket_Name") + ":"), bucketComboBox}, {new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_Directory") + ":"), directoryValuePane}, {new UILabel(DesignKit.i18nText("Plugin-File_Submit_Oss_File_Name") + ":"), fileNameValuePane} }, rowSize, columnSize); this.add(centerPane, BorderLayout.CENTER); } @Override public void populateBean(OssDownloadHyperlink hyperlink) { if (hyperlink == null) { return; } bucketComboBox.setSelectedItem(hyperlink.getBucket()); directoryValuePane.populate(hyperlink.getDirectory() == null ? null : hyperlink.getDirectory().getValue()); fileNameValuePane.populate(hyperlink.getFileName() == null ? null : hyperlink.getFileName().getValue()); } @Override public OssDownloadHyperlink updateBean() { OssDownloadHyperlink hyperlink = new OssDownloadHyperlink(); hyperlink.setBucket(GeneralKit.objectToString(bucketComboBox.getSelectedItem())); hyperlink.setDirectory(new OssVariableValue(directoryValuePane.update())); hyperlink.setFileName(new OssVariableValue(fileNameValuePane.update())); return hyperlink; } @Override protected String title4PopupWindow() { return DesignKit.i18nText("Plugin-File_Download_Hyperlink"); } }