本文整理汇总了Java中org.openide.util.datatransfer.ExClipboard类的典型用法代码示例。如果您正苦于以下问题:Java ExClipboard类的具体用法?Java ExClipboard怎么用?Java ExClipboard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExClipboard类属于org.openide.util.datatransfer包,在下文中一共展示了ExClipboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
File f = FileUtil.toFile(
matchingObject.getFileObject());
if (f != null) {
String path = f.getPath();
Clipboard clipboard = Lookup.getDefault().lookup(
ExClipboard.class);
if (clipboard == null) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
if (toolkit != null) {
clipboard = toolkit.getSystemClipboard();
}
}
if (clipboard != null) {
StringSelection strSel = new StringSelection(path);
clipboard.setContents(strSel, null);
}
}
}
示例2: setUp
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
protected void setUp() throws Exception {
MockServices.setServices(Clip.class);
System.setProperty ("netbeans.security.nocheck", "true");
Object clip = Lookup.getDefault ().lookup (ExClipboard.class);
assertNotNull ("Some clipboard found", clip);
assertEquals ("Correct clipboard found", Clip.class, clip.getClass());
this.clip = (Clip)clip;
if (System.getSecurityManager () == null) {
java.text.NumberFormat.getInstance ();
Object clazz = org.netbeans.TopSecurityManager.class;
SecurityManager m = new org.netbeans.TopSecurityManager ();
System.setSecurityManager (m);
inMiddleOfSettingUpTheManager();
org.netbeans.TopSecurityManager.makeSwingUseSpecialClipboard (this.clip);
} else {
inMiddleOfSettingUpTheManager();
}
field = new javax.swing.JTextField ();
}
示例3: testClipboard
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
public void testClipboard() throws Exception {
MockServices.setServices(Cnv.class);
Clipboard c = Lookup.getDefault().lookup(Clipboard.class);
ExClipboard ec = Lookup.getDefault().lookup(ExClipboard.class);
assertEquals("Clipboard == ExClipboard", c, ec);
assertNotNull(Lookup.getDefault().lookup(ExClipboard.Convertor.class));
assertEquals(Cnv.class, Lookup.getDefault().lookup(ExClipboard.Convertor.class).getClass());
c.setContents(new ExTransferable.Single(DataFlavor.stringFlavor) {
protected Object getData() throws IOException, UnsupportedFlavorException {
return "17";
}
}, null);
Transferable t = c.getContents(null);
assertTrue("still supports stringFlavor", t.isDataFlavorSupported(DataFlavor.stringFlavor));
assertEquals("correct string in clipboard", "17", t.getTransferData(DataFlavor.stringFlavor));
assertTrue("support Integer too", t.isDataFlavorSupported(MYFLAV));
assertEquals("correct Integer", new Integer(17), t.getTransferData(MYFLAV));
}
示例4: actionPerformed
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
public void actionPerformed(ActionEvent event) {
PasteType type = getPasteType();
if (type != null) {
try {
Transferable trans = type.paste();
if (trans != null) {
ClipboardOwner owner = trans instanceof ClipboardOwner ?
(ClipboardOwner)trans : new StringSelection(""); // NOI18N
Clipboard clipboard = (Clipboard)Lookup.getDefault().lookup(ExClipboard.class);
clipboard.setContents(trans, owner);
}
} catch (java.io.IOException e) {
ERR.log( Level.INFO, e.getLocalizedMessage(), e );
}
}
}
示例5: actionPerformed
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent evt, JTextComponent target) {
BaseDocument bdoc = Utilities.getDocument(target);
if(bdoc == null) {
return ; //no document?!?!
}
DataObject csso = NbEditorUtilities.getDataObject(bdoc);
if(csso == null) {
return ; //document not backuped by DataObject
}
String pi = createText(csso);
StringSelection ss = new StringSelection(pi);
ExClipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
clipboard.setContents(ss, null);
StatusDisplayer.getDefault().setStatusText( NbBundle.getMessage(CopyStyleAction.class, "MSG_Style_tag_in_clipboard")); // NOI18N
}
示例6: setClipboardContents
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
/**
* Sets the clipboard context in textual-format.
*
* @param content
*/
@Messages({
"# {0} - copied file path",
"CTL_Status_CopyToClipboardSingle=Copy to Clipboard: {0}",
"# {0} - number of copied paths",
"CTL_Status_CopyToClipboardMulti={0} paths were copied to clipboard"
})
private void setClipboardContents(String content, int items) {
Clipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
if (clipboard != null) {
String statusText = items > 1
? Bundle.CTL_Status_CopyToClipboardMulti(items)
: Bundle.CTL_Status_CopyToClipboardSingle(content);
StatusDisplayer.getDefault().setStatusText(statusText);
clipboard.setContents(new StringSelection(content), null);
}
}
示例7: clipboardChanged
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
@Override
public void clipboardChanged(ClipboardEvent ev) {
ExClipboard clipboard = ev.getClipboard();
Transferable transferable = null;
String clipboardContent = null;
try {
transferable = clipboard.getContents(null);
if (transferable != null && transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
clipboardContent = (String) transferable.getTransferData(DataFlavor.stringFlavor);
}
} catch (OutOfMemoryError oom) {
NotificationDisplayer.getDefault().notify( NbBundle.getBundle(ClipboardHistory.class).getString("clipboard-history-oom"),NotificationDisplayer.Priority.NORMAL.getIcon(), NbBundle.getBundle(ClipboardHistory.class).getString("clipboard-history-oom-details"), null);
return;
} catch (IOException ioe) {
//ignored for bug #218255
} catch (UnsupportedFlavorException ufe) {
}
if (clipboardContent != null) {
addHistory(transferable, clipboardContent);
}
}
示例8: componentClosed
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
@Override
public void componentClosed() {
try {
this.mindMapPanel.dispose();
LOGGER.info("MMD Editor is disposed : " + this.mindMapPanel.toString());
}
finally {
final Clipboard clipboard = NbUtils.findClipboard();
if (clipboard instanceof ExClipboard) {
((ExClipboard) clipboard).removeClipboardListener(this);
} else {
clipboard.removeFlavorListener(this);
}
super.componentClosed();
}
}
示例9: NbClipboard
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
NbClipboard( Clipboard systemClipboard ) {
super("NBClipboard"); // NOI18N
this.systemClipboard = systemClipboard;
result = Lookup.getDefault().lookupResult(ExClipboard.Convertor.class);
result.addLookupListener(this);
systemClipboard.addFlavorListener(this);
resultChanged(null);
if (System.getProperty("netbeans.slow.system.clipboard.hack") != null) {
slowSystemClipboard = Boolean.getBoolean("netbeans.slow.system.clipboard.hack"); // NOI18N
} else if (Utilities.isMac()) {
slowSystemClipboard = false;
}
else {
slowSystemClipboard = true;
}
if (System.getProperty("sun.awt.datatransfer.timeout") == null) { // NOI18N
System.setProperty("sun.awt.datatransfer.timeout", "1000"); // NOI18N
}
if (slowSystemClipboard) {
Toolkit.getDefaultToolkit().addAWTEventListener(
this, AWTEvent.WINDOW_EVENT_MASK);
}
}
示例10: getNodeTransferable
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
/** Gets right transferable of given nodes (according to given
* drag action) and also converts the transferable.<br>
* Can be called only with correct action constant.
* @return The transferable.
*/
static Transferable getNodeTransferable(Node[] nodes, int dragAction)
throws IOException {
Transferable[] tArray = new Transferable[nodes.length];
for (int i = 0; i < nodes.length; i++) {
if ((dragAction & DnDConstants.ACTION_MOVE) != 0) {
tArray[i] = nodes[i].clipboardCut();
} else {
tArray[i] = nodes[i].drag ();
}
}
Transferable result;
if (tArray.length == 1) {
// only one node, so return regular single transferable
result = tArray[0];
} else {
// enclose the transferables into multi transferable
result = ExternalDragAndDrop.maybeAddExternalFileDnd( new Multi(tArray) );
}
Clipboard c = getClipboard();
if (c instanceof ExClipboard) {
return ((ExClipboard) c).convert(result);
} else {
return result;
}
}
示例11: getConvertors
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
public ExClipboard.Convertor[] getConvertors() {
return new ExClipboard.Convertor[] {new ExClipboard.Convertor() {
public Transferable convert(Transferable t) {
last = t;
return t;
}
}};
}
示例12: getClipboard
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
private static Clipboard getClipboard() {
Clipboard clipboard = Lookup.getDefault().lookup(ExClipboard.class);
if (clipboard == null) {
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
}
return clipboard;
}
示例13: getPasteType
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
private PasteType getPasteType() {
Clipboard clipboard = (Clipboard) Lookup.getDefault().lookup(ExClipboard.class);
Transferable trans = clipboard.getContents(this);
if (trans != null) {
PasteType[] pasteTypes = categoryNode.getPasteTypes(trans);
if (pasteTypes != null && pasteTypes.length != 0)
return pasteTypes[0];
}
return null;
}
示例14: findClipboard
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
@Nonnull
public static Clipboard findClipboard() {
Clipboard result = Lookup.getDefault().lookup(ExClipboard.class);
if (result == null) {
result = Toolkit.getDefaultToolkit().getSystemClipboard();
}
return Assertions.assertNotNull("Clipbard is not found", result);
}
示例15: registerAsClipboardListener
import org.openide.util.datatransfer.ExClipboard; //导入依赖的package包/类
private void registerAsClipboardListener() {
final Clipboard clipboard = NbUtils.findClipboard();
if (clipboard instanceof ExClipboard) {
((ExClipboard) clipboard).addClipboardListener(this);
} else {
clipboard.addFlavorListener(this);
}
processClipboardChange(clipboard);
}