org.openide.nodes.CookieSet Java Examples

The following examples show how to use org.openide.nodes.CookieSet. 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: 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 #2
Source File: DiffSidebar.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * 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
}
 
Example #3
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 #4
Source File: XMLJ2eeDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public XMLJ2eeDataObject(FileObject pf, MultiFileLoader loader)
    throws org.openide.loaders.DataObjectExistsException {
    super(pf,loader);
    
    CookieSet cs = getCookieSet();
    cs.add(XMLJ2eeEditorSupport.class, this);
    cs.add(EditCookie.class, this);
    cs.add(EditorCookie.class, this);
    cs.add(LineCookie.class, this);
    cs.add(PrintCookie.class, this);
    cs.add(CloseCookie.class, this);
    // added CheckXMLCookie
    InputSource in = DataObjectAdapters.inputSource(this);
    CheckXMLCookie checkCookie = new CheckXMLSupport(in);
    cs.add(checkCookie);
}
 
Example #5
Source File: PresentableFileEntry.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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;
    }
}
 
Example #6
Source File: PresentableFileEntry.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: JShellDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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())
            );
        }
    });
}
 
Example #8
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 #9
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 #10
Source File: LayerDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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)));
}
 
Example #11
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 #12
Source File: AttrsDataObject.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
public AttrsDataObject(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("attrs.xsd")));
}
 
Example #13
Source File: CookieActionTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public NodeWithDefaultLookup() {
    super(Children.LEAF);
    getCookieSet().add(OpenCookie.class, new CookieSet.Factory() {
        public Node.Cookie createCookie(Class clazz) {
            if(clazz.isAssignableFrom(OpenCookie.class)) {
                synchronized(NodeWithDefaultLookup.this) {
                    NodeWithDefaultLookup.this.cookieCreated = true;
                }
                return new Open();
            }
            return null;
        }
    });
}
 
Example #14
Source File: AntProjectDataObjectProblemTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
        }
 
Example #15
Source File: AntProjectDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #16
Source File: TestNGSuiteDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TestNGSuiteDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);
    CookieSet cookies = getCookieSet();
    cookies.add(new CheckXMLSupport(DataObjectAdapters.inputSource(this)));
    cookies.add(new ValidateXMLSupport(DataObjectAdapters.inputSource(this)));
    registerEditor(MIME_TYPE, true);
}
 
Example #17
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 #18
Source File: CookieManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 */
public CookieManager (DataObject dataObject, CookieSet cookieSet, Class clazz) {        
    if ( CookieFactoryCreator.class.isAssignableFrom (clazz) == false ) {
        throw new IllegalArgumentException ("Parameter class must extend CookieFactoryCreator class.");
    }

    this.dataObject = dataObject;
    this.cookieSet  = cookieSet;
    this.factoryMap = new HashMap<CookieFactoryCreator, CookieFactory>();

    register (clazz);

    addedToResult (getResult());
}
 
Example #19
Source File: MultiDataObjectDeleteSecondaryEntryTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public FXKitDataObject(FileObject ffo, FileObject jfo, FXKitDataLoader loader) throws DataObjectExistsException, IOException
{
    super(jfo, loader);
    formEntry = (FileEntry)registerEntry(ffo);

    CookieSet cookies = getCookieSet();
    //cookies.add((Node.Cookie) DataEditorSupport.create(this, getPrimaryEntry(), cookies));
}
 
Example #20
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 #21
Source File: EjbJarMultiViewDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public EjbJarMultiViewDataObject(FileObject pf, EjbJarDataLoader loader) throws DataObjectExistsException {
    super(pf, loader);
    
    // added ValidateXMLCookie
    InputSource in = DataObjectAdapters.inputSource(this);
    ValidateXMLCookie validateCookie = new ValidateXMLSupport(in);
    CookieSet set = getCookieSet();
    set.add(validateCookie);
    CookieSet.Factory viewCookieFactory = new ViewCookieFactory();
    set.add(ViewCookie.class, viewCookieFactory);

    // initialize srcRoots
    refreshSourcesTask.schedule(0);

    RP.submit(new Runnable() {
        @Override
        public void run() {
            Project project = getProject();
            if (project != null) {
                Sources sources = ProjectUtils.getSources(project);
                sources.addChangeListener(EjbJarMultiViewDataObject.this);
            }
            // refresh srcRoots if any change happened in the meantime
            refreshSourcesTask.schedule(0);
        }
    });
}
 
Example #22
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 #23
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 #24
Source File: DiffStreamSource.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #25
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 #26
Source File: PresentableFileEntry.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Set the set of cookies.
 * To the provided cookie set a listener is attached,
 * and any change to the set is propagated by
 * firing a change on {@link #PROP_COOKIE}.
 *
 * @param s the cookie set to use
 * @deprecated
 */
protected final synchronized void setCookieSet (CookieSet s) {
    if (cookieSet != null) {
        cookieSet.removeChangeListener (cookieL);
}

    s.addChangeListener (cookieL);
    cookieSet = s;

    firePropertyChange (Node.PROP_COOKIE, null, null);
}
 
Example #27
Source File: DiffStreamSource.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #28
Source File: DiffUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #29
Source File: DiffSidebarManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example #30
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 );
        }
    });
}