📄 selectfilewizardpage.java
字号:
package net.sf.pim.contract.wizard;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class SelectFileWizardPage extends WizardPage {
protected SelectFileWizardPage(String pageName) {
super(pageName);
setTitle("选择文件");
setDescription("请选择一个要导入的文件");
}
public void createControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new RowLayout());
Label label=new Label(composite,SWT.NONE);
label.setText("文件:");
final Text text=new Text(composite,SWT.NONE);
text.setText(" ");
Button button=new Button(composite,SWT.PUSH);
button.setText("浏览");
button.addSelectionListener(new SelectionListener(){
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
FileDialog fd = new FileDialog(composite.getShell(), SWT.OPEN | SWT.SINGLE);
fd.setText("请选择要导入的文件");
fd.setFilterExtensions(new String[]{"*.csv"});
fd.open();
String fname = fd.getFileName();
if (fname == null || fname.length() == 0)
return;
//处理文件名
String fileName = fd.getFilterPath() + "/" + fname;
text.setText(fileName);
((CSVWizard)SelectFileWizardPage.this.getWizard()).setFileName(fileName);
setPageComplete(true);
}
});
setControl(composite);
setPageComplete(false);
}
@Override
public IWizardPage getNextPage() {
//初始化一下下一页
MakeAssociationsWizardPage nextPage=(MakeAssociationsWizardPage) super.getNextPage();
nextPage.onEnterPage();
return nextPage;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -