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


Java ExClipboard类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MatchingObjectNode.java

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

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

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

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

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

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

示例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();
  }
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:19,代码来源:MMDGraphEditor.java

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

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

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

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

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

示例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);
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:9,代码来源:NbUtils.java

示例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);
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:10,代码来源:MMDGraphEditor.java


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