本文整理汇总了Java中javax.swing.TransferHandler.TransferSupport方法的典型用法代码示例。如果您正苦于以下问题:Java TransferHandler.TransferSupport方法的具体用法?Java TransferHandler.TransferSupport怎么用?Java TransferHandler.TransferSupport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.TransferHandler
的用法示例。
在下文中一共展示了TransferHandler.TransferSupport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
if (!support.isDrop()) {
return false;
}
JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
if (dl.getColumn() < 1) {
return false;
}
try {
if (support.isDataFlavorSupported(ProjectDnD.TESTCASE_FLAVOR)) {
dropObject = support.getTransferable().getTransferData(ProjectDnD.TESTCASE_FLAVOR);
return true;
} else {
return false;
}
} catch (UnsupportedFlavorException | IOException ex) {
Logger.getLogger(ScenarioDnD.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
}
示例2: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
if (!support.isDrop()) {
return false;
}
if (!support.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
return false;
}
boolean actionSupported = (MOVE & support.getSourceDropActions()) == MOVE;
if (!actionSupported) {
return false;
}
support.setDropAction(MOVE);
return true;
}
示例3: reorderProjects
import javax.swing.TransferHandler; //导入方法依赖的package包/类
private Boolean reorderProjects(TransferHandler.TransferSupport support) {
JList list = (JList) support.getComponent();
try {
int[] selectedIndices = (int[]) support.getTransferable().getTransferData(INDICES);
DefaultListModel model = (DefaultListModel) list.getModel();
JList.DropLocation dl = (JList.DropLocation) support.getDropLocation();
if (dl.getIndex() != -1) {
for (int selectedIndex : selectedIndices) {
Object value = model.get(selectedIndex);
model.removeElement(value);
model.add(dl.getIndex(), value);
}
return true;
} else {
LOG.warning("Invalid Drop Location");
}
} catch (UnsupportedFlavorException | IOException ex) {
LOG.log(Level.SEVERE, ex.getMessage(), ex);
}
return false;
}
示例4: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
/**
* Returns true if data flavor is good and entrant isn't the same as the one dropping.
* @param support DND support object
* @return true if okay to drop
*/
@Override
public boolean canImport(TransferHandler.TransferSupport support)
{
try
{
EntrantLabel l = (EntrantLabel)support.getComponent();
BracketEntry e = (BracketEntry) support.getTransferable().getTransferData(BracketEntry.Transfer.myFlavor);
if (e.source == null)
return true;
if (l.entryId.round == e.source.round) // can't drag to same round
return false;
if (e.source.getDepth() < l.entryId.getDepth()) // can't drag backwards
return false;
if ((e.source.getDepth() - l.entryId.getDepth()) > 1) // can't go more than one forward
return false;
if (e.source.getDepth() == l.entryId.getDepth())
support.setDropAction(LINK);
else
support.setDropAction(COPY);
return true;
}
catch (Exception ex)
{
return false;
}
}
示例5: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport info) {
if (JDragDropList.this.dropListener != null) {
return JDragDropList.this.dropListener.acceptDrop(JDragDropList.this, info);
} else {
return canImportHere(info);
}
}
示例6: importData
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport info) {
if (!info.isDrop()) {
return false;
}
if (!canImportHere(info)) {
if (
(JDragDropList.this.dropListener != null) &&
JDragDropList.this.dropListener.acceptDrop(JDragDropList.this, info)
) {
return JDragDropList.this.dropListener.handleDrop(JDragDropList.this, info);
} else {
return false;
}
}
JDDLTransferData<T> data = getData(info);
int destIndex = JDragDropList.this.getDropLocation().getIndex();
/*
System.err.print("[ ");
for (int index : data.getIndices()) {
System.err.print(index + " ");
}
System.err.print("] -> ");
System.err.println(destIndex);
*/
if ((info.getDropAction() & DnDConstants.ACTION_COPY) != 0) {
copyItems(data.getSourceList(), JDragDropList.this, data.getValuesList(), destIndex);
} else if ((info.getDropAction() & DnDConstants.ACTION_MOVE) != 0) {
moveItems(data.getSourceList(), JDragDropList.this, data.getIndices(), destIndex);
} else {
return false;
}
return true;
}
示例7: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport support)
{
try
{
BracketEntry e = (BracketEntry) support.getTransferable().getTransferData(BracketEntry.Transfer.myFlavor);
if (e.source == null) return false;
support.setDropAction(MOVE);
return true;
}
catch (Exception ex) { return false; }
}
示例8: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport info) {
if (!info.isDataFlavorSupported(taskFlavor)) {
return false;
}
Category category = getTargetCategory(info);
return category != null;
}
示例9: importData
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support) {
if (canImport(support)) {
return dropFeature(support);
}
return false;
}
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:8,代码来源:FeatureListTransferHandler.java
示例10: importData
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support) {
if (!canImport(support)) {
return false;
}
// Extract transfer data.
DefaultMutableTreeNode[] nodes = null;
try {
Transferable t = support.getTransferable();
nodes = (DefaultMutableTreeNode[]) t.getTransferData(nodesFlavor);
} catch (UnsupportedFlavorException ufe) {
System.out.println("UnsupportedFlavor: " + ufe.getMessage());
} catch (java.io.IOException ioe) {
System.out.println("I/O error: " + ioe.getMessage());
}
// Get drop location info.
JTree.DropLocation dl = (JTree.DropLocation) support.getDropLocation();
int childIndex = dl.getChildIndex();
TreePath dest = dl.getPath();
DefaultMutableTreeNode parent = (DefaultMutableTreeNode)
dest.getLastPathComponent();
JTree tree = (JTree) support.getComponent();
DefaultTreeModel model = (DefaultTreeModel) tree.getModel();
// Configure for drop mode.
int index = childIndex; // DropMode.INSERT
if (childIndex == -1) { // DropMode.ON
index = parent.getChildCount();
}
// Add data to model.
for (DefaultMutableTreeNode node : nodes) {
model.insertNodeInto(node, parent, index++);
}
return true;
}
示例11: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
if (!support.isDrop()) {
return false;
}
support.setShowDropLocation(true);
if (!support.isDataFlavorSupported(nodesFlavor)) {
return false;
}
// Do not allow a drop on the drag source selections.
JTree.DropLocation dl = (JTree.DropLocation) support.getDropLocation();
JTree tree = (JTree) support.getComponent();
int dropRow = tree.getRowForPath(dl.getPath());
int[] selRows = tree.getSelectionRows();
for (int i = 0; i < selRows.length; i++) {
if (selRows[i] == dropRow) {
return false;
}
}
// Do not allow MOVE-action drops if a non-leaf node is
// selected unless all of its children are also selected.
int action = support.getDropAction();
if (action == MOVE) {
return haveCompleteNode(tree);
}
// Do not allow a non-leaf node to be copied to a level
// which is less than its source level.
TreePath dest = dl.getPath();
DefaultMutableTreeNode target = (DefaultMutableTreeNode)
dest.getLastPathComponent();
TreePath path = tree.getPathForRow(selRows[0]);
DefaultMutableTreeNode firstNode = (DefaultMutableTreeNode)
path.getLastPathComponent();
if (firstNode.getChildCount() > 0
&& target.getLevel() < firstNode.getLevel()) {
return false;
}
return true;
}
示例12: importData
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support)
{
try
{
if (support.isDrop())
{
BracketEntry transfer = (BracketEntry)support.getTransferable().getTransferData(BracketEntry.Transfer.myFlavor);
return transfer.source != null;
}
}
catch (Exception ioe) { log.log(Level.WARNING, "\bError during drop:{0}", ioe); }
return false;
}
示例13: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@Override
public boolean canImport(TransferHandler.TransferSupport info) {
if (!tabs[0].isSelected()) return false;
boolean b = info.getComponent() == table && info.isDrop() && info.isDataFlavorSupported(localObjectFlavor);
table.setCursor(b ? DragSource.DefaultMoveDrop : DragSource.DefaultMoveNoDrop);
return b;
}
示例14: importData
import javax.swing.TransferHandler; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean importData(TransferHandler.TransferSupport info) {
if (!info.isDrop()) {
return false;
}
// Check for FileList flavor
if (!info.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
System.out.println("List doesn't accept a drop of this type.");
return false;
}
// Get the fileList that is being dropped.
Transferable t = info.getTransferable();
List<File> data;
try {
data = (List<File>)t.getTransferData(DataFlavor.javaFileListFlavor);
}
catch (Exception e) { return false; }
if(data.size() > 1) { // More than one file!
main.ready = false;
return false;
}
main.receiveFile(data.get(0));
return true;
}
示例15: canImport
import javax.swing.TransferHandler; //导入方法依赖的package包/类
/**
* Called to allow drop operations, allow driver drag full range of rows
* except for last (Add driver box).
*/
@Override
public boolean canImport(TransferHandler.TransferSupport support)
{
JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
JTable target = (JTable)support.getComponent();
if (dl.getRow() > target.getRowCount()) return false;
return true;
}