/*
* Created on 2005/02/05
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.srtipod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.jpn.xucker.commons.ipod.TextUtil;
import org.jpn.xucker.commons.swt.ui.FileListImage;
import org.jpn.xucker.commons.swt.ui.FileListImageStatusChangeListener;
import org.jpn.xucker.subplayer.SubPlayMain;
/**
*
*
*/
public class SrtIPodMain implements FileListImageStatusChangeListener,SelectionListener{
public static Log log=LogFactory.getLog(SrtIPodMain.class);
/**
* @param shell
*/
Shell shell;
Button showTime;
Button noneTime;
Group group;
Button execButton;
double version=0.1;
public SrtIPodMain(Shell shell) {
this.shell=shell;
shell.setSize(214,330);
shell.setText("Srt字幕Note "+version);
shell.setBackground(new Color(null,0xff,0xff,0xff));
// TODO Auto-generated constructor stub
shell.setLayout(null);
FileListImage fileListImage=new FileListImage(shell,SWT.NULL);
fileListImage.setBounds(0+3,0,200,200);
fileListImage.setImage(new Image(Display.getCurrent(),
SubPlayMain.class.getClassLoader().getResourceAsStream(
"org/jpn/xucker/srtipod/resource/drugfile.png")));
group=new Group(shell,SWT.NULL);
group.setBackground(new Color(null,0xff,0xff,0xff));
group.setBounds(4+3,254,196,40);
group.setLayout(new FillLayout());
group.setText("[時間表示]");
showTime=new Button(group,SWT.RADIO);
showTime.setBackground(new Color(null,0xff,0xff,0xff));
showTime.setText("簡易");
noneTime=new Button(group,SWT.RADIO);
noneTime.setBackground(new Color(null,0xff,0xff,0xff));
noneTime.setText("表示しない");
group.layout();
execButton=new Button(shell,SWT.NULL);
execButton.setImage(new Image(Display.getCurrent(),
SubPlayMain.class.getClassLoader().getResourceAsStream(
"org/jpn/xucker/srtipod/resource/note.png")));
execButton.setBounds(50+3,200,100,50);
execButton.addSelectionListener(this);
fileListImage.setFocus();
execButton.setVisible(false);
fileListImage.addFileListImageStatusListener(this);
}
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display, SWT.CLOSE | SWT.MIN);
try {
SrtIPodMain main = new SrtIPodMain(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
} catch (Exception e) {
e.printStackTrace();
log.fatal(e.getMessage());
} finally {
if (!shell.isDisposed()) {
shell.close();
}
display.dispose();
System.exit(0);
}
}
/* (non-Javadoc)
* @see org.jpn.xucker.commons.swt.ui.FileListImageStatusChangeListener#imageMode()
*/
public void imageMode() {
execButton.setVisible(false);
}
/* (non-Javadoc)
* @see org.jpn.xucker.commons.swt.ui.FileListImageStatusChangeListener#fileMode()
*/
public void fileMode() {
execButton.setVisible(true);
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent event) {
Object target = event.getSource();
if (target == null) {
//maybe not happen.
log.warn("target==null");
}
//null1
else if (target == execButton) {
//do_button1();
execNote();
//mode play
}
}
/**
*
*/
private void execNote() {
String text="こんにちは";
log.info(""+TextUtil.countUTF8(text));
}
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetDefaultSelected(SelectionEvent arg0) {
// TODO Auto-generated method stub
}
}
|