/[classpath]/classpath/javax/swing/TransferHandler.java
ViewVC logotype

Diff of /classpath/javax/swing/TransferHandler.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by audriusa, Tue Nov 22 16:07:57 2005 UTC revision 1.13 by mark, Sun Dec 4 19:51:44 2005 UTC
# Line 1  Line 1 
1  /* TransferHandler.java --  /* TransferHandler.java --
2     Copyright (C) 2004 Free Software Foundation, Inc.     Copyright (C) 2004, 2005 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 43  import java.awt.datatransfer.DataFlavor; Line 43  import java.awt.datatransfer.DataFlavor;
43  import java.awt.datatransfer.Transferable;  import java.awt.datatransfer.Transferable;
44  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
45  import java.awt.event.InputEvent;  import java.awt.event.InputEvent;
46    import java.awt.Toolkit;
47  import java.io.Serializable;  import java.io.Serializable;
48    
49  public class TransferHandler implements Serializable  public class TransferHandler implements Serializable
# Line 62  public class TransferHandler implements Line 63  public class TransferHandler implements
63        TransferHandler transferHandler = component.getTransferHandler();        TransferHandler transferHandler = component.getTransferHandler();
64        Clipboard clipboard = getClipboard(component);        Clipboard clipboard = getClipboard(component);
65    
66          if (clipboard == null)
67            {
68              // Access denied!
69              Toolkit.getDefaultToolkit().beep();
70              return;
71            }
72    
73        if (command.equals(COMMAND_COPY))        if (command.equals(COMMAND_COPY))
74          transferHandler.exportToClipboard(component, clipboard, COPY);          transferHandler.exportToClipboard(component, clipboard, COPY);
75        else if (command.equals(COMMAND_CUT))        else if (command.equals(COMMAND_CUT))
# Line 76  public class TransferHandler implements Line 84  public class TransferHandler implements
84      }      }
85        
86      /**      /**
87       * Get the system cliboard. If not available, create and return the VM-local       * Get the system cliboard or null if the caller isn't allowed to
88       * clipboard.       * access the system clipboard.
89       *       *
90       * @param component a component, used to get the toolkit.       * @param component a component, used to get the toolkit.
91       * @return the clipboard       * @return the clipboard
# Line 85  public class TransferHandler implements Line 93  public class TransferHandler implements
93      private static Clipboard getClipboard(JComponent component)      private static Clipboard getClipboard(JComponent component)
94      {      {
95        try        try
96          {          {
97            SecurityManager sm = System.getSecurityManager();            return component.getToolkit().getSystemClipboard();
98            if (sm != null)          }
99              sm.checkSystemClipboardAccess();        catch (SecurityException se)
100            {
101            // We may access the system clipboard.            return null;
102            return component.getToolkit().getSystemClipboard();          }
         }  
       catch (Exception e)  
         {  
           // We may not access system clipboard.  
           // Create VM-local clipboard if none exists yet.  
           if (clipboard == null)  
             clipboard = new Clipboard("Clipboard");  
           return clipboard;  
         }  
103      }      }
104    }    }
105        
# Line 119  public class TransferHandler implements Line 118  public class TransferHandler implements
118    private static Action cutAction = new TransferAction(COMMAND_CUT);    private static Action cutAction = new TransferAction(COMMAND_CUT);
119    private static Action pasteAction = new TransferAction(COMMAND_PASTE);    private static Action pasteAction = new TransferAction(COMMAND_PASTE);
120        
   /**  
    * Clipboard if system clipboard may not be used.  
    * Package-private to avoid an accessor method.  
    */  
   static Clipboard clipboard;  
     
121    private int sourceActions;    private int sourceActions;
122    private Icon visualRepresentation;    private Icon visualRepresentation;
123        

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26