當前位置: 首頁>>代碼示例>>Java>>正文


Java DataObject.getPrimaryFile方法代碼示例

本文整理匯總了Java中org.openide.loaders.DataObject.getPrimaryFile方法的典型用法代碼示例。如果您正苦於以下問題:Java DataObject.getPrimaryFile方法的具體用法?Java DataObject.getPrimaryFile怎麽用?Java DataObject.getPrimaryFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.loaders.DataObject的用法示例。


在下文中一共展示了DataObject.getPrimaryFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getSchemaFileName

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public String getSchemaFileName(){
    DataObject dobj = (DataObject) getLookup().lookup(DataObject.class);
    if (dobj != null) {
         FileObject fobj = dobj.getPrimaryFile();
         File file = FileUtil.toFile(fobj);
         String uri = file.getPath();
         if (uri != null) {
           try {
                // escape the non-ASCII characters
                uri = new URI(uri).toASCIIString();
            } catch (URISyntaxException e) {
              // the specified uri is not valid, it is too late to fix it now
            }
         }
         return uri;
    }
    
    return null;
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:ExternalReferenceDataNode.java

示例2: runTaskWithinContext

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public void runTaskWithinContext(Lookup context, Task task) {
    JTextComponent component = context.lookup(JTextComponent.class);
    if (component != null) {
        DataObject dobj = NbEditorUtilities.getDataObject(component.getDocument());
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            ModelSource ms = Utilities.createModelSource(fo);
            if (ms.isEditable()) {
                POMModel model = POMModelFactory.getDefault().getModel(ms);
                if (model != null) {
                    Lookup newContext = new ProxyLookup(context, Lookups.fixed(model));
                    task.run(newContext);
                    return;
                }
            }
        }
    }
    task.run(context);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:ContextProvider.java

示例3: getText

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public String getText( TabData tab ) {
    if( !settings.isShowFolderName() )
        return null;
    if( tab.getComponent() instanceof TopComponent ) {
        TopComponent tc = ( TopComponent ) tab.getComponent();
        DataObject dob = tc.getLookup().lookup( DataObject.class );
        if( null != dob ) {
            FileObject fo = dob.getPrimaryFile();
            if( fo.isData() ) {
                FileObject folder = fo.getParent();
                if( null != folder ) {
                    String folderName = folder.getNameExt() + pathSeparator;
                    String defaultText = tab.getText();

                    return merge( folderName, defaultText );
                }
            }
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:FolderNameTabDecorator.java

示例4: enable

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
protected boolean enable(Node[] node) {
    if (node.length == 0) {
        return false;
    }
    DataObject dobj = (DataObject) node[0].getLookup().lookup(DataObject.class);
    if (dobj == null) {
        return false;
    }
    FileObject fo = dobj.getPrimaryFile();
    Project project = FileOwnerQuery.getOwner(fo);
    if(project == null)
        return false;
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] srcGrps = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (srcGrps == null || srcGrps.length == 0) {
        return false;
    } else {
        return true;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:GenerateDocumentHandlerAction.java

示例5: getFilesFromLookup

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** In given lookup will find all FileObjects owned by given project
 * with given command supported.
 */    
public static FileObject[] getFilesFromLookup( Lookup lookup, Project project ) {
    HashSet<FileObject> result = new HashSet<FileObject>();
    for (DataObject dObj : lookup.lookupAll(DataObject.class)) {
        FileObject fObj = dObj.getPrimaryFile();
        Project p = FileOwnerQuery.getOwner(fObj);
        if ( p != null && p.equals( project ) ) {
            result.add( fObj );                                        
        }

    }
    
    FileObject[] fos = new FileObject[ result.size() ];
    result.toArray( fos );        
    return fos;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ActionsUtil.java

示例6: actionPerformed

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public void actionPerformed( ActionEvent e ) {
    String command = e.getActionCommand();

    if ( COMMAND_SELECT.equals( command ) ) {
        Node selection[] = browsePanel.getExplorerManager().getSelectedNodes();
        
        if ( selection != null && selection.length > 0 ) {
            DataObject dobj = (DataObject)selection[0].getLookup().
                lookup( DataObject.class );
            if (dobj!=null && dobj.getClass().isAssignableFrom(target)) {
                result = dobj.getPrimaryFile();
            }
            /*
            if ( dobj != null ) {
                FileObject fo = dobj.getPrimaryFile();
                if ( fo.isFolder() ) {
                    result = fo;
                }
            }
            */
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:BrowseFolders.java

示例7: updateDataObject

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/**
 * Update data object. Can be called when a module is enabled and new data
 * loader produces new data object.
 */
public void updateDataObject(DataObject updatedDataObject) {
    FileObject updatedPF = updatedDataObject.getPrimaryFile();
    if (dataObject == null
            || dataObject.getPrimaryFile().equals(updatedPF)) {
        if (updatedPF.isValid()) {
            this.invalidityStatus = null;
            if (fileListener == null) {
                this.fileListener = new FileListener();
                updatedPF.addFileChangeListener(fileListener);
            } else if (updatedPF != dataObject.getPrimaryFile()) {
                dataObject.getPrimaryFile().removeFileChangeListener(
                        fileListener);
                updatedPF.addFileChangeListener(fileListener);
            }
            this.dataObject = updatedDataObject;
            this.nodeDelegate = updatedDataObject.getNodeDelegate();
            this.valid = true;
            for (TextDetail td : textDetails) {
                td.updateDataObject(updatedDataObject);
            }
        }
    } else {
        throw new IllegalArgumentException(
                "Expected data object for the same file");          //NOI18N
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:MatchingObject.java

示例8: fileForDocument

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:DiffSidebarManager.java

示例9: discardChanges

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/** Discards all changes in modified files of given project. */
private static void discardChanges(Project project) {
    // discard all changes in modified files
    Iterator iter = DataObject.getRegistry().getModifiedSet().iterator();
    while (iter.hasNext()) {
        DataObject dobj = (DataObject) iter.next();
        if (dobj != null) {
            FileObject fobj = dobj.getPrimaryFile();
            Project owner = FileOwnerQuery.getOwner(fobj);
            if(owner == project) {
                dobj.setModified(false);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ProjectSupport.java

示例10: run

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
public void run() {
    List<FileObject> fileObjects = new ArrayList<FileObject>(nodes.size());
    for (Node node : nodes) {
        DataObject dataObject = node.getLookup().lookup(DataObject.class);
        if (dataObject != null) {
            FileObject primaryFileObject = dataObject.getPrimaryFile();
            if (primaryFileObject != null) {
                fileObjects.add(primaryFileObject);
            }
        }
    }
    UI.openRefactoringUI(createRefactoringUI(fileObjects.toArray(new FileObject[fileObjects.size()])));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:HibernateMappingRefactoringActionsProvider.java

示例11: getCurrentFile

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
/**
 * Gets a the file related to the document
 *
 * @return the file related to the document, <code>null</code> if none
 * exists.
 */
File getCurrentFile() {
    File result = referencedFile;
    if (result == null) {
        DataObject dobj = (DataObject) doc.getProperty(Document.StreamDescriptionProperty);
        if (dobj != null) {
            FileObject fo = dobj.getPrimaryFile();
            result = FileUtil.toFile(fo);
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:AnnotationBar.java

示例12: canRemove

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private boolean canRemove(final JavaPlatform platform, final DataObject dobj) {
    if (isDefaultPlatform(platform)) {
        return false;
    }
    if (dobj != null) {
        final FileObject fo = dobj.getPrimaryFile();
        Object attr = fo.getAttribute(ATTR_CAN_REMOVE);  //NOI18N
        if (attr instanceof Boolean && ((Boolean)attr) == Boolean.FALSE) {
            return false;
        }
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:PlatformsCustomizer.java

示例13: getShortDescription

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@Override
public String getShortDescription() {
    final DataObject dobj = getLookup().lookup(DataObject.class);
    FileObject pf;
    if (dobj != null && (pf = dobj.getPrimaryFile()) != null) {
        return FileUtil.getFileDisplayName(pf);

    } else {
        return super.getShortDescription();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:ActionFilterNode.java

示例14: DataObjectListener

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
@SuppressWarnings("LeakingThisInConstructor")
public DataObjectListener(final DataObject dobj) {            
    this.dobj = dobj;
    this.fobj = dobj.getPrimaryFile();
    wlistener = WeakListeners.propertyChange(this, dobj);
    this.dobj.addPropertyChangeListener(wlistener);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:EventSupport.java

示例15: canBePasted

import org.openide.loaders.DataObject; //導入方法依賴的package包/類
private static boolean canBePasted(final DataObject[] dataObjects, final DataFolder targetFolder, final int operation) throws FileStateInvalidException {
    final Set<DataObject> pasteableDataObjects = new HashSet<DataObject> ();
    final FileObject folder = targetFolder.getPrimaryFile();
    
    DataObject[] folderChildren = targetFolder.getChildren();
    
    for (int j = 0; j < dataObjects.length; j++) {
        final DataObject dataObject = dataObjects[j];
        final FileObject fo = dataObject.getPrimaryFile ();
        
        if (!isAction(dataObject) || !fo.getFileSystem().isDefault()) {
            break;    
        }

        final boolean isCopyPaste = operation == LoaderTransfer.CLIPBOARD_COPY && dataObject.isCopyAllowed();
        final boolean isCutPaste = operation == LoaderTransfer.CLIPBOARD_CUT && dataObject.isMoveAllowed() && 
                !(fo.getParent() == folder);//prevents from cutting into the same folder where it was 
                        
        if (isCopyPaste || isCutPaste) {
            
            boolean isDuplicate = false;
            for( int i=0; i<folderChildren.length; i++ ) {
                if( 0 == folderChildren[i].getName().compareTo( dataObject.getName() ) ) {
                    isDuplicate = true;
                    break;
                }
            }
            if( !isDuplicate )
                pasteableDataObjects.add(dataObject);                        
        }
    }
    return (pasteableDataObjects.size() == dataObjects.length);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:ActionPasteType.java


注:本文中的org.openide.loaders.DataObject.getPrimaryFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。