/*
* Created on 2004/12/03
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.subconverter;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.MessageBox;
import org.jpn.xucker.commons.swt.ui.FileDirChoicer;
import java.awt.CardLayout;
public class SubConverter implements SelectionListener{
/**
* @param shell
*/
Shell shell;
private double version=0.1;
private String HOMEPAGE_URL="http://www.xucker.jpn.org/";
private String APP_NAME="App";
private String inputFilePath=null;
public SubConverter(Shell shell) {
this.shell=shell;
shell.setText("");
shell.setBounds(0,0,500,400);
RowLayout layout=new RowLayout();
shell.setLayout(new FillLayout());
setFileChooseCanvas();
}
/**
*
*/
private void setFileChooseCanvas() {
Control[] controls=shell.getChildren();
if(controls.length>0){
controls[0].dispose();
}
FileChooseCanvasl canvas=new FileChooseCanvasl(shell,SWT.NULL);
canvas.setFilePath(inputFilePath);
}
public class SpumuxTextSubCanvas extends Canvas{
/**
* @param parent
* @param style
*/
public SpumuxTextSubCanvas(Composite parent, int style) {
super(parent, style);
// TODO Auto-generated constructor stub
Button convertButton=new Button(parent,SWT.NULL);
convertButton.setText("変換");
}
}
public class FileChooseCanvasl extends Canvas{
/**
* @param parent
* @param style
*/
public FileChooseCanvasl(Composite parent, int style) {
super(parent, style);
setLayout(new RowLayout());
// TODO Auto-generated constructor stub
Text text=new Text(this,SWT.MULTI);
text.setText("字幕ファイル選択");
RowData textData=new RowData();
textData.width=200;
textData.height=50;
text.setLayoutData(textData);
choicer = new FileDirChoicer(this,SWT.NULL,FileDirChoicer.FILE,null);
Button spumuxTextConvertButton=new Button(this,SWT.NULL);
spumuxTextConvertButton.setText("Spumux形式(テキスト)\r\n");
Button srtTextConvertButton=new Button(this,SWT.NULL);
srtTextConvertButton.setText("SRT形式(テキスト)\r\n");
Button subTextConvertButton=new Button(this,SWT.NULL);
subTextConvertButton.setText("SUB形式(テキスト)\r\n");
}
/**
* @param inputFilePath
*/
public void setFilePath(String inputFilePath) {
choicer.setFilePath(inputFilePath);
}
public String getFilePath() {
return choicer.getAbsoluteFilePath();
}
private FileDirChoicer choicer;
}
public static void main(String[] args) {
Display display=new Display();
Shell shell=new Shell(display,SWT.CLOSE|SWT.MIN);
try {
SubConverter main=new SubConverter(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (!shell.isDisposed()) {
shell.close();
}
display.dispose();
//System.exit(0);
}
}
public void widgetSelected(SelectionEvent event) {
Object target=event.getSource();
if(target==null){
//maybe not happen.
System.out.println("target==null");
}
}
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
public void execHomepage(){
Program program=Program.findProgram("html");
if(program!=null){
program.execute(HOMEPAGE_URL);
}
}
public void execVersion() {
MessageBox box = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
box.setMessage(APP_NAME+" v" + version + "\r\n\r\n"
+ "License CPL or Apache2.0\r\n (c)アッキー 2004\r\n"
+ HOMEPAGE_URL);
//int result=box.open();
//never use result int,for PMD
box.open();
}
}
|