Various changes related to Quicktime and JMF
support, as well as keyboard modularization. Not quite done yet, though, so may not compile.
This commit is contained in:
parent
3f17daab67
commit
7f3f0eb8e1
2 changed files with 246 additions and 151 deletions
|
@ -30,9 +30,13 @@ import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.dnd.*;
|
import java.awt.dnd.*;
|
||||||
import java.awt.datatransfer.*;
|
import java.awt.datatransfer.*;
|
||||||
|
import java.lang.reflect.*;
|
||||||
|
|
||||||
import org.thdl.tib.input.*;
|
import org.thdl.tib.input.*;
|
||||||
import org.thdl.tib.text.*;
|
import org.thdl.tib.text.*;
|
||||||
import org.thdl.tib.text.TibetanDocument.*;
|
import org.thdl.tib.text.TibetanDocument.*;
|
||||||
|
import org.thdl.savant.JdkVersionHacks;
|
||||||
|
import org.thdl.media.*;
|
||||||
|
|
||||||
import org.jdom.*;
|
import org.jdom.*;
|
||||||
import org.jdom.input.SAXBuilder;
|
import org.jdom.input.SAXBuilder;
|
||||||
|
@ -45,8 +49,12 @@ import org.thdl.util.ThdlDebug;
|
||||||
import org.thdl.util.ThdlActionListener;
|
import org.thdl.util.ThdlActionListener;
|
||||||
import org.thdl.util.ThdlAbstractAction;
|
import org.thdl.util.ThdlAbstractAction;
|
||||||
import org.thdl.util.ThdlOptions;
|
import org.thdl.util.ThdlOptions;
|
||||||
|
import org.thdl.util.SimpleSpinner;
|
||||||
|
|
||||||
public class QD extends JDesktopPane {
|
public class QD extends JDesktopPane {
|
||||||
|
private final static JskadKeyboardManager keybdMgr
|
||||||
|
= new JskadKeyboardManager(JskadKeyboardFactory.getAllAvailableJskadKeyboards());
|
||||||
|
|
||||||
//project related data
|
//project related data
|
||||||
protected Project project;
|
protected Project project;
|
||||||
|
|
||||||
|
@ -90,8 +98,6 @@ public class QD extends JDesktopPane {
|
||||||
protected TibetanDocument findDoc = null;
|
protected TibetanDocument findDoc = null;
|
||||||
protected TibetanDocument replaceDoc = null;
|
protected TibetanDocument replaceDoc = null;
|
||||||
|
|
||||||
protected URL keyboard_url = null;
|
|
||||||
|
|
||||||
protected KeyStroke cutKey, copyKey, pasteKey, selectAllKey;
|
protected KeyStroke cutKey, copyKey, pasteKey, selectAllKey;
|
||||||
protected KeyStroke insert1TimeKey, insert2TimesKey, insertSpeakerKey;
|
protected KeyStroke insert1TimeKey, insert2TimesKey, insertSpeakerKey;
|
||||||
protected KeyStroke findKey, replaceKey;
|
protected KeyStroke findKey, replaceKey;
|
||||||
|
@ -286,8 +292,7 @@ class TimePoint extends JLabel implements DragGestureListener, DragSourceListene
|
||||||
if (e.getButton() == MouseEvent.BUTTON1)
|
if (e.getButton() == MouseEvent.BUTTON1)
|
||||||
playSegment();
|
playSegment();
|
||||||
else {
|
else {
|
||||||
SpinnerNumberModel snm1 = new SpinnerNumberModel(0, 0, player.getEndTime(), 10);
|
SimpleSpinner spinner = new SimpleSpinner();
|
||||||
JSpinner spinner = new JSpinner(snm1);
|
|
||||||
spinner.setPreferredSize(new Dimension(100, 40));
|
spinner.setPreferredSize(new Dimension(100, 40));
|
||||||
spinner.setValue(getTime());
|
spinner.setValue(getTime());
|
||||||
if (JOptionPane.showOptionDialog(tp, spinner, messages.getString("AdjustTimeCode"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION)
|
if (JOptionPane.showOptionDialog(tp, spinner, messages.getString("AdjustTimeCode"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION)
|
||||||
|
@ -439,14 +444,13 @@ public class TimePointDropTarget implements DropTargetListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
class TimeCodeManager extends JPanel {
|
class TimeCodeManager extends JPanel {
|
||||||
JSpinner inSpinner, outSpinner;
|
SimpleSpinner inSpinner, outSpinner;
|
||||||
|
|
||||||
TimeCodeManager() {
|
TimeCodeManager() {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
JPanel inPanel = new JPanel();
|
JPanel inPanel = new JPanel();
|
||||||
JButton inButton = new JButton(messages.getString("In"));
|
JButton inButton = new JButton(messages.getString("In"));
|
||||||
SpinnerNumberModel snm1 = new SpinnerNumberModel(0, 0, player.getEndTime(), 10);
|
inSpinner = new SimpleSpinner();
|
||||||
inSpinner = new JSpinner(snm1);
|
|
||||||
inSpinner.setValue(new Integer(0));
|
inSpinner.setValue(new Integer(0));
|
||||||
inSpinner.setPreferredSize(new Dimension(100, inButton.getPreferredSize().height));
|
inSpinner.setPreferredSize(new Dimension(100, inButton.getPreferredSize().height));
|
||||||
inPanel.add(inButton);
|
inPanel.add(inButton);
|
||||||
|
@ -463,8 +467,7 @@ class TimeCodeManager extends JPanel {
|
||||||
|
|
||||||
JPanel outPanel = new JPanel();
|
JPanel outPanel = new JPanel();
|
||||||
JButton outButton = new JButton(messages.getString("Out"));
|
JButton outButton = new JButton(messages.getString("Out"));
|
||||||
SpinnerNumberModel snm2 = new SpinnerNumberModel(0, 0, player.getEndTime(), 10);
|
outSpinner = new SimpleSpinner();
|
||||||
outSpinner = new JSpinner(snm2);
|
|
||||||
outSpinner.setValue(new Integer(player.getEndTime()));
|
outSpinner.setValue(new Integer(player.getEndTime()));
|
||||||
outSpinner.setPreferredSize(new Dimension(100, inButton.getPreferredSize().height));
|
outSpinner.setPreferredSize(new Dimension(100, inButton.getPreferredSize().height));
|
||||||
outPanel.add(outButton);
|
outPanel.add(outButton);
|
||||||
|
@ -533,10 +536,10 @@ class TimeCodeManager extends JPanel {
|
||||||
add("North", box);
|
add("North", box);
|
||||||
}
|
}
|
||||||
public Integer getInTime() {
|
public Integer getInTime() {
|
||||||
return (Integer)inSpinner.getValue();
|
return inSpinner.getValue();
|
||||||
}
|
}
|
||||||
public Integer getOutTime() {
|
public Integer getOutTime() {
|
||||||
return (Integer)outSpinner.getValue();
|
return outSpinner.getValue();
|
||||||
}
|
}
|
||||||
public void setInTime(int k) {
|
public void setInTime(int k) {
|
||||||
inSpinner.setValue(new Integer(k));
|
inSpinner.setValue(new Integer(k));
|
||||||
|
@ -568,14 +571,14 @@ class Work {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMediaPlayerProperty(String property) {
|
public void setMediaPlayerProperty(String property) {
|
||||||
if (property.equals("jmf") || property.equals("qt4j"))
|
if (property.equals("org.thdl.media.SmartJMFPlayer") || property.equals("org.thdl.media.SmartQT4JPlayer"))
|
||||||
if (!thdl_mediaplayer_property.equals(property)) {
|
if (thdl_mediaplayer_property == null || !thdl_mediaplayer_property.equals(property)) {
|
||||||
thdl_mediaplayer_property = new String(property);
|
thdl_mediaplayer_property = new String(property);
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
File f = project.getMedia();
|
URL url = project.getMedia();
|
||||||
if (f != null) {
|
if (url != null) {
|
||||||
project.setMedia(null);
|
project.setMedia(null);
|
||||||
project.setMedia(f);
|
project.setMedia(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -590,12 +593,12 @@ public String getMediaPlayerProperty() {
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
os = "unknown";
|
os = "unknown";
|
||||||
}
|
}
|
||||||
if (os.indexOf("mac") != -1) //macs default to qt4j
|
if (os.indexOf("mac") != -1) //macs default to org.thdl.media.SmartQT4JPlayer
|
||||||
thdl_mediaplayer_property = ThdlOptions.getStringOption("thdl.media.player", "qt4j");
|
thdl_mediaplayer_property = ThdlOptions.getStringOption("thdl.media.player", "org.thdl.media.SmartQT4JPlayer");
|
||||||
else if (os.indexOf("windows") != -1)
|
else if (os.indexOf("windows") != -1)
|
||||||
thdl_mediaplayer_property = ThdlOptions.getStringOption("thdl.media.player", "jmf");
|
thdl_mediaplayer_property = ThdlOptions.getStringOption("thdl.media.player", "org.thdl.media.SmartJMFPlayer");
|
||||||
else //put linux etc. here
|
else //put linux etc. here
|
||||||
thdl_mediaplayer_property = ThdlOptions.getStringOption("thdl.media.player", "jmf");
|
thdl_mediaplayer_property = ThdlOptions.getStringOption("thdl.media.player", "org.thdl.media.SmartJMFPlayer");
|
||||||
}
|
}
|
||||||
return thdl_mediaplayer_property;
|
return thdl_mediaplayer_property;
|
||||||
}
|
}
|
||||||
|
@ -603,7 +606,7 @@ public String getMediaPlayerProperty() {
|
||||||
class Project extends JPanel {
|
class Project extends JPanel {
|
||||||
JTextField titleField, mediaField, transcriptField, nameField, taskField;
|
JTextField titleField, mediaField, transcriptField, nameField, taskField;
|
||||||
File transcript = null;
|
File transcript = null;
|
||||||
File media = null;
|
URL media = null;
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return titleField.getText();
|
return titleField.getText();
|
||||||
|
@ -633,12 +636,12 @@ public void setTranscript(File f) { //doesn't actually load or save transcript,
|
||||||
else
|
else
|
||||||
transcriptField.setText(transcript.getPath());
|
transcriptField.setText(transcript.getPath());
|
||||||
}
|
}
|
||||||
public File getMedia() {
|
public URL getMedia() {
|
||||||
return media;
|
return media;
|
||||||
}
|
}
|
||||||
public void setMedia(File f) {
|
public void setMedia(URL url) {
|
||||||
if (f == null) {
|
if (url == null) {
|
||||||
media = f;
|
media = url;
|
||||||
mediaField.setText("");
|
mediaField.setText("");
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -660,9 +663,6 @@ public void setMedia(File f) {
|
||||||
actionFrame.setSize(new Dimension(actionFrame.getSize().width, QD.this.getSize().height));
|
actionFrame.setSize(new Dimension(actionFrame.getSize().width, QD.this.getSize().height));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
|
||||||
URL url = f.toURL();
|
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
try {
|
try {
|
||||||
player.cmd_stop();
|
player.cmd_stop();
|
||||||
|
@ -677,26 +677,52 @@ public void setMedia(File f) {
|
||||||
try {
|
try {
|
||||||
if (thdl_mediaplayer_property == null)
|
if (thdl_mediaplayer_property == null)
|
||||||
thdl_mediaplayer_property = getMediaPlayerProperty();
|
thdl_mediaplayer_property = getMediaPlayerProperty();
|
||||||
if (thdl_mediaplayer_property.equals("qt4j")) {
|
|
||||||
player = new SmartQT4JPlayer();
|
Class mediaClass = Class.forName(thdl_mediaplayer_property);
|
||||||
player.loadMovie(url);
|
Class[] mediaArgsClass = new Class[] {Container.class, URL.class};
|
||||||
} else if (thdl_mediaplayer_property.equals("jmf")) {
|
Object[] mediaArgs = new Object[] {QD.this, url};
|
||||||
player = new SmartJMFPlayer(QD.this, url);
|
Constructor mediaConstructor = mediaClass.getConstructor(mediaArgsClass);
|
||||||
}
|
player = (SmartMoviePanel)createObject(mediaConstructor, mediaArgs);
|
||||||
media = f;
|
media = url;
|
||||||
mediaField.setText(media.getPath());
|
mediaField.setText(media.getPath());
|
||||||
startTimer();
|
startTimer();
|
||||||
} catch (SmartMoviePanelException smpe) {
|
|
||||||
smpe.printStackTrace();
|
//FIXME if neither media player is supported then friendly error rather than just doing nothing
|
||||||
|
|
||||||
|
|
||||||
|
} catch (ClassNotFoundException cnfe) {
|
||||||
|
cnfe.printStackTrace();
|
||||||
|
ThdlDebug.noteIffyCode();
|
||||||
|
} catch (NoSuchMethodException nsme) {
|
||||||
|
nsme.printStackTrace();
|
||||||
ThdlDebug.noteIffyCode();
|
ThdlDebug.noteIffyCode();
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException murle) {
|
|
||||||
murle.printStackTrace();
|
|
||||||
ThdlDebug.noteIffyCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object createObject(Constructor constructor,
|
||||||
|
Object[] arguments) {
|
||||||
|
|
||||||
|
System.out.println ("Constructor: " + constructor.toString());
|
||||||
|
Object object = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
object = constructor.newInstance(arguments);
|
||||||
|
System.out.println ("Object: " + object.toString());
|
||||||
|
return object;
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
System.out.println(e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
System.out.println(e);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
System.out.println(e);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
System.out.println(e);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Project() {
|
public Project() {
|
||||||
JPanel p = new JPanel(new GridLayout(2,2));
|
JPanel p = new JPanel(new GridLayout(2,2));
|
||||||
titleField = new JTextField();
|
titleField = new JTextField();
|
||||||
|
@ -763,43 +789,20 @@ public Project() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeKeyboard(ActionEvent e) {
|
public void changeKeyboard(JskadKeyboard kbd) {
|
||||||
DuffPane dp = (DuffPane)pane;
|
DuffPane dp = (DuffPane)pane;
|
||||||
if (e.getActionCommand().equals("wylie")) {
|
kbd.activate(dp);
|
||||||
dp.registerKeyboard();
|
kbd.activate(sharedDP);
|
||||||
// project.tName.setupKeyboard();
|
kbd.activate(sharedDP2);
|
||||||
// project.tTask.setupKeyboard();
|
|
||||||
sharedDP.setupKeyboard();
|
|
||||||
sharedDP2.setupKeyboard();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
keyboard_url = null;
|
|
||||||
if (e.getActionCommand().equals("sambhota1"))
|
|
||||||
keyboard_url = TibetanMachineWeb.class.getResource("sambhota_keyboard_1.ini");
|
|
||||||
else if (e.getActionCommand().equals("tcc1"))
|
|
||||||
keyboard_url = TibetanMachineWeb.class.getResource("tcc_keyboard_1.ini");
|
|
||||||
else if (e.getActionCommand().equals("tcc2"))
|
|
||||||
keyboard_url = TibetanMachineWeb.class.getResource("tcc_keyboard_2.ini");
|
|
||||||
dp.registerKeyboard(keyboard_url);
|
|
||||||
// project.tName.setupKeyboard();
|
|
||||||
// project.tTask.setupKeyboard();
|
|
||||||
sharedDP.setupKeyboard();
|
|
||||||
sharedDP2.setupKeyboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveTranscript() {
|
public boolean saveTranscript() {
|
||||||
currentWork.stopWork();
|
currentWork.stopWork();
|
||||||
|
|
||||||
|
//URGENT!! fix saving problem
|
||||||
|
|
||||||
//change keyboard back to wylie for a second
|
//change keyboard back to wylie for a second
|
||||||
DuffPane dp = (DuffPane)pane;
|
DuffPane dp = (DuffPane)pane;
|
||||||
if (keyboard_url != null) {
|
|
||||||
|
|
||||||
dp.registerKeyboard();
|
|
||||||
// project.tName.setupKeyboard();
|
|
||||||
// project.tTask.setupKeyboard();
|
|
||||||
sharedDP.setupKeyboard();
|
|
||||||
sharedDP.setupKeyboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
org.jdom.Element title = new org.jdom.Element("title");
|
org.jdom.Element title = new org.jdom.Element("title");
|
||||||
|
@ -810,11 +813,15 @@ if (keyboard_url != null) {
|
||||||
media.setText("");
|
media.setText("");
|
||||||
else {
|
else {
|
||||||
String tPath = project.getTranscript().getPath();
|
String tPath = project.getTranscript().getPath();
|
||||||
String mPath = project.getMedia().getPath();
|
String mPath = project.getMedia().getFile();
|
||||||
if (tPath.substring(0, tPath.lastIndexOf(File.separatorChar)).equals(mPath.substring(0, mPath.lastIndexOf(File.separatorChar))))
|
if (mPath == null)
|
||||||
media.setText(mPath.substring(mPath.lastIndexOf(File.separatorChar)+1));
|
media.setText(project.getMedia().toString());
|
||||||
else
|
else {
|
||||||
media.setText(mPath);
|
if (tPath.substring(0, tPath.lastIndexOf(File.separatorChar)).equals(mPath.substring(0, mPath.lastIndexOf(File.separatorChar))))
|
||||||
|
media.setText("file:" + mPath.substring(mPath.lastIndexOf(File.separatorChar)+1));
|
||||||
|
else
|
||||||
|
media.setText(project.getMedia().toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
org.jdom.Element speakers = new org.jdom.Element("speakers");
|
org.jdom.Element speakers = new org.jdom.Element("speakers");
|
||||||
|
@ -910,13 +917,7 @@ if (keyboard_url != null) {
|
||||||
File htmlOut = new File(f.substring(0, f.lastIndexOf('.')) + ".html");
|
File htmlOut = new File(f.substring(0, f.lastIndexOf('.')) + ".html");
|
||||||
transformer.transform(new JDOMSource(qdDoc), new StreamResult(new FileOutputStream(htmlOut)));
|
transformer.transform(new JDOMSource(qdDoc), new StreamResult(new FileOutputStream(htmlOut)));
|
||||||
|
|
||||||
if (keyboard_url != null) {
|
//URGENT FIX SAVING PROBLEM
|
||||||
dp.registerKeyboard(keyboard_url);
|
|
||||||
// project.tName.setupKeyboard();
|
|
||||||
// project.tTask.setupKeyboard();
|
|
||||||
sharedDP.setupKeyboard();
|
|
||||||
sharedDP2.setupKeyboard();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
|
@ -939,7 +940,6 @@ protected void clearProject() {
|
||||||
project.setMedia(null); //do this first to properly dispose of media player
|
project.setMedia(null); //do this first to properly dispose of media player
|
||||||
jtp.remove(project);
|
jtp.remove(project);
|
||||||
project = null;
|
project = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tcp != null) {
|
if (tcp != null) {
|
||||||
|
@ -949,6 +949,9 @@ protected void clearProject() {
|
||||||
|
|
||||||
SpeakerData sd = (SpeakerData)speakerTable.getModel();
|
SpeakerData sd = (SpeakerData)speakerTable.getModel();
|
||||||
sd.removeAllSpeakers();
|
sd.removeAllSpeakers();
|
||||||
|
speakerTable.invalidate();
|
||||||
|
speakerTable.validate();
|
||||||
|
speakerTable.repaint();
|
||||||
|
|
||||||
jtp.invalidate();
|
jtp.invalidate();
|
||||||
jtp.validate();
|
jtp.validate();
|
||||||
|
@ -957,11 +960,11 @@ protected void clearProject() {
|
||||||
pane.setText("");
|
pane.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void newProject(File mediaFile) {
|
public void newProject(URL mediaUrl) {
|
||||||
clearProject();
|
clearProject();
|
||||||
project = new Project();
|
project = new Project();
|
||||||
jtp.addTab(messages.getString("ProjectDetails"), project);
|
jtp.addTab(messages.getString("ProjectDetails"), project);
|
||||||
project.setMedia(mediaFile);
|
project.setMedia(mediaUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean loadTranscript(File t) {
|
public boolean loadTranscript(File t) {
|
||||||
|
@ -976,6 +979,10 @@ public boolean loadTranscript(File t) {
|
||||||
|
|
||||||
//change keyboard back to wylie for a second
|
//change keyboard back to wylie for a second
|
||||||
DuffPane dp = (DuffPane)pane;
|
DuffPane dp = (DuffPane)pane;
|
||||||
|
|
||||||
|
//URGENT FIX LOADING PROBLEM
|
||||||
|
|
||||||
|
/*
|
||||||
if (keyboard_url != null) {
|
if (keyboard_url != null) {
|
||||||
|
|
||||||
dp.registerKeyboard();
|
dp.registerKeyboard();
|
||||||
|
@ -985,7 +992,7 @@ if (keyboard_url != null) {
|
||||||
sharedDP.setupKeyboard();
|
sharedDP.setupKeyboard();
|
||||||
sharedDP2.setupKeyboard();
|
sharedDP2.setupKeyboard();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
org.jdom.Document doc = builder.build(t);
|
org.jdom.Document doc = builder.build(t);
|
||||||
org.jdom.Element qd = doc.getRootElement();
|
org.jdom.Element qd = doc.getRootElement();
|
||||||
|
@ -995,13 +1002,21 @@ if (keyboard_url != null) {
|
||||||
String mediaString = meta.getChild("mediafile").getText().trim();
|
String mediaString = meta.getChild("mediafile").getText().trim();
|
||||||
|
|
||||||
if (!mediaString.equals("")) {
|
if (!mediaString.equals("")) {
|
||||||
String tPath = t.getPath().substring(0, t.getPath().lastIndexOf(File.separatorChar)+1);
|
if (mediaString.startsWith("file:")) {
|
||||||
if (new File(tPath + mediaString).exists())
|
try {
|
||||||
project.setMedia(new File(tPath + mediaString));
|
String mPath = mediaString.substring(5);
|
||||||
else if (new File(mediaString).exists())
|
String tPath = t.getPath().substring(0, t.getPath().lastIndexOf(File.separatorChar)+1);
|
||||||
project.setMedia(new File(mediaString));
|
if (new File(tPath + mPath).exists())
|
||||||
else
|
project.setMedia(new URL("file:" + tPath + mPath));
|
||||||
project.setMedia(null);
|
else if (new File(mPath).exists())
|
||||||
|
project.setMedia(new URL("file:" + mPath));
|
||||||
|
else
|
||||||
|
project.setMedia(null);
|
||||||
|
} catch (MalformedURLException murle) {
|
||||||
|
murle.printStackTrace();
|
||||||
|
ThdlDebug.noteIffyCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
project.setMedia(null);
|
project.setMedia(null);
|
||||||
|
|
||||||
|
@ -1078,6 +1093,7 @@ if (keyboard_url != null) {
|
||||||
currentWork = new Work();
|
currentWork = new Work();
|
||||||
work.add(currentWork);
|
work.add(currentWork);
|
||||||
|
|
||||||
|
/* URGENT FIX LOADING PROBLEM
|
||||||
if (keyboard_url != null) {
|
if (keyboard_url != null) {
|
||||||
dp.registerKeyboard(keyboard_url);
|
dp.registerKeyboard(keyboard_url);
|
||||||
// project.tName.setupKeyboard();
|
// project.tName.setupKeyboard();
|
||||||
|
@ -1085,6 +1101,7 @@ if (keyboard_url != null) {
|
||||||
sharedDP.setupKeyboard();
|
sharedDP.setupKeyboard();
|
||||||
sharedDP2.setupKeyboard();
|
sharedDP2.setupKeyboard();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
project.setTranscript(t);
|
project.setTranscript(t);
|
||||||
jtp.addTab(messages.getString("ProjectDetails"), project);
|
jtp.addTab(messages.getString("ProjectDetails"), project);
|
||||||
|
|
|
@ -98,41 +98,82 @@ public class QDShell extends JFrame {
|
||||||
qd = new QD(messages);
|
qd = new QD(messages);
|
||||||
getContentPane().add(qd);
|
getContentPane().add(qd);
|
||||||
setJMenuBar(getQDShellMenu());
|
setJMenuBar(getQDShellMenu());
|
||||||
|
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
|
||||||
addWindowListener(new WindowAdapter () {
|
addWindowListener(new WindowAdapter () {
|
||||||
public void windowClosing (WindowEvent e) {
|
public void windowClosing (WindowEvent e) {
|
||||||
if (getSave())
|
if (getWantSave())
|
||||||
System.exit(0);
|
getSave();
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public JMenuBar getQDShellMenu() {
|
public JMenuBar getQDShellMenu() {
|
||||||
JMenu projectMenu = new JMenu(messages.getString("Project"));
|
JMenu projectMenu = new JMenu(messages.getString("Project"));
|
||||||
|
|
||||||
JMenuItem newItem = new JMenuItem(messages.getString("New"));
|
JMenuItem newItem = new JMenuItem(messages.getString("New"));
|
||||||
newItem.addActionListener(new ThdlActionListener() {
|
newItem.addActionListener(new ThdlActionListener() {
|
||||||
public void theRealActionPerformed(ActionEvent e) {
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
if (getSave()) {
|
if (getWantSave())
|
||||||
JFileChooser fc = new JFileChooser();
|
getSave();
|
||||||
if (fc.showDialog(QDShell.this, messages.getString("SelectMedia")) == JFileChooser.APPROVE_OPTION) {
|
qd.clearProject();
|
||||||
File mediaFile = fc.getSelectedFile();
|
|
||||||
qd.newProject(mediaFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
JMenuItem openItem = new JMenuItem(messages.getString("Open"));
|
|
||||||
openItem.addActionListener(new ThdlActionListener() {
|
JMenuItem openVideoItem = new JMenuItem(messages.getString("OpenMediaFile"));
|
||||||
|
openVideoItem.addActionListener(new ThdlActionListener() {
|
||||||
public void theRealActionPerformed(ActionEvent e) {
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
if (getSave()) {
|
if (getWantSave())
|
||||||
JFileChooser fc = new JFileChooser();
|
getSave();
|
||||||
fc.addChoosableFileFilter(new QDFileFilter());
|
|
||||||
if (fc.showDialog(QDShell.this, messages.getString("OpenTranscript")) == JFileChooser.APPROVE_OPTION) {
|
JFileChooser fc = new JFileChooser();
|
||||||
File transcriptFile = fc.getSelectedFile();
|
if (fc.showDialog(QDShell.this, messages.getString("SelectMedia")) == JFileChooser.APPROVE_OPTION) {
|
||||||
qd.loadTranscript(transcriptFile);
|
File mediaFile = fc.getSelectedFile();
|
||||||
|
try {
|
||||||
|
qd.newProject(mediaFile.toURL());
|
||||||
|
} catch (MalformedURLException murle) {
|
||||||
|
murle.printStackTrace();
|
||||||
|
ThdlDebug.noteIffyCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
JMenuItem openURLItem = new JMenuItem(messages.getString("OpenMediaURL"));
|
||||||
|
openURLItem.addActionListener(new ThdlActionListener() {
|
||||||
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
String url = JOptionPane.showInputDialog(QDShell.this,
|
||||||
|
messages.getString("TypeMediaURL"));
|
||||||
|
if (url != null) {
|
||||||
|
if (getWantSave())
|
||||||
|
getSave();
|
||||||
|
|
||||||
|
try {
|
||||||
|
qd.newProject(new URL(url));
|
||||||
|
} catch (MalformedURLException murle) {
|
||||||
|
murle.printStackTrace();
|
||||||
|
ThdlDebug.noteIffyCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JMenuItem openItem = new JMenuItem(messages.getString("OpenTranscript"));
|
||||||
|
openItem.addActionListener(new ThdlActionListener() {
|
||||||
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
if (getWantSave())
|
||||||
|
getSave();
|
||||||
|
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.addChoosableFileFilter(new QDFileFilter());
|
||||||
|
if (fc.showDialog(QDShell.this, messages.getString("OpenTranscript")) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
File transcriptFile = fc.getSelectedFile();
|
||||||
|
qd.loadTranscript(transcriptFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
JMenuItem closeItem = new JMenuItem(messages.getString("Close"));
|
JMenuItem closeItem = new JMenuItem(messages.getString("Close"));
|
||||||
closeItem.addActionListener(new ThdlActionListener() {
|
closeItem.addActionListener(new ThdlActionListener() {
|
||||||
public void theRealActionPerformed(ActionEvent e) {
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
@ -140,6 +181,7 @@ public class QDShell extends JFrame {
|
||||||
qd.clearProject();
|
qd.clearProject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
JMenuItem saveItem = new JMenuItem(messages.getString("Save"));
|
JMenuItem saveItem = new JMenuItem(messages.getString("Save"));
|
||||||
saveItem.addActionListener(new ThdlActionListener() {
|
saveItem.addActionListener(new ThdlActionListener() {
|
||||||
|
@ -150,20 +192,30 @@ public class QDShell extends JFrame {
|
||||||
JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
|
JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
|
||||||
quitItem.addActionListener(new ThdlActionListener() {
|
quitItem.addActionListener(new ThdlActionListener() {
|
||||||
public void theRealActionPerformed(ActionEvent e) {
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
if (getSave())
|
if (getWantSave())
|
||||||
System.exit(0);
|
getSave();
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
projectMenu.add(newItem);
|
projectMenu.add(newItem);
|
||||||
projectMenu.add(openItem);
|
|
||||||
projectMenu.add(closeItem);
|
|
||||||
projectMenu.addSeparator();
|
projectMenu.addSeparator();
|
||||||
|
projectMenu.add(openVideoItem);
|
||||||
|
projectMenu.add(openURLItem);
|
||||||
|
projectMenu.add(openItem);
|
||||||
|
projectMenu.addSeparator();
|
||||||
|
// projectMenu.add(closeItem);
|
||||||
|
// projectMenu.addSeparator();
|
||||||
projectMenu.add(saveItem);
|
projectMenu.add(saveItem);
|
||||||
projectMenu.addSeparator();
|
projectMenu.addSeparator();
|
||||||
projectMenu.add(quitItem);
|
projectMenu.add(quitItem);
|
||||||
|
|
||||||
//Tibetan-specific value: remove in non-Tibetan version
|
//Tibetan-specific value: remove in non-Tibetan version
|
||||||
//non-Tibetan specific version would have Transcription Language option here instead
|
//non-Tibetan specific version would have Transcription Language option here instead
|
||||||
|
|
||||||
|
|
||||||
|
/* Note that on the Mac, you radio buttons don't appear possible as
|
||||||
|
submenus on menu bars. They just don't show up.
|
||||||
|
|
||||||
JRadioButton[] buttons = new JRadioButton[4];
|
JRadioButton[] buttons = new JRadioButton[4];
|
||||||
buttons[0] = new JRadioButton("THDL Extended Wylie");
|
buttons[0] = new JRadioButton("THDL Extended Wylie");
|
||||||
buttons[1] = new JRadioButton("TCC Keyboard 1");
|
buttons[1] = new JRadioButton("TCC Keyboard 1");
|
||||||
|
@ -199,38 +251,53 @@ public class QDShell extends JFrame {
|
||||||
|
|
||||||
buttons[initialKeyboard].setSelected(true);
|
buttons[initialKeyboard].setSelected(true);
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
JMenu keyboardMenu = new JMenu(messages.getString("Keyboard"));
|
JMenu keyboardMenu = new JMenu(messages.getString("Keyboard"));
|
||||||
keyboardMenu.add(b1);
|
|
||||||
|
|
||||||
|
for (int i = 0; i < keybdMgr.size(); i++) {
|
||||||
|
final JskadKeyboard kbd = keybdMgr.elementAt(i);
|
||||||
|
if (kbd.hasQuickRefFile()) {
|
||||||
|
JMenuItem keybdItem = new JMenuItem(kbd.getIdentifyingString());
|
||||||
|
keybdItem.addActionListener(new ThdlActionListener() {
|
||||||
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
qd.changeKeyboard(kbd);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
keyboardMenu.add(keybdItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JRadioButton[] buttons2 = new JRadioButton[2];
|
|
||||||
buttons2[0] = new JRadioButton("Java Media Framework");
|
|
||||||
buttons2[1] = new JRadioButton("Quicktime for Java");
|
|
||||||
buttons2[0].setActionCommand("jmf");
|
|
||||||
buttons2[1].setActionCommand("qt4j");
|
|
||||||
ThdlActionListener l2 = new ThdlActionListener() {
|
|
||||||
public void theRealActionPerformed(ActionEvent e) {
|
|
||||||
qd.setMediaPlayerProperty(e.getActionCommand());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
buttons2[0].addActionListener(l2);
|
|
||||||
buttons2[1].addActionListener(l2);
|
|
||||||
ButtonGroup bg2 = new ButtonGroup();
|
|
||||||
bg2.add(buttons2[0]);
|
|
||||||
bg2.add(buttons2[1]);
|
|
||||||
JPanel b2 = new JPanel(new GridLayout(0,1));
|
|
||||||
b2.add(buttons2[0]);
|
|
||||||
b2.add(buttons2[1]);
|
|
||||||
|
|
||||||
String initialMediaPlayer = qd.getMediaPlayerProperty();
|
|
||||||
if (initialMediaPlayer.equals("jmf"))
|
|
||||||
buttons2[0].setSelected(true);
|
|
||||||
else if (initialMediaPlayer.equals("qt4j"))
|
|
||||||
buttons2[1].setSelected(true);
|
|
||||||
|
|
||||||
JMenu mediaPlayerMenu = new JMenu(messages.getString("MediaPlayer"));
|
JMenu mediaPlayerMenu = new JMenu(messages.getString("MediaPlayer"));
|
||||||
mediaPlayerMenu.add(b2);
|
|
||||||
|
for (int i = 0; i < keybdMgr.size(); i++) {
|
||||||
|
final JskadKeyboard kbd = keybdMgr.elementAt(i);
|
||||||
|
if (kbd.hasQuickRefFile()) {
|
||||||
|
JMenuItem keybdItem = new JMenuItem(kbd.getIdentifyingString());
|
||||||
|
keybdItem.addActionListener(new ThdlActionListener() {
|
||||||
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
qd.changeKeyboard(kbd);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
keyboardMenu.add(keybdItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JMenuItem jmfItem = new JMenuItem("Java Media Framework");
|
||||||
|
jmfItem.addActionListener(new ThdlActionListener() {
|
||||||
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
qd.setMediaPlayerProperty("org.thdl.media.SmartJMFPlayer");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JMenuItem qtItem = new JMenuItem("Quicktime for Java");
|
||||||
|
qtItem.addActionListener(new ThdlActionListener() {
|
||||||
|
public void theRealActionPerformed(ActionEvent e) {
|
||||||
|
qd.setMediaPlayerProperty("org.thdl.media.SmartQT4JPlayer");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
JMenu preferencesMenu = new JMenu(messages.getString("Preferences"));
|
JMenu preferencesMenu = new JMenu(messages.getString("Preferences"));
|
||||||
preferencesMenu.add(keyboardMenu);
|
preferencesMenu.add(keyboardMenu);
|
||||||
|
@ -241,9 +308,18 @@ public class QDShell extends JFrame {
|
||||||
bar.add(preferencesMenu);
|
bar.add(preferencesMenu);
|
||||||
return bar;
|
return bar;
|
||||||
}
|
}
|
||||||
private boolean getSave() {
|
private boolean getWantSave() {
|
||||||
if (qd.pane.getDocument().getLength() == 0 && qd.speakerTable.getRowCount() == 0)
|
if (qd.pane.getDocument().getLength() == 0 && qd.speakerTable.getRowCount() == 0)
|
||||||
return true; //nothing to save
|
return false; //nothing to save
|
||||||
|
|
||||||
|
if (JOptionPane.showConfirmDialog(QDShell.this, messages.getString("WantSave"), null, JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.YES_OPTION)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private void getSave() {
|
||||||
|
if (qd.pane.getDocument().getLength() == 0 && qd.speakerTable.getRowCount() == 0)
|
||||||
|
return; //nothing to save
|
||||||
|
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser();
|
||||||
if (qd.project.getTranscript() == null) {
|
if (qd.project.getTranscript() == null) {
|
||||||
|
@ -254,13 +330,15 @@ public class QDShell extends JFrame {
|
||||||
path = path.substring(0, path.lastIndexOf('.')) + QDShell.dotQuillDriver;
|
path = path.substring(0, path.lastIndexOf('.')) + QDShell.dotQuillDriver;
|
||||||
fc.setSelectedFile(new File(path));
|
fc.setSelectedFile(new File(path));
|
||||||
}
|
}
|
||||||
if (fc.showSaveDialog(QDShell.this) == JFileChooser.APPROVE_OPTION) {
|
} else
|
||||||
File f = fc.getSelectedFile();
|
fc.setSelectedFile(qd.project.getTranscript());
|
||||||
qd.project.setTranscript(f);
|
|
||||||
} else
|
int op = fc.showSaveDialog(QDShell.this);
|
||||||
return false;
|
if (op == JFileChooser.APPROVE_OPTION) {
|
||||||
|
File f = fc.getSelectedFile();
|
||||||
|
qd.project.setTranscript(f);
|
||||||
|
qd.saveTranscript();
|
||||||
}
|
}
|
||||||
return qd.saveTranscript();
|
|
||||||
}
|
}
|
||||||
private class QDFileFilter extends javax.swing.filechooser.FileFilter {
|
private class QDFileFilter extends javax.swing.filechooser.FileFilter {
|
||||||
// accepts all directories and all savant files
|
// accepts all directories and all savant files
|
||||||
|
@ -277,4 +355,4 @@ public class QDShell extends JFrame {
|
||||||
return "QD File Format (" + QDShell.dotQuillDriver + ")";
|
return "QD File Format (" + QDShell.dotQuillDriver + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue