org.openide.loaders.MultiDataObject Java Examples

The following examples show how to use org.openide.loaders.MultiDataObject. 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: 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 #2
Source File: JspServletDataLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Create a secondary file entry.
* By default, {@link FileEntry.Numb} is used for the class files
*
* @param secondaryFile secondary file to create entry for
* @return the entry
*/
protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, FileObject secondaryFile) {
    //The JavaDataObject itself has no secondary entries, but its subclasses have.
    //So we have to keep it as MultiFileLoader
    Logger.getLogger("global").log(Level.INFO, "Subclass of JavaDataLoader (" + this.getClass().getName() + ") has secondary entries but does not override createSecondaryEntries (MultidataObject, FileObject) method."); // NOI18N
    return new FileEntry.Numb(obj, secondaryFile);
}
 
Example #3
Source File: JspServletDataLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Create the primary file entry.
* @param primaryFile primary file recognized by this loader
* @return primary entry for that file
*/
protected MultiDataObject.Entry createPrimaryEntry (MultiDataObject obj, FileObject primaryFile) {
    if (JAVA_EXTENSION.equals(primaryFile.getExt())) {
        return JavaDataSupport.createJavaFileEntry(obj, primaryFile);
    }
    else {
        return new FileEntry(obj, primaryFile);
    }
}
 
Example #4
Source File: DataEditorReadOnlyTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected FileLock takeLock () throws IOException {
    if (getDataObject() instanceof MultiDataObject) {
        return ((MultiDataObject)getDataObject()).getPrimaryEntry().takeLock();
    } else {
        return super.getDataObject ().getPrimaryFile ().lock ();
    }
}
 
Example #5
Source File: FormDataLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj,
                                                     FileObject secondaryFile)
{
    assert FORM_EXTENSION.equals(secondaryFile.getExt());
    
    FileEntry formEntry = new FormEntry(obj, secondaryFile);
    ((FormDataObject)obj).formEntry = formEntry;
    return formEntry;
}
 
Example #6
Source File: JaxWsDataLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Create a secondary file entry.
* By default, {@link FileEntry.Numb} is used for the class files; subclasses wishing to have useful
* secondary files should override this for those files, typically to {@link FileEntry}.
*
* @param secondaryFile secondary file to create entry for
* @return the entry
*/
protected MultiDataObject.Entry createSecondaryEntry (MultiDataObject obj, 
        FileObject secondaryFile) {
    //The JavaDataObject itself has no secondary entries, but its subclasses have.
    //So we have to keep it as MultiFileLoader
    ErrorManager.getDefault().log ("Subclass of JavaDataLoader ("+
            this.getClass().getName()
            +") has secondary entries but does not override createSecondaryEntries (MultidataObject, FileObject) method."); // NOI18N
    return new FileEntry.Numb(obj, secondaryFile);
}
 
Example #7
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 #8
Source File: DiffSidebarManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private FileObject fileForDocument(Document doc) {
    DataObject dobj = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
    LOG.log(Level.FINEST, "document {0} returns {1} for property=" + Document.StreamDescriptionProperty, new Object[] {doc, dobj});
    if (dobj == null) return null;
    LOG.log(Level.FINER, "looking up file for {0}", dobj);
    if (dobj instanceof MultiDataObject) {
        return fileForDataobject(doc, (MultiDataObject) dobj);
    } else if (dobj != null) {
        return dobj.getPrimaryFile();
    } else {
        return null;
    }
}
 
Example #9
Source File: JspNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Set request parameters for a given entry.
* @param entry the entry
* @param args array of arguments
* @exception IOException if arguments cannot be set
*/
static void setRequestParams(MultiDataObject.Entry entry, String params) throws IOException {
    StringBuffer newParams=new StringBuffer();
    String s=null;
    if (params!=null){
        for (int i=0;i<params.length();i++) {
            char ch = params.charAt(i);
            if ((int)ch!=13 && (int)ch!=10) newParams.append(ch);
        }
        s=newParams.toString();
        if (s.length()==0) s=null;
    } 
    WebExecSupport.setQueryString(entry.getFile (), s);
}
 
Example #10
Source File: JaxWsDataLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Create the <code>JaxWsDataObject</code>.
*
* @param primaryFile the primary file
* @return the data object for this file
* @exception DataObjectExistsException if the primary file already has a data object
*/
protected MultiDataObject createMultiObject (FileObject primaryFile)
throws DataObjectExistsException, java.io.IOException {
    if (primaryFile.getExt().equals(JAVA_EXTENSION)) {
        return new JaxWsDataObject(primaryFile, this);
    }
    return null;
}
 
Example #11
Source File: JspLoader.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected MultiDataObject createMultiObject (final FileObject primaryFile)
throws DataObjectExistsException, IOException {
    JspDataObject obj = createJspObject(primaryFile, this);
    // [PENDING] add these from JspDataObject, not from the loader
    obj.getCookieSet0 ().add (new TagLibParseSupport(primaryFile));
    return obj;
}
 
Example #12
Source File: EmbeddedIndexerTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
    if (getExtensions().isRegistered(primaryFile)) {
        return new TopDataObject(primaryFile, this);
    }
    return null;
}
 
Example #13
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 #14
Source File: SimpleES.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Constructor. */
public Environment(DataObject obj, MultiDataObject.Entry entry) {
    super(obj);
    this.entry = entry;
}
 
Example #15
Source File: JDBCDriverConvertor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor for writing to an existing file.
 */
AtomicWriter(JDBCDriver instance, MultiDataObject holder) {
    this.instance = instance;
    this.holder = holder;
}
 
Example #16
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj, FileObject secondaryFile) {
    LOG.fine("new snd entry: " + secondaryFile);
    return new FE(obj, secondaryFile);
}
 
Example #17
Source File: GradleDataLoader.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Override
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
    return new GradleDataObject(primaryFile, this);
}
 
Example #18
Source File: DataEditorSupportMoveTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
    return new FileEntry (obj, primaryFile);
}
 
Example #19
Source File: PropertiesProviderTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
    LOG.fine("new primary entry " + primaryFile);
    return new FE(obj, primaryFile);
}
 
Example #20
Source File: GsfDataObject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected FileLock takeLock() throws java.io.IOException {
    return ((MultiDataObject)this.getDataObject()).getPrimaryEntry().takeLock();
}
 
Example #21
Source File: GradleDataObject.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
protected @Override
FileLock takeLock() throws IOException {
    return ((MultiDataObject) getDataObject()).getPrimaryEntry().takeLock();
}
 
Example #22
Source File: ScriptingCreateFromTemplateTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FE(MultiDataObject mo, FileObject fo) {
    super(mo, fo);
}
 
Example #23
Source File: JaxWsDataObject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected FileLock takeLock() throws java.io.IOException {
    return ((MultiDataObject)this.getDataObject()).getPrimaryEntry().takeLock();
}
 
Example #24
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj, FileObject secondaryFile) {
    LOG.fine("new snd entry: " + secondaryFile);
    return new FE(obj, secondaryFile);
}
 
Example #25
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
    LOG.fine("new primary entry " + primaryFile);
    return new FE(obj, primaryFile);
}
 
Example #26
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
    LOG.info("New data object for " + primaryFile);
    return new TwoPartObject(this, primaryFile);
}
 
Example #27
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FE(MultiDataObject mo, FileObject fo) {
    super(mo, fo);
}
 
Example #28
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject.Entry createSecondaryEntry(MultiDataObject obj, FileObject secondaryFile) {
    return new FileEntry(obj, secondaryFile);
}
 
Example #29
Source File: SCFTHandlerTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
    LOG.fine("new primary entry " + primaryFile);
    return new FE(obj, primaryFile);
}
 
Example #30
Source File: IndentEngineIntTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FE(MultiDataObject mo, FileObject fo) {
    super(mo, fo);
}