paintFlag removed
[jalview.git] / src / jalview / gui / Desktop.java
index 8bf7523..b2c86bb 100755 (executable)
@@ -16,9 +16,13 @@ import jalview.schemes.*;
 import javax.swing.*;\r
 import java.awt.*;\r
 import java.awt.event.*;\r
+import java.awt.dnd.*;\r
+import javax.swing.*;\r
+import java.awt.datatransfer.*;\r
+import java.io.*;\r
 \r
 \r
-public class Desktop extends jalview.jbgui.GDesktop\r
+public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener\r
 {\r
   public static JDesktopPane desktop;\r
   static int openFrameCount = 0;\r
@@ -42,12 +46,17 @@ public class Desktop extends jalview.jbgui.GDesktop
 \r
     setTitle("Jalview 2005");\r
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r
-    setVisible(true);\r
     desktop = new JDesktopPane();\r
-    desktop.setBackground(Color.white);\r
+ //   desktop.setBackground(Color.white);\r
     setContentPane(desktop);\r
     desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);\r
 \r
+\r
+    // This line prevents Windows Look&Feel resizing all new windows to maximum\r
+    // if previous window was maximised\r
+    desktop.setDesktopManager( new DefaultDesktopManager() );\r
+\r
+\r
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();\r
     String x = jalview.bin.Cache.getProperty("SCREEN_X");\r
     String y = jalview.bin.Cache.getProperty("SCREEN_Y");\r
@@ -77,8 +86,9 @@ public void windowClosing(WindowEvent evt)
  jalview.bin.Cache.setProperty("SCREEN_HEIGHT", getHeight() + "");\r
 }\r
 });\r
+setVisible(true);\r
 \r
-/////////Add a splashscreen on startup\r
+this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this));\r
 \r
 \r
    /////////Add a splashscreen on startup\r
@@ -87,7 +97,7 @@ public void windowClosing(WindowEvent evt)
     SplashScreen splash = new SplashScreen(frame, image);\r
     frame.setContentPane(splash);\r
     desktop.add(frame);\r
-    frame.setVisible(true);\r
+\r
     openFrameCount++;\r
     try\r
     {\r
@@ -102,13 +112,13 @@ public void windowClosing(WindowEvent evt)
     frame.setIconifiable(false);\r
     frame.setMaximizable(false);\r
     frame.setFrameIcon(null);\r
+    frame.setVisible(true);\r
 \r
   }\r
 \r
   public static void addInternalFrame(final JInternalFrame frame, String title, int w, int h)\r
   {\r
    desktop.add(frame);\r
-   frame.setVisible(true);\r
    openFrameCount++;\r
    try {\r
        frame.setSelected(true);\r
@@ -140,10 +150,34 @@ public void windowClosing(WindowEvent evt)
       }\r
     });\r
 \r
+   frame.setVisible(true);\r
    windowMenu.add(menuItem);\r
  }\r
 \r
+ public void dragEnter(DropTargetDragEvent evt){}\r
+ public void dragExit(DropTargetEvent evt){}\r
+ public void dragOver(DropTargetDragEvent evt){}\r
+ public void dropActionChanged(DropTargetDragEvent evt){}\r
+ public void drop(DropTargetDropEvent evt)\r
+{\r
+   Transferable t = evt.getTransferable();\r
+   if(!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor))\r
+     return;\r
 \r
+   evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);\r
+   try{\r
+     java.util.List files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor);\r
+\r
+     for (int i = 0; i < files.size(); i++)\r
+     {\r
+       String file = files.get(i).toString();\r
+       String protocol = "File";\r
+       String format = jalview.io.IdentifyFile.Identify(file, protocol);\r
+       LoadFile(file, protocol, format);\r
+     }\r
+\r
+   }catch(Exception ex){ex.printStackTrace();}\r
+  }\r
 \r
  public void inputLocalFileMenuItem_actionPerformed(ActionEvent e)\r
  {\r
@@ -169,18 +203,17 @@ public void windowClosing(WindowEvent evt)
    if (FormatProperties.contains(format))\r
        sequences = FormatAdapter.read(file, protocol, format);\r
 \r
-   if (sequences != null)\r
+   if (sequences != null && sequences.length>0)\r
    {\r
      AlignFrame af = new AlignFrame(new Alignment(sequences));\r
      addInternalFrame(af, file, 700, 500);\r
      af.statusBar.setText("Successfully loaded file " + file);\r
 \r
-\r
    }\r
    else\r
      JOptionPane.showInternalMessageDialog(Desktop.desktop,  "Couldn't open file.\n"\r
                           + "Formats currently supported are\n"\r
-                          + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM"\r
+                          + "Fasta, MSF, Clustal, BLC, PIR, MSP or PFAM" // JBPNote - message should be generated through FormatAdapter!\r
                           ,"Error loading file",\r
                                    JOptionPane.WARNING_MESSAGE);\r
 \r
@@ -196,7 +229,6 @@ public void windowClosing(WindowEvent evt)
 \r
    String format = IdentifyFile.Identify(url, "URL");\r
 \r
-   System.out.println(format +" format");\r
    if (format.equals("URL NOT FOUND"))\r
    {\r
      JOptionPane.showInternalMessageDialog(Desktop.desktop,"Couldn't locate " + url,\r
@@ -261,7 +293,8 @@ public void windowClosing(WindowEvent evt)
                                          "JalView 2005 version " + jalview.bin.Cache.VERSION+"; last updated: "+jalview.bin.Cache.BUILD_DATE\r
                                        +"\nAuthors:  Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton."\r
                                        +"\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee."\r
-                                       +"\nIf  you use JalView, please cite:  \"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",\r
+                                       +"\nIf  you use JalView, please cite:  Bioinformatics,  2004 12;426-7."\r
+                                       +"\n\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"",\r
                                          "About Jalview",\r
                                          JOptionPane.INFORMATION_MESSAGE);\r
  }\r
@@ -291,14 +324,17 @@ public void windowClosing(WindowEvent evt)
  public static int setConservationSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source)\r
  {\r
    SliderPanel sp = null;\r
+   ConservationColourScheme ccs = (ConservationColourScheme)cs;\r
+   int value = ccs.inc;\r
 \r
    if(conservationSlider == null)\r
    {\r
-     sp = new SliderPanel(ap, 30, true, cs);\r
+     sp = new SliderPanel(ap, value, true, cs);\r
      conservationSlider = new JInternalFrame();\r
      conservationSlider.setContentPane(sp);\r
-     conservationSlider.setResizable(false);\r
      addInternalFrame(conservationSlider, "Conservation Colour Increment  ("+source+")", 420, 90);\r
+     conservationSlider.setResizable(false);\r
+     conservationSlider.setMaximizable(false);\r
      conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter()\r
                   {\r
                     public void internalFrameClosed(javax.swing.event.InternalFrameEvent e)\r
@@ -309,9 +345,11 @@ public void windowClosing(WindowEvent evt)
    }\r
    else\r
    {\r
+\r
        conservationSlider.setTitle("Conservation Colour Increment  ("+source+")");\r
        sp = (SliderPanel)conservationSlider.getContentPane();\r
        sp.cs = cs;\r
+       sp.setValue(value);\r
    }\r
 \r
    if(ap.av.alignment.getGroups()!=null)\r
@@ -348,8 +386,9 @@ public void windowClosing(WindowEvent evt)
      pid = new SliderPanel(ap, 50, false, cs);\r
      PIDSlider = new JInternalFrame();\r
      PIDSlider.setContentPane(pid);\r
-     PIDSlider.setResizable(false);\r
      addInternalFrame(PIDSlider, "Percentage Identity Threshold ("+source+")", 420, 90);\r
+     PIDSlider.setResizable(false);\r
+     PIDSlider.setMaximizable(false);\r
    }\r
    else\r
    {\r