X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fext%2Farchaeopteryx%2FAptxInit.java;h=dfc438715fabe11d225be882a66dbf8c58be8886;hb=7199905c8a7d8a46f4f27189caff52b9520e0479;hp=da9e34832c4e2f9792b13c0ae4855e8bfa7abddd;hpb=cee3e3317b502447c55edb8e887dd0c2c4db46d0;p=jalview.git diff --git a/src/jalview/ext/archaeopteryx/AptxInit.java b/src/jalview/ext/archaeopteryx/AptxInit.java index da9e348..dfc4387 100644 --- a/src/jalview/ext/archaeopteryx/AptxInit.java +++ b/src/jalview/ext/archaeopteryx/AptxInit.java @@ -9,6 +9,7 @@ import jalview.gui.JvOptionPane; import jalview.util.MessageManager; import jalview.viewmodel.AlignmentViewport; +import java.awt.Component; import java.awt.Dimension; import java.io.File; import java.io.FileNotFoundException; @@ -18,6 +19,11 @@ import java.net.URL; import java.util.HashMap; import java.util.Map; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JSeparator; + import org.forester.archaeopteryx.AptxUtil; import org.forester.archaeopteryx.Archaeopteryx; import org.forester.archaeopteryx.Configuration; @@ -46,9 +52,9 @@ import org.forester.util.ForesterUtil; */ public final class AptxInit { - private final static Configuration APTX_CONFIG = new Configuration( - "_aptx_jalview_configuration_file", false, false, false); + "_aptx_jalview_configuration_file", + false, false, false); private final static boolean VALIDATE_PHYLOXML_XSD = APTX_CONFIG .isValidatePhyloXmlAgainstSchema(); @@ -470,9 +476,27 @@ public final class AptxInit final Phylogeny aptxTree, final AlignmentViewport jalviewAlignport, String treeTitle) { + if (APTX_CONFIG == null || APTX_CONFIG.isCouldReadConfigFile() == false) + { + int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop, + MessageManager.getString("label.aptx_config_not_found"), + MessageManager.formatMessage("label.couldnt_locate", + new String[] + { "_aptx_jalview_configuration_file" }), + JvOptionPane.YES_NO_CANCEL_OPTION); + + if (keepGoing == JvOptionPane.CANCEL_OPTION + || keepGoing == JvOptionPane.CLOSED_OPTION + || keepGoing == JvOptionPane.NO_OPTION) + { + return null; + } + + } MainFrame aptxApp = Archaeopteryx.createApplication(aptxTree, APTX_CONFIG, treeTitle); + adaptAptxGui(aptxApp); LoadedTreeSequenceAssociation bindAptxNodes = new LoadedTreeSequenceAssociation( jalviewAlignport.getAlignment().getSequencesArray(), aptxTree); bindAptxNodes.associateLeavesToSequences(); @@ -523,6 +547,58 @@ public final class AptxInit } + /** + * Hides certain redundant Archaeopteryx GUI elements such as the menu items + * for reading in trees and adds extra items related to Jalview such as the + * tree sorting item. + * + * + * @param aptxFrame + */ + private static void adaptAptxGui(MainFrame aptxFrame) + { + JMenuBar frameBar = aptxFrame.getJMenuBar(); + + for (int i = 0; i < frameBar.getMenuCount();i++) { + JMenu menu = frameBar.getMenu(i); + + if (menu.getText().contains("File")) + { + // hide all "Read from ..." and "New" menu items and any Separators that + // come directly after them + Component previousMenuItem = null; + for (Component menuItem : menu.getMenuComponents()) { + if (previousMenuItem instanceof JMenuItem) + { + if (((JMenuItem) previousMenuItem).getText().startsWith("Read") + || ((JMenuItem) previousMenuItem).getText() + .startsWith("New")) + { + previousMenuItem.setVisible(false); + + if (menuItem instanceof JSeparator) + { + menuItem.setVisible(false); + } + } + } + previousMenuItem = menuItem; + } + } + else if (menu.getText().contains("Inference")) + { + menu.setVisible(false); + } + else if (menu.getText().contains("View")) + { + menu.addSeparator(); + menu.add(new JMenuItem("Sort alignment by tree")); + } + + } + aptxFrame.validate(); + } + public static Map getAllAptxFrames() { return activeAptx;