Ejemplo n.º 1
0
  public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
      try {
        content =
            (java.util.List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        repaint();
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      dtde.dropComplete(true);

      boolean listsAreEqual = true;

      for (int i = 0; i < content.size(); i++) {
        if (!FileListTransferable.files[i].getName().equals(content.get(i).getName())) {
          listsAreEqual = false;
        }
      }

      if (listsAreEqual) {
        System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL);
        System.exit(0);
      }
    }
    dtde.rejectDrop();
    System.err.println(InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED);
    System.exit(1);
  }
Ejemplo n.º 2
0
  public void drop(DropTargetDropEvent dtde) {
    if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
      dtde.rejectDrop();
      return;
    }
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    Vector<RowContainer> oldvec = this.filevector;

    Transferable transferable = dtde.getTransferable();
    try {
      java.util.List<File> filelist =
          (java.util.List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
      for (File f : filelist) {
        filevector.add(new RowContainer(f));

        model.fireTableDataChanged();
        System.out.println(f.toString());
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    } catch (UnsupportedFlavorException ex) {
      ex.printStackTrace();
    }
    dtde.dropComplete(true);
    File[] filar = new File[filevector.size()];
    for (int i = 0; i < filevector.size(); i++) {
      filar[i] = filevector.get(i).getFile();
    }
    super.firePropertyChange("filevector", null, filar);
  }
Ejemplo n.º 3
0
  /** Pastes Items from the Clipboard on the Board */
  public void paste() {

    ComponentSelection clipboardContent = (ComponentSelection) tbe.getClipboard().getContents(this);

    if ((clipboardContent != null)
        && (clipboardContent.isDataFlavorSupported(ComponentSelection.itemFlavor))) {

      Object[] tempItems = null;
      try {
        tempItems =
            board.cloneItems(clipboardContent.getTransferData(ComponentSelection.itemFlavor));
      } catch (UnsupportedFlavorException e1) {

        e1.printStackTrace();
      }
      ItemComponent[] items = new ItemComponent[tempItems.length];
      for (int i = 0; i < tempItems.length; i++) {
        items[i] = (ItemComponent) tempItems[i];
      }
      PasteCommand del = new PasteCommand(items);
      ArrayList<Command> actCommands = new ArrayList<Command>();
      actCommands.add(del);
      tbe.addCommands(actCommands);
      board.addItem(items);
    }
  }
Ejemplo n.º 4
0
  /**
   * This method causes a transfer to a component from a clipboard or a DND drop operation. The
   * Transferable represents the data to be imported into the component.
   *
   * @param comp The component to receive the transfer. This argument is provided to enable sharing
   *     of TransferHandlers by multiple components.
   * @param t The data to import
   * @return <code>true</code> iff the data was inserted into the component.
   */
  public boolean importData(JComponent comp, Transferable t) {

    JTextComponent c = (JTextComponent) comp;
    withinSameComponent = c == exportComp;

    // if we are importing to the same component that we exported from
    // then don't actually do anything if the drop location is inside
    // the drag location and set shouldRemove to false so that exportDone
    // knows not to remove any data
    if (withinSameComponent && c.getCaretPosition() >= p0 && c.getCaretPosition() <= p1) {
      shouldRemove = false;
      return true;
    }

    boolean imported = false;
    DataFlavor importFlavor = getImportFlavor(t.getTransferDataFlavors(), c);
    if (importFlavor != null) {
      try {
        InputContext ic = c.getInputContext();
        if (ic != null) ic.endComposition();
        Reader r = importFlavor.getReaderForText(t);
        handleReaderImport(r, c);
        imported = true;
      } catch (UnsupportedFlavorException ufe) {
        ufe.printStackTrace();
      } catch (BadLocationException ble) {
        ble.printStackTrace();
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }

    return imported;
  }
Ejemplo n.º 5
0
  public void drop(DropTargetDropEvent dtde) {
    logger.info("Drop: " + dtde);
    if (dtde.isDataFlavorSupported(OWLObjectDataFlavor.OWL_OBJECT_DATA_FLAVOR)) {
      try {
        List<OWLObject> objects =
            (List<OWLObject>)
                dtde.getTransferable().getTransferData(OWLObjectDataFlavor.OWL_OBJECT_DATA_FLAVOR);
        List<OWLClass> clses = new ArrayList<OWLClass>();
        for (OWLObject obj : objects) {
          if (obj instanceof OWLClass) {
            clses.add((OWLClass) obj);
          }
        }

        if (!clses.isEmpty()) {
          getAssertedGraphComponent().getVisualisedObjectManager().showObjects(clses.toArray());
          dtde.dropComplete(true);
        }
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Ejemplo n.º 6
0
  /* (non-Javadoc)
   * @see javax.swing.TransferHandler#importData(javax.swing.TransferHandler.TransferSupport)
   */
  @Override
  public boolean importData(TransferSupport support) {
    try {
      if (support.getComponent() instanceof JTree) {
        JTree tree = (JTree) support.getComponent();
        Point dropPoint = support.getDropLocation().getDropPoint();
        TreePath path = tree.getPathForLocation(dropPoint.x, dropPoint.y);
        Object node = path.getLastPathComponent();
        if (support.isDataFlavorSupported(ProcessVar.PvDataFlavors[0])) {
          ProcessVar tVar = (ProcessVar) ((PvTreeNode) node).getUserObject();
          ProcessVar chldPv =
              (ProcessVar) support.getTransferable().getTransferData(ProcessVar.PvDataFlavors[0]);

          Object chldKey = chldPv.getKeyValue();
          tVar.put(chldKey, chldPv, PvChangeEvent.PV_ADDED);
          DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
          model.nodeStructureChanged((TreeNode) model.getRoot());
          return true;
        }
      }
    } catch (UnsupportedFlavorException e) {
      ProcessVar.log.error(this.toString() + ":" + e.getMessage());
    } catch (IOException e) {
      ProcessVar.log.error(this.toString() + ":" + e.getMessage());
    }
    // anything else is handled by superclass
    return super.importData(support);
  }
Ejemplo n.º 7
0
 /**
  * Manages mouse clicks
  *
  * @param e the event
  * @see javax.swing.text.DefaultCaret#mouseClicked(java.awt.event.MouseEvent)
  */
 public void mouseClicked(MouseEvent e) {
   if (SwingUtilities.isMiddleMouseButton(e) && e.getClickCount() == 1) {
     /** * PASTE USING MIDDLE BUTTON ** */
     JTextComponent c = (JTextComponent) e.getSource();
     if (c != null) {
       Toolkit tk = c.getToolkit();
       Clipboard buffer = tk.getSystemSelection();
       if (buffer != null) {
         Transferable trans = buffer.getContents(null);
         if (trans.isDataFlavorSupported(DataFlavor.stringFlavor)) {
           try {
             String pastedText = (String) trans.getTransferData(DataFlavor.stringFlavor);
             ((JTextPane) getConsole().getConfiguration().getInputCommandView())
                 .replaceSelection(pastedText);
           } catch (UnsupportedFlavorException e1) {
             e1.printStackTrace();
           } catch (IOException e1) {
             e1.printStackTrace();
           }
         }
       }
     }
   } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 1) {
     /** * SEND THE FOCUS TO THE INPUT COMMAND VIEW ** */
     ((JTextPane) getConsole().getConfiguration().getInputCommandView()).requestFocus();
     ((JTextPane) getConsole().getConfiguration().getInputCommandView())
         .getCaret()
         .setVisible(true);
   } else {
     /** * DELEGATE TO THE SYSTEM ** */
     super.mouseClicked(e);
   }
 }
  @SuppressWarnings("rawtypes")
  public void drop(DropTargetDropEvent dtde) {
    try {
      Transferable tr = dtde.getTransferable();
      if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        List files = (List) tr.getTransferData(DataFlavor.javaFileListFlavor);

        this.txtRawData.setText(((File) files.get(0)).getAbsolutePath());

        dtde.getDropTargetContext().dropComplete(true);
      } else {
        System.err.println("DataFlavor.javaFileListFlavor is not supported, rejected");
        dtde.rejectDrop();
      }
    } catch (IOException ex) {
      System.err.println("IOException");
      ex.printStackTrace();
      dtde.rejectDrop();
    } catch (UnsupportedFlavorException ex) {
      System.err.println("UnsupportedFlavorException");
      ex.printStackTrace();
      dtde.rejectDrop();
    }
  }
      public boolean isDragAcceptable(DropTargetDragEvent e) {

        // if dragging from this tab, do not accept
        // (dragging only to other tabbed panes)
        if (dragSourceNow) return false;

        // eventually check, whether the frame belongs to the same "group"
        // => this frame is a dependent frame of the dragSource or
        // this frame and the drag source are the dependent fames of the same
        // tabbedPane
        // => aks the client
        Transferable t = e.getTransferable();
        try {

          UIDetachableTabbedPane tp = (UIDetachableTabbedPane) t.getTransferData(TABFLAVOR);

          if (getGroupId() != tp.getGroupId()) return false;

        } catch (UnsupportedFlavorException ufe) {
          ufe.printStackTrace();
        } catch (IOException iex) {
          iex.printStackTrace();
        }

        return e.isDataFlavorSupported(TABFLAVOR);
      }
Ejemplo n.º 10
0
    /** Overridden to import a Pathname (Fileliste or String) if it is available. */
    public boolean importData(JComponent c, Transferable t) {
      Object o;
      List fileList;
      File newPath = null;

      try {
        if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
          o = t.getTransferData(DataFlavor.javaFileListFlavor);
          if (o instanceof List) {
            fileList = (List) o;
            if (!fileList.isEmpty()) {
              o = fileList.get(0);
              if (o instanceof File) {
                newPath = (File) o;
              } else {
                newPath = new File(o.toString());
              }
            }
          }
        } else if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
          newPath = new File((String) t.getTransferData(DataFlavor.stringFlavor));
        }
        if (newPath != null) {
          setPathAndDispatchEvent(newPath);
          return true;
        }
      } catch (UnsupportedFlavorException e1) {
        e1.printStackTrace();
      } catch (IOException e2) {
        e2.printStackTrace();
      }

      return false;
    }
Ejemplo n.º 11
0
 /* (non-Javadoc)
  * @see javax.swing.TransferHandler#exportDone(javax.swing.JComponent, java.awt.datatransfer.Transferable, int)
  */
 @Override
 protected void exportDone(JComponent c, Transferable t, int action) {
   try {
     if (action == MOVE) {
       ProcessVar pv = (ProcessVar) t.getTransferData(ProcessVar.PvDataFlavors[0]);
       pv.firePvChanged(
           new PvChangeEvent(pv, pv.getKeyAttribute(), pv, PvChangeEvent.PV_ELIMINATED));
     }
   } catch (UnsupportedFlavorException e) {
     ProcessVar.log.error(this.toString() + ":" + e.getMessage());
   } catch (IOException e) {
     ProcessVar.log.error(this.toString() + ":" + e.getMessage());
   }
 }
Ejemplo n.º 12
0
 protected String getClipboardContent() {
   Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
   try {
     if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
       String text = (String) t.getTransferData(DataFlavor.stringFlavor);
       return text;
     }
   } catch (UnsupportedFlavorException ex) {
     ex.printStackTrace();
     return null;
   } catch (IOException ex) {
     ex.printStackTrace();
     return null;
   }
   return null;
 }
Ejemplo n.º 13
0
 protected void exportDone(JComponent c, Transferable data, int action) {
   if (action == MOVE) {
     JList listaOrigem = (JList) c;
     Sistema[] sistemas;
     try {
       sistemas = (Sistema[]) data.getTransferData(SistemaTransferable.getSistemaDataFlavor());
       ModeloListaObjetosGrupo modelo = (ModeloListaObjetosGrupo) listaOrigem.getModel();
       modelo.removerSistemas(sistemas);
     } catch (UnsupportedFlavorException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
Ejemplo n.º 14
0
  /**
   * Handle a data transfer into the tree - this can be initiated via dnd or directly. @@TODO DnD -
   * it works but is all messed up and needs doing PROPERLY.
   */
  public boolean doTransfer(Transferable t, int action) {
    try {
      log.debug(t.getTransferDataFlavors()[0]);

      if (t.getTransferDataFlavors()[0].isMimeTypeEqual("application/x-java-file-list")) {
        return doJavaFileTransfer((List) t.getTransferData(DataFlavor.javaFileListFlavor));

      } else {
        return doLocalTransfer(t, action);
      }
    } catch (UnsupportedFlavorException e) {
      log.error(e.getMessage(), e);
    } catch (IOException e) {
      log.error(e.getMessage(), e);
    }

    return false;
  }
 // TODO portapapeles
 public void pegarDelPortapapeles() {
   portapapeles = Toolkit.getDefaultToolkit().getSystemClipboard();
   datosPortapapeles = portapapeles.getContents(null);
   if (datosPortapapeles.isDataFlavorSupported(DataFlavor.stringFlavor))
     try {
       System.out.println("" + datosPortapapeles.getTransferData(DataFlavor.stringFlavor));
       int n = jtaTexto.getCaretPosition();
       String textoJta = jtaTexto.getText();
       // String
       String sub1 = (String) textoJta.subSequence(0, n);
       String sub2 = (String) textoJta.subSequence(n, textoJta.length());
       jtaTexto.setText(
           sub1 + "" + datosPortapapeles.getTransferData(DataFlavor.stringFlavor) + "" + sub2);
     } catch (UnsupportedFlavorException e) {
       e.printStackTrace();
     } catch (IOException e) {
       e.printStackTrace();
     }
 }
  public boolean importData(JComponent c, Transferable t) {
    Object obj;
    try {
      List<File> files = (List<File>) t.getTransferData(fileFlavor);
      for (File f : files) {
        System.out.println("Got a file: " + f.getName());
        Boolean retval =
            UISupport.confirmOrCancel("Cache attachment in request?", "Att Attachment");
        if (retval == null) return false;

        attachmentModel.addFile(f, retval);
      }

    } catch (IOException ex) {
      ex.printStackTrace();
    } catch (UnsupportedFlavorException ex) {
      ex.printStackTrace();
    }
    return false;
  }
Ejemplo n.º 17
0
 /**
  * Get the String residing on the clipboard.
  *
  * @return any text found on the Clipboard; if none found, return an empty String.
  */
 public String getClipboardContents() {
   String result = "";
   Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
   // odd: the Object param of getContents is not currently used
   Transferable contents = clipboard.getContents(null);
   boolean hasTransferableText =
       (contents != null) && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
   if (hasTransferableText) {
     try {
       result = (String) contents.getTransferData(DataFlavor.stringFlavor);
     } catch (UnsupportedFlavorException ex) {
       // highly unlikely since we are using a standard DataFlavor
       System.out.println(ex);
       ex.printStackTrace();
     } catch (IOException ex) {
       System.out.println(ex);
       ex.printStackTrace();
     }
   }
   return result;
 }
Ejemplo n.º 18
0
  public void drop(
      java.awt.dnd.DropTargetDropEvent evt) { // System.out.println( "DropTargetListener.drop" );
    java.awt.datatransfer.Transferable transferable = evt.getTransferable();

    // If it's our native TransferableObject, use that
    if (transferable.isDataFlavorSupported(TransferableObject.DATA_FLAVOR)) {
      evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_MOVE);
      Object obj = null;
      try {
        obj = transferable.getTransferData(TransferableObject.DATA_FLAVOR);
      } // end try
      catch (java.awt.datatransfer.UnsupportedFlavorException e) {
        e.printStackTrace();
      } // end catch
      catch (java.io.IOException e) {
        e.printStackTrace();
      } // end catch

      if (obj != null) {
        // See where in the list we dropped the element.
        int dropIndex = locationToIndex(evt.getLocation());
        javax.swing.DefaultListModel model = (javax.swing.DefaultListModel) getModel();

        if (dropIndex < 0) model.addElement(obj);

        // Else is it moving down the list?
        else if (sourceIndex >= 0 && dropIndex > sourceIndex) model.add(dropIndex - 1, obj);
        else model.add(dropIndex, obj);

      } // end if: we got the object

      // Else there was a problem getting the object
      else {
        evt.rejectDrop();
      } // end else: can't get the object
    } // end if: it's a native TransferableObject

    // Else we can't handle this
    else evt.rejectDrop();
  } // end drop
Ejemplo n.º 19
0
  public boolean importData(JComponent comp, Transferable tr) {
    // if (log.isDebugEnabled()) log.debug("DnDStringImportHandler.importData ");
    DataFlavor[] flavors = tr.getTransferDataFlavors();

    if (!canImport(comp, flavors)) {
      return false;
    }

    try {
      String data = (String) tr.getTransferData(DataFlavor.stringFlavor);
      JTextField field = (JTextField) comp;
      field.setText(data);
      // Notify listeners drop happened
      field.firePropertyChange("DnDrop", 0, 1);
      return true;
    } catch (UnsupportedFlavorException ufe) {
      log.warn("DnDStringImportHandler.importData: " + ufe.getMessage());
    } catch (IOException ioe) {
      log.warn("DnDStringImportHandler.importData: " + ioe.getMessage());
    }
    return false;
  }
Ejemplo n.º 20
0
	/**
	 * 当拖动系统中的文件放置drop到该List中时,调用此方法。
	 */
	public synchronized void drop(DropTargetDropEvent dropTargetDropEvent) {
		System.out
				.println("method: drop(DropTargetDropEvent dropTargetDropEvent)");
		try {
			// 获取传入的Transfer对象
			Transferable tr = dropTargetDropEvent.getTransferable();
			// 如果Transfer对象支持文件放置到java平台,则进行下一步处理
			if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
				// 使用“拷贝、移动”方式接收放置操作。
				dropTargetDropEvent
						.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
				// 从Transfer中取数据,得到的是一个文件列表。即可以一次拖放多个文件
				java.util.List fileList = (java.util.List) tr
						.getTransferData(DataFlavor.javaFileListFlavor);
				Iterator iterator = fileList.iterator();
				while (iterator.hasNext()) {
					// 将拖放进来的文件的信息添加到List的数据模型中
					File file = (File) iterator.next();
					Hashtable hashtable = new Hashtable();
					hashtable.put("name", file.getName());
					hashtable.put("url", file.toURL().toString());
					hashtable.put("path", file.getAbsolutePath());
					((DefaultListModel) getModel()).addElement(hashtable);
				}
				// 放置操作成功结束
				dropTargetDropEvent.getDropTargetContext().dropComplete(true);
			} else {
				// Transferable对象不支持文件放置到java中,拒绝。
				System.err.println("Rejected");
				dropTargetDropEvent.rejectDrop();
			}
		} catch (IOException io) {
			io.printStackTrace();
			dropTargetDropEvent.rejectDrop();
		} catch (UnsupportedFlavorException ufe) {
			ufe.printStackTrace();
			dropTargetDropEvent.rejectDrop();
		}
	}
      public void drop(DropTargetDropEvent e) {

        // transferring the tab
        Transferable t = e.getTransferable();

        try {
          UIDetachableTabbedPane tp = (UIDetachableTabbedPane) t.getTransferData(TABFLAVOR);
          int sIdx = tp.getBasicTabbedPane().getSelectedIndex();
          int objectId = tp.getId();

          invokeULC("importTab", new Object[] {new Integer(objectId), new Integer(sIdx)});

          setSelectedIndex(getComponentCount() - 1);

        } catch (UnsupportedFlavorException ufe) {
          ufe.printStackTrace();
          e.dropComplete(false);
        } catch (IOException iex) {
          iex.printStackTrace();
          e.dropComplete(false);
        }
      }
Ejemplo n.º 22
0
 @SuppressWarnings("unchecked")
 @Override
 public boolean importData(JComponent comp, Transferable t) {
   if (!isSupportedFlavor(t.getTransferDataFlavors())) return false;
   if (isViaListInDragOperation) {
     // this is a drag operation on itself
     int targetRow = getSelectedIndex();
     if (targetRow < 0) return true;
     model.moveVias(selectedRowsMemento, targetRow);
   } else {
     // this is a drag operation from another component
     try {
       List<PrimitiveId> idsToAdd =
           (List<PrimitiveId>)
               t.getTransferData(PrimitiveIdTransferable.PRIMITIVE_ID_LIST_FLAVOR);
       model.insertVias(idsToAdd);
     } catch (IOException e) {
       e.printStackTrace();
     } catch (UnsupportedFlavorException e) {
       e.printStackTrace();
     }
   }
   return true;
 }
Ejemplo n.º 23
0
  /**
   * Imports data from the passed Transferable-object and tries to extract level data from it.
   *
   * <p>This method is only used by the application.
   *
   * @param transferable the transferable object tried to extract level data from
   * @return the <code>LevelCollection</code> created from the read in data
   */
  public final LevelCollection getLevelCollectionFromStringDataFlavor(Transferable transferable) {

    // Level data from the clipboard.
    List<String> levelData = new ArrayList<String>();

    // Check if the stringFlavor is supported. If not, return an empty level collection.
    if (transferable == null
        || transferable.isDataFlavorSupported(DataFlavor.stringFlavor) == false) {
      return new LevelCollection.Builder().build();
    }

    try {
      String transferString = ((String) transferable.getTransferData(DataFlavor.stringFlavor));
      transferString = transferString.replaceAll("\\r\\n|\\r", "\n"); // Ensure there is only \n
      String[] levelDataString = transferString.split("\n");

      // The method "extractLevelData" needs the data to be in List (or any subtype).
      levelData.addAll(Arrays.asList(levelDataString));
    } catch (UnsupportedFlavorException ex) {
      ex.printStackTrace();
    } catch (IOException ex) {
      ex.printStackTrace();
    }

    //		if(Settings.isDebugModeActivated) {
    //			try {
    //				levelDataAsArrayList = FormatConverter.getXSBList(levelDataAsArrayList);
    //			} catch (ParseException e) {
    //				e.printStackTrace();
    //			}
    //		}

    // Extract the level data from the clipboard data and return the LevelCollection created from
    // that data.
    return dataParser.extractData(levelData, null);
  }
Ejemplo n.º 24
0
  private void addSoftwareUnits(DropTargetDropEvent arg) {
    try {

      AnalyzedModuleTree palo =
          (AnalyzedModuleTree) arg.getTransferable().getTransferData(currentFlavor);
      ArrayList<AnalyzedModuleComponent> tobesaved = new ArrayList<AnalyzedModuleComponent>();
      for (TreePath pathe : palo.getSelectionPaths()) {

        AnalyzedModuleComponent top = (AnalyzedModuleComponent) pathe.getLastPathComponent();
        String type = top.getType().toLowerCase();
        boolean res =
            ((!type.equals("root")
                && !type.equals("application")
                && !type.equals("externalpackage")));
        if (res) {

          AnalyzedModuleComponent referencedUnit =
              StateService.instance().getAnalyzedSoftWareUnit(top.getUniqueName());
          if (!referencedUnit.isMapped()) {
            tobesaved.add(referencedUnit);
          }
        }
      }

      SoftwareUnitController controller =
          new SoftwareUnitController(getSelectedNode(arg).getModuleId());
      controller.save(tobesaved);

    } catch (UnsupportedFlavorException e) {

      e.printStackTrace();
    } catch (IOException e) {

      e.printStackTrace();
    }
  }
  @SuppressWarnings("unchecked")
  public boolean importData(JComponent comp, Transferable t) {
    // If the drop target is the main table, we want to record which
    // row the item was dropped on, to identify the entry if needed:

    try {

      List<File> files = null;
      // This flavor is used for dragged file links in Windows:
      if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
        // JOptionPane.showMessageDialog(null, "Received
        // javaFileListFlavor");
        files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
      }

      if (t.isDataFlavorSupported(urlFlavor)) {
        URL dropLink = (URL) t.getTransferData(urlFlavor);
        System.out.println("URL: " + dropLink);
        // return handleDropTransfer(dropLink, dropRow);
      }

      // This is used when one or more files are pasted from the file manager
      // under Gnome. The data consists of the file paths, one file per line:
      if (t.isDataFlavorSupported(stringFlavor)) {
        String dropStr = (String) t.getTransferData(stringFlavor);
        files = EntryTableTransferHandler.getFilesFromDraggedFilesString(dropStr);
      }

      if (files != null) {
        final List<File> theFiles = files;
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                // addAll(files);
                for (File f : theFiles) {
                  // Find the file's extension, if any:
                  String name = f.getAbsolutePath();
                  String extension = "";
                  ExternalFileType fileType = null;
                  int index = name.lastIndexOf('.');
                  if ((index >= 0) && (index < name.length())) {
                    extension = name.substring(index + 1).toLowerCase();
                    fileType = Globals.prefs.getExternalFileTypeByExt(extension);
                  }
                  if (fileType != null) {
                    if (dfh == null) {
                      dfh = new DroppedFileHandler(frame, frame.basePanel());
                    }
                    dfh.handleDroppedfile(name, fileType, true, entryContainer.getEntry());
                  }
                }
              }
            });
        return true;
      }

    } catch (IOException ioe) {
      System.err.println("failed to read dropped data: " + ioe.toString());
    } catch (UnsupportedFlavorException ufe) {
      System.err.println("drop type error: " + ufe.toString());
    }

    // all supported flavors failed
    System.err.println("can't transfer input: ");
    DataFlavor inflavs[] = t.getTransferDataFlavors();
    for (int i = 0; i < inflavs.length; i++) {
      System.out.println("  " + inflavs[i].toString());
    }

    return false;
  }
  /** Handles data import. */
  @Override
  public boolean importData(JComponent comp, Transferable t) {

    // give the drop target (this EV) the view focus
    requestViewFocus();

    Point mousePos = ev.getMousePosition();

    // ------------------------------------------
    // Import handling is done in this order:
    // 1) PlotPanel GeoElement copies
    // 2) Images
    // 3) Text
    // 4) CASTableCells
    // 5) GGB files
    // ------------------------------------------

    // try to get PlotPanel GeoElement copies
    if (t.isDataFlavorSupported(PlotPanelEuclidianView.plotPanelFlavor)) {

      try {
        AbstractAction act =
            (AbstractAction) t.getTransferData(PlotPanelEuclidianView.plotPanelFlavor);
        act.putValue("euclidianViewID", ev.getViewID());
        act.actionPerformed(new ActionEvent(act, 0, null));
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
        return false;
      } catch (IOException e) {
        e.printStackTrace();
        return false;
      }

      return true;
    }

    // try to get an image
    boolean imageDropped = ((GuiManagerD) ev.getApplication().getGuiManager()).loadImage(t, false);
    if (imageDropped) return true;

    // handle CAS table cells as simple latex string (not dynamic!!)
    // ToDo: make it dynamic (after ticket 2449 is finished)
    DataFlavor[] df = t.getTransferDataFlavors();
    for (DataFlavor d : df) {
      App.debug(d);
    }
    if (t.isDataFlavorSupported(CASTransferHandler.casTableFlavor)) {
      try {

        // after it is possible to refer to cas cells with "$1" we can refer dynamically

        // String tableRef;
        StringBuilder sb = new StringBuilder("FormulaText[$");
        sb.append(1 + (Integer) t.getTransferData(CASTransferHandler.casTableFlavor));
        sb.append("]");
        // tableRef = "$" + (cellnumber+1);

        // create a GeoText on the specific mouse position
        GeoElement[] ret =
            ev.getApplication()
                .getKernel()
                .getAlgebraProcessor()
                .processAlgebraCommandNoExceptionHandling(sb.toString(), true, false, false);

        if (ret != null && ret[0].isTextValue()) {
          GeoText geo = (GeoText) ret[0];
          geo.setLaTeX(true, false);

          // TODO: h should equal the geo height, this is just an
          // estimate
          double h = 2 * app.getFontSize();

          geo.setRealWorldLoc(
              ev.toRealWorldCoordX(mousePos.x), ev.toRealWorldCoordY(mousePos.y - h));
          geo.updateRepaint();
        }

        return true;
      } catch (Exception e) {
        e.printStackTrace();
        return false;
      }
    }

    // check for ggb file drop
    boolean ggbFileDropped = ((GuiManagerD) app.getGuiManager()).handleGGBFileDrop(t);
    if (ggbFileDropped) return true;

    // handle all text flavors
    if (t.isDataFlavorSupported(DataFlavor.stringFlavor)
        || t.isDataFlavorSupported(AlgebraViewTransferHandler.algebraViewFlavor)) {
      try {

        String text = null; // expression to be converted into GeoText
        boolean isLaTeX = false;

        // get text from AlgebraView flavor
        if (t.isDataFlavorSupported(AlgebraViewTransferHandler.algebraViewFlavor)) {

          isLaTeX = true;

          // get list of selected geo labels
          ArrayList<String> list =
              (ArrayList<String>) t.getTransferData(AlgebraViewTransferHandler.algebraViewFlavor);

          // exit if empty list
          if (list.size() == 0) return false;

          // single geo
          if (list.size() == 1) {
            text = "FormulaText[" + list.get(0) + ", true, true]";
          }

          // multiple geos, wrap in TableText
          else {
            text = "TableText[";
            for (int i = 0; i < list.size(); i++) {

              text += "{FormulaText[" + list.get(i) + ", true, true]}";
              if (i < list.size() - 1) {
                text += ",";
              }
            }
            text += "]";
          }
        }

        // get text from String flavor
        else {
          try {
            // first try to read text line-by-line
            Reader r = textReaderFlavor.getReaderForText(t);
            if (r != null) {
              StringBuilder sb = new StringBuilder();
              String line = null;
              BufferedReader br = new BufferedReader(r);
              line = br.readLine();
              while (line != null) {
                sb.append(line + "\n");
                line = br.readLine();
              }
              br.close();
              text = sb.toString();
            }
          } catch (Exception e) {
            App.debug("Caught exception decoding text transfer:" + e.getMessage());
          }

          // if the reader didn't work, try to get whatever string is
          // available
          if (text == null) text = (String) t.getTransferData(DataFlavor.stringFlavor);

          // exit if no text found
          if (text == null) return false;

          // TODO --- validate the text? e.g. no quotes for a GeoText

          // wrap text in quotes
          text = "\"" + text + "\"";
        }

        // ---------------------------------
        // create GeoText

        GeoElement[] ret =
            ev.getApplication().getKernel().getAlgebraProcessor().processAlgebraCommand(text, true);

        if (ret != null && ret[0].isTextValue()) {
          GeoText geo = (GeoText) ret[0];
          geo.setLaTeX(isLaTeX, false);

          // TODO: h should equal the geo height, this is just an
          // estimate
          double h = 2 * app.getFontSize();

          geo.setRealWorldLoc(
              ev.toRealWorldCoordX(mousePos.x), ev.toRealWorldCoordY(mousePos.y - h));
          geo.updateRepaint();
        }

        return true;

      } catch (UnsupportedFlavorException ignored) {
        // TODO
      } catch (IOException ignored) {
        // TODO
      }
    }
    return false;
  }