當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。