Java Code Examples for org.openide.nodes.CookieSet#assign()

The following examples show how to use org.openide.nodes.CookieSet#assign() . 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: TplDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public TplDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    CookieSet set = getCookieSet();
    set.add(TplEditorSupport.class, this);
    set.assign(SaveAsCapable.class, new SaveAsCapable() {

        @Override
        public void saveAs(FileObject folder, String fileName) throws IOException {
            TplEditorSupport es = getLookup().lookup(TplEditorSupport.class);
            try {
                es.updateEncoding();
                es.saveAs(folder, fileName);
            } catch (UserCancelException e) {
                //ignore, just not save anything
            }
        }
    });

    set.assign(FileEncodingQueryImplementation.class, new FileEncodingQueryImpl());
}
 
Example 2
Source File: EntityDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 );
            }
        });
    }
 
Example 3
Source File: HtmlDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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));
    
}
 
Example 4
Source File: SpringXMLConfigDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 5
Source File: JSFConfigDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init() {
    CookieSet cookies = getCookieSet();

    cookies.add(JSFConfigEditorSupport.class, this);

    //Lookup JSFConfigEditorContext for Page Flow Editor multiview
    cookies.assign(JSFConfigEditorContext.class, new JSFConfigEditorContextImpl(this));

    // Creates Check XML and Validate XML context actions
    InputSource in = DataObjectAdapters.inputSource(this);
    cookies.add(new CheckXMLSupport(in));
    cookies.add(new ValidateXMLSupport(in));
    cookies.assign(FileEncodingQueryImplementation.class, XmlFileEncodingQueryImpl.singleton());
}
 
Example 6
Source File: StrutsConfigDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init() {
    CookieSet cookies = getCookieSet();

    cookies.add(StrutsConfigEditorSupport.class, this);
    cookies.assign(FileEncodingQueryImplementation.class, XmlFileEncodingQueryImpl.singleton());
    // Creates Check XML and Validate XML context actions
    InputSource in = DataObjectAdapters.inputSource(this);
    cookies.add(new CheckXMLSupport(in));
    cookies.add(new ValidateXMLSupport(in));
}
 
Example 7
Source File: SQLDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SQLDataObject(FileObject primaryFile, MultiFileLoader loader) throws DataObjectExistsException {
    super(primaryFile, loader);
    CookieSet cookies = getCookieSet();
    final SQLEditorSupport sqlEditorSupport = new SQLEditorSupport(this);
    cookies.add(sqlEditorSupport);
    cookies.assign( SaveAsCapable.class, new SaveAsCapable() {
        @Override
        public void saveAs(FileObject folder, String fileName) throws IOException {
            sqlEditorSupport.saveAs( folder, fileName );
        }
    });
}
 
Example 8
Source File: XSLDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public XSLDataObject(final FileObject obj, final UniFileLoader loader) throws DataObjectExistsException {
    super (obj, loader);

    CookieSet set = getCookieSet();
    cookieManager = new DataObjectCookieManager (this, set);
    set.add (cookieManager);

    // add check and validate cookies
    InputSource is = DataObjectAdapters.inputSource (this);
    set.add(new CheckXMLSupport (is));
    set.add(new ValidateXSLSupport (is));

    // add TransformableCookie
    Source source = DataObjectAdapters.source (this);
    set.add (new TransformableSupport (source));

    // editor support defines MIME type understood by EditorKits registry         
    final TextEditorSupport.TextEditorSupportFactory editorFactory =
        new TextEditorSupport.TextEditorSupportFactory (this, MIME_TYPE);
    editorFactory.registerCookies (set);

    set.assign(XmlFileEncodingQueryImpl.class, XmlFileEncodingQueryImpl.singleton());

    set.assign( SaveAsCapable.class, new SaveAsCapable() {
        public void saveAs(FileObject folder, String fileName) throws IOException {
            editorFactory.createEditor().saveAs( folder, fileName );
        }
    });
}