JAL-2351 first refactoring and outline of read/write Jmol properties
[jalview.git] / src / jalview / gui / AppJmol.java
index e2e54aa..29c388c 100644 (file)
@@ -50,8 +50,11 @@ import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -66,7 +69,7 @@ import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JColorChooser;
 import javax.swing.JInternalFrame;
 import javax.swing.JMenu;
-import javax.swing.JOptionPane;
+import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JSplitPane;
 import javax.swing.SwingUtilities;
@@ -170,6 +173,8 @@ public class AppJmol extends StructureViewerBase
 
   private void initMenus()
   {
+    String jmol = MessageManager.getString("label.jmol");
+    viewerActionMenu.setText(jmol);
     seqColour.setSelected(jmb.isColourBySequence());
     viewerColour.setSelected(!jmb.isColourBySequence());
     if (_colourwith == null)
@@ -243,6 +248,35 @@ public class AppJmol extends StructureViewerBase
 
       }
     });
+
+    JMenuItem writeFeatures = new JMenuItem(
+            MessageManager.getString("label.create_viewer_attributes"));
+    writeFeatures.setToolTipText(MessageManager.formatMessage(
+            "label.create_viewer_attributes_tip", jmol));
+    writeFeatures.addActionListener(new ActionListener()
+    {
+      @Override
+      public void actionPerformed(ActionEvent e)
+      {
+        sendFeaturesToViewer();
+      }
+    });
+    viewerActionMenu.add(writeFeatures);
+
+    final JMenu fetchAttributes = new JMenu(MessageManager.formatMessage(
+            "label.fetch_viewer_attributes", jmol));
+    fetchAttributes.setToolTipText(MessageManager.formatMessage(
+            "label.fetch_viewer_attributes_tip", jmol));
+    fetchAttributes.addMouseListener(new MouseAdapter()
+    {
+
+      @Override
+      public void mouseEntered(MouseEvent e)
+      {
+        buildAttributesMenu(fetchAttributes);
+      }
+    });
+    viewerActionMenu.add(fetchAttributes);
   }
 
   IProgressIndicator progressBar = null;
@@ -1031,10 +1065,10 @@ public class AppJmol extends StructureViewerBase
     setChainMenuItems(jmb.getChainNames());
 
     this.setTitle(jmb.getViewerTitle());
-    if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
-    {
+    // if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
+    // {
       viewerActionMenu.setVisible(true);
-    }
+    // }
     if (!jmb.isLoadingFromArchive())
     {
       seqColour_actionPerformed(null);
@@ -1143,4 +1177,36 @@ public class AppJmol extends StructureViewerBase
     return jmb;
   }
 
+  @Override
+  protected void sendFeaturesToViewer()
+  {
+    /*
+     * Atom properties may also be set directly using {atom expression}.xxxx = y.
+     */
+  }
+
+  @Override
+  protected void getResidueAttributes(String attName)
+  {
+    /*
+     * getproperty atominfo returns properties for all atoms
+     * - could parse this for unique/specific property names?
+     *
+     * _ipt atomID atomIndex atomno bondCount chain clickabilityFlags colix color coord 
+     * element elemno formalCharge groupID info model name occupancy partialCharge 
+     * polymerLength radius resname resno shape spacefill structure sym temp 
+     * visibilityFlags visible x y z
+     *
+     * getproperty chaininfo is residue level info
+     * no sign of average bfactor for a residue :-(
+     */
+  }
+
+  @Override
+  protected List<String> getResidueAttributeNames()
+  {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
 }