当前位置: 首页>>代码示例>>Java>>正文


Java TransferHandler类代码示例

本文整理汇总了Java中javax.swing.TransferHandler的典型用法代码示例。如果您正苦于以下问题:Java TransferHandler类的具体用法?Java TransferHandler怎么用?Java TransferHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransferHandler类属于javax.swing包,在下文中一共展示了TransferHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDocument

import javax.swing.TransferHandler; //导入依赖的package包/类
@Override
public void setDocument(Document doc) {
    super.setDocument(doc);
    
    // Setting DelegatingTransferHandler, where CallbackTransferable will
    // be handled in importData method. 
    // For more details, please refer issue #53439        
    if (doc != null){
        TransferHandler thn = getTransferHandler();
        if( !(thn instanceof DelegatingTransferHandler) ) {
            DelegatingTransferHandler dth = new DelegatingTransferHandler(thn);
            setTransferHandler(dth);
        }

        DropTarget currDt = getDropTarget();
        if( !(currDt instanceof DelegatingDropTarget ) ) {
            DropTarget dt = new DelegatingDropTarget( currDt );
            setDropTarget( dt );
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:QuietEditorPane.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FolderList.java

示例3: canImport

import javax.swing.TransferHandler; //导入依赖的package包/类
/**
 * Method description
 * 
 * @see
 * @param objPtransferSupport
 * @return
 */
@Override final public boolean canImport(TransferHandler.TransferSupport objPtransferSupport) {

	if (this.objGcontrolJFrame.getJuggleMasterPro().bolGprogramTrusted
		|| this.objGcontrolJFrame.getJuggleMasterPro().bytGprogramType == Constants.bytS_STATE_PROGRAM_LOCAL_APPLET) {
		final DataFlavor[] objLdataFlavorA = objPtransferSupport.getDataFlavors();
		if (objLdataFlavorA.length > 0) {
			if (objLdataFlavorA.length == 1) {
				return this.objGtextTransferHandler != null && objLdataFlavorA[0].equals(DataFlavor.stringFlavor)
						|| objLdataFlavorA[0].equals(DataFlavor.javaFileListFlavor);
			}
			for (final DataFlavor objLdataFlavor : objLdataFlavorA) {
				if (!objLdataFlavor.equals(DataFlavor.javaFileListFlavor)) {
					return false;
				}
			}
			return true;
		}
	}
	return false;
}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:28,代码来源:ExtendedTransferHandler.java

示例4: importData

import javax.swing.TransferHandler; //导入依赖的package包/类
/**
 * Called for drop and paste operations
 */
@Override
public boolean importData(TransferHandler.TransferSupport support)
{
	try
	{
		JTable target = (JTable)support.getComponent();
		EntryModel model = (EntryModel)target.getModel();

		if (support.isDrop())
		{
			JTable.DropLocation dl = (JTable.DropLocation)support.getDropLocation();
			model.moveRow(rowsidx[0], rowsidx[rowsidx.length-1], dl.getRow());
			target.clearSelection();
		}

		return true;
	}
	catch (Exception e) { log.warning("\bGeneral error during driver drag:" + e); }

	return false;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:25,代码来源:DriverTable.java

示例5: exportDone

import javax.swing.TransferHandler; //导入依赖的package包/类
/**
 * 
 */
public void exportDone(JComponent c, Transferable data, int action) {
  initialImportCount = 1;

  if (c instanceof mxGraphComponent && data instanceof mxGraphTransferable) {
    // Requires that the graph handler resets the location to null if the drag leaves the
    // component. This is the condition to identify a cross-component move.
    boolean isLocalDrop = location != null;

    if (action == TransferHandler.MOVE && !isLocalDrop) {
      removeCells((mxGraphComponent) c, originalCells);
      initialImportCount = 0;
    }
  }

  originalCells = null;
  location = null;
  offset = null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:22,代码来源:mxGraphTransferHandler.java

示例6: 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;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:InjectScript.java

示例7: setCCP

import javax.swing.TransferHandler; //导入依赖的package包/类
private void setCCP() {
    TransferActionListener actionListener = new TransferActionListener();
    cut = new JMenuItem("Cut");
    cut.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME));
    cut.addActionListener(actionListener);
    cut.setAccelerator(Keystroke.CUT);
    cut.setMnemonic(KeyEvent.VK_T);
    add(cut);

    copy = new JMenuItem("Copy");
    copy.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME));
    copy.addActionListener(actionListener);
    copy.setAccelerator(Keystroke.COPY);
    copy.setMnemonic(KeyEvent.VK_C);
    add(copy);

    paste = new JMenuItem("Paste");
    paste.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME));
    paste.addActionListener(actionListener);
    paste.setAccelerator(Keystroke.PASTE);
    paste.setMnemonic(KeyEvent.VK_P);
    add(paste);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:24,代码来源:ProjectTree.java

示例8: importData

import javax.swing.TransferHandler; //导入依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport ts) {
    if (ts.isDataFlavorSupported(TESTCASE_FLAVOR)) {
        try {
            TestCaseDnD testCaseDnD
                    = (TestCaseDnD) ts.getTransferable()
                    .getTransferData(TESTCASE_FLAVOR);
            sourceTreeModel = testCaseDnD.model;
            if (testCaseDnD.isTestCases()) {
                return importTestCases(testCaseDnD.getTestCaseList(), ts);
            } else {
                return importScenarios(testCaseDnD.getScenarioList(), ts);
            }

        } catch (UnsupportedFlavorException | IOException ex) {
            Logger.getLogger(ProjectDnD.class
                    .getName()).log(Level.SEVERE, null, ex);
            return false;
        }

    }
    return false;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:24,代码来源:ProjectDnD.java

示例9: importTestCases

import javax.swing.TransferHandler; //导入依赖的package包/类
private Boolean importTestCases(List<TestCaseNode> testCaseNodes,
        TransferHandler.TransferSupport ts) {
    Boolean shouldCut = ts.isDrop() ? ts.getDropAction() == MOVE : isCut;
    Object destObject = getDestinationObject(ts);
    ScenarioNode scNode = getScenarioNode(destObject);
    if (scNode != null) {
        copySelectedTestCases(testCaseNodes, scNode, shouldCut);
        return true;
    }
    if (!(destObject instanceof TestPlanNode)
            && destObject instanceof GroupNode) {
        copySelectedTestCases(testCaseNodes, (GroupNode) destObject, shouldCut);
        return true;
    }
    return false;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:ProjectDnD.java

示例10: 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;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:ScenarioDnD.java

示例11: importData

import javax.swing.TransferHandler; //导入依赖的package包/类
@Override
public boolean importData(TransferHandler.TransferSupport support) {
    if (!canImport(support)) {
        return false;
    }
    JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
    JTable table = (JTable) support.getComponent();
    int row = dl.getRow();
    int tcRow = dl.getColumn() - 1;
    if (row == -1) {
        return false;
    }

    Scenario scenario = (Scenario) table.getModel();
    TestCase testCase = scenario.getTestCaseByName(
            table.getValueAt(row, 0).toString());

    if (dropObject instanceof TestCaseDnD) {
        putReusables(testCase, tcRow);
    } else {
        return false;
    }
    return super.importData(support);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:25,代码来源:ScenarioDnD.java

示例12: 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);
	}
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:9,代码来源:JDragDropList.java

示例13: 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;
}
 
开发者ID:mgropp,项目名称:pdfjumbler,代码行数:39,代码来源:JDragDropList.java

示例14: inMiddleOfSettingUpTheManager

import javax.swing.TransferHandler; //导入依赖的package包/类
protected void inMiddleOfSettingUpTheManager() {
    assertNotNull("There is a manager already", System.getSecurityManager());
    // do some strange tricks to initialize the system
    field = new javax.swing.JTextField ();
    TransferHandler.getCopyAction();
    TransferHandler.getCutAction();
    TransferHandler.getPasteAction();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:NbClipboardIsUsedByAlreadyInitializedComponentsTest.java

示例15: mapDragOperationFromModifiers

import javax.swing.TransferHandler; //导入依赖的package包/类
protected int mapDragOperationFromModifiers(MouseEvent e) {
    int mods = e.getModifiersEx();
    
    if ((mods & InputEvent.BUTTON1_DOWN_MASK) == 0) {
        return TransferHandler.NONE;
    }
    
    return TransferHandler.COPY_OR_MOVE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:BaseCaret.java


注:本文中的javax.swing.TransferHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。