帆软报表设计器源代码。
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.
 
 
 
 

98 lines
3.2 KiB

package com.fr.env;
import com.fr.design.beans.BasicBeanPane;
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.design.layout.FRGUIPaneFactory;
import com.fr.file.filter.OnlyShowDirectoryFileFilter;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.BorderLayout;
import java.io.File;
/**
* @author yaohwu
*/
public class LocalEnvPane extends BasicBeanPane<LocalDesignerWorkspaceInfo> {
private UITextField pathTextField;
private JFileTree localEnvTree;
public LocalEnvPane() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
// northPane
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(northPane, BorderLayout.NORTH);
northPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Location") + ":"), BorderLayout.WEST);
pathTextField = new UITextField();
northPane.add(pathTextField, BorderLayout.CENTER);
// 删除选择文件按钮 添加JFileTree
// centerPane
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
// 添加JFileTree
localEnvTree = new JFileTree();
JScrollPane localEnvPane = new JScrollPane(localEnvTree);
centerPane.add(localEnvPane, BorderLayout.CENTER);
// 设置根路径File 和 文件过滤类型
localEnvTree.setFileFilter(new OnlyShowDirectoryFileFilter());
localEnvTree.setRootFiles(File.listRoots());
localEnvTree.addTreeSelectionListener(new TreeSelectionListener() {
@Override
public void valueChanged(TreeSelectionEvent e) {
File selectFile = localEnvTree.getSelectedFile();
if (selectFile == null) {
return;
}
pathTextField.setText(selectFile.getPath());
}
});
UITextArea description = new UITextArea();
centerPane.add(description, BorderLayout.SOUTH);
description.setText(Toolkit.i18nText("Fine-Design_Basic_Env_Des1"));
description.setEditable(false);
}
@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);
}
}