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;
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
+
+ }
+
+ });
+
+
}
}