diff --git a/src/beastfx/app/beast/BeastMCMC.java b/src/beastfx/app/beast/BeastMCMC.java index 1bea774..0576cd9 100644 --- a/src/beastfx/app/beast/BeastMCMC.java +++ b/src/beastfx/app/beast/BeastMCMC.java @@ -26,7 +26,6 @@ -import beastfx.app.util.ExtensionFileFilter; import beast.base.core.BEASTVersion2; import beast.base.core.Log; import beast.base.core.ProgramStatus; @@ -39,23 +38,16 @@ import beast.base.util.FileUtils; import beast.base.util.Randomizer; import beast.pkgmgmt.PackageManager; -import beast.pkgmgmt.Version; import org.json.JSONException; import org.json.JSONObject; import org.xml.sax.SAXException; -import javax.swing.*; -import javax.swing.border.EtchedBorder; -import javax.swing.filechooser.FileFilter; import javax.xml.parsers.ParserConfigurationException; -import java.awt.*; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; -import java.net.URL; import java.util.*; -import java.util.List; import java.util.concurrent.Executors; /** @@ -124,10 +116,6 @@ public void parseArgs(String[] args) throws IOException, XMLParserException, JSO ProgramStatus.m_nThreads = Integer.parseInt(args[i + 1]); ProgramStatus.g_exec = Executors.newFixedThreadPool(ProgramStatus.m_nThreads); i += 2; -// use BEAST environment variable to set Beast directories as colon separated list -// } else if (args[i].equals("-beastlib")) { -// ClassDiscovery.setJarPath(args[i + 1]); -// i += 2; } else if (args[i].equals("-prefix")) { System.setProperty("file.name.prefix", args[i + 1].trim()); i += 2; @@ -199,79 +187,6 @@ public void parseArgs(String[] args) throws IOException, XMLParserException, JSO if (beastFile == null) { // Not resuming so get starting options... - - List MCMCargs = new ArrayList<>(); - Version version = new BEASTVersion2(); - String titleString = "

Bayesian Evolutionary Analysis Sampling Trees
" + - "Version " + version.getVersionString() + ", " + version.getDateString() + "

"; - //javax.swing.Icon icon = IconUtils.getIcon(BeastMain.class, "images/beast.png"); - String nameString = "BEAST " + version.getVersionString(); - -// BeastDialog dialog = new BeastDialog(new JFrame(), titleString, icon); -// -// if (!dialog.showDialog(nameString, m_nSeed)) { -// return; -// } -// -// switch (dialog.getLogginMode()) { -// case 0:/* do not ovewrite */ -// break; -// case 1: -// MCMCargs.add("-overwrite"); -// break; -// case 2: -// MCMCargs.add("-resume"); -// break; -// } -// MCMCargs.add("-seed"); -// MCMCargs.add(dialog.getSeed() + ""); -// -// if (dialog.getThreadPoolSize() > 0) { -// MCMCargs.add("-threads"); -// MCMCargs.add(dialog.getThreadPoolSize() + ""); -// } -// -// boolean useBeagle = dialog.useBeagle(); -// boolean beagleShowInfo = false; -// long beagleFlags = 0; -// if (useBeagle) { -// beagleShowInfo = dialog.showBeagleInfo(); -// if (dialog.preferBeagleCPU()) { -// beagleFlags |= BeagleFlag.PROCESSOR_CPU.getMask(); -// } -// if (dialog.preferBeagleSSE()) { -// beagleFlags |= BeagleFlag.VECTOR_SSE.getMask();import jam.util.IconUtils; - -// } -// if (dialog.preferBeagleGPU()) { -// beagleFlags |= BeagleFlag.PROCESSOR_GPU.getMask(); -// } -// if (dialog.preferBeagleDouble()) { -// beagleFlags |= BeagleFlag.PRECISION_DOUBLE.getMask(); -// } -// if (dialog.preferBeagleSingle()) { -// beagleFlags |= BeagleFlag.PRECISION_SINGLE.getMask(); -// } -// } -// if (beagleFlags != 0) { -// System.setProperty("beagle.preferred.flags", Long.toString(beagleFlags)); -// } -// if (!useBeagle) { -// System.setProperty("java.only", "true"); -// } -// -// File inputFile = dialog.getInputFile(); -// if (!beagleShowInfo && inputFile == null) { -// System.err.println("No input file specified"); -// System.exit(1); -// } -// MCMCargs.add(inputFile.getAbsolutePath()); -// -//// BeastStartDialog dlg = new BeastStartDialog(); -//// if (dlg.m_bOK) { -//// parseArgs(dlg.getArgs()); -//// } -// parseArgs(MCMCargs.toArray(new String[0])); return; } @@ -338,39 +253,6 @@ public static String getUsage() { "-beastlib : Colon separated list of directories. All jar files in the path are loaded. (default 'beastlib')"; } // getUsage - /** - * open file dialog for prompting the user to specify an xml script file to process * - */ - String getFileNameByDialog() { - JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); - fc.addChoosableFileFilter(new FileFilter() { - @Override - public boolean accept(File f) { - if (f.isDirectory()) { - return true; - } - String name = f.getName().toLowerCase(); - if (name.endsWith(".xml")) { - return true; - } - return false; - } - - // The description of this filter - @Override - public String getDescription() { - return "xml files"; - } - }); - - fc.setDialogTitle("Load xml file"); - int rval = fc.showOpenDialog(null); - - if (rval == JFileChooser.APPROVE_OPTION) { - return fc.getSelectedFile().toString(); - } - return null; - } // getFileNameByDialog public void run() throws Exception { ProgramStatus.g_exec = Executors.newFixedThreadPool(ProgramStatus.m_nThreads); @@ -380,205 +262,15 @@ public void run() throws Exception { } // run - /** - * class for starting Beast with a dialog * - */ - class BeastStartDialog extends JDialog { - private static final long serialVersionUID = 1L; - boolean m_bOK = false; - JTextField m_fileEntry; - JTextField m_seedEntry; - JCheckBox m_bUseGPU; - JComboBox m_mode; - - public BeastStartDialog() { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setModalityType(DEFAULT_MODALITY_TYPE); - init(); - setVisible(true); - } - - String[] getArgs() { - List args = new ArrayList<>(); - args.add("-seed"); - args.add(m_seedEntry.getText()); - switch (m_mode.getSelectedIndex()) { - case 0: - break; - case 1: - args.add("-overwrite"); - break; - case 2: - args.add("-resume"); - break; - } -// if (m_bUseGPU.isSelected()) { -// args.add("-useGPU"); -// } - args.add(m_fileEntry.getText()); - return args.toArray(new String[0]); - } - - void init() { - try { - setTitle("Beast Start Dialog"); - Box box = Box.createVerticalBox(); - - box.add(createHeader()); - box.add(Box.createVerticalStrut(10)); - box.add(createFileInput()); - box.add(Box.createVerticalStrut(10)); - box.add(Box.createVerticalBox()); - box.add(Box.createVerticalStrut(10)); - box.add(createSeedInput()); -// box.add(Box.createVerticalStrut(10)); -// box.add(createBeagleInput()); - box.add(Box.createVerticalStrut(10)); - box.add(createModeInput()); - - box.add(Box.createVerticalGlue()); - box.add(createRunQuitButtons()); - add(box); - int size = UIManager.getFont("Label.font").getSize(); - setSize(600 * size / 13, 500 * size / 13); - } catch (Exception e) { - e.printStackTrace(); - JOptionPane.showMessageDialog(this, "Could not create dialog: " + e.getMessage()); - } - } // BeastStartDialog::init - - private Component createHeader() { - Box box = Box.createHorizontalBox(); - - String iconLocation = "beast/app/draw/icons/beast.png"; - ImageIcon icon = null; - try { - URL url = BeastMCMC.class.getClassLoader().getResource(iconLocation); - if (url == null) { - System.err.println("Cannot find icon " + iconLocation); - return null; - } - icon = new ImageIcon(url); - } catch (Exception e) { - System.err.println("Cannot load icon " + iconLocation + " " + e.getMessage()); - return null; - } - - - JLabel label = new JLabel(icon); - label.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); - box.add(label, BorderLayout.WEST); - label = new JLabel("
BEAST
Version: " + VERSION + "
Developers: " + DEVELOPERS + "
Copyright: " + COPYRIGHT + ""); - label.setHorizontalAlignment(SwingConstants.CENTER); - box.add(label); - return box; - } // BeastStartDialog::createHeader - - private Component createFileInput() { - Box box = Box.createHorizontalBox(); - box.add(new JLabel("Beast XML File: ")); - m_fileEntry = new JTextField(); - int fontsize = m_fileEntry.getFont().getSize(); - Dimension size = new Dimension(300 * fontsize / 13, 20 * fontsize / 13); - m_fileEntry.setMinimumSize(size); - m_fileEntry.setPreferredSize(size); - m_fileEntry.setSize(size); - m_fileEntry.setToolTipText("Enter file name of Beast 2 XML file"); - m_fileEntry.setMaximumSize(new Dimension(1024 * fontsize / 13, 20 * fontsize / 13)); - box.add(m_fileEntry); - //box.add(Box.createHorizontalGlue()); - - JButton button = new JButton("Choose file"); - button.addActionListener(e -> { - JFileChooser fileChooser = new JFileChooser(ProgramStatus.g_sDir); - File file = new File(m_fileEntry.getText()); - if (file.exists()) - fileChooser.setSelectedFile(file); - fileChooser.addChoosableFileFilter(new ExtensionFileFilter(".xml", "Beast xml file (*.xml)")); - fileChooser.setDialogTitle("Select Beast 2 XML file"); - int rval = fileChooser.showOpenDialog(null); - if (rval == JFileChooser.APPROVE_OPTION) { - String fileName = fileChooser.getSelectedFile().toString(); - if (fileName.lastIndexOf(File.separator) > 0) { - ProgramStatus.setCurrentDir(fileName.substring(0, fileName.lastIndexOf(File.separator))); - } - m_fileEntry.setText(fileName); - } - }); - box.add(button); - - return box; - } // BeastStartDialog::createFileInput - - private Component createSeedInput() { - Box box = Box.createHorizontalBox(); - box.add(new JLabel("Random number seed: ")); - m_seedEntry = new JTextField("127"); - m_seedEntry.setHorizontalAlignment(SwingConstants.RIGHT); - Dimension size = new Dimension(100, 20); - m_seedEntry.setMinimumSize(size); - m_seedEntry.setPreferredSize(size); - m_seedEntry.setSize(size); - m_seedEntry.setToolTipText("Enter seed number used for initialising the random number generator"); - int fontsize = m_seedEntry.getFont().getSize(); - m_seedEntry.setMaximumSize(new Dimension(1024 * fontsize / 13, 20 * fontsize / 13)); - box.add(m_seedEntry); - box.add(Box.createHorizontalGlue()); - return box; - } // BeastStartDialog::createSeedInput - - private Component createModeInput() { - Box box = Box.createHorizontalBox(); - box.add(new JLabel("Mode of running: ")); - m_mode = new JComboBox<>(new String[]{"default: only write new log files", - "overwrite: overwrite log files", - "resume: appends log to existing files (if any)"}); - Dimension size = new Dimension(350, 20); - m_mode.setMinimumSize(size); - m_mode.setPreferredSize(size); - m_mode.setSize(size); - m_mode.setMaximumSize(size); - - m_mode.setSelectedIndex(0); - box.add(m_mode); - box.add(Box.createHorizontalGlue()); - return box; - } // BeastStartDialog::createModeInput - - Component createRunQuitButtons() { - Box cancelOkBox = Box.createHorizontalBox(); - cancelOkBox.setBorder(new EtchedBorder()); - JButton okButton = new JButton("Run"); - okButton.addActionListener(e -> { - m_bOK = true; - dispose(); - }); - JButton cancelButton = new JButton("Quit"); - cancelButton.addActionListener(e -> { - dispose(); - System.exit(0); - }); - cancelOkBox.add(Box.createHorizontalGlue()); - cancelOkBox.add(cancelButton); - cancelOkBox.add(Box.createHorizontalStrut(20)); - cancelOkBox.add(okButton); - cancelOkBox.add(Box.createHorizontalStrut(20)); - return cancelOkBox; - } // BeastStartDialog::createRunQuitButtons - - } // class BeastStartDialog - public static void main(String[] args) { try { System.setProperty("beast.debug", "true"); BeastMCMC app = new BeastMCMC(); app.parseArgs(args); - app.run(); } catch (XMLParserException e) { System.out.println(e.getMessage()); - //e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); System.out.println(BeastMCMC.getUsage()); diff --git a/src/beastfx/app/beast/BeastMain.java b/src/beastfx/app/beast/BeastMain.java index 229e8f8..48d23c5 100644 --- a/src/beastfx/app/beast/BeastMain.java +++ b/src/beastfx/app/beast/BeastMain.java @@ -7,7 +7,6 @@ import java.io.PrintStream; import java.util.ArrayList; import java.util.List; -import java.util.Optional; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -30,30 +29,14 @@ import beastfx.app.beauti.ThemeProvider; import beastfx.app.util.Console; import javafx.fxml.FXMLLoader; -import javafx.scene.control.ButtonType; import javafx.scene.control.Dialog; import javafx.scene.control.DialogPane; -import javafx.scene.control.TextArea; -import javafx.scene.control.ButtonBar.ButtonData; public class BeastMain extends Console { private final static Version version = new BEASTVersion2(); @Override protected void createDialog() { -// -// PrintStream err = System.err; -// System.setErr(new PrintStream(new OutputStream() { -// public void write(int b) { -// } -// })); -// // Utils.loadUIManager(); -// System.setErr(err); - -// System.setProperty("com.apple.macos.useScreenMenuBar", "true"); -// System.setProperty("apple.laf.useScreenMenuBar", "true"); -// System.setProperty("apple.awt.showGrowBox", "true"); - Dialog dialog = new Dialog<>(); dialog.setTitle("BEAST " + BEASTVersion.INSTANCE.getVersion()); @@ -64,7 +47,6 @@ protected void createDialog() { try { root = fl.load(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } dialog.getDialogPane(); @@ -76,29 +58,9 @@ protected void createDialog() { ((Controller)o).dialog = dialog; ((Controller)o).textView = textView; } - -// ButtonType run = new ButtonType("Run", ButtonData.OK_DONE); -// dialog.getDialogPane().getButtonTypes().add(run); -// ButtonType cancel = new ButtonType("Quit", ButtonData.CANCEL_CLOSE); -// dialog.getDialogPane().getButtonTypes().add(cancel); - + //Showing the dialog on clicking the button dialog.show(); -// Optional result = dialog.showAndWait(); -// dialog.close(); -// -// Object o = result.get(); -// String str = o.toString(); -// -// if (str.equals("RUN")) { -// Controller controller = fl.getController(); -// controller.run(); -// } else { -// Log.warning("Quiting BEAST"); -// System.exit(0); -// return; -// } - } public static void centreLine(final String line, final int pageWidth) { @@ -158,14 +120,9 @@ private static void printVersion() { public static void main(String[] args) { final List MCMCargs = new ArrayList<>(); -// Utils.loadUIManager(); final Arguments arguments = new Arguments( new Arguments.Option[]{ - -// new Arguments.Option("verbose", "Give verbose XML parsing messages"), -// new Arguments.Option("warnings", "Show warning messages about BEAST XML file"), -// new Arguments.Option("strict", "Fail on non-conforming BEAST XML file"), new Arguments.Option("window", "Provide a console window"), new Arguments.Option("options", "Display an options dialog"), new Arguments.Option("working", "Change working directory to input file's directory"), @@ -242,16 +199,12 @@ public static void main(String[] args) { System.exit(0); } -// final boolean verbose = arguments.hasOption("verbose"); -// final boolean parserWarning = arguments.hasOption("warnings"); // if dev, then auto turn on, otherwise default to turn off -// final boolean strictXML = arguments.hasOption("strict"); final boolean window = arguments.hasOption("window"); final boolean options = arguments.hasOption("options"); final boolean working = arguments.hasOption("working"); final boolean doNotRun = arguments.hasOption("validate"); String fileNamePrefix = null; String stateFileName = null; - //boolean allowOverwrite = arguments.hasOption("overwrite"); long seed = Randomizer.getSeed(); boolean useJava = false; @@ -462,10 +415,6 @@ public void write(int b) { Log.info.println("Writing state to file " + stateFileName); } -// if (allowOverwrite) { -// System.setProperty("log.allow.overwrite", "true"); -// } - if (beagleFlags != 0) { System.setProperty("beagle.preferred.flags", Long.toString(beagleFlags)); diff --git a/src/beastfx/app/beast/Controller.java b/src/beastfx/app/beast/Controller.java index 1a446b6..eb2815d 100644 --- a/src/beastfx/app/beast/Controller.java +++ b/src/beastfx/app/beast/Controller.java @@ -265,9 +265,9 @@ public Message(String data, String style) { List backLog = new ArrayList<>(); void logToView(String _data, String _style) { - //textView.setStyle("-fx-fill:" + _style + ";"); + textView.setStyle("-fx-fill:" + _style + ";"); Log.info(_data); - //textView.setStyle("-fx-fill:black;"); + textView.setStyle("-fx-fill:black;"); } diff --git a/src/beastfx/app/beauti/BeautiTabPane.java b/src/beastfx/app/beauti/BeautiTabPane.java index 091340e..e3adb4c 100644 --- a/src/beastfx/app/beauti/BeautiTabPane.java +++ b/src/beastfx/app/beauti/BeautiTabPane.java @@ -5,6 +5,7 @@ +import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.scene.Cursor; import javafx.scene.Scene; @@ -12,6 +13,7 @@ import javafx.scene.control.ButtonType; import javafx.scene.control.CheckMenuItem; import javafx.scene.control.Dialog; +import javafx.scene.control.Label; import javafx.scene.control.Menu; import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; @@ -24,6 +26,7 @@ import javafx.scene.layout.BorderPane; import javafx.scene.web.WebView; import javafx.stage.Stage; +import javafx.stage.StageStyle; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -46,7 +49,6 @@ import beastfx.app.inputeditor.BeautiDoc.ActionOnExit; import beastfx.app.inputeditor.BeautiDoc.DOC_STATUS; import beastfx.app.tools.AppLauncher; -import beastfx.app.tools.HelpBrowser; import beastfx.app.util.Utils; import beast.base.core.BEASTInterface; import beast.base.core.BEASTVersion2; @@ -59,7 +61,6 @@ import beast.pkgmgmt.PackageManager; import beast.pkgmgmt.Utils6; -import javax.swing.*; import javax.xml.parsers.DocumentBuilderFactory; import java.awt.Toolkit; @@ -173,7 +174,6 @@ int tabNrForPanel(int panelNr) { MenuItem a_managePackages = new ActionManagePacakges(); MenuItem a_clearClassPath = new ActionClearClassPath(); -// public Action a_import = new ActionImport(); public MenuItem a_save = new ActionSave(); MenuItem a_saveas = new ActionSaveAs(); MenuItem a_close = new ActionClose(); @@ -293,12 +293,8 @@ public ActionNew() { @Override public void actionPerformed(ActionEvent ae) { Stage stage = new Stage(); - main2(new String[0], stage); + main2(new String[0], stage); stage.show(); - // doc.newAnalysis(); - // a_save.setEnabled(false); - // a_saveas.setEnabled(false); - // setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } @@ -318,12 +314,6 @@ public ActionLoad(String name, String toolTipText, String icon, public void actionPerformed(ActionEvent ae) { File file = FXUtils.getLoadFile("Load Beast XML File", new File(ProgramStatus.g_sDir), "Beast XML files", "xml");//, "BEAST json file", "json"); - // JFileChooser fileChooser = new JFileChooser(g_sDir); - // fileChooser.addChoosableFileFilter(ef1); - // fileChooser.setDialogTitle("Load Beast XML File"); - // if (fileChooser.showOpenDialog(null) == - // JFileChooser.APPROVE_OPTION) { - // fileName = fileChooser.getSelectedFile().toString(); if (file != null) { setCursor(Cursor.WAIT); doc.newAnalysis(); @@ -363,13 +353,6 @@ public void actionPerformed(ActionEvent ae) { setCursor(Cursor.WAIT); File file = beastfx.app.util.FXUtils .getLoadFile("Load Template XML File"); - // JFileChooser fileChooser = new - // JFileChooser(System.getProperty("user.dir")+"/" + BeautiConfig.TEMPLATE_DIR); - // fileChooser.addChoosableFileFilter(ef1); - // fileChooser.setDialogTitle("Load Template XML File"); - // if (fileChooser.showOpenDialog(null) == - // JFileChooser.APPROVE_OPTION) { - // String fileName = fileChooser.getSelectedFile().toString(); if (file != null) { String fileName = file.getAbsolutePath(); try { @@ -443,51 +426,6 @@ public void actionPerformed(ActionEvent ae) { } - // class ActionImport extends MyAction { -// -// -// public ActionImport() { -// super("Import Alignment", "Import Alignment File", "import", -// KeyEvent.VK_I); -// } -// -// public ActionImport(String name, String toolTipText, String icon, -// int acceleratorKey) { -// super(name, toolTipText, icon, acceleratorKey); -// } -// -// public void actionPerformed(ActionEvent ae) { -// -// try { -// setCursor(new Cursor(Cursor.WAIT_CURSOR)); -// -// // get user-specified alignments -// doc.beautiConfig.selectAlignments(doc,Beauti.this); -// -// doc.connectModel(); -// doc.fireDocHasChanged(); -// a_save.setEnabled(true); -// a_saveas.setEnabled(true); -// } catch (Exception e) { -// e.printStackTrace(); -// -// String text = "Something went wrong importing the alignment:\n"; -// JTextArea textArea = new JTextArea(text); -// textArea.setColumns(30); -// textArea.setLineWrap(true); -// textArea.setWrapStyleWord(true); -// textArea.append(e.getMessage()); -// textArea.setSize(textArea.getPreferredSize().width, 1); -// textArea.setOpaque(false); -// Alert.showMessageDialog(null, textArea, -// "Error importing alignment", -// Alert.WARNING_MESSAGE); -// } -// setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); -// // } -// } // actionPerformed -// } - class ActionClose extends ActionSave { public ActionClose() { super("Close", "Close Window", "close", new KeyCodeCombination(KeyCode.W, KeyCombination.CONTROL_DOWN)); @@ -578,7 +516,6 @@ public void actionPerformed(ActionEvent ae) { dlg.getDialogPane().setContent(webView); dlg.getDialogPane().getButtonTypes().add(ButtonType.CLOSE); dlg.showAndWait(); - //Alert.showMessageDialog(null, webView); } catch (Exception e) { e.printStackTrace(); Alert.showMessageDialog(null, e.getMessage()); @@ -636,11 +573,6 @@ public ActionHelp() { public void actionPerformed(ActionEvent ae) { setCursor(Cursor.WAIT); FXUtils.openInBrowser(FXUtils.getHMCBase()); - //HelpBrowser b = new HelpBrowser(currentTab.config.getType()); - //int size = UIManager.getFont("Label.font").getSize(); - //b.setSize(800 * size / 13, 800 * size / 13); - //b.setVisible(true); - //b.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setCursor(Cursor.DEFAULT); } } // class ActionHelp @@ -797,16 +729,6 @@ public MenuBar createMenuBar() { }); modeMenu.getItems().add(autoUpdateFixMeanSubstRate); - // final JCheckBoxMenuItem muteSound = new - // JCheckBoxMenuItem("Mute sound", false); - // muteSound.setOnAction(new ActionListener() { - // public void actionPerformed(ActionEvent ae) { - // BeautiPanel.soundIsPlaying = !muteSound.getState(); - // refreshPanel(); - // } - // }); - // modeMenu.add(muteSound); - viewMenu = new Menu("_View"); viewMenu.setId("View"); menuBar.getMenus().add(viewMenu); @@ -828,27 +750,13 @@ public MenuBar createMenuBar() { helpMenu.getItems().add(a_about); } -// for (MenuItem m : menuBar.getMenus()) { -// setMenuVisibiliy("", m); -// } - return menuBar; } // makeMenuBar // Find sub-classes of BeautiHelpAction and add custom help menu items // for these classes private void addCustomHelpMenus(Menu helpMenu) { - String[] PACKAGE_DIRS = {"beast.app",}; String helpClass = "beastfx.app.beauti.BeautiHelpAction"; -// List helpActions = new ArrayList<>(); -//// for (String packageName : PACKAGE_DIRS) { -//// helpActions.addAll(PackageManager.find(helpClass, packageName)); -//// } -// -// for (BeautiHelpAction helpAction : ServiceLoader.load(BeautiHelpAction.class)) { -// helpActions.add(helpAction.getClass().getName()); -// } - Set helpActions = Utils.loadService(BeautiHelpAction.class); if (helpActions.size() > 1) { @@ -1059,7 +967,6 @@ public TemplateAction(File file) { if (templateInfo == null || templateInfo.length() == 0) { templateInfo = "switch to " + name + " template"; } - //templateInfo = "" + templateInfo + ""; Tooltip tooltip = new Tooltip(templateInfo); // Tooltip.install(getContent(), tooltip); } catch (Exception e) { @@ -1185,18 +1092,6 @@ void setMenuVisibiliy(String parentName, MenuItem c) { } } - // hide panels as indicated in the hidepanels attribute in the XML template, - // or use default tabs to hide otherwise. - public void hidePanels() { - // for (int panelIndex = 0; panelIndex < BeautiConfig.g_panels.size(); panelIndex++) - // { - // BeautiPanelConfig panelConfig = BeautiConfig.g_panels.get(panelIndex); - // if (!panelConfig.m_bIsVisibleInput.get()) { - // toggleVisible(panelIndex); - // } - // } - } // hidePanels - public void setUpPanels() throws NoSuchMethodException, SecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (isInitialising) { //return; @@ -1263,8 +1158,6 @@ private static String usage() { public static BeautiTabPane main2(String[] args, Stage primaryStage) { -// Utils6.startSplashScreen(); -// Utils6.logToSplashScreen("Initialising BEAUti"); ProgramStatus.name = "BEAUti"; @@ -1349,71 +1242,10 @@ public void close() throws IOException { final BeautiTabPane beauti = new BeautiTabPane(doc); - if (Utils.isMac() && Utils6.isMajorAtLeast(Utils6.JAVA_1_8)) { - - // TODO: https://github.com/codecentric/NSMenuFX looks relevant - -// // set up application about-menu for Mac -// // Mac-only stuff -// try { -// URL url = BEASTClassLoader.classLoader.getResource(ModelBuilder.ICONPATH + "beauti.png"); -// Icon icon = null; -// if (url != null) { -// icon = new ImageIcon(url); -// } else { -// Log.warning.println("Unable to find image: " + ModelBuilder.ICONPATH + "beauti.png"); -// } -// jam.framework.Application application = new jam.framework.MultiDocApplication(null, "BEAUti", "about", icon) { -// -// @Override -// protected JFrame getDefaultFrame() { -// return null; -// } -// -// @Override -// public void doQuit() { -// beauti.a_quit.actionPerformed(null); -// } -// -// @Override -// public void doAbout() { -// beauti.a_about.actionPerformed(null); -// } -// -// @Override -// public DocumentFrame doOpenFile(File file) { -// return null; -// } -// -// @Override -// public DocumentFrame doNew() { -// return null; -// } -// }; -// -// // https://github.com/CompEvol/beast2/issues/805 -// if (Utils6.isMajorAtLeast(Utils6.JAVA_9)) // >= Java 9 -// beastfx.app.util.Utils.macOSXRegistration(application); -// else // <= Java 8 -// jam.mac.Utils.macOSXRegistration(application); -// } catch (Throwable e) { -// // ignore -// } -// if (Utils6.isMajorLower(Utils6.JAVA_9)) { -// try { -// Class class_ = BEASTClassLoader.forName("jam.maconly.OSXAdapter"); -// Method method = class_.getMethod("enablePrefs", boolean.class); -// method.invoke(null, false); -// } catch (java.lang.NoSuchMethodException e) { -// // ignore -// } -// } - } beauti.setUpPanels(); beauti.currentTab = beauti.panels[0]; beauti.currentTab.setHMCVisible(true); - beauti.hidePanels(); beauti.getSelectionModel().selectedItemProperty().addListener(e -> { if (beauti.currentTab == null) { @@ -1435,7 +1267,7 @@ public void close() throws IOException { Stage frame = primaryStage; primaryStage.setTitle("BEAUti"); beauti.frame = primaryStage; - // Stage frame = new Stage(); + frame.setTitle("BEAUti 2: " + doc.getTemplateName() + " " + doc.getFileName()); beauti.frame = frame; @@ -1457,8 +1289,6 @@ public void close() throws IOException { BorderPane vb = new BorderPane(); vb.setTop(menuBar); vb.setCenter(beauti); - int size = UIManager.getFont("Label.font").getSize(); - //vb.setPrefSize(1024 * size / 13, 768 * size / 13); vb.setPrefSize(1024, 768); Scene scene = new Scene(vb); @@ -1467,7 +1297,6 @@ public void close() throws IOException { frame.setScene(scene); frame.setX(BEAUtiIntances * 10); frame.setY(10 + BEAUtiIntances * 10); - // frame.setVisible(true); // check file needs to be save on closing main frame frame.setOnCloseRequest(e-> { @@ -1490,54 +1319,8 @@ public void close() throws IOException { primaryStage.heightProperty().addListener((obs, oldVal, newVal) -> { beauti.currentTab.setHeight(oldVal, newVal); }); - - // Toolkit toolkit = Toolkit.getDefaultToolkit(); - // // PropertyChangeListener plistener = new - // PropertyChangeListener() { - // // @Override - // // public void propertyChange(PropertyChangeEvent event) { - // // Object o = event.getSource(); - // // Object o2 = event.getNewValue(); - // // event.getPropertyName(); - // // System.err.println(">>> " + event.getPropertyName() + " " + - // o.getClass().getName() + "\n" + o2.getClass().getName()); - // // } - // // }; - // AWTEventListener listener = new AWTEventListener() { - // @Override - // public void eventDispatched(AWTEvent event) { - // Object o = event.getSource(); - // String label = ""; - // try { - // Method method = o.getClass().getMethod("getText", Object.class); - // label = (String) method.invoke(o); - // } catch (Exception e) { - // // TODO: handle exception - // } - // if (event.paramString().matches(".*\\([0-9]*,[0-9]*\\).*")) { - // String s = event.paramString(); - // String sx = s.substring(s.indexOf('(') + 1); - // String sy = sx; - // sx = sx.substring(0, sx.indexOf(',')); - // sy = sy.substring(sy.indexOf(',') + 1, sy.indexOf(')')); - // int x = Integer.parseInt(sx); - // int y = Integer.parseInt(sy); - // Component c = beauti.findComponentAt(x, y); - // if (c != null) { - // System.err.println(c.getClass().getName()); - // } - // } - // - // System.err.println(label + " " + event.paramString() + " " + - // o.getClass().getName()); - // - // } - // }; - // toolkit.addAWTEventListener(listener, - // AWTEvent.ACTION_EVENT_MASK|AWTEvent.ITEM_EVENT_MASK|AWTEvent.MOUSE_EVENT_MASK); - // // beauti.addPropertyChangeListener(plistener); - -// Utils6.endSplashScreen(); + + Utils6.endSplashScreen(); beauti.setId("BeautiTabPane"); return beauti; @@ -1581,5 +1364,10 @@ public BeautiPanel getCurrentPanel() { return currentTab; } + + + + + } // class Beauti diff --git a/src/beastfx/app/inputeditor/MRCAPriorInputEditor.java b/src/beastfx/app/inputeditor/MRCAPriorInputEditor.java index 01be3ff..4218916 100644 --- a/src/beastfx/app/inputeditor/MRCAPriorInputEditor.java +++ b/src/beastfx/app/inputeditor/MRCAPriorInputEditor.java @@ -138,15 +138,7 @@ public void init(Input input, BEASTInterface beastObject, final int listItemN List list = (List) m_input.get(); MRCAPrior prior2 = (MRCAPrior) list.get(itemNr); -//System.err.println("PRIOR" + beastObject2); -// try { -// prior.m_distInput.setValue(beastObject2, prior); -// } catch (Exception e1) { -// // TODO Auto-generated catch block -// e1.printStackTrace(); -// } try { - //BEASTObject beastObject2 = template.createSubNet(new PartitionContext(""), prior2, prior2.distInput, true); } catch (Exception e1) { e1.printStackTrace(); @@ -268,27 +260,6 @@ protected Set getTaxonCandidates(MRCAPrior prior) { return candidates; } - /** - * class to deal with toggling monophyletic flag on an MRCAPrior * - */ -// class MRCAPriorActionListener implements ActionListener { -// MRCAPrior m_prior; -// -// MRCAPriorActionListener(MRCAPrior prior) { -// m_prior = prior; -// } -// -// @Override -// public void actionPerformed(ActionEvent e) { -// try { -// m_prior.isMonophyleticInput.setValue(((CheckBox) e.getSource()).isSelected(), m_prior); -// refreshPanel(); -// } catch (Exception ex) { -// Log.warning.println("PriorListInputEditor " + ex.getMessage()); -// } -// } -// } - InputEditor tipsonlyEditor; @@ -299,9 +270,6 @@ public InputEditor createTipsonlyEditor() throws NoSuchMethodException, Security public void init(Input input, BEASTInterface beastObject, int itemNr, ExpandOption isExpandOption, boolean addButtons) { super.init(input, beastObject, itemNr, isExpandOption, addButtons); - // hack to get to Button - //Node [] components = getComponents(); - //((Button) components[0]) for (Node o : getChildren()) { if (o instanceof CheckBox) { ((CheckBox)o).setOnAction(e -> { diff --git a/src/beastfx/app/util/FXUtils.java b/src/beastfx/app/util/FXUtils.java index c223522..1c2dadb 100644 --- a/src/beastfx/app/util/FXUtils.java +++ b/src/beastfx/app/util/FXUtils.java @@ -2,6 +2,7 @@ + import javafx.application.Platform; import javafx.geometry.Insets; import javafx.scene.control.Button; @@ -27,8 +28,6 @@ import beast.base.core.BEASTInterface; import beast.base.core.Input; -import beastfx.app.beauti.Beauti; -import beastfx.app.inputeditor.BEASTObjectDialog; import beastfx.app.inputeditor.BeautiPanelConfig; public class FXUtils {