|
|
|
package com.fr.env;
|
|
|
|
|
|
|
|
import com.fine.theme.utils.FineLayoutBuilder;
|
|
|
|
import com.fine.theme.utils.FineUIStyle;
|
|
|
|
import com.fr.design.beans.BasicBeanPane;
|
|
|
|
import com.fr.design.border.FineBorderFactory;
|
|
|
|
import com.fr.design.env.LocalDesignerWorkspaceInfo;
|
|
|
|
import com.fr.design.gui.ilable.UILabel;
|
|
|
|
import com.fr.design.gui.itextarea.UITextArea;
|
|
|
|
import com.fr.design.gui.itextfield.UITextField;
|
|
|
|
import com.fr.design.gui.itree.filetree.JFileTree;
|
|
|
|
import com.fr.design.i18n.Toolkit;
|
|
|
|
import com.fr.file.filter.OnlyShowDirectoryFileFilter;
|
|
|
|
import com.fr.stable.StringUtils;
|
|
|
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
import javax.swing.JScrollPane;
|
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell;
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.column;
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author yaohwu
|
|
|
|
*/
|
|
|
|
public class LocalEnvPane extends BasicBeanPane<LocalDesignerWorkspaceInfo> {
|
|
|
|
|
|
|
|
private UITextField pathTextField;
|
|
|
|
private JFileTree localEnvTree;
|
|
|
|
|
|
|
|
public LocalEnvPane() {
|
|
|
|
this.setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
pathTextField = new UITextField();
|
|
|
|
// 添加JFileTree
|
|
|
|
localEnvTree = new JFileTree();
|
|
|
|
FineUIStyle.setStyle(localEnvTree, FineUIStyle.PURE_TREE);
|
|
|
|
JScrollPane localEnvPane = new JScrollPane(localEnvTree);
|
|
|
|
|
|
|
|
JPanel centerPane = FineLayoutBuilder.asBorderLayoutWrapped(localEnvPane);
|
|
|
|
// 设置根路径File 和 文件过滤类型
|
|
|
|
localEnvTree.setFileFilter(new OnlyShowDirectoryFileFilter());
|
|
|
|
localEnvTree.setRootFiles(File.listRoots());
|
|
|
|
localEnvTree.addTreeSelectionListener(e -> {
|
|
|
|
File selectFile = localEnvTree.getSelectedFile();
|
|
|
|
if (selectFile == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pathTextField.setText(selectFile.getPath());
|
|
|
|
});
|
|
|
|
|
|
|
|
UITextArea description = new UITextArea();
|
|
|
|
description.setText(Toolkit.i18nText("Fine-Design_Basic_Env_Des1"));
|
|
|
|
description.setEditable(false);
|
|
|
|
|
|
|
|
this.add(column(10,
|
|
|
|
row(5,
|
|
|
|
cell(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Location") + ":")), cell(pathTextField).weight(1)
|
|
|
|
),
|
|
|
|
cell(centerPane).with(it -> it.setBorder(FineBorderFactory.createWrappedRoundBorder())).weight(1),
|
|
|
|
cell(description).with(it -> it.setBorder(null))
|
|
|
|
).getComponent());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String title4PopupWindow() {
|
|
|
|
return Toolkit.i18nText("Fine-Design_Basic_Location");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public LocalDesignerWorkspaceInfo updateBean() {
|
|
|
|
String path = pathTextField.getText();
|
|
|
|
return LocalDesignerWorkspaceInfo.create(StringUtils.EMPTY, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getPath() {
|
|
|
|
return pathTextField.getText();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void populateBean(LocalDesignerWorkspaceInfo ob) {
|
|
|
|
if (StringUtils.isBlank(ob.getPath())) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pathTextField.setText(ob.getPath());
|
|
|
|
|
|
|
|
final File tmpFile = new File(ob.getPath());
|
|
|
|
localEnvTree.selectFile(tmpFile);
|
|
|
|
localEnvTree.setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|