本文整理汇总了Java中org.openide.loaders.DataObject类的典型用法代码示例。如果您正苦于以下问题:Java DataObject类的具体用法?Java DataObject怎么用?Java DataObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataObject类属于org.openide.loaders包,在下文中一共展示了DataObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openHistory
import org.openide.loaders.DataObject; //导入依赖的package包/类
public static void openHistory (File repositoryRoot, File[] files, String revision) {
List<Node> nodes = new ArrayList<Node>(files.length);
for (File file : files) {
FileObject fo = FileUtil.toFileObject(file);
if(fo == null) continue;
DataObject dao;
try {
dao = DataObject.find(fo);
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
continue;
}
nodes.add(dao.getNodeDelegate());
}
if(nodes.isEmpty()) return;
String title = NbBundle.getMessage(
LogAction.class,
"MSG_Log_TabTitle", // NOI18N
Utils.getContextDisplayName(VCSContext.forNodes(nodes.toArray(new Node[nodes.size()]))));
openHistory(repositoryRoot, files, title, revision);
}
示例2: getDocument
import org.openide.loaders.DataObject; //导入依赖的package包/类
@Override
protected BaseDocument getDocument(FileObject fo, String mimeType, Language language) {
// for some reason GsfTestBase is not using DataObjects for BaseDocument construction
// which means that for example Java formatter which does call EditorCookie to retrieve
// document will get difference instance of BaseDocument for indentation
try {
DataObject dobj = DataObject.find(fo);
assertNotNull(dobj);
EditorCookie ec = dobj.getLookup().lookup(EditorCookie.class);
assertNotNull(ec);
return (BaseDocument)ec.openDocument();
}
catch (Exception ex){
fail(ex.toString());
return null;
}
}
示例3: getEditorCookie
import org.openide.loaders.DataObject; //导入依赖的package包/类
/**
* Tries to obtain an {@code EditorCookie} representing the given file.
* @param fileObj file to get an {@code EditorCookie} from
* @return {@code EditorCookie} representing the file, or {@code null}
* @throws java.io.IOException
* if there was some I/O error while reading the file's content
*/
private static EditorCookie getEditorCookie(FileObject fileObj) throws IOException {
DataObject dao;
try {
dao = DataObject.find(fileObj);
} catch (DataObjectNotFoundException ex) {
return null;
}
if (dao instanceof MultiDataObject) {
MultiDataObject.Entry entry = findEntryForFile((MultiDataObject) dao, fileObj);
if ((entry != null) && (entry instanceof CookieSet.Factory)) {
CookieSet.Factory factory = (CookieSet.Factory) entry;
return factory.createCookie(EditorCookie.class); //can be null
}
}
return dao.getCookie(EditorCookie.class); //can be null
}
示例4: copyNode
import org.openide.loaders.DataObject; //导入依赖的package包/类
protected Node copyNode (Node node) {
boolean filter = false;
try {
DataObject d = (DataObject) node.getCookie (DataObject.class);
if (d != null) {
InstanceCookie.Of inst = (InstanceCookie.Of)d.getCookie(InstanceCookie.Of.class);
if (inst != null && (inst.instanceOf(Node.class) || inst.instanceOf(Node.Handle.class))) {
// This is just a node, not a real setting. E.g. ModuleNode, LoaderPoolNode. As such,
// it itself should not display any origin information, it would make no sense. However
// its children might have a legitimate DataObject cookie from the SFS.
d = null;
}
}
DataFolder folder = (DataFolder) node.getCookie (DataFolder.class);
FileSystem fs = d == null || folder != null ? null : d.getPrimaryFile ().getFileSystem ();
filter = fs == null ? false : fs.isDefault();
} catch (FileStateInvalidException e) {
// ignore
}
return filter ? new SettingFilterNode (node) :
node.isLeaf() ? node.cloneNode() : new TrivialFilterNode(node);
}
示例5: prepareMatchingObject
import org.openide.loaders.DataObject; //导入依赖的package包/类
private MatchingObject prepareMatchingObject(int numTextDetails)
throws IOException {
ResultModel rm = new org.netbeans.modules.search.ResultModel(
new BasicSearchCriteria(), null, null);
FileObject fo = FileUtil.createMemoryFileSystem().getRoot()
.createData("test.tst");
List<TextDetail> details = new LinkedList<TextDetail>();
for (int i = 0; i < numTextDetails; i++) {
TextDetail td = new TextDetail(DataObject.find(fo),
SearchPattern.create("test", false, false, false));
details.add(td);
}
rm.objectFound(fo, Charset.defaultCharset(), details);
MatchingObject mo = rm.getMatchingObjects().get(0);
return mo;
}
示例6: setUp
import org.openide.loaders.DataObject; //导入依赖的package包/类
/** setUp method */
public void setUp() {
System.out.println("######## "+getName()+" #######");
OptionsOperator optionsOperator = OptionsOperator.invoke();
optionsOperator.selectOption(Bundle.getString("org.netbeans.core.Bundle", "UI/Services/Editing")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "PROP_Option_Menu"));
PropertySheetOperator propertySheetTabOperator = new PropertySheetOperator(optionsOperator);
new Property(propertySheetTabOperator, Bundle.getString("org.netbeans.modules.beans.Bundle", "PROP_Option_Prop_Style")).setValue(Bundle.getString("org.netbeans.modules.beans.Bundle", "MSG_Option_Gen_This"));
FileObject testFile = Repository.getDefault().findResource("gui/data/" + NAME_TEST_FILE + ".java");
FileObject destination = Repository.getDefault().findFileSystem(sampleDir.replace('\\', '/')).getRoot();
optionsOperator.close();
try {
DataObject.find(testFile).copy(DataFolder.findFolder(destination));
} catch (IOException e) {
fail(e);
}
new PropertiesAction().perform();
}
示例7: setUp
import org.openide.loaders.DataObject; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
clearWorkDir();
dir = FileUtil.toFileObject(getWorkDir());
f1 = dir.createData("f1.data");
f1form = dir.createData("f1.form");
f2 = dir.createData("f2");
subdir = dir.createFolder("sub");
f3 = subdir.createData("f3.data");
f3a = subdir.createData("f3a.data");
subdir2 = dir.createFolder("subdir2");
f4 = subdir2.createData("f3.nondata");
subsubdir = subdir2.createFolder("sub");
f5 = subdir2.createData("f1.data");
f5a = subsubdir.createData("f3.data");
fx = new XMLFileSystem().getRoot();
d1 = DataObject.find(f1);
d2 = DataObject.find(f2);
d3 = DataObject.find(f3);
dx = DataObject.find(fx);
n1 = d1.getNodeDelegate();
n2 = d2.getNodeDelegate();
n3 = d3.getNodeDelegate();
nx = dx.getNodeDelegate();
}
示例8: closeAllDocuments
import org.openide.loaders.DataObject; //导入依赖的package包/类
/** Closes all opened documents and waits until this top component is closed. */
public void closeAllDocuments() {
DataObject[] modifs = DataObject.getRegistry().getModified();
if (modifs.length != 0) {
// some object modified => need to call in new thread because modal question dialog appears
new Thread(new Runnable() {
@Override
public void run() {
pushMenuOnTab(closeAllDocumentsItem);
}
;
}, "thread to closeAllDocuments").start();
} else {
// no object modified
new CloseAllDocumentsAction().perform(this);
waitComponentShowing(false);
}
}
示例9: testPreCreateDecorator
import org.openide.loaders.DataObject; //导入依赖的package包/类
public void testPreCreateDecorator() throws Exception {
MockLookup.setLayersAndInstances(new Deco() {
@Override
public boolean isBeforeCreation() {
return true;
}
@Override
public List<FileObject> decorate(CreateDescriptor desc, List<FileObject> createdFiles) throws IOException {
assertSize("No files should have been created", createdFiles, 0);
decorated = true;
assertEquals(0, target.getChildren().length);
return null;
}
});
Map<String,String> parameters = Collections.singletonMap("type", "empty");
DataObject n = obj.createFromTemplate(folder, "complex", parameters);
assertTrue(decorated);
assertNotNull(n);
}
示例10: getRootNodes
import org.openide.loaders.DataObject; //导入依赖的package包/类
private static List<Node> getRootNodes(Project prj,
List<FileObject> roots,
FilteredNode.NodeFilter filter,
boolean includeFiles) {
List<Node> nodes = new ArrayList<Node>(roots.size());
for (FileObject rfo : roots) {
try {
if (includeFiles || (FileUtil.toFile(rfo)!=null)) {
Project owner = org.netbeans.api.project.FileOwnerQuery.getOwner(rfo);
Node origNode = DataObject.find(rfo).getNodeDelegate();
FilteredNode node = new FilteredNode(origNode,filter, getDisplayName(rfo, owner, prj!=owner));
nodes.add(node);
}
} catch (org.openide.loaders.DataObjectNotFoundException ex) {}
}
return nodes;
}
示例11: createKeys
import org.openide.loaders.DataObject; //导入依赖的package包/类
@Messages({"LBL_this_layer=<this layer>", "LBL_this_layer_in_context=<this layer in context>"})
@Override protected boolean createKeys(List<DataObject> keys) {
handle.setAutosave(true);
FileObject layer = handle.getLayerFile();
if (layer == null) { // #180872, #212541
return true;
}
Project p = FileOwnerQuery.getOwner(layer);
if (p == null) { // #175861: inside JAR etc.
return true;
}
FileSystem layerfs = handle.layer(false);
try {
if (layerfs != null) {
keys.add(DataObject.find(badge(layerfs, handle.getLayerFile(), LBL_this_layer(), null).getRoot()));
}
LayerHandle h = LayerHandle.forProject(p);
if (layer.equals(h.getLayerFile())) {
h.setAutosave(true); // #135376
keys.add(DataObject.find(badge(LayerUtils.getEffectiveSystemFilesystem(p), handle.getLayerFile(), LBL_this_layer_in_context(), handle.layer(false)).getRoot()));
}
} catch (IOException e) {
Util.err.notify(ErrorManager.INFORMATIONAL, e);
}
return true;
}
示例12: create
import org.openide.loaders.DataObject; //导入依赖的package包/类
public static List<Task> create(TextlintJsonResult[] results, FileObject fileObject) {
List<Task> tasks = new ArrayList<>();
final DataObject dataObject = getDataObject(fileObject);
if (results != null && dataObject != null) {
Line.Set lineSet = getLineSet(dataObject);
if (lineSet != null) {
for (TextlintJsonResult result : results) {
result.getMessages().forEach((message) -> {
Line line = getCurrentLine(lineSet, message.getLine());
OpenAction defaultAction = line != null ? new OpenAction(line) : null;
Action[] popupActions = createPopupActions(dataObject, fileObject, message.getFix());
String description = String.format(MESSAGE_FORMAT,
message.getRuleId(),
message.getMessage(),
message.getLine(),
message.getIndex());
String groupName = message.getFix() != null ? TEXTLINT_FIXABLE_GROUP_NAME : TEXTLINT_GROUP_NAME;
tasks.add(Task.create(fileObject.toURL(), groupName, description, defaultAction, popupActions));
});
}
}
}
return tasks;
}
示例13: fileChanged
import org.openide.loaders.DataObject; //导入依赖的package包/类
@Override
public void fileChanged(final FileEvent fe) {
if (fe.getTime() > lastSaveTime) {
lastSaveTime = System.currentTimeMillis();
// Refresh image viewer
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
currentDataObject = DataObject.find(fe.getFile());
setNewContent(currentDataObject);
} catch (DataObjectNotFoundException ex) {
Logger.getLogger(ImageNavigatorPanel.class.getName()).info(NbBundle.getMessage(ImageNavigatorPanel.class, "ERR_DataObject"));
}
}
});
}
}
示例14: toCompletionItems
import org.openide.loaders.DataObject; //导入依赖的package包/类
private void toCompletionItems(String folderName, Collection<FileObject> files) {
for (FileObject f : files) {
DataObject d;
try {
d = DataObject.find(f);
} catch (DataObjectNotFoundException ex) {
// ???
continue;
}
String value = folderName == null ? f.getNameExt() : folderName + "/" + f.getNameExt();
if (f.isFolder()) {
value = value + "/";
}
if (resourceRef) {
value = "@" + value;
}
if (context.isAttribute()) {
value = "\"" + value + "\"";
}
CompletionItem item = new ResourcePathItem(d, context, value, null);
results.add(item);
}
}
示例15: testCreateFromTemplateUsingFreemarker
import org.openide.loaders.DataObject; //导入依赖的package包/类
public void testCreateFromTemplateUsingFreemarker() throws Exception {
FileObject root = FileUtil.createMemoryFileSystem().getRoot();
FileObject fo = FileUtil.createData(root, "simpleObject.txt");
OutputStream os = fo.getOutputStream();
String txt = "print('<html><h1>', title, '</h1></html>');";
os.write(txt.getBytes());
os.close();
fo.setAttribute(ScriptingCreateFromTemplateHandler.SCRIPT_ENGINE_ATTR, "js");
DataObject obj = DataObject.find(fo);
DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
Map<String,String> parameters = Collections.singletonMap("title", "Nazdar");
DataObject n = obj.createFromTemplate(folder, "complex", parameters);
assertEquals("Created in right place", folder, n.getFolder());
assertEquals("Created with right name", "complex.txt", n.getName());
String exp = "<html><h1> Nazdar </h1></html>\n";
assertEquals(exp, readFile(n.getPrimaryFile()));
}