|
What this is
Other links
The source code/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun
* Microsystems, Inc. All Rights Reserved.
*/
/*
* DataTransferSupport.java
*
* Created on June 18, 2001, 1:26 PM
*/
package org.openide.loaders;
import org.openide.cookies.InstanceCookie;
import org.openide.util.HelpCtx;
import org.openide.NotifyDescriptor;
import org.openide.util.datatransfer.*;
import org.openide.filesystems.*;
import java.awt.datatransfer.*;
import java.io.IOException;
import java.io.ObjectOutputStream;
import org.openide.DialogDisplayer;
/** Support for data transfer Paste operation.
* @author Vita Stejskal
*/
abstract class DataTransferSupport {
/** Defines array of classes implementing paste for specified clipboard operation.
* @param op clopboard operation to specify paste types for
* @return array of classes extending PasteTypeExt class
*/
protected abstract PasteTypeExt [] definePasteTypes (int op);
/** Defines array of data clipboard operations recognized by this paste support.
* @return array of DataFlavors
*/
protected abstract int [] defineOperations ();
/** Override in order to support additional paste types.
* @param t clipboard Transferable object, list of transfered DataObjects with their flavors
* @param s list of paste types supported for transfered objects
*/
protected void handleCreatePasteTypes (Transferable t, java.util.List s) {
}
/** Fills in the list of paste types available for given set to transfered
* DataObjects.
* @param t clipboard Transferable object, list of transfered DataObjects with their flavors
* @param s list of paste types supported for transfered objects
*/
public final void createPasteTypes (Transferable t, java.util.List s) {
/** All supported operations. */
int [] ops = defineOperations ();
for (int i = 0; i < ops.length; i++) {
DataObject objs [] = LoaderTransfer.getDataObjects (t, ops[i]);
PasteTypeExt pts [];
if (objs == null || objs.length == 0)
continue;
pts = definePasteTypes (ops[i]);
for (int j = 0; j < pts.length; j++) {
pts[j].setDataObjects (objs);
if (pts[j].canPaste ())
s.add (pts[j]);
}
}
handleCreatePasteTypes (t, s);
}
/** Supports paste of multiple DataObject at once.
*/
static abstract class PasteTypeExt extends PasteType {
/** All DataObjects being pasted. */
private DataObject objs [];
/** Create paste type. */
public PasteTypeExt () {
}
/** Can DataObject be pasted.
* @param obj DataObject to be pasted
* @return result of the test
*/
protected abstract boolean handleCanPaste (DataObject obj);
/** Handles the paste action
* @param obj pasted DataObject
*/
protected abstract void handlePaste (DataObject obj) throws IOException;
/** Could be clipboard cleand up after the paste operation is finished or
* should its content be preserved.
* @return default implementation returns
|
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.