-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add application support, useful for writing package apps supported th…
…rough BEAST appstore
- Loading branch information
1 parent
7e64724
commit d8b52bb
Showing
13 changed files
with
694 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package beast.app.beauti; | ||
|
||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
|
||
import javax.swing.JButton; | ||
|
||
import beast.app.draw.InputEditor; | ||
import beast.app.util.Utils; | ||
import beast.core.BEASTInterface; | ||
import beast.core.Input; | ||
|
||
|
||
/** for opening files for reading | ||
* use OutFile when you need a file for writing | ||
*/ | ||
public class FileInputEditor extends InputEditor.Base { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public Class<?> type() { | ||
return File.class; | ||
} | ||
|
||
public FileInputEditor(BeautiDoc doc) { | ||
super(doc); | ||
} | ||
|
||
@Override | ||
public void init(Input<?> input, BEASTInterface plugin, int itemNr, ExpandOption bExpandOption, boolean bAddButtons) { | ||
super.init(input, plugin, itemNr, bExpandOption, bAddButtons); | ||
if (input.get() == null) { | ||
m_entry.setText("[[none]]"); | ||
} else { | ||
m_entry.setText(((File) m_input.get()).getName()); | ||
} | ||
|
||
JButton button = new JButton("browse"); | ||
button.addActionListener(new ActionListener() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent arg0) { | ||
File defaultFile; | ||
if (m_input.get() != null && ((File) m_input.get()).exists()) { | ||
defaultFile = (File) m_input.get(); | ||
} else { | ||
defaultFile = new File(Beauti.g_sDir); | ||
} | ||
File file = Utils.getLoadFile(m_input.getTipText(), defaultFile, "All files", ""); | ||
try { | ||
m_entry.setText(file.getName()); | ||
m_input.setValue(file, m_beastObject); | ||
String path = file.getPath(); | ||
Beauti.g_sDir = path; | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
add(button); | ||
} | ||
|
||
@Override | ||
protected void setValue(Object o) { | ||
String file = o.toString(); | ||
if (file.equals("")) { | ||
return; | ||
} | ||
String fileSep = System.getProperty("file.separator"); | ||
String origFile = ((File) m_input.get()).getAbsolutePath(); | ||
if (origFile.indexOf(fileSep) >= 0 && file.indexOf(fileSep) < 0) { | ||
if (origFile.contains(origFile)) { | ||
file = origFile.substring(0, origFile.lastIndexOf(fileSep) + 1) + file; | ||
} | ||
} | ||
m_input.setValue(file, m_beastObject); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package beast.app.beauti; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
|
||
import javax.swing.JButton; | ||
|
||
import beast.app.draw.InputEditor; | ||
import beast.app.util.LogFile; | ||
import beast.app.util.Utils; | ||
import beast.core.BEASTInterface; | ||
import beast.core.Input; | ||
|
||
public class LogFileInputEditor extends InputEditor.Base { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public Class<?> type() { | ||
return LogFile.class; | ||
} | ||
|
||
public LogFileInputEditor(BeautiDoc doc) { | ||
super(doc); | ||
} | ||
|
||
@Override | ||
public void init(Input<?> input, BEASTInterface plugin, int itemNr, ExpandOption bExpandOption, boolean bAddButtons) { | ||
super.init(input, plugin, itemNr, bExpandOption, bAddButtons); | ||
m_entry.setText(((File) m_input.get()).getName()); | ||
|
||
JButton button = new JButton("browse"); | ||
button.addActionListener(new ActionListener() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent arg0) { | ||
File defaultFile; | ||
if (((File) m_input.get()).exists()) { | ||
defaultFile = (File) m_input.get(); | ||
} else { | ||
defaultFile = new File(Beauti.g_sDir); | ||
} | ||
File file = Utils.getLoadFile(m_input.getTipText(), defaultFile, "trace files", "log"); | ||
if (file != null) | ||
file = new LogFile(file.getPath()); | ||
try { | ||
m_entry.setText(file.getName()); | ||
m_input.setValue(file, m_beastObject); | ||
String path = file.getPath(); | ||
Beauti.g_sDir = path; | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
add(button); | ||
} | ||
|
||
@Override | ||
protected void setValue(Object o) { | ||
String file = o.toString(); | ||
if (file.equals("")) { | ||
return; | ||
} | ||
String fileSep = System.getProperty("file.separator"); | ||
String origFile = ((File) m_input.get()).getAbsolutePath(); | ||
if (origFile.indexOf(fileSep) >= 0 && file.indexOf(fileSep) < 0) { | ||
if (origFile.contains(origFile)) { | ||
file = origFile.substring(0, origFile.lastIndexOf(fileSep) + 1) + file; | ||
} | ||
} | ||
m_input.setValue(file, m_beastObject); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package beast.app.beauti; | ||
|
||
|
||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
|
||
import javax.swing.JButton; | ||
|
||
import beast.app.util.OutFile; | ||
import beast.app.util.Utils; | ||
import beast.core.BEASTInterface; | ||
import beast.core.Input; | ||
import beast.app.draw.InputEditor; | ||
|
||
public class OutFileInputEditor extends InputEditor.Base { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public Class<?> type() { | ||
return OutFile.class; | ||
} | ||
|
||
public OutFileInputEditor(BeautiDoc doc) { | ||
super(doc); | ||
} | ||
|
||
@Override | ||
public void init(Input<?> input, BEASTInterface plugin, int itemNr, ExpandOption bExpandOption, boolean bAddButtons) { | ||
super.init(input, plugin, itemNr, bExpandOption, bAddButtons); | ||
m_entry.setText(((File) m_input.get()).getName()); | ||
|
||
JButton button = new JButton("browse"); | ||
button.addActionListener(new ActionListener() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent arg0) { | ||
File defaultFile; | ||
if (((File) m_input.get()).exists()) { | ||
defaultFile = (File) m_input.get(); | ||
} else { | ||
defaultFile = new File(Beauti.g_sDir); | ||
} | ||
File file = Utils.getSaveFile(m_input.getTipText(), defaultFile, "All files", ""); | ||
if (file != null) | ||
file = new OutFile(file.getPath()); | ||
try { | ||
m_entry.setText(file.getName()); | ||
m_input.setValue(file, m_beastObject); | ||
String path = file.getPath(); | ||
Beauti.g_sDir = path; | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
add(button); | ||
} | ||
|
||
|
||
@Override | ||
protected void setValue(Object o) { | ||
String file = o.toString(); | ||
if (file.equals("")) { | ||
return; | ||
} | ||
String fileSep = System.getProperty("file.separator"); | ||
String origFile = ((File) m_input.get()).getAbsolutePath(); | ||
if (origFile.indexOf(fileSep) >= 0 && file.indexOf(fileSep) < 0) { | ||
if (origFile.contains(origFile)) { | ||
file = origFile.substring(0, origFile.lastIndexOf(fileSep) + 1) + file; | ||
} | ||
} | ||
m_input.setValue(file, m_beastObject); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package beast.app.beauti; | ||
|
||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
|
||
import javax.swing.JButton; | ||
|
||
import beast.app.draw.InputEditor; | ||
import beast.app.util.XMLFile; | ||
import beast.app.util.Utils; | ||
import beast.core.BEASTInterface; | ||
import beast.core.Input; | ||
|
||
public class TreeFileInputEditor extends InputEditor.Base { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public Class<?> type() { | ||
return XMLFile.class; | ||
} | ||
|
||
public TreeFileInputEditor(BeautiDoc doc) { | ||
super(doc); | ||
} | ||
|
||
@Override | ||
public void init(Input<?> input, BEASTInterface plugin, int itemNr, ExpandOption bExpandOption, boolean bAddButtons) { | ||
super.init(input, plugin, itemNr, bExpandOption, bAddButtons); | ||
m_entry.setText(((File) m_input.get()).getName()); | ||
|
||
JButton button = new JButton("browse"); | ||
button.addActionListener(new ActionListener() { | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent arg0) { | ||
File defaultFile; | ||
if (((File) m_input.get()).exists()) { | ||
defaultFile = (File) m_input.get(); | ||
} else { | ||
defaultFile = new File(Beauti.g_sDir); | ||
} | ||
File file = Utils.getLoadFile(m_input.getTipText(), defaultFile, "tree files", "trees"); | ||
if (file != null) { | ||
file = new XMLFile(file.getPath()); | ||
} | ||
try { | ||
m_entry.setText(file.getName()); | ||
m_input.setValue(file, m_beastObject); | ||
String path = file.getPath(); | ||
Beauti.g_sDir = path; | ||
} catch (Exception e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
add(button); | ||
} | ||
|
||
@Override | ||
protected void setValue(Object o) { | ||
String file = o.toString(); | ||
if (file.equals("")) { | ||
return; | ||
} | ||
String fileSep = System.getProperty("file.separator"); | ||
String origFile = ((File) m_input.get()).getAbsolutePath(); | ||
if (origFile.indexOf(fileSep) >= 0 && file.indexOf(fileSep) < 0) { | ||
if (origFile.contains(origFile)) { | ||
file = origFile.substring(0, origFile.lastIndexOf(fileSep) + 1) + file; | ||
} | ||
} | ||
m_input.setValue(file, m_beastObject); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.