当前位置: 首页>>代码示例>>Java>>正文


Java CookieSet类代码示例

本文整理汇总了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)));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:LayerDataObject.java

示例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
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:DiffSidebar.java

示例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())
            );
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JShellDataObject.java

示例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) {
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PropertiesLocaleNode.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:PresentableFileEntry.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:PresentableFileEntry.java

示例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 );
            }
        });
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:EntityDataObject.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:HibernateCfgDataObject.java

示例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));
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:HtmlDataObject.java

示例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);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:22,代码来源:TLDataObject.java

示例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 ();
    }
}
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:23,代码来源:MultiDataObject.java

示例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);
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:GlslGeometryShaderDataObject.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:AntProjectDataObject.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SpringXMLConfigDataObject.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:DiffStreamSource.java


注:本文中的org.openide.nodes.CookieSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。