View Javadoc

1   package net.sf.mmapps.applications.developer.modules.editor;
2   
3   import java.awt.BorderLayout;
4   import java.awt.datatransfer.*;
5   import java.awt.dnd.*;
6   import java.awt.event.*;
7   import java.io.IOException;
8   
9   import javax.swing.*;
10  
11  import net.sf.mmapps.applications.developer.dnd.XMLConfigurationTransferable;
12  import net.sf.mmapps.modules.config.*;
13  import org.apache.commons.logging.*;
14  
15  /***
16   * @author Kees Jongenburger
17   * @version $Id: NodeManagerEditor.java,v 1.2 2004/07/16 20:55:48 keesj Exp $
18   **/
19  public class NodeManagerEditor extends JPanel implements DropTargetListener, ActionListener {
20      private static Log log = LogFactory.getLog(NodeManagerEditor.class);
21      
22      JTabbedPane jTabbedPane;
23      NodeManagerConfiguration conf;
24      Configuration configuration;
25      String applicationName;
26  
27      JTextArea jTextArea;
28  
29      public NodeManagerEditor(Configuration configuration, String applicationName, NodeManagerConfiguration nodeManagerConfiguration) {
30          super();
31          setLayout(new BorderLayout());
32          this.conf = nodeManagerConfiguration;
33          this.configuration = configuration;
34          this.applicationName = applicationName;
35          jTabbedPane = new JTabbedPane();
36  
37          JPanel pan = new NodeManagerDrawingPanel(configuration, applicationName, nodeManagerConfiguration);
38          jTabbedPane.addTab("view", pan);
39  
40          //HACKS HACKS AND MORE HACKING...
41          JScrollPane sp = new JScrollPane();
42          sp.setViewportView(jTextArea = new JTextArea(ConfigurationXMLWriter.createNodeManagerConfiguration(conf), 40, 80));
43          jTabbedPane.addTab("XML", sp);
44  
45          add(jTabbedPane, BorderLayout.CENTER);
46  		DropTarget dropTarget = new DropTarget(this, this);
47  
48      }
49  
50      public void dragEnter(DropTargetDragEvent dtde) {}
51      public void dragExit(DropTargetEvent dte) {}
52      public void dragOver(DropTargetDragEvent dtde) {}
53      public void dropActionChanged(DropTargetDragEvent dtde) {}
54      public void drop(DropTargetDropEvent dtde) {
55          Transferable tr = dtde.getTransferable();
56          try {
57              if (tr.isDataFlavorSupported(XMLConfigurationTransferable.XML_FLAVOR)) {
58                  XMLConfigurationTransferable confData = (XMLConfigurationTransferable)tr.getTransferData(XMLConfigurationTransferable.XML_FLAVOR);
59                  if (confData.getType().equals("nodemanager")){
60                          log.debug(confData.getXMLData());
61                          NodeManagerConfiguration conf = configuration.getNodeManagerConfiguration(confData.getName());
62                          
63                  }
64                  
65                  dtde.dropComplete(true);
66              } else {
67                  dtde.rejectDrop();
68              }
69          } catch (UnsupportedFlavorException e) {
70              dtde.rejectDrop();
71          } catch (IOException ioe) {
72              dtde.rejectDrop();
73          }
74      }
75  
76      public void actionPerformed(ActionEvent e) {}
77  }