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

The following examples show how to use org.openide.nodes.CookieSet#add() . 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: GlslGeometryShaderDataObject.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
 
Example 2
Source File: PropertiesLocaleNode.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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) {
    }
}
 
Example 3
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 4
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 );
        }
    });
}
 
Example 5
Source File: SunDescriptorDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SunDescriptorDataObject(FileObject pf, SunDescriptorDataLoader loader) throws DataObjectExistsException {
    super(pf, loader);
    
    descriptorType = DDType.getDDType(pf.getNameExt());
    
    // XML Validation cookies
    InputSource in = DataObjectAdapters.inputSource(this);
    CheckXMLCookie checkCookie = new CheckXMLSupport(in);
    getCookieSet().add(checkCookie);
    ValidateXMLCookie validateCookie = new ValidateXMLSupport(in);
    CookieSet set = getCookieSet();
    set.add(validateCookie);
    if (null == descriptorType) {
        xmlIndex = 0;
    } else if (descriptorType.equals(DDType.DD_GF_WEB_APP) || 
            descriptorType.equals(DDType.DD_SUN_WEB_APP)) {
        xmlIndex = 6;
    } else if (descriptorType.equals(DDType.DD_GF_APPLICATION) || 
            descriptorType.equals(DDType.DD_SUN_APPLICATION)) {
        xmlIndex = 1;
    } else if (descriptorType.equals(DDType.DD_GF_EJB_JAR) || 
            descriptorType.equals(DDType.DD_SUN_EJB_JAR)) {
        xmlIndex = 5;
    } else if (descriptorType.equals(DDType.DD_GF_APP_CLIENT) || 
            descriptorType.equals(DDType.DD_SUN_APP_CLIENT)) {
        xmlIndex = 4;
    } else {
        xmlIndex = 0;
    }
}
 
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: 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 8
Source File: IdsDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public IdsDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    final CookieSet cookies = getCookieSet();
    registerEditor(SETTINGS_MIME_TYPE, false);
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ResourceXsdValidateXMLSupport(DataObjectAdapters.inputSource(this), AndroidStyleable.class.getResource("ids.xsd")));
}
 
Example 9
Source File: LayoutDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public LayoutDataObject(FileObject fo, MultiFileLoader loader) throws DataObjectExistsException {
    super(fo, loader);
    final CookieSet cookies = getCookieSet();
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ValidateXMLSupport(DataObjectAdapters.inputSource(this)));
    registerEditor(LAYOUT_MIME_TYPE, true);
}
 
Example 10
Source File: SymbolsDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public SymbolsDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    final CookieSet cookies = getCookieSet();
    registerEditor(SETTINGS_MIME_TYPE, false);
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ResourceXsdValidateXMLSupport(DataObjectAdapters.inputSource(this), AndroidStyleable.class.getResource("symbols.xsd")));
}
 
Example 11
Source File: GlslVertexShaderDataObject.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public GlslVertexShaderDataObject(FileObject pf, GlslVertexShaderDataLoader 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);
}
 
Example 12
Source File: JnlpDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JnlpDataObject(FileObject pf, JnlpDataLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    registerEditor(JnlpDataLoader.REQUIRED_MIME, true);
    CookieSet cookies = getCookieSet();
    InputSource in = DataObjectAdapters.inputSource(this);
    CheckXMLSupport checkCookieImpl = new CheckXMLSupport(in);
    ValidateXMLSupport validateCookieImpl = new ValidateXMLSupport(in);
    cookies.add(checkCookieImpl);
    cookies.add(validateCookieImpl);
}
 
Example 13
Source File: PDFDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public PDFDataObject(FileObject pf, MultiFileLoader loader)
                                        throws DataObjectExistsException {
    super(pf, loader);
    CookieSet cookies = getCookieSet();
    // [PENDING] try also Java-implemented reader
    File f = FileUtil.toFile(pf);
    if (f != null) {
        cookies.add(new PDFOpenSupport(this));
    }
}
 
Example 14
Source File: MenuDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public MenuDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    final CookieSet cookies = getCookieSet();
    registerEditor(SETTINGS_MIME_TYPE, false);
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ResourceXsdValidateXMLSupport(DataObjectAdapters.inputSource(this), AndroidStyleable.class.getResource("menu.xsd")));
}
 
Example 15
Source File: UnknownValuesDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public UnknownValuesDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    final CookieSet cookies = getCookieSet();
    registerEditor(SETTINGS_MIME_TYPE, false);
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ResourceXsdValidateXMLSupport(DataObjectAdapters.inputSource(this), AndroidStyleable.class.getResource("all.xsd")));
}
 
Example 16
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 17
Source File: DimensDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public DimensDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    final CookieSet cookies = getCookieSet();
    registerEditor(SETTINGS_MIME_TYPE, false);
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ResourceXsdValidateXMLSupport(DataObjectAdapters.inputSource(this), AndroidStyleable.class.getResource("dimens.xsd")));
}
 
Example 18
Source File: Sample60M7ProblemWithGetDataObjectTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Sample60M6DataObject(FileObject pf, Sample60M6DataLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    CookieSet cookies = getCookieSet();
    cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
}
 
Example 19
Source File: WhereUsedDataObject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public WhereUsedDataObject(FileObject pf, WhereUsedDataLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    CookieSet cookies = getCookieSet();
    cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
}
 
Example 20
Source File: JMEMaterialDefinitionDataObject.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public JMEMaterialDefinitionDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    CookieSet cookies = getCookieSet();
    cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
}