/*
* Created on 2004/07/27 Author aki@www.xucker.jpn.org License Apache2.0 or
* Common Public License
*/
package org.jpn.xucker.playdict;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class DictPreference implements SelectionListener {
/**
* @param shell
*/
private Group group1;
private Label filePath;
private Button browseButton;
private Button okButton;
private Button cancelButton;
Shell shell;
PlayDictMain playDictMain;
private Button useFreeTTSSound;
private Button freettsButton;
public Shell getShell() {
return shell;
}
public void setShell(Shell shell) {
this.shell = shell;
}
public String getSoundDirectory() {
return filePath.getText();
}
public void setSoundDirectory(String path) {
filePath.setText(path);
}
public DictPreference(PlayDictMain playDictMain, Shell shell) {
this.playDictMain = playDictMain;
this.shell = shell;
shell.setText("設定");
shell.setBounds(0, 0, 270, 150);
RowLayout layout = new RowLayout();
shell.setLayout(layout);
group1 = new Group(shell, SWT.NULL);
group1.setText("音声ファイルディレクトリー");
RowData group1_data = new RowData();
group1_data.width = 250;
group1.setLayoutData(group1_data);
RowLayout group1_layout = new RowLayout();
group1.setLayout(group1_layout);
filePath = new Label(group1, SWT.NULL);
filePath.setText("");
RowData filePath_data = new RowData();
filePath_data.width = 200;
filePath.setLayoutData(filePath_data);
//参照
browseButton = new Button(group1, SWT.NULL);
browseButton.setText("参照");
browseButton.addSelectionListener(this);
RowData browseButton_data = new RowData();
browseButton.setLayoutData(browseButton_data);
Group freettsgroup=new Group(shell,SWT.NULL);
freettsgroup.setLayout(new RowLayout());
freettsgroup.setText("Zipファイル");
RowData freettsgroup_data = new RowData();
freettsgroup_data.width=250;
freettsgroup.setLayoutData(freettsgroup_data);
freettsButton=new Button(freettsgroup,SWT.CHECK);
freettsButton.addSelectionListener(this);
freettsButton.setText("freetts_jmdict_wav.zipを使用する");
//OK
okButton = new Button(shell, SWT.NULL);
okButton.setText("OK");
okButton.addSelectionListener(this);
RowData okButton_data = new RowData();
okButton.setLayoutData(okButton_data);
//キャンセル
cancelButton = new Button(shell, SWT.NULL);
cancelButton.setText("キャンセル");
cancelButton.addSelectionListener(this);
RowData cancelButton_data = new RowData();
cancelButton.setLayoutData(cancelButton_data);
}
public void widgetSelected(SelectionEvent event) {
Object target = event.getSource();
if (target == null) {
//
System.out.println("target==null");
}
//参照
else if (target == browseButton) {
do_browseButton();
}
//OK
else if (target == okButton) {
do_okButton();
}
//キャンセル
else if (target == cancelButton) {
do_cancelButton();
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
//参照
public void do_browseButton() {
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN);
String path = dialog.open();
if (path != null) {
filePath.setText(path);
}
}
//OK
public void do_okButton() {
shell.close();
playDictMain.updatePreference(this);
}
//キャンセル
public void do_cancelButton() {
shell.close();
}
public boolean isFreeTTSJMDict(){
return freettsButton.getSelection();
}
public void setFreeTTSJMDict(boolean bool){
freettsButton.setSelection(bool);
}
}
|