當前位置: 首頁>>代碼示例>>Java>>正文


Java DataObject.copy方法代碼示例

本文整理匯總了Java中org.openide.loaders.DataObject.copy方法的典型用法代碼示例。如果您正苦於以下問題:Java DataObject.copy方法的具體用法?Java DataObject.copy怎麽用?Java DataObject.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.loaders.DataObject的用法示例。


在下文中一共展示了DataObject.copy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performChange

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public void performChange() {
    try {
        FileObject targetFo = FileHandlingFactory.getOrCreateFolder(target);
        FileObject Fo = fo;
        DataObject dob = DataObject.find(Fo);
        newOne = dob.copy(DataFolder.findFolder(targetFo));
        if(newName != null) {
            newOne.rename(newName);
        }
        FileObject[] newFiles = context.lookup(FileObject[].class);
        FileObject newFile = newOne.getPrimaryFile();
        newFile.setAttribute("originalFile", fo.getNameExt()); //NOI18N
        if (newFiles == null) {
            newFiles = new FileObject[]{newFile};
        } else {
            // rather a special case: there can be files from former run of the refactoring,
            // which had been undone. In that case, those files may be invalid and will cause
            // parser errors if processed.
            List<FileObject> stillValidFiles = new ArrayList<>(newFiles.length);
            for (FileObject f : newFiles) {
                if (f.isValid()) {
                    stillValidFiles.add(f);
                }
            }
            newFiles = new FileObject[stillValidFiles.size() + 1];
            stillValidFiles.toArray(newFiles);
            newFiles[newFiles.length - 1] = newFile;
        }
        context.add(newFiles);
        context.add(newFile);
    } catch (IOException ex) {
        throw new IllegalStateException(ex);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:CopyFile.java

示例2: createDuplicateFromNode

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
static DataObject createDuplicateFromNode (Node n) {
    DataObject source = getDOFromNode (n);
    try {
        Node parent = n.getParentNode ();
        DataObject target = source.copy(source.getFolder());
        FileObject srcFo = source.getPrimaryFile();
        FileObject targetFo = target.getPrimaryFile();
        setTemplateAttributes(targetFo, srcFo);
        if (parent != null) {
            Node duplicateNode = null;
            for (Node k : parent.getChildren ().getNodes (true)) {
                if (k.getName ().startsWith (targetFo.getName ())) {
                    duplicateNode = k;
                    break;
                }
            }
            if (duplicateNode != null) {
                final Node finalNode = duplicateNode;
                SwingUtilities.invokeLater (new Runnable () {
                    @Override public void run() {
                        try {
                            manager.setSelectedNodes (new Node [] { finalNode });
                            view.invokeInplaceEditing ();
                        } catch (PropertyVetoException ex) {
                            Logger.getLogger (TemplatesPanel.class.getName ()).log (Level.INFO, ex.getLocalizedMessage (), ex);
                        }
                    }
                });
            }
        }
        return target;
    } catch (IOException ioe) {
        Logger.getLogger(TemplatesPanel.class.getName()).log(Level.WARNING, null, ioe);
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:TemplatesPanel.java

示例3: createDuplicateFromNode

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
static DataObject createDuplicateFromNode(Node n) {
    DataObject source = getDOFromNode(n);
    try {
        return source.copy(source.getFolder());
    } catch (IOException ioe) {
        Logger.getLogger(CatalogPanel.class.getName()).log(Level.WARNING, null, ioe);
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:CatalogPanel.java

示例4: copyDO

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private void copyDO(File from, File to) throws DataObjectNotFoundException, IOException {
    DataObject daoFrom = DataObject.find(FileUtil.toFileObject(from));
    DataObject daoTarget = DataObject.find(FileUtil.toFileObject(to.getParentFile()));
    daoFrom.copy((DataFolder) daoTarget);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:FilesystemInterceptorTest.java

示例5: copyDO

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private void copyDO (File from, File to) throws DataObjectNotFoundException, IOException {
    DataObject daoFrom = DataObject.find(FileUtil.toFileObject(from));
    DataObject daoTarget = DataObject.find(FileUtil.toFileObject(to.getParentFile()));
    daoFrom.copy((DataFolder) daoTarget);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:InterceptorTest.java


注:本文中的org.openide.loaders.DataObject.copy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。