当前位置: 首页>>代码示例>>Java>>正文


Java DataFolder.getPrimaryFile方法代码示例

本文整理汇总了Java中org.openide.loaders.DataFolder.getPrimaryFile方法的典型用法代码示例。如果您正苦于以下问题:Java DataFolder.getPrimaryFile方法的具体用法?Java DataFolder.getPrimaryFile怎么用?Java DataFolder.getPrimaryFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.loaders.DataFolder的用法示例。


在下文中一共展示了DataFolder.getPrimaryFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRename

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public void handleRename(DataFolder folder, String newName) {
    InstanceContent ic = new InstanceContent();
    ic.add(folder.getNodeDelegate());
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    final Lookup l = new AbstractLookup(ic);
    if (ActionsImplementationFactory.canRename(l)) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
                a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
            }
        });
    } else {
        FileObject fo = folder.getPrimaryFile();
        try {
            folder.rename(newName);
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FolderRenameHandlerImpl.java

示例2: attributesFor

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public Map<String, ?> attributesFor(DataObject template, DataFolder target, String name) {
    FileObject targetF = target.getPrimaryFile();
    Project prj = FileOwnerQuery.getOwner(targetF);
    Map<String, Object> all = new HashMap();
    if (prj != null) {
        // call old providers
        Collection<? extends CreateFromTemplateAttributesProvider> oldProvs = prj.getLookup().lookupAll(CreateFromTemplateAttributesProvider.class);
        if (!oldProvs.isEmpty()) {
            for (CreateFromTemplateAttributesProvider attrs : oldProvs) {
                Map<String, ? extends Object> m = attrs.attributesFor(template, target, name);
                if (m != null) {
                    all.putAll(m);
                }
            }
        }
    }
    all.put(ProjectTemplateAttributesLegacy.class.getName(), Boolean.TRUE);
    return checkProjectAttrs(all, targetF);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ProjectTemplateAttributesLegacy.java

示例3: isCustomProfile

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
 * Custom profile is present if:
 * a/ the profile's folder can be reverted (=> was materialized on writable layer)
 * b/ there's no "reveal" entry for it in its parent => was not present
 * @param profileName
 * @return C
 */
public boolean isCustomProfile(String profileName) {
    DataFolder profileFolder = getExistingProfile(profileName);
    if (profileFolder == null) {
        return true;
    }
    FileObject f = profileFolder.getPrimaryFile();
    if (!f.canRevert()) {
        return false;
    }
    FileObject parentF = profileFolder.getPrimaryFile().getParent();
    if (parentF == null) {
        // very very unlikely
        return true;
    }
    Collection<FileObject> col = (Collection<FileObject>)parentF.getAttribute("revealEntries");
    if (col == null) {
        return true;
    }
    for (FileObject f2 : col) {
        if (f2.getNameExt().equals(profileName)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:LayersBridge.java

示例4: getPasteType

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
*  
*/ 
   static PasteType getPasteType(final DataFolder targetFolder, final Transferable transfer) {
       final FileObject folder = targetFolder.getPrimaryFile();
       PasteType retVal = null;

       try {
           /*Copy/Cut/Paste is allowed just on SystemFileSystem*/ 
           if (folder.getFileSystem().isDefault()) {
               final int[] pasteOperations = new int[]{LoaderTransfer.CLIPBOARD_COPY, LoaderTransfer.CLIPBOARD_CUT};

               for (int i = 0; i < pasteOperations.length; i++) {
                   final DataObject[] dataObjects = LoaderTransfer.getDataObjects(transfer, pasteOperations[i]);
                   if (dataObjects != null) {                                                
                       if (canBePasted(dataObjects, targetFolder, pasteOperations[i])) {
                           retVal = new PasteTypeImpl(Arrays.asList(dataObjects), targetFolder, pasteOperations[i]);
                           break;
                       }
                   }
               }
           }
       } catch (FileStateInvalidException e) {/*just null is returned if folder.getFileSystem fires ISE*/}

       return retVal;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ActionPasteType.java

示例5: attributesFor

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
public Map<String,?> attributesFor(DataObject template, DataFolder target, String name) {
    FileObject templateFO = template.getPrimaryFile();
    if (!JavaDataLoader.JAVA_EXTENSION.equals(templateFO.getExt()) || templateFO.isFolder()) {
        return null;
    }
    
    FileObject targetFO = target.getPrimaryFile();
    Map<String,Object> result = new HashMap<String,Object>();
    
    ClassPath cp = ClassPath.getClassPath(targetFO, ClassPath.SOURCE);
    if (cp == null) {
        LOG.warning("No classpath was found for folder: " + target.getPrimaryFile()); // NOI18N
    }
    else {
        result.put("package", cp.getResourceName(targetFO, '.', false)); // NOI18N
    }
    
    String sourceLevel = SourceLevelQuery.getSourceLevel(targetFO);
    if (sourceLevel != null) {
        result.put("javaSourceLevel", sourceLevel); // NOI18N
        if (isJava15orLater(sourceLevel))
            result.put("java15style", Boolean.TRUE); // NOI18N
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:JavaTemplateAttributesProvider.java

示例6: attributesFor

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public Map<String, ?> attributesFor(DataObject template, DataFolder target, String name) {
    FileObject templateFO = template.getPrimaryFile();
    if (!JFXProjectProperties.FXML_EXTENSION.equals(templateFO.getExt()) || templateFO.isFolder()) {
        return null;
    }
    
    FileObject targetFO = target.getPrimaryFile();
    Map<String,Object> result = new HashMap<String,Object>();
    
    ClassPath cp = ClassPath.getClassPath(targetFO, ClassPath.SOURCE);
    if (cp == null) {
        LOG.log(
            Level.WARNING,
            "No classpath was found for folder: {0}",   // NOI18N
            FileUtil.getFileDisplayName(targetFO));
    } else if (cp.findOwnerRoot(targetFO) == null) {
        LOG.log(
            Level.WARNING,
            "Folder {0} is not on its classpath: {1}",  // NOI18N
            new Object[] {
                FileUtil.getFileDisplayName(targetFO),
                cp.toString(ClassPath.PathConversionMode.PRINT)
            });
    }
    else {
        result.put("package", cp.getResourceName(targetFO, '.', false)); // NOI18N
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:FXMLTemplateAttributesProvider.java

示例7: constructPrefsFileName

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private String constructPrefsFileName( Model model ) {
    DataFolder dof = (DataFolder)model.getRoot().lookup( DataFolder.class );
    if( null != dof ) {
        FileObject fo = dof.getPrimaryFile();
        if( null != fo ) {
            return fo.getPath();
        }
    }
    return model.getName();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DefaultSettings.java

示例8: getDisplayName

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public String getDisplayName() {

    String retValue = null;
    DataFolder folder = (DataFolder)getCookie( DataFolder.class );
    if( null != folder ) {
        FileObject fob = folder.getPrimaryFile();
        Object catName = fob.getAttribute( CAT_NAME );
        if (catName instanceof String)
            retValue = catName.toString();
    } 
    if( null == retValue ) {
        retValue = super.getDisplayName();
    }
    // XXX poor impl; should not depend on org.openide.loaders.Bundle#FMT_shadowName:
    if( null != retValue && retValue.indexOf("\u2192") > 0 ) {
        DataShadow shadow = (DataShadow)getCookie( DataShadow.class );
        if( null != shadow ) {
            DataObject dobj = shadow.getOriginal();
            if( null != dobj ) {
                Node origNode = dobj.getNodeDelegate();
                if( null != origNode && null != origNode.getDisplayName() ) {
                    retValue = origNode.getDisplayName();
                }
            }
        }
    }
    return retValue;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CategoryNode.java

示例9: setDisplayName

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
@Override
public void setDisplayName( String displayName ) {
    try {
        DataFolder folder = (DataFolder)getCookie( DataFolder.class );
        if( null != folder ) {
            FileObject fo = folder.getPrimaryFile();
            fo.setAttribute( CAT_NAME, displayName );
        }
    } catch (java.io.IOException ex) {
        RuntimeException e = new IllegalArgumentException();
        org.openide.ErrorManager.getDefault().annotate(e, ex);
        throw e;
    }
    super.setDisplayName( displayName );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:CategoryNode.java

示例10: findFolder

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private FileObject findFolder( Lookup category ) {
    Node n = category.lookup( Node.class );
    if( null != n ) {
        DataFolder df = n.getCookie( DataFolder.class );
        if( null != df ) {
            return df.getPrimaryFile();
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:TextImporter.java

示例11: getPaletteId

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
private static String getPaletteId( PaletteController pc ) {
    if( null == pc ) {
        return "_empty_";
    }
    DataFolder dof = (DataFolder)pc.getModel().getRoot().lookup( DataFolder.class );
    if( null != dof ) {
        FileObject fo = dof.getPrimaryFile();
        if( null != fo ) {
            return fo.getPath();
        }
    }
    return pc.getModel().getName();
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:PaletteVisibility.java

示例12: testGetRoot

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
 * Test of getRoot method, of class org.netbeans.modules.palette.Model.
 */
public void testGetRoot() throws IOException {
    PaletteController pc = PaletteFactory.createPalette( getRootFolderName(), new DummyActions() );
    Model model = pc.getModel();
    Lookup rootLookup = model.getRoot();
    
    DataFolder df = (DataFolder)rootLookup.lookup( DataFolder.class );
    assertNotNull( df );
    
    FileObject fo = df.getPrimaryFile();
    assertNotNull( fo );
    
    assertEquals( getRootFolderName(), fo.getName() );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ModelTest.java

示例13: LazyMenu

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/** Constructor. */
public LazyMenu(final DataFolder df, boolean icon) {
    this.master = df;
    this.icon = icon;
    this.dynaModel = new DynaMenuModel();
    this.slave = new MenuFolder();
    
    setName(df.getName());
    final FileObject pf = df.getPrimaryFile();
    Object prefix = pf.getAttribute("property-prefix"); // NOI18N
    if (prefix instanceof String) {
        Enumeration<String> en = pf.getAttributes();
        while (en.hasMoreElements()) {
            String attrName = en.nextElement();
            if (attrName.startsWith((String)prefix)) {
                putClientProperty(
                    attrName.substring(((String)prefix).length()), 
                    pf.getAttribute(attrName)
                );
            }
        }
    }

    // Listen for changes in Node's DisplayName/Icon
    Node n = master.getNodeDelegate ();
    n.addNodeListener (org.openide.nodes.NodeOp.weakNodeListener (this, n));
    Mutex.EVENT.readAccess(this);
    getModel().addChangeListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MenuBar.java

示例14: acceptFolder

import org.openide.loaders.DataFolder; //导入方法依赖的package包/类
/**
       * Returns a <code>Toolbar.Folder</code> cookie for the specified
       * <code>DataFolder</code>.
       * @param df a <code>DataFolder</code> to create the cookie for
       * @return a <code>Toolbar.Folder</code> for the specified folder
       */
      @Override
      protected InstanceCookie acceptFolder (DataFolder df) {
          Toolbar res = new Toolbar(df);
   //#223266
   FileObject fo = df.getPrimaryFile();
   Object disable = fo.getAttribute("nb.toolbar.overflow.disable"); //NOI18N
   if (Boolean.TRUE.equals(disable)) {
res.putClientProperty("nb.toolbar.overflow.disable", Boolean.TRUE); //NOI18N
   }
   return res.waitFinished();
      }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ToolbarPool.java

示例15: canBePasted

import org.openide.loaders.DataFolder; //导入方法依赖的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.DataFolder.getPrimaryFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。