📄 seleteinputdailog.java
字号:
package com.code10.face;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import com.code10.access.ReadProperty;
import com.code10.basecomponent.strDeal;
public class SeleteInputDailog {
private Shell sShell = null; // @jve:decl-index=0:visual-constraint="71,28"
private Text txtDba = null;
private Button button = null;
ReadProperty readProperty = ReadProperty.newInstance();
private Button buttonFileSelete = null;
private Button buttonDbSelete = null;
private Text txtFileSelete = null;
private CenterComposite parent = null;
/**
* This method initializes sShell
*/
public SeleteInputDailog(CenterComposite c){
parent = c;
}
public SeleteInputDailog(){
}
private void createSShell() {
sShell = new Shell();
sShell.setText("选择方式");
sShell.setSize(new org.eclipse.swt.graphics.Point(449,178));
txtDba = new Text(sShell, SWT.BORDER);
txtDba.setBounds(new org.eclipse.swt.graphics.Rectangle(33,70,236,25));
txtDba.setText(readProperty.getPara("smtpPassword"));
button = new Button(sShell, SWT.NONE);
button.setBounds(new org.eclipse.swt.graphics.Rectangle(182,107,99,21));
button.setText("确定");
buttonFileSelete = new Button(sShell, SWT.NONE);
buttonFileSelete.setBounds(new org.eclipse.swt.graphics.Rectangle(289,23,93,23));
buttonFileSelete.setText("选择文件");
buttonDbSelete = new Button(sShell, SWT.NONE);
buttonDbSelete.setBounds(new org.eclipse.swt.graphics.Rectangle(291,74,90,23));
buttonDbSelete.setText("选择数据表");
txtFileSelete = new Text(sShell, SWT.BORDER);
txtFileSelete.setBounds(new org.eclipse.swt.graphics.Rectangle(31,22,239,25));
button.addSelectionListener(new SelectionAdapter(){
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
@Override
public void widgetSelected(SelectionEvent e) {
String strAdd = txtFileSelete.getText();
File myFile = new File(strAdd);
String str;
String strContent = new String();
StringBuffer sB = new StringBuffer();
if(myFile.exists()){
FileReader fr;
try {
fr = new FileReader(myFile);
BufferedReader br = new BufferedReader(fr);
str=br.readLine();
while(str != null){
sB.append("\n" + str);
str = br.readLine();
}
strContent = sB.toString();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
ArrayList<String> argEmail = strDeal.parseEmail(strContent);
StringBuffer strBuf = new StringBuffer();
for(int i = 0 ; i < argEmail.size() ; i++){
strBuf.append(argEmail.get(i)).append(";") ;
}
strContent = strBuf.toString();
parent.setToStr(strContent);
sShell.dispose();
}
});
buttonFileSelete.addSelectionListener(new SelectionAdapter(){
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog fileDlg = new FileDialog(sShell,SWT.OPEN);
fileDlg.setFilterExtensions(new String[]{"*.txt"});
fileDlg.open();
txtFileSelete.setText(fileDlg.getFilterPath() + "\\" + fileDlg.getFileNames()[0]);
}
});
}
public void open(Display display){
createSShell();
sShell.open();
while (!sShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
sShell.dispose();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -