org.openide.loaders.DataFolder Java Examples

The following examples show how to use org.openide.loaders.DataFolder. 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: CopyClassesUI.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private final Vector getNodes() {
    Vector<Node> result = new Vector<Node>(javaObjects.size());
    LinkedList<FileObject> q = new LinkedList<FileObject>(javaObjects);
    while (!q.isEmpty()) {
        FileObject f = q.removeFirst();
        if (!VisibilityQuery.getDefault().isVisible(f)) {
            continue;
        }
        DataObject d = null;
        try {
            d = DataObject.find(f);
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
        if (d instanceof DataFolder) {
            for (DataObject o : ((DataFolder) d).getChildren()) {
                q.addLast(o.getPrimaryFile());
            }
        } else if(d != null) {
            result.add(d.getNodeDelegate());
        }
    }
    return result;
}
 
Example #2
Source File: AnnotationProviderTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@RandomlyFails
public void testContextLookupIsConsistentAfterMove() throws Exception {              
    ConsistencyCheckProvider.setCalled(0);
    // Prepare the data object (to initialize the lookup)
    FileObject fo = fs.getRoot().createData("test2", "txt");
    DataObject data = DataObject.find(fo);
    EditorCookie ec = data.getCookie(EditorCookie.class);

    // now move it (the lookup should update itself)
    FileObject fld = fs.getRoot().createFolder("folder1");
    DataFolder df = DataFolder.findFolder(fld);
    data.move(df);

    // now open the editor (invoke AnnotationProviders)
    // and check the lookup
    ec.open();
    assertEquals("Consistent lookup content", data.getPrimaryFile(),ConsistencyCheckProvider.getInLkp());
}
 
Example #3
Source File: I18nUtil.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 
 * Indicates if folder or its subfolders contains data object
 * that is supported by any internationalization factory. 
 */
public static boolean containsAcceptedDataObject(DataFolder folder) {
    DataObject[] children = folder.getChildren();
    DataObject[] folders = new DataObject[children.length];
    int i, foldersCount = 0;

    for (DataObject child : children) {
        if (child instanceof DataFolder) {  
            folders[foldersCount++] = child;
        } else if (FactoryRegistry.hasFactory(child.getClass())) {
            return true;
        }
    }
    for (i = 0; i < foldersCount; i++) {
        if (containsAcceptedDataObject((DataFolder) children[i])) {
            return true;
        }
    }
    return false;
}
 
Example #4
Source File: OpenProjectFolderAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public ContextAction(Lookup context) {
    super(OpenProjectFolderAction_LBL_action());
    this.context = context;
    boolean foundProject = false;
    for (DataFolder d : context.lookupAll(DataFolder.class)) {
        if (ProjectManager.getDefault().isProject(d.getPrimaryFile())) {
            foundProject = true;
            break;
        }
    }
    if (!foundProject) {
        putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
        setEnabled(false);
    }
    // #199137: do not try to adjust label, etc. according to actual projects
    // 1. such computation cannot be done in EQ without sometimes blocking
    // 2. even if done asynch, looks bad to update label after popup is posted
}
 
Example #5
Source File: JavaTemplateAttributesProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: Util.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Adds source to source map (I18N wizard settings). If there is already no change is done.
 * If it's added anew then it is tried to find correspondin reousrce, i.e.
 * first resource from the same folder.
 * @param sourceMap settings where to add teh sources
 * @param source source to add */
public static void addSource(Map<DataObject,SourceData> sourceMap,
                             DataObject source) {
    if (sourceMap.containsKey(source)) {
        return;
    }
    
    DataFolder folder = source.getFolder();
    
    if (folder == null) {
        sourceMap.put(source, null);
        return;
    }

    // try to associate Bundle file

    for (DataObject child : folder.getChildren()) {
        if (child instanceof PropertiesDataObject) { // PENDING 
            sourceMap.put(source, new SourceData(child));
            return;
        }
    }
    
    // No resource found in the same folder.
    sourceMap.put(source, null);
}
 
Example #7
Source File: DocumentTitlePropertyTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Test updating document property Document.TitleProperty when dataobject is moved */
public void testMove () throws IOException {
    FileUtil.createData(FileUtil.getConfigRoot(), "someFolder/someFile.obj");
    FileUtil.createFolder(FileUtil.getConfigRoot(), "newFolder");

    DataObject obj = DataObject.find(FileUtil.getConfigFile("someFolder/someFile.obj"));
    DataFolder dFolder = (DataFolder) DataObject.find(FileUtil.getConfigFile("newFolder"));

    assertEquals( MyDataObject.class, obj.getClass());
    assertTrue( "we need UniFileLoader", obj.getLoader() instanceof UniFileLoader );

    EditorCookie ec = obj.getCookie(EditorCookie.class);

    StyledDocument doc = ec.openDocument();

    String val = (String) doc.getProperty(Document.TitleProperty);
    assertTrue("Test property value", val.startsWith("someFolder/someFile.obj"));

    obj.move(dFolder);

    val = (String) doc.getProperty(Document.TitleProperty);
    assertTrue("Test property value", val.startsWith("newFolder/someFile.obj"));
}
 
Example #8
Source File: NewTestSuiteWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Set<DataObject> instantiate() throws IOException {
    FileObject targetFolder = Templates.getTargetFolder(wiz);
    TestNGSupport.findTestNGSupport(FileOwnerQuery.getOwner(targetFolder)).configureProject(targetFolder);
    String targetName = Templates.getTargetName(wiz);

    DataFolder df = DataFolder.findFolder(targetFolder);
    FileObject template = Templates.getTemplate(wiz);

    DataObject dTemplate = DataObject.find(template);
    String pkgName = getSelectedPackageName(targetFolder);
    String suiteName = pkgName + " suite";
    String projectName = ProjectUtils.getInformation(FileOwnerQuery.getOwner(targetFolder)).getName();
    if (pkgName == null || pkgName.trim().length() < 1) {
        pkgName = ".*"; //NOI18N
        suiteName = "All tests for " + projectName;
    }
    
    Map<String, String> props = new HashMap<String, String>();
    props.put("suiteName", projectName);
    props.put("testName", suiteName);
    props.put("pkg", pkgName);

    DataObject dobj = dTemplate.createFromTemplate(df, targetName, props);

    return Collections.singleton(dobj);
}
 
Example #9
Source File: JavaDataLoaderTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void recognize(int count) throws IOException {
    clearWorkDir();
    FileUtil.refreshAll();

    File wd = getWorkDir();

    while (count-- > 0) {
        new FileOutputStream(new File(wd, "f" + count + ".java")).close();
        new FileOutputStream(new File(wd, "f" + count + ".bbb")).close();
    }

    long s = System.currentTimeMillis();
    FileUtil.refreshAll();

    FileObject f = FileUtil.toFileObject(wd);
    DataFolder df = DataFolder.findFolder(f);

    System.err.println("preparation took: " + (System.currentTimeMillis() - s));
    System.err.println(df.getChildren().length);
    System.err.println("recognition took:" + (System.currentTimeMillis() - s));
}
 
Example #10
Source File: TemplatesPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static private DataFolder getTargetFolder (Node [] nodes) {
    DataFolder folder;
    if (nodes == null || nodes.length == 0) {
        folder = DataFolder.findFolder (getTemplatesRoot ());
    } else {
        // try if has a data folder (alert: leaf node can be a empty folder)
        folder = nodes[0].getLookup ().lookup (DataFolder.class);
        
        // if not this node then try its parent
        if (folder == null && nodes [0].isLeaf ()) {
            Node parent = nodes [0].getParentNode ();
            folder = parent.getLookup ().lookup (DataFolder.class);
        }
    }
    return folder;
}
 
Example #11
Source File: CreateNewNonIndexedProperty.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** setUp method  */
public void setUp() {
    System.out.println("########  "+getName()+"  #######");
    
    OptionsOperator optionsOperator = OptionsOperator.invoke();
    optionsOperator.selectOption(Bundle.getString("org.netbeans.core.Bundle", "UI/Services/Editing")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "PROP_Option_Menu"));
    PropertySheetOperator propertySheetTabOperator = new PropertySheetOperator(optionsOperator);
    new Property(propertySheetTabOperator, Bundle.getString("org.netbeans.modules.beans.Bundle", "PROP_Option_Prop_Style")).setValue(Bundle.getString("org.netbeans.modules.beans.Bundle", "MSG_Option_Gen_This"));

    FileObject testFile = Repository.getDefault().findResource("gui/data/" + NAME_TEST_FILE + ".java");
    FileObject destination = Repository.getDefault().findFileSystem(sampleDir.replace('\\', '/')).getRoot();
    optionsOperator.close();
    try {
        DataObject.find(testFile).copy(DataFolder.findFolder(destination));
    } catch (IOException e) {
        fail(e);
    }
    new PropertiesAction().perform();
}
 
Example #12
Source File: DefaultCreationNoTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Checks that a file without CreateFromTemplate handler creates OK as copy of the template
 * @throws Exception 
 */
public void testCreateNoHandler() throws Exception {
    FileObject root = FileUtil.createMemoryFileSystem().getRoot();
    FileObject templ = FileUtil.createData(root, "simpleTemplate.txt");
    String txt = "{a}";
    OutputStream os = templ.getOutputStream();
    os.write(txt.getBytes());
    os.close();
    
    DataObject obj = DataObject.find(templ);
    DataFolder folder = DataFolder.findFolder(FileUtil.createFolder(root, "target"));
    Map m = new HashMap();
    m.put("a", "eeee");
    DataObject x = obj.createFromTemplate(folder, "nue", m);
    
    assertEquals(txt + "\n", x.getPrimaryFile().asText());
}
 
Example #13
Source File: PropertiesDataObject.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Copies primary and secondary files to new folder.
     * Overrides superclass method.
     * @param df the new folder
     * @return data object for the new primary
     * @throws IOException if there was a problem copying
     * @throws UserCancelException if the user cancelled the copy */
    @Override
    protected synchronized DataObject handleCopy(DataFolder df) throws IOException {
        if (LOG.isLoggable(FINER)) {
            LOG.finer("handleCopy("                                     //NOI18N
                    + FileUtil.getFileDisplayName(df.getPrimaryFile()) + ')');
        }
        try {
//            pasteSuffix = createPasteSuffix(df);

            return super.handleCopy(df);
        } finally {
            pasteSuffix = null;
            bundleStructure = null;
        }
    }
 
Example #14
Source File: TargetEvaluator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Used by the ObjectNameWizard panel to set the target folder
 * gotten from the system wizard initially. 
 */
void setInitialFolder(DataFolder selectedFolder, Project p) {
    if (selectedFolder == null) {
        return;
    }
    FileObject targetFolder = selectedFolder.getPrimaryFile();
    Sources sources = ProjectUtils.getSources(p);
    SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    String packageName = null;
    for (int i = 0; i < groups.length && packageName == null; i++) {
        packageName = org.openide.filesystems.FileUtil.getRelativePath(groups[i].getRootFolder(), targetFolder);
        deployData.setWebApp(DeployData.getWebAppFor(groups[i].getRootFolder()));
    }
    if (packageName == null) {
        packageName = "";
    }
    setInitialPath(packageName);
}
 
Example #15
Source File: ActionPasteType.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
*  
*/ 
   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;
   }
 
Example #16
Source File: DTDWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * This is where, the schema gets instantiated from the template.
 */
public Set instantiate (TemplateWizard wizard) throws IOException {        
    FileObject dir = Templates.getTargetFolder( wizard );        
    DataFolder df = DataFolder.findFolder( dir );
    FileObject template = Templates.getTemplate( wizard );        
    DataObject dTemplate = DataObject.find( template );                
    DataObject dobj = dTemplate.createFromTemplate(df, Templates.getTargetName(wizard));
    if (dobj == null)
        return Collections.emptySet();
        
    encoding = EncodingUtil.getProjectEncoding(df.getPrimaryFile());
    if(!EncodingUtil.isValidEncoding(encoding))
        encoding = "UTF-8"; //NOI18N
    EditCookie edit = dobj.getCookie(EditCookie.class);
    if (edit != null) {
        EditorCookie editorCookie = dobj.getCookie(EditorCookie.class);
        Document doc = (Document)editorCookie.openDocument();
        fixEncoding(doc, encoding);
        SaveCookie save = dobj.getCookie(SaveCookie.class);
        if (save!=null) save.save();
    }
    
    return Collections.singleton(dobj.getPrimaryFile());
}
 
Example #17
Source File: NewFileWizardIterator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Set<FileObject> instantiate() throws IOException {
    FileObject dir = Templates.getTargetFolder(wizard);
    FileObject template = Templates.getTemplate(wizard);

    DataFolder dataFolder = DataFolder.findFolder(dir);
    DataObject dataTemplate = DataObject.find(template);
    DataObject createdFile = dataTemplate.createFromTemplate(dataFolder, Templates.getTargetName(wizard), getTemplateParams());

    // #187374
    try {
        FileUtils.reformatFile(createdFile);
    } catch (IOException exc) {
        LOGGER.log(Level.WARNING, exc.getMessage(), exc);
    }

    return Collections.singleton(createdFile.getPrimaryFile());
}
 
Example #18
Source File: DnDSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void reorderButtons( DataObject objToMove, DataObject objUnderCursor ) throws IOException {
    DataFolder backingFolder = getBackingFolder(currentToolbar);
    List<DataObject> children = new ArrayList<DataObject>( Arrays.asList( backingFolder.getChildren() ) );
    if( null == objUnderCursor ) {
        children.remove( objToMove );
        children.add( objToMove );
    } else {
        int targetIndex = children.indexOf( objUnderCursor );
        int currentIndex = children.indexOf( objToMove );
        if( currentIndex < targetIndex )
            targetIndex--;
        targetIndex = Math.max( 0, targetIndex );
        targetIndex = Math.min( children.size(), targetIndex );
        children.remove( objToMove );
        children.add( targetIndex, objToMove );
    }

    backingFolder.setOrder( children.toArray( new DataObject[children.size()]) );
}
 
Example #19
Source File: DefaultPlugin.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new test class.
 * 
 * @param  targetRoot     <!-- //PENDING -->
 * @param  testClassName  <!-- //PENDING -->
 * @param  testCreator  {@code TestCreator} to be used for filling
 *                      the test class template
 * @param  templateDataObj  {@code DataObject} representing
 *                          the test file template
 * @return  the created test, or {@code null} if no test was created
 */
private DataObject createEmptyTest(FileObject targetRoot,
                                   String testClassName,
                                   TestCreator testCreator,
                                   final Map<String, ? extends Object> templateParams,
                                   DataObject templateDataObj) {
    if (testClassName == null) {
        throw new IllegalArgumentException("testClassName = null"); //NOI18N
    }
    
    DataObject testDataObj = null;
    try {
        DataFolder targetFolderDataObj = DataFolder.findFolder(targetRoot);
        testDataObj = templateDataObj.createFromTemplate(
                                    targetFolderDataObj,
                                    testClassName,
                                    templateParams);

        /* fill in setup etc. according to dialog settings */
        testCreator.createEmptyTest(testDataObj.getPrimaryFile());
    } catch (IOException ex) {
        ErrorManager.getDefault().notify(ex);
    }
    return testDataObj;
}
 
Example #20
Source File: InstanceDataObjectInXMLTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testInstanceDataObjectCreate() throws Exception {
    final FileObject fo = FileUtil.createMemoryFileSystem().getRoot();
    final DataFolder folder = DataFolder.findFolder(fo);
    final ArrayList<Object> obj = new ArrayList<Object>();
    InstanceDataObject dataObj = InstanceDataObject.create(folder, null, obj, null);
    assertSame("Instance is preserved", dataObj.instanceCreate(), obj);
}
 
Example #21
Source File: CurrentJavaProjectScopeProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean initialize(Lookup context, AtomicBoolean cancel) {
    FileObject file = context.lookup(FileObject.class);
    Project selected = null;
    if (file != null) {
        selected = FileOwnerQuery.getOwner(file);
    }
    if (selected == null) {
        selected = context.lookup(Project.class);
        if (selected == null) {
            SourceGroup sg = context.lookup(SourceGroup.class);
            if (sg != null) {
                selected = FileOwnerQuery.getOwner(sg.getRootFolder());
            }
        }
        if (selected == null) {
            DataFolder df = context.lookup(DataFolder.class);
            if (df != null) {
                selected = FileOwnerQuery.getOwner(df.getPrimaryFile());
            }
        }
    }
    if (selected == null || !OpenProjects.getDefault().isProjectOpen(selected)) {
        return false;
    }

    ProjectInformation pi = ProjectUtils.getInformation(selected);
    final SourceGroup[] sourceGroups = ProjectUtils.getSources(pi.getProject()).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    FileObject[] projectSources = new FileObject[sourceGroups.length];
    for (int i = 0; i < sourceGroups.length; i++) {
        projectSources[i] = sourceGroups[i].getRootFolder();
    }
    scope = Scope.create(Arrays.asList(projectSources), null, null);

    detail = pi.getDisplayName();
    icon = pi.getIcon();
    return true;
}
 
Example #22
Source File: ExpandFolderTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testGetNodesForAFolderExtjava() throws Exception {
    CountingSecurityManager.initialize(getWorkDirPath());
    long now = System.currentTimeMillis();
    DataFolder f = DataFolder.findFolder(root);
    Node n = f.getNodeDelegate();
    Node[] arr = n.getChildren().getNodes(true);
    
    assertEquals("1000 nodes", 1000, arr.length);
    
    CountingSecurityManager.assertCounts("About 1000 * 4?", 4000, len);
}
 
Example #23
Source File: DefaultFileObjectFromTemplateCreator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public FileObject create(FileObject template, FileObject folder, String name) throws IOException {
    DataObject templateDobj = DataObject.find(template);
    if (templateDobj == null || !templateDobj.isTemplate()) {
        return FileUtil.createData(folder, name);
    }
    DataFolder target = DataFolder.findFolder(folder);
    String simpleName = FileObjects.stripExtension(name);
    DataObject newDobj = templateDobj.createFromTemplate(target, simpleName);
    return newDobj.getPrimaryFile();
}
 
Example #24
Source File: MenuBar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a new <code>MenuBar</code> from given folder.
 * @param folder The folder from which to create the content of the menubar.
 * If the parameter is null, default menu folder is obtained.
 */
public MenuBar(DataFolder folder) {
    this();
    DataFolder theFolder = folder;
    if (theFolder == null) {
        FileObject root = FileUtil.getConfigRoot();
        FileObject fo = null;
        try {
            fo = FileUtil.createFolder(root, "Menu"); // NOI18N
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
        if (fo == null) throw new IllegalStateException("No Menu/"); // NOI18N
        theFolder = DataFolder.findFolder(fo);
    }
    startLoading(theFolder);
    if (!EventQueue.isDispatchThread()) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                updateUI();
            }
        });
    }

    if(folder != null) {
        getAccessibleContext().setAccessibleDescription(folder.getName());
    }
}
 
Example #25
Source File: SelectFolderPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void visit(List<DataFolder> folders, DataFolder f) {
    folders.add(f);
    DataObject[] kids = f.getChildren();
    for (int i = 0; i < kids.length; i++) {
        if (kids[i] instanceof DataFolder) {
            visit(folders, (DataFolder)kids[i]);
        }
    }
}
 
Example #26
Source File: AnnotationTypeActionsFolder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates new AnnotationTypesFolder */
private AnnotationTypeActionsFolder(AnnotationType type, DataFolder fld) {
    super(fld);
    this.type = type;
    recreate();
    instanceFinished();
}
 
Example #27
Source File: OthersRootNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages({"LBL_Other_Test_Sources=Other Test Sources", "LBL_Other_Sources=Other Sources"})
OthersRootNode(NbMavenProjectImpl mavproject, boolean testResource, FileObject fo) {
    super(new OthersRootChildren(mavproject, testResource), Lookups.fixed(fo, DataFolder.findFolder(fo), new ChildDelegateFind()));
    setName(testResource ? "OtherTestRoots" : "OtherRoots"); //NOI18N
    setDisplayName(testResource ? LBL_Other_Test_Sources() : LBL_Other_Sources());
    file = fo;
}
 
Example #28
Source File: ToolbarPool.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
       * 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();
      }
 
Example #29
Source File: NewFileWizardIterator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Set<FileObject> instantiate() throws IOException {
    getBottomPanel().save();

    FileObject dir = Templates.getTargetFolder(wizard);
    FileObject template = Templates.getTemplate(wizard);

    DataFolder dataFolder = DataFolder.findFolder(dir);
    DataObject dataTemplate = DataObject.find(template);
    DataObject createdFile = dataTemplate.createFromTemplate(dataFolder, Templates.getTargetName(wizard));
    return Collections.singleton(createdFile.getPrimaryFile());
}
 
Example #30
Source File: SelectFolderPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Create the wizard panel component and set up some basic properties. */
public SelectFolderPanel(SelectFolderWizardPanel wiz, String name, 
        String hint, String displayNameLabelText, DataFolder top, 
        boolean stripAmps, String prop) {
    this.wiz = wiz;
    initComponents ();
    // Provide a name in the title bar.
    setName (name);
    hintsArea.setText (hint);
    initAccessibility (hint);                
    //displayNameLabel.setText(displayNameLabelText);
    displayNameLabel.getAccessibleContext().setAccessibleDescription( 
            displayNameLabelText );
    Mnemonics.setLocalizedText(displayNameLabel,displayNameLabelText);
    displayNameField.getAccessibleContext().setAccessibleName(displayNameLabelText);
    displayNameField.getAccessibleContext().setAccessibleDescription(displayNameLabelText);
    
    this.prop = prop;
    this.top = top;
    this.stripAmps = stripAmps;
    DefaultListModel model = new DefaultListModel();
    DataObject[] folders = findFolders(top);
    for (int i = 0; i < folders.length; i++) {
        model.addElement(folders[i]);
    }
    folderList.setModel(model);
    folderList.setCellRenderer(new CellRenderer());
    displayNameField.getDocument().addDocumentListener(this);
}