From: kjvdheide Date: Fri, 15 Dec 2017 16:07:57 +0000 (+0000) Subject: JAL-2852 merged the EPS button adding from main branch into interfaces X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4b3a91d41752dd07a70daa0e21c28564453dd8b7;p=jalview.git JAL-2852 merged the EPS button adding from main branch into interfaces --- diff --git a/src/jalview/ext/archaeopteryx/AptxFrame.java b/src/jalview/ext/archaeopteryx/AptxFrame.java index b00b24d..c105c25 100644 --- a/src/jalview/ext/archaeopteryx/AptxFrame.java +++ b/src/jalview/ext/archaeopteryx/AptxFrame.java @@ -13,6 +13,8 @@ import java.awt.Event; import java.awt.Font; import java.awt.Image; import java.awt.MenuComponent; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import javax.accessibility.AccessibleContext; import javax.swing.JLayeredPane; @@ -54,45 +56,90 @@ public class AptxFrame implements ExternalTreeFrame private void adaptAptxGui(MainFrame aptxFrame) { JMenuBar frameBar = aptxFrame.getJMenuBar(); - - for (int i = 0; i < frameBar.getMenuCount(); i++) - { + boolean epsAdded = false; + for (int i = 0; i < frameBar.getMenuCount();i++) { JMenu menu = frameBar.getMenu(i); + int menuCount = menu.getMenuComponentCount(); - if (menu.getText().startsWith("File")) + 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()) + Component previousComp = null; + for (int x = 0; x < menuCount; x++) { - if (previousMenuItem instanceof JMenuItem) + Component menuItem = menu.getMenuComponent(x); + if (previousComp instanceof JMenuItem) { - if (((JMenuItem) previousMenuItem).getText().startsWith("Read") - || ((JMenuItem) previousMenuItem).getText() - .startsWith("New")) + JMenuItem previousMenuItem = (JMenuItem) previousComp; + if (previousMenuItem.getText().startsWith("Read") + || previousMenuItem.getText() + .startsWith("New") + || previousMenuItem.getText() + .startsWith("Close Tab")) { - previousMenuItem.setVisible(false); + previousComp.setVisible(false); if (menuItem instanceof JSeparator) { menuItem.setVisible(false); } + + } + + if ((!epsAdded) && previousMenuItem.getText() + .startsWith("Export to")) + { + JMenuItem exportEps = new JMenuItem("Export to EPS file..."); + menu.add(exportEps, x); + exportEps.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + + }); + epsAdded = true; + } } - previousMenuItem = menuItem; + previousComp = menuItem; } } - else if (menu.getText().startsWith("Inference")) + else if (menu.getText().contains("Inference")) { menu.setVisible(false); } - else if (menu.getText().startsWith("View")) + else if (menu.getText().contains("View")) { menu.addSeparator(); - JMenuItem sortMenuItem = new JMenuItem("Sort alignment by tree"); - sortMenuItem.setVisible(false); - menu.add(sortMenuItem); + JMenuItem sortByTree = new JMenuItem("Sort alignment by tree"); + JMenuItem refreshJalview = new JMenuItem( + "Filter alignment to show only currently visible sequences"); + + refreshJalview.setFont(menu.getFont()); + + menu.add(sortByTree); + menu.add(refreshJalview); + + sortByTree.setFont(menu.getFont()); + refreshJalview.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + // TODO Auto-generated method stub + + } + + }); + + } }