本文整理匯總了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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}