List of usage examples for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE
int ACTION_COPY_OR_MOVE
To view the source code for java.awt.dnd DnDConstants ACTION_COPY_OR_MOVE.
Click Source Link
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
public void drop(DropTargetDropEvent evt) { logger.debug("=-> drop"); try {/*from w w w .j a va 2s.c o m*/ Transferable t = evt.getTransferable(); if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) { logger.debug(" Accepting 'string' data flavor..."); evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); String s = (String) t.getTransferData(DataFlavor.stringFlavor); evt.getDropTargetContext().dropComplete(true); logger.debug("DnD: '" + s + "'"); if (s != null) { int indexOf = s.indexOf("\n"); if (indexOf != -1) { dragAndDropReference = new DragAndDropReference(s.substring(indexOf + 1), s.substring(0, indexOf), DragAndDropReference.BROWSER_LINK); } else { dragAndDropReference = new DragAndDropReference(s, DragAndDropReference.BROWSER_LINK); } } } else { if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { logger.debug(" Accepting 'file list' data flavor..."); evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); List<Object> list = (List<Object>) t.getTransferData(DataFlavor.javaFileListFlavor); if (list != null) { Iterator<Object> iterator = list.iterator(); while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof File) { logger.debug(" DnD file: " + next); dragAndDropReference = new DragAndDropReference(((File) next).getAbsolutePath(), DragAndDropReference.EXPLORER_LINK); } } } } else { logger.debug("DnD rejected! "); dragAndDropReference = null; // DataFlavor[] dfs=t.getTransferDataFlavors(); // for (int i = 0; i < dfs.length; i++) { // logger.debug(" "+i+" ... "+dfs[i].getMimeType()); // logger.debug(" "+i+" ... // "+dfs[i].getDefaultRepresentationClassAsString()); // logger.debug(" "+i+" ... // "+dfs[i].getHumanPresentableName()); // } } } } catch (Exception e) { logger.debug("Drag&Drop error:", e); dragAndDropReference = null; } OutlineJPanel.getInstance().enableDisableAttachToolbarButton(); if (dragAndDropReference != null) { JOptionPane.showMessageDialog(this, "Dropped local/web resource reference stored! Use \n'clip' icon from Notebook outline toolbar to attach it.", "Drag&Drop Info", JOptionPane.INFORMATION_MESSAGE); dragAndDropReference.debug(); } logger.debug("<-= drop"); }
From source file:com.SE.myPlayer.MusicPlayerGUI.java
public void tableReferesh(JTable songData_Table, String tableName, String columName) { int emptyResultSet = 0; try {/* w w w .java 2 s. c o m*/ con = db.getCon(); stmt = con.createStatement(); ResultSet rs; switch (tableName) { case "library": rs = stmt.executeQuery("select * from library order by " + columName + ""); break; case "playlist": rs = stmt.executeQuery("select * from library order by " + columName + ""); break; default: rs = stmt.executeQuery( "Select library.id_songs, library.song_location, library.song_name, library.song_album, library.song_artist, library.genre, library.year, library.time, library.comment from playlist INNER JOIN library ON library.id_songs = playlist.id_songs AND playlist.playlist_name = '" + tableName + "' order by " + columName + ""); break; } DefaultTableModel myModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { return false; } }; String[] songsColumnsName = { "Location", "Name", "Album", "Artist", "Genre", "Year", "Time", "Comment" }; myModel.setColumnIdentifiers(songsColumnsName); ResultSetMetaData rsmd = rs.getMetaData(); int colNumbers = rsmd.getColumnCount(); Object[] objects = new Object[colNumbers]; while (rs.next()) { emptyResultSet = 1; for (int i = 0; i < colNumbers - 1; i++) { objects[i] = rs.getObject(i + 2); } myModel.addRow(objects); } if (emptyResultSet == 0) { myModel.addRow(objects); } songData_Table.setModel(myModel); rs = stmt.executeQuery("select col_name from col_name where col_status = 0"); while (rs.next()) { songData_Table.removeColumn(songData_Table.getColumn(rs.getString(1))); } songData_Table.getTableHeader().removeMouseListener(ma); songData_Table.getTableHeader().addMouseListener(ma); songData_Table.setDragEnabled(true); songData_Table.setDropTarget(new DropTarget() { @Override public synchronized void drop(DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Transferable t = dtde.getTransferable(); try { if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { Object fileList = t.getTransferData(DataFlavor.javaFileListFlavor); String files = fileList.toString(); finalString = convertFileString(files); if (dropControl == 0 && lastOpen.equals("library")) { songAddDB(finalString); } else if (dropControl == 0 && !lastOpen.equals("library")) { songAddPlaylistFromLibrary(lastOpen, finalString); getSongTable(lastOpen); } else { songAddPlaylistFromLibrary(tableName, finalString); } } else if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { Object fileList = t.getTransferData(DataFlavor.stringFlavor); String fileListString = fileList.toString(); fileListString = Arrays.toString(fileListString.split("\\n")); String[] splitLocations = fileListString.split(",\\s"); for (int i = 0; i < splitLocations.length; i++) { if (i == 0) { splitLocations[i] = splitLocations[i].substring(1, splitLocations[i].indexOf(".mp3") + 4); } else { splitLocations[i] = splitLocations[i].substring(0, splitLocations[i].indexOf(".mp3") + 4); } } for (int i = 0; i < splitLocations.length; i++) { splitLocations[i] = sd.getLocations(splitLocations[i]); } finalString = Arrays.asList(splitLocations); if (dropControl == 0 && lastOpen.equals("library")) { songAddDB(finalString); } else if (dropControl == 0 && !lastOpen.equals("library")) { songAddPlaylistFromLibrary(lastOpen, finalString); getSongTable(lastOpen); } else { songAddPlaylistFromLibrary(tableName, finalString); } } } catch (UnsupportedFlavorException | IOException | InvalidDataException | UnsupportedTagException ex) { System.out.println("Error in second drop flavour............" + ex); } } }); if (con != null) { stmt.close(); con.close(); } } catch (SQLException e) { System.out.println("Error in Stmt " + e); } }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
@Override public void dragEnter(DropTargetDragEvent dtde) { if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor) || dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { if (dtde.getDropTargetContext().getComponent() == jSourcesTable || dtde.getDropTargetContext().getComponent() == jVictimTable) { dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } else {//from w w w . ja v a 2 s .co m dtde.rejectDrag(); } } else { dtde.rejectDrag(); } }
From source file:de.tor.tribes.ui.windows.TribeTribeAttackFrame.java
@Override public void drop(DropTargetDropEvent dtde) { Transferable t = dtde.getTransferable(); List<Village> villages = new LinkedList<Village>(); if (dtde.getDropTargetContext().getComponent() == jSourcesTable || dtde.getDropTargetContext().getComponent() == jVictimTable) { if (dtde.isDataFlavorSupported(VillageTransferable.villageDataFlavor)) { //village dnd dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); try { villages = (List<Village>) t.getTransferData(VillageTransferable.villageDataFlavor); } catch (Exception ex) { }//from w w w . j a va2 s. c om } else if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) { //string dnd try { villages = PluginManager.getSingleton() .executeVillageParser((String) t.getTransferData(DataFlavor.stringFlavor)); } catch (Exception e) { } } else { dtde.rejectDrop(); return; } } else { dtde.rejectDrop(); return; } MapPanel.getSingleton().setCurrentCursor(MapPanel.getSingleton().getCurrentCursor()); if (!villages.isEmpty()) { if (jideTabbedPane1.getSelectedIndex() == 0) { fireAddSourcesEvent(villages); } else if (jideTabbedPane1.getSelectedIndex() == 1) { fireAddTargetsEvent(villages); } } }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void setDragSourceFileSystem() { theDragSource = this.depositPresenter.new TreeDragSource(treeFileSystem, DnDConstants.ACTION_COPY_OR_MOVE); theDragTarget = this.depositPresenter.new TreeDropTarget(treeEntities); theDragTargetSelf = null;/*from w w w . j a v a 2 s . co m*/ }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void setDragSourceEntity() { theDragSource = this.depositPresenter.new TreeDragSource(treeEntities, DnDConstants.ACTION_COPY_OR_MOVE); theDragTarget = this.depositPresenter.new TreeDropTarget(treeStructMap); theDragTargetSelf = this.depositPresenter.new TreeDropTarget(treeEntities); }
From source file:nz.govt.natlib.ndha.manualdeposit.ManualDepositMain.java
private void setDragSourceStructMap() { theDragSource = this.depositPresenter.new TreeDragSource(treeStructMap, DnDConstants.ACTION_COPY_OR_MOVE); theDragTarget = this.depositPresenter.new TreeDropTarget(treeStructMap); theDragTargetSelf = this.depositPresenter.new TreeDropTarget(treeStructMap); }
From source file:org.apache.jmeter.gui.MainFrame.java
/** * Handler of Top level Dnd//from www. ja v a2s . c o m */ @Override public void drop(DropTargetDropEvent dtde) { try { Transferable tr = dtde.getTransferable(); DataFlavor[] flavors = tr.getTransferDataFlavors(); for (DataFlavor flavor : flavors) { // Check for file lists specifically if (flavor.isFlavorJavaFileListType()) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); try { openJmxFilesFromDragAndDrop(tr); } finally { dtde.dropComplete(true); } return; } } } catch (UnsupportedFlavorException | IOException e) { log.warn("Dnd failed", e); } }
From source file:org.nuclos.client.ui.collect.searcheditor.AtomicSearchConditionTreeNode.java
@Override public int getDataTransferSourceActions() { return DnDConstants.ACTION_COPY_OR_MOVE; }
From source file:org.orbisgis.core.ui.plugins.views.geocatalog.Catalog.java
public Catalog() { menuTree = new org.orbisgis.core.ui.pluginSystem.menu.MenuTree(); lstSources = new OGList(); lstSources.addMouseListener(new MouseAdapter() { @Override/*from w w w . ja va2 s . co m*/ public void mousePressed(MouseEvent e) { showPopup(e); } @Override public void mouseReleased(MouseEvent e) { showPopup(e); } private void showPopup(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { int path = -1; for (int i = 0; i < listModel.getSize(); i++) { if (lstSources.getCellBounds(i, i).contains(e.getPoint())) { path = i; break; } } int[] selectionPaths = lstSources.getSelectedIndices(); if ((selectionPaths != null) && (path != -1)) { if (!CollectionUtils.contains(selectionPaths, path)) { if (e.isControlDown()) { lstSources.addSelectionInterval(path, path); } else { lstSources.setSelectionInterval(path, path); } } } else if (path == -1) { lstSources.clearSelection(); } else { } } if (e.isPopupTrigger()) { JPopupMenu popup = getPopup(); if (popup != null) { popup.show(e.getComponent(), e.getX(), e.getY()); } } } }); listModel = new SourceListModel(); lstSources.setModel(listModel); this.setLayout(new BorderLayout()); this.add(new JScrollPane(lstSources), BorderLayout.CENTER); this.add(getNorthPanel(), BorderLayout.NORTH); SourceListRenderer cellRenderer = new SourceListRenderer(this); cellRenderer.setRenderers(new SourceRenderer[0]); lstSources.setCellRenderer(cellRenderer); dragSource = DragSource.getDefaultDragSource(); dragSource.createDefaultDragGestureRecognizer(lstSources, DnDConstants.ACTION_COPY_OR_MOVE, this); editingSources = new HashMap<String, EditableSource>(); //Init the file drop system FileDrop fileDrop = new FileDrop(this, new FileDrop.Listener() { @Override public void filesDropped(java.io.File[] files) { DataManager dm = (DataManager) Services.getService(DataManager.class); SourceManager sourceManager = dm.getSourceManager(); for (File file : files) { // For each file, we ensure that we have a driver // that can be used to read it. If we don't, we don't // open the file. if (OrbisConfiguration.isFileEligible(file)) { try { String name = sourceManager .getUniqueName(FilenameUtils.removeExtension(file.getName())); sourceManager.register(name, file); } catch (SourceAlreadyExistsException e) { ErrorMessages.error(ErrorMessages.SourceAlreadyRegistered + ": ", e); } } } } }); }