本文整理汇总了Java中org.openide.nodes.CookieSet类的典型用法代码示例。如果您正苦于以下问题:Java CookieSet类的具体用法?Java CookieSet怎么用?Java CookieSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CookieSet类属于org.openide.nodes包,在下文中一共展示了CookieSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LayerDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public LayerDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
final CookieSet cookies = getCookieSet();
final Lookup baseLookup = cookies.getLookup();
lkp = new ProxyLookup(baseLookup) {
final AtomicBoolean checked = new AtomicBoolean();
protected @Override void beforeLookup(Template<?> template) {
if (template.getType() == LayerHandle.class && checked.compareAndSet(false, true)) {
FileObject xml = getPrimaryFile();
Project p = FileOwnerQuery.getOwner(xml);
if (p != null) {
setLookups(baseLookup, Lookups.singleton(new LayerHandle(p, xml)));
}
}
}
};
registerEditor("text/x-netbeans-layer+xml", true);
cookies.add(new ValidateXMLSupport(DataObjectAdapters.inputSource(this)));
}
示例2: 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
}
示例3: JShellDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public JShellDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException {
super(fo, loader);
CookieSet cks = getCookieSet();
cks.add(new Class[] {
OpenCookie.class,
EditorCookie.Observable.class,
CloseCookie.class,
LineCookie.class,
SimpleES.class,
}, new CookieSet.Factory() {
private CloneableEditorSupport supp;
public <T extends Node.Cookie> T createCookie(Class<T> klass) {
if (supp != null) {
return klass.cast(supp);
}
return klass.cast(
/*
supp = DataEditorSupport.create(JShellDataObject.this,
getPrimaryEntry(), getCookieSet(),
() -> createPane())
);*/
supp = new SimpleES(JShellDataObject.this, getPrimaryEntry())
);
}
});
}
示例4: PropertiesLocaleNode
import org.openide.nodes.CookieSet; //导入依赖的package包/类
/** Creates a new PropertiesLocaleNode for the given locale-specific file */
public PropertiesLocaleNode (PropertiesFileEntry fe) {
super(fe, fe.getChildren());
setDisplayName(Util.getLocaleLabel(fe));
setIconBaseWithExtension(LOCALE_ICON_BASE);
setShortDescription(messageToolTip());
// the node uses lookup based on CookieSet from PropertiesFileEntry
CookieSet cookieSet = fe.getCookieSet();
cookieSet.add(PropertiesOpen.class, this);
cookieSet.add(fe);
cookieSet.add(fe.getDataObject());
cookieSet.add(this);
fsStatusListener = new FSListener();
try {
FileSystem fs = fe.getFile().getFileSystem();
fs.addFileStatusListener(FileUtil.weakFileStatusListener(fsStatusListener, fs));
} catch (FileStateInvalidException ex) {
}
}
示例5: getCookieSet
import org.openide.nodes.CookieSet; //导入依赖的package包/类
/** Get the set of cookies.
* If the set had been
* previously set by {@link #setCookieSet}, that set
* is returned. Otherwise an empty set is
* returned.
*
* @return the cookie set (never <code>null</code>)
*/
protected final CookieSet getCookieSet () {
CookieSet s = cookieSet;
if (s != null) {
return s;
}
synchronized (this) {
if (cookieSet != null) {
return cookieSet;
}
// sets an empty sheet and adds a listener to it
setCookieSet (CookieSet.createGeneric(null));
cookieSet.assign(FileObject.class, getFile());
return cookieSet;
}
}
示例6: getCookie
import org.openide.nodes.CookieSet; //导入依赖的package包/类
/**
* Looks for a cookie in the current cookie set matching the requested class.
*
* @param type the class to look for
* @return an instance of that class, or <code>null</code> if this class of cookie
* is not supported
*/
@SuppressWarnings("unchecked")
public <T extends Node.Cookie> T getCookie(Class<T> type) {
CookieSet c = cookieSet;
if (c != null) {
T cookie = c.getCookie(type);
if (cookie != null) {
return cookie;
}
}
if (type.isInstance (this)) {
return (T) this;
}
return null;
}
示例7: EntityDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public EntityDataObject (final FileObject obj, final UniFileLoader loader) throws DataObjectExistsException {
super (obj, loader);
CookieSet set = getCookieSet();
set.add (cookieManager = new DataObjectCookieManager (this, set));
final TextEditorSupport.TextEditorSupportFactory editorFactory =
new TextEditorSupport.TextEditorSupportFactory (this, MIME_TYPE);
editorFactory.registerCookies (set);
// CookieSet.Factory treeEditorFactory = new TreeEditorCookieImpl.CookieFactoryImpl (this);
// set.add (TreeEditorCookie.class, treeEditorFactory);
// add check cookie
InputSource in = DataObjectAdapters.inputSource(this);
set.add(new CheckXMLSupport(in, CheckXMLSupport.CHECK_ENTITY_MODE));
// new CookieManager (this, set, EntityCookieFactoryCreator.class);
//enable "Save As"
set.assign( SaveAsCapable.class, new SaveAsCapable() {
public void saveAs(FileObject folder, String fileName) throws IOException {
editorFactory.createEditor().saveAs( folder, fileName );
}
});
}
示例8: HibernateCfgDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public HibernateCfgDataObject(FileObject pf, HibernateCfgDataLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
// Make sure to reset the MIME type here. See bug 127051
getEditorSupport().setMIMEType(HibernateCfgDataLoader.REQUIRED_MIME);
// Synchronize between the vew and XML file
modelSynchronizer = new ModelSynchronizer(this);
CookieSet cookies = getCookieSet();
//cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
org.xml.sax.InputSource in = DataObjectAdapters.inputSource(this);
CheckXMLCookie checkCookie = new CheckXMLSupport(in);
cookies.add(checkCookie);
ValidateXMLCookie validateCookie = new ValidateXMLSupport(in);
cookies.add(validateCookie);
parseDocument();
}
示例9: HtmlDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
/** New instance.
* @param pf primary file object for this data object
* @param loader the data loader creating it
* @exception DataObjectExistsException if there was already a data object for it
*/
public HtmlDataObject(FileObject pf, UniFileLoader loader) throws DataObjectExistsException {
super(pf, loader);
CookieSet set = getCookieSet();
set.add(HtmlEditorSupport.class, this);
set.add(ViewSupport.class, this);
set.assign(SaveAsCapable.class, new SaveAsCapable() {
public void saveAs( FileObject folder, String fileName ) throws IOException {
HtmlEditorSupport es = getCookie( HtmlEditorSupport.class );
try {
es.updateEncoding();
es.saveAs( folder, fileName );
} catch (UserCancelException e) {
//ignore, just not save anything
}
}
});
set.assign(FileEncodingQueryImplementation.class, new FileEncodingQueryImpl());
//add check/validate xml cookies
InputSource in = DataObjectAdapters.inputSource(this);
set.add(new ValidateXMLSupport(in));
set.add(new CheckXMLSupport(in));
}
示例10: TLDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public TLDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
getCookieSet().assign(SaveCookie.class, saveDB);
setModified(true);
if (pf.getSize() > 0) {
database = getDBFromFile(pf);
} else {
database = new TLDatabase();
}
CookieSet cookies = getCookieSet();
cookies.assign(TLDatabase.class, database);
cookies.add(new TLOpenSupport(this.getPrimaryEntry()));
cookies.assign(Node.class, this.getNodeDelegate());
// Set modified if current time of db changes
database.addDBListener(changeListener);
}
示例11: setCookieSet
import org.openide.nodes.CookieSet; //导入依赖的package包/类
/** Set the set of cookies.
*
* @param s the cookie set to use
* @param fireChange used when called from getter. In this case event shouldn't
* be fired.
*/
private void setCookieSet (CookieSet s, boolean fireChange) {
synchronized (cookieSetLock) {
ChangeListener ch = getChangeListener();
if (cookieSet != null) {
cookieSet.removeChangeListener (ch);
}
s.addChangeListener (ch);
cookieSet = s;
}
if (fireChange) {
fireCookieChange ();
}
}
示例12: GlslGeometryShaderDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public GlslGeometryShaderDataObject(FileObject pf, GlslGeometryShaderDataLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
CookieSet cookies = getCookieSet();
observer = new GlslShaderFileObserver(this);
final CloneableEditorSupport support = DataEditorSupport.create(this, getPrimaryEntry(), cookies);
support.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent event) {
if ("document".equals(event.getPropertyName())) {
if (event.getNewValue() != null) {
support.getDocument().addDocumentListener(observer);
observer.runCompileTask();
} else if (event.getOldValue() != null) {
// cylab: I think this is never called.
// But I don't know if unregistering the observer makes any difference...
((Document) event.getOldValue()).removeDocumentListener(observer);
}
}
}
});
cookies.add((Node.Cookie) support);
}
示例13: AntProjectDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public AntProjectDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
super(pf, loader);
CookieSet cookies = getCookieSet();
cookies.add (new AntProjectDataEditor (this));
FileObject prim = getPrimaryFile ();
AntProjectCookie proj = new AntProjectSupport (prim);
cookies.add (proj);
if (proj.getFile () != null) {
cookies.add (new AntActionInstance (proj));
}
cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
addPropertyChangeListener (this);
}
示例14: SpringXMLConfigDataObject
import org.openide.nodes.CookieSet; //导入依赖的package包/类
public SpringXMLConfigDataObject(FileObject pf, SpringXMLConfigDataLoader loader) throws DataObjectExistsException {
super(pf, loader);
CookieSet cookies = getCookieSet();
InputSource in = DataObjectAdapters.inputSource(this);
cookies.add(new CheckXMLSupport(in));
cookies.add(new ValidateXMLSupport(in));
cookies.assign(FileEncodingQueryImplementation.class, XmlFileEncodingQueryImpl.singleton());
registerEditor(SpringConstants.CONFIG_MIME_TYPE, true);
}
示例15: 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;
}