本文整理汇总了Java中org.openide.nodes.CookieSet.Factory方法的典型用法代码示例。如果您正苦于以下问题:Java CookieSet.Factory方法的具体用法?Java CookieSet.Factory怎么用?Java CookieSet.Factory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.nodes.CookieSet
的用法示例。
在下文中一共展示了CookieSet.Factory方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEditorCookie
import org.openide.nodes.CookieSet; //导入方法依赖的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
}
示例2: getEditableCookie
import org.openide.nodes.CookieSet; //导入方法依赖的package包/类
private static EditorCookie.Observable getEditableCookie (File file) {
EditorCookie.Observable editorCookie = null;
if (file == null) {
return null;
}
FileObject fileObj = FileUtil.toFileObject(file);
if (fileObj != null) {
try {
DataObject dao = DataObject.find(fileObj);
if (dao instanceof MultiDataObject) {
MultiDataObject mdao = (MultiDataObject) dao;
for (MultiDataObject.Entry entry : mdao.secondaryEntries()) {
if (fileObj == entry.getFile() && entry instanceof CookieSet.Factory) {
CookieSet.Factory factory = (CookieSet.Factory) entry;
EditorCookie ec = factory.createCookie(EditorCookie.class);
if (ec instanceof EditorCookie.Observable) {
editorCookie = (EditorCookie.Observable) ec;
}
}
}
}
if (editorCookie == null) {
EditorCookie cookie = dao.getCookie(EditorCookie.class);
if (cookie instanceof EditorCookie.Observable) {
editorCookie = (EditorCookie.Observable) cookie;
}
}
} catch (DataObjectNotFoundException ex) {
}
}
return editorCookie;
}
示例3: getEditorCookie
import org.openide.nodes.CookieSet; //导入方法依赖的package包/类
/**
* @since 1.9.1
*/
public static EditorCookie getEditorCookie(Document doc) {
if (doc == null) {
return null;
}
DataObject dataObj = (DataObject) doc.getProperty(
Document.StreamDescriptionProperty);
if (dataObj == null) {
return null;
}
EditorCookie plain = null;
if (dataObj instanceof MultiDataObject) {
MultiDataObject multiDataObj = (MultiDataObject) dataObj;
for (MultiDataObject.Entry entry : multiDataObj.secondaryEntries()) {
if (entry instanceof CookieSet.Factory) {
CookieSet.Factory factory = (CookieSet.Factory) entry;
EditorCookie ec = factory.createCookie(EditorCookie.class);
if (ec.getDocument() == doc) {
if (ec instanceof EditorCookie.Observable) {
return (EditorCookie.Observable) ec;
}
if (plain == null) {
plain = ec;
}
}
}
}
}
return chooseBetterEditorCookie(getEditorCookie(dataObj, false), plain);
}
示例4: fileForDataobject
import org.openide.nodes.CookieSet; //导入方法依赖的package包/类
private FileObject fileForDataobject(Document doc, MultiDataObject dobj) {
for (MultiDataObject.Entry entry : dobj.secondaryEntries()) {
if (entry instanceof CookieSet.Factory) {
CookieSet.Factory factory = (CookieSet.Factory) entry;
EditorCookie ec = factory.createCookie(EditorCookie.class);
Document entryDocument = ec.getDocument();
if (entryDocument == doc) {
return entry.getFile();
}
}
}
return dobj.getPrimaryFile();
}
示例5: setSource2
import org.openide.nodes.CookieSet; //导入方法依赖的package包/类
private void setSource2 (StreamSource ss, Document sdoc) throws IOException {
secondSourceAvailable = false;
EditorKit kit = jEditorPane2.getEditorPane().getEditorKit();
if (kit == null) throw new IOException("Missing Editor Kit"); // NOI18N
modifiedDocument = sdoc;
if (sdoc != null && ss.isEditable()) {
DataObject dao = (DataObject) sdoc.getProperty(Document.StreamDescriptionProperty);
if (dao != null) {
if (dao instanceof MultiDataObject) {
MultiDataObject mdao = (MultiDataObject) dao;
for (MultiDataObject.Entry entry : mdao.secondaryEntries()) {
if (entry instanceof CookieSet.Factory) {
CookieSet.Factory factory = (CookieSet.Factory) entry;
EditorCookie ec = factory.createCookie(EditorCookie.class);
Document entryDocument = ec.getDocument();
if (entryDocument == sdoc && ec instanceof EditorCookie.Observable) {
editableCookie = (EditorCookie.Observable) ec;
editableDocument = sdoc;
editorUndoRedo = getUndoRedo(ec);
}
}
}
}
if (editableCookie == null) {
EditorCookie cookie = dao.getCookie(EditorCookie.class);
if (cookie instanceof EditorCookie.Observable) {
editableCookie = (EditorCookie.Observable) cookie;
editableDocument = sdoc;
editorUndoRedo = getUndoRedo(cookie);
}
}
}
}
Document doc = sdoc != null ? sdoc : kit.createDefaultDocument();
if (sdoc != null || !Boolean.TRUE.equals(skipFile)) {
if (jEditorPane2.getEditorPane().getUI() instanceof BaseTextUI) {
if (sdoc == null) {
Reader r = ss.createReader();
if (r != null) {
secondSourceAvailable = true;
try {
kit.read(r, doc, 0);
} catch (javax.swing.text.BadLocationException e) {
throw new IOException("Can not locate the beginning of the document."); // NOI18N
} finally {
r.close();
}
}
} else {
secondSourceAvailable = true;
}
} else {
secondSourceUnsupportedTextUI = true;
}
}
jEditorPane2.initActions();
view.putClientProperty(UndoRedo.class, editorUndoRedo);
jEditorPane2.getEditorPane().setDocument(doc);
jEditorPane2.getEditorPane().setEditable(editableCookie != null);
if (doc instanceof NbDocument.CustomEditor) {
Component c = ((NbDocument.CustomEditor)doc).createEditor(jEditorPane2.getEditorPane());
if (c instanceof JComponent) {
jEditorPane2.setCustomEditor((JComponent)c);
}
}
customizeEditor(jEditorPane2.getEditorPane());
jViewport2 = jEditorPane2.getScrollPane().getViewport();
joinScrollBars();
}
示例6: XMLDataObject
import org.openide.nodes.CookieSet; //导入方法依赖的package包/类
/**
* Create new XMLDataObject. It is usually called by a loader.
* A user can get existing XMLDataObject by calling {@link DataObject#find(FileObject)
* <code>DataObject.find(FileObject f)</code>} instead.
*
* @param fo the primary file object, never <code>null</code>
* @param loader loader of this data object, never <code>null</code>
*
*/
public XMLDataObject (FileObject fo, MultiFileLoader loader)
throws DataObjectExistsException {
super (fo, loader);
fo.addFileChangeListener (WeakListener.fileChange (getIP (), fo));
status = STATUS_NOT;
// register provided cookies
// EditorCookie must be for back compatability consulted with subclasses
//
// In new model subclasses should directly provide its CookieSet.Factory that
// uses last prevails order instead of old CookieSet first prevails order.
// It completely prevails over this factory :-)
CookieSet.Factory factory = new CookieSet.Factory() {
public Node.Cookie createCookie(Class klass) {
if (klass.isAssignableFrom(EditorCookie.class)
|| klass.isAssignableFrom(OpenCookie.class)
|| klass.isAssignableFrom(CloseCookie.class)
|| klass.isAssignableFrom(PrintCookie.class) ) {
if (editor == null) editor = createEditorCookie(); // the first pass
if (editor == null) return null; //??? gc unfriendly
return klass.isAssignableFrom(editor.getClass()) ? editor : null;
} else {
return null;
}
}
};
CookieSet cookies = getCookieSet();
// EditorCookie.class must be synchronized with
// XMLEditor.Env->findCloneableOpenSupport
cookies.add(EditorCookie.class, factory);
cookies.add(OpenCookie.class, factory);
cookies.add(CloseCookie.class, factory);
cookies.add(PrintCookie.class, factory);
// set info for this file
//getIP ().resolveInfo (); #16045
}