Java Code Examples for org.openide.loaders.DataObject#files()
The following examples show how to use
org.openide.loaders.DataObject#files() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From netbeans with Apache License 2.0 | 6 votes |
/** * @param file * @return Set<File> all files that belong to the same DataObject as the argument */ public static Set<File> getAllDataObjectFiles(File file) { Set<File> filesToCheckout = new HashSet<File>(2); filesToCheckout.add(file); FileObject fo = FileUtil.toFileObject(file); if (fo != null) { try { DataObject dao = DataObject.find(fo); Set<FileObject> fileObjects = dao.files(); for (FileObject fileObject : fileObjects) { filesToCheckout.add(FileUtil.toFile(fileObject)); } } catch (DataObjectNotFoundException e) { // no dataobject, never mind } } return filesToCheckout; }
Example 2
Source File: NodeFactoryUtils.java From netbeans with Apache License 2.0 | 5 votes |
public @Override String getHtmlDisplayName() { String result = null; DataObject dob = getLookup().lookup(DataObject.class); if (dob != null) { Set<FileObject> files = dob.files(); result = computeAnnotatedHtmlDisplayName(getDisplayName(), files); } return result; }
Example 3
Source File: EditableDiffView.java From netbeans with Apache License 2.0 | 5 votes |
private Difference[] computeDiff (boolean includeUnavailable) { if(editableDocument != null) { // refresh fo before computing the diff, external changes might not have been recognized in some setups // see also issue #210834 DataObject dao = (DataObject) editableDocument.getProperty(Document.StreamDescriptionProperty); if (dao != null) { Set<FileObject> files = dao.files(); if(files != null) { for (FileObject fo : files) { LOG.log(Level.FINE, "refreshing FileOBject {0}", fo); // NOI18N fo.refresh(); } } else { LOG.log(Level.FINE, "no FileObjects to refresh for {0}", dao); // NOI18N } } else { LOG.log(Level.FINE, "no DataObject to refresh"); // NOI18N } } if (!includeUnavailable && (!secondSourceAvailable || !firstSourceAvailable)) { return NO_DIFFERENCES; } Reader first = includeUnavailable && !firstSourceAvailable ? new StringReader("") : getReader(jEditorPane1.getEditorPane().getDocument()); Reader second = includeUnavailable && !secondSourceAvailable ? new StringReader("") : getReader(jEditorPane2.getEditorPane().getDocument()); if (first == null || second == null) { return NO_DIFFERENCES; } DiffProvider diff = DiffModuleConfig.getDefault().getDefaultDiffProvider(); Difference[] diffs; try { return diff.computeDiff(first, second); } catch (IOException e) { diffs = NO_DIFFERENCES; } return diffs; }
Example 4
Source File: AndroidFileNode.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public @Override String getHtmlDisplayName() { String result = null; DataObject dob = getLookup().lookup(DataObject.class); if (dob != null) { Set<FileObject> files = dob.files(); result = ImportantFilesNodeFactory.computeAnnotatedHtmlDisplayName(getDisplayName(), files); } return result; }
Example 5
Source File: HistoryComponent.java From netbeans with Apache License 2.0 | 4 votes |
private synchronized void initFromContext() { if(context == null) return; synchronized(FILE_LOCK) { DataObject dataObject = context.lookup(DataObject.class); List<VCSFileProxy> filesList = new LinkedList<VCSFileProxy>(); if (dataObject instanceof DataShadow) { dataObject = ((DataShadow) dataObject).getOriginal(); } if (dataObject != null) { Set<FileObject> daoFiles = dataObject.files(); Collection<VCSFileProxy> doFiles = toFileCollection(daoFiles); if(files != null && files.length > 0) { // check for possible changes Set<FileObject> s = new HashSet<FileObject>(Arrays.asList(files)); boolean changed = false; for (FileObject fo : daoFiles) { if(!s.contains(fo)) { changed = true; break; } } if(!changed) { registerFileListeners(); return; } } filesList.addAll(doFiles); } initFiles(filesList.toArray(new VCSFileProxy[filesList.size()])); } Runnable r = new Runnable() { @Override public void run() { resetUI(); } }; if(EventQueue.isDispatchThread()) { r.run(); } else { SwingUtilities.invokeLater(r); } }