View Javadoc

1   /*
2    * PasteAction.java
3    *
4    * Created on 27. mai 2005, 21:24
5    */
6   
7   package com.vikash.firsttool.UI;
8   import com.vikash.firsttool.Diagram.*;
9   import java.awt.event.*;
10  import java.net.URL;
11  import javax.swing.*;
12  
13    import javax.swing.TransferHandler;
14  /***
15   *
16   * @author  studajb
17   */
18  public class PasteAction extends AbstractAction{
19      ToolGraph graph;
20       ToolInternalFrame internalframe;
21       MainFrame frame;
22       static PasteAction instance;
23      
24      
25      public static PasteAction getinstance(final MainFrame frame,boolean flag){
26          if(flag)
27              instance=null;
28          if(instance==null){
29              instance=new PasteAction(frame);
30          }
31              return instance;
32          }
33      
34      /*** Creates a new instance of PasteAction */
35      public PasteAction(MainFrame frame) {
36           URL icon=getClass().getClassLoader().getResource("com/vikash/firsttool/resources/paste.gif");
37            putValue(Action.SMALL_ICON,new ImageIcon(icon));
38          putValue(Action.SHORT_DESCRIPTION,"Paste");
39          putValue(Action.ACCELERATOR_KEY,KeyStroke.getKeyStroke(KeyEvent.VK_V,InputEvent.CTRL_MASK));
40           this.frame=frame;
41      }
42      
43      public void actionPerformed(ActionEvent e) {
44          internalframe=(ToolInternalFrame)frame.getDesktopPane().getSelectedFrame();
45          if(internalframe != null){ 
46              
47          graph=internalframe.getGraph();
48          TransferHandler .getPasteAction() .actionPerformed(
49  			new ActionEvent(graph, e.getID() , e.getActionCommand(),e.getModifiers() ));
50          }
51      }
52      
53  }