X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDesktop.java;h=5076243ebae7fc2274c3c0a18a4b620624c3bde7;hb=6d5aff5f7ace98b6416c7e9dc2a8fdc6ad194902;hp=fe25cd46c599aa5a9d7d5da4b1dde5b37ca5f18a;hpb=a2d2bfc9a2efd08446954c01dc5957560fdec9be;p=jalview.git diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index fe25cd4..5076243 100755 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -16,9 +16,13 @@ import jalview.schemes.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.awt.dnd.*; +import javax.swing.*; +import java.awt.datatransfer.*; +import java.io.*; -public class Desktop extends jalview.jbgui.GDesktop +public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener { public static JDesktopPane desktop; static int openFrameCount = 0; @@ -42,12 +46,17 @@ public class Desktop extends jalview.jbgui.GDesktop setTitle("Jalview 2005"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - setVisible(true); desktop = new JDesktopPane(); - desktop.setBackground(Color.white); + // desktop.setBackground(Color.white); setContentPane(desktop); desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE); + + // This line prevents Windows Look&Feel resizing all new windows to maximum + // if previous window was maximised + desktop.setDesktopManager( new DefaultDesktopManager() ); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); String x = jalview.bin.Cache.getProperty("SCREEN_X"); String y = jalview.bin.Cache.getProperty("SCREEN_Y"); @@ -77,8 +86,9 @@ public void windowClosing(WindowEvent evt) jalview.bin.Cache.setProperty("SCREEN_HEIGHT", getHeight() + ""); } }); +setVisible(true); -/////////Add a splashscreen on startup +this.setDropTarget(new java.awt.dnd.DropTarget(desktop, this)); /////////Add a splashscreen on startup @@ -87,7 +97,7 @@ public void windowClosing(WindowEvent evt) SplashScreen splash = new SplashScreen(frame, image); frame.setContentPane(splash); desktop.add(frame); - frame.setVisible(true); + openFrameCount++; try { @@ -102,23 +112,30 @@ public void windowClosing(WindowEvent evt) frame.setIconifiable(false); frame.setMaximizable(false); frame.setFrameIcon(null); + frame.setVisible(true); } - public static void addInternalFrame(final JInternalFrame frame, String title, int w, int h) { + addInternalFrame(frame, title, w, h, true); + } + + public static void addInternalFrame(final JInternalFrame frame, String title, + int w, + int h, + boolean resizable ) + { desktop.add(frame); - frame.setVisible(true); openFrameCount++; try { frame.setSelected(true); } catch (java.beans.PropertyVetoException e) {} frame.setTitle(title); - frame.setResizable(true); frame.setSize(w,h); frame.setClosable(true); - frame.setMaximizable(true); - frame.setIconifiable(true); + frame.setResizable(resizable); + frame.setMaximizable(resizable); + frame.setIconifiable(resizable); frame.setFrameIcon(null); frame.setLocation(xOffset*openFrameCount, yOffset*openFrameCount); frame.toFront(); @@ -140,10 +157,34 @@ public void windowClosing(WindowEvent evt) } }); + frame.setVisible(true); windowMenu.add(menuItem); } + public void dragEnter(DropTargetDragEvent evt){} + public void dragExit(DropTargetEvent evt){} + public void dragOver(DropTargetDragEvent evt){} + public void dropActionChanged(DropTargetDragEvent evt){} + public void drop(DropTargetDropEvent evt) +{ + Transferable t = evt.getTransferable(); + if(!t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) + return; + + evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); + try{ + java.util.List files = (java.util.List) t.getTransferData(DataFlavor.javaFileListFlavor); + for (int i = 0; i < files.size(); i++) + { + String file = files.get(i).toString(); + String protocol = "File"; + String format = jalview.io.IdentifyFile.Identify(file, protocol); + LoadFile(file, protocol, format); + } + + }catch(Exception ex){ex.printStackTrace();} + } public void inputLocalFileMenuItem_actionPerformed(ActionEvent e) { @@ -169,13 +210,12 @@ public void windowClosing(WindowEvent evt) if (FormatProperties.contains(format)) sequences = FormatAdapter.read(file, protocol, format); - if (sequences != null) + if (sequences != null && sequences.length>0) { AlignFrame af = new AlignFrame(new Alignment(sequences)); - addInternalFrame(af, file, 700, 500); + addInternalFrame(af, file, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); af.statusBar.setText("Successfully loaded file " + file); - } else JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't open file.\n" @@ -196,7 +236,6 @@ public void windowClosing(WindowEvent evt) String format = IdentifyFile.Identify(url, "URL"); - System.out.println(format +" format"); if (format.equals("URL NOT FOUND")) { JOptionPane.showInternalMessageDialog(Desktop.desktop,"Couldn't locate " + url, @@ -230,7 +269,9 @@ public void windowClosing(WindowEvent evt) if(sequences!=null) { AlignFrame af = new AlignFrame(new Alignment(sequences)); - addInternalFrame(af, "Cut & Paste input - "+format, 700, 500); + addInternalFrame(af, "Cut & Paste input - "+format, + AlignFrame.NEW_WINDOW_WIDTH, + AlignFrame.NEW_WINDOW_HEIGHT); af.statusBar.setText("Successfully pasted alignment file"); } else @@ -261,7 +302,8 @@ public void windowClosing(WindowEvent evt) "JalView 2005 version " + jalview.bin.Cache.VERSION+"; last updated: "+jalview.bin.Cache.BUILD_DATE +"\nAuthors: Michele Clamp, James Cuff, Steve Searle, Andrew Waterhouse, Jim Procter & Geoff Barton." +"\nCurrent development managed by Andrew Waterhouse; Barton Group, University of Dundee." - +"\nIf you use JalView, please cite: \"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", + +"\nIf you use JalView, please cite: Bioinformatics, 2004 12;426-7." + +"\n\"Clamp, M., Cuff, J., Searle, S. M. and Barton, G. J. (2004), The Jalview Java Alignment Editor\"", "About Jalview", JOptionPane.INFORMATION_MESSAGE); } @@ -285,87 +327,4 @@ public void windowClosing(WindowEvent evt) ex.printStackTrace(); } } - - static JInternalFrame conservationSlider; - static JInternalFrame PIDSlider; - public static int setConservationSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) - { - SliderPanel sp = null; - - if(conservationSlider == null) - { - sp = new SliderPanel(ap, 30, true, cs); - conservationSlider = new JInternalFrame(); - conservationSlider.setContentPane(sp); - conservationSlider.setResizable(false); - addInternalFrame(conservationSlider, "Conservation Colour Increment ("+source+")", 420, 90); - conservationSlider.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() - { - public void internalFrameClosed(javax.swing.event.InternalFrameEvent e) - { - conservationSlider = null; - } - }); - } - else - { - conservationSlider.setTitle("Conservation Colour Increment ("+source+")"); - sp = (SliderPanel)conservationSlider.getContentPane(); - sp.cs = cs; - } - - if(ap.av.alignment.getGroups()!=null) - sp.setAllGroupsCheckEnabled( true ); - else - sp.setAllGroupsCheckEnabled( false); - - return sp.getValue(); - - } - - public static void hideConservationSlider() - { - try{ - conservationSlider.setClosed(true); - conservationSlider = null; - }catch(Exception ex){} -} - - - public static void hidePIDSlider() - { - try{ - PIDSlider.setClosed(true); - PIDSlider = null; - }catch(Exception ex){} - } - - public static int setPIDSliderSource(AlignmentPanel ap, ColourSchemeI cs, String source) - { - SliderPanel pid = null; - if(PIDSlider == null) - { - pid = new SliderPanel(ap, 50, false, cs); - PIDSlider = new JInternalFrame(); - PIDSlider.setContentPane(pid); - PIDSlider.setResizable(false); - addInternalFrame(PIDSlider, "Percentage Identity Threshold ("+source+")", 420, 90); - } - else - { - PIDSlider.setTitle("Percentage Identity Threshold ("+source+")"); - pid = (SliderPanel)PIDSlider.getContentPane(); - pid.cs = cs; - } - - if (ap.av.alignment.getGroups() != null) - pid.setAllGroupsCheckEnabled(true); - else - pid.setAllGroupsCheckEnabled(false); - - - return pid.getValue(); - - } - }