/*
* Created on 2004/09/27
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.commons.swt.ui;
import java.io.File;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.jpn.xucker.commons.util.AbstractBasicFileApplication;
/**
*
*
*/
public abstract class SWTBasicFileApplication extends AbstractBasicFileApplication{
protected Shell shell;
public Shell getShell() {
return shell;
}
public void setShell(Shell shell) {
this.shell = shell;
}
/* (non-Javadoc)
* @see org.jpn.xucker.rssCreator.AbstractBasicFileApplication#execOpen()
*/
private String defaultFileName;
protected File execChooseOpenFile() {
FileDialog dialog=new FileDialog(shell,SWT.OPEN);
if(getFileExtension()!=null){
String extension[]=new String[1];
extension[0]="*."+getFileExtension();
dialog.setFilterExtensions(extension);
}
String path=dialog.open();
if(path!=null){
return new File(path);
}else{
return null;
}
}
/* (non-Javadoc)
* @see org.jpn.xucker.rssCreator.AbstractBasicFileApplication#execChooseSave()
*/
protected File execChooseSaveFile() {
FileDialog dialog=new FileDialog(shell,SWT.SAVE);
String path=dialog.open();
if(path!=null){
return new File(fixFileExtension(path));
}else{
return null;
}
}
/* (non-Javadoc)
* @see org.jpn.xucker.rssCreator.AbstractBasicFileApplication#executeAskSave(java.lang.String, java.lang.String)
*/
protected int executeAskSave(String title, String message) {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL);
box.setText(title);
box.setMessage(message);
int result=box.open();
if(result==SWT.YES){
return AbstractBasicFileApplication.YES;
}else if(result==SWT.NO){
return AbstractBasicFileApplication.NO;
}else{
return AbstractBasicFileApplication.CANCEL;
}
}
public String getDefaultFileName() {
return defaultFileName;
}
public void setDefaultFileName(String defaultFileName) {
this.defaultFileName = defaultFileName;
}
}
|