Java Code Examples for org.openide.filesystems.FileObject#getName()
The following examples show how to use
org.openide.filesystems.FileObject#getName() .
These examples are extracted from open source projects.
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 Project: netbeans File: AntProjectUtil.java License: Apache License 2.0 | 6 votes |
public static void backupBuildImplFile(UpdateHelper updateHelper) throws IOException { final FileObject projectDir = updateHelper.getAntProjectHelper().getProjectDirectory(); final FileObject buildImpl = projectDir.getFileObject(GeneratedFilesHelper.BUILD_IMPL_XML_PATH); if (buildImpl != null) { final String name = buildImpl.getName(); final String backupext = String.format("%s~", buildImpl.getExt()); final FileObject oldBackup = buildImpl.getParent().getFileObject(name, backupext); if (oldBackup != null) { oldBackup.delete(); } FileLock lock = buildImpl.lock(); try { buildImpl.rename(lock, name, backupext); } finally { lock.releaseLock(); } } }
Example 2
Source Project: netbeans File: LicenseHeadersPanel.java License: Apache License 2.0 | 6 votes |
private void loadGlobalLicenses() { FileObject root = FileUtil.getConfigFile("Templates/Licenses"); DefaultComboBoxModel<GlobalItem> model = new DefaultComboBoxModel<>(); for (FileObject fo : root.getChildren()) { if (fo.getAttribute("template") == null) { continue; } String displayName = (String) fo.getAttribute("displayName"); if (displayName == null) { displayName = fo.getName(); if (displayName.startsWith("license-")) { displayName = displayName.substring("license-".length()); } } model.addElement(new GlobalItem(displayName, fo)); } comGlobal.setModel(model); }
Example 3
Source Project: netbeans File: IntentHandler.java License: Apache License 2.0 | 6 votes |
public static IntentHandler create(FileObject fo) { String n = fo.getName(); int lastDash = n.lastIndexOf('-'); if (lastDash <= 0 || lastDash + 1 >= n.length()) { throw new IllegalArgumentException("Invalid handler file"); //NOI18N } String className = n.substring(0, lastDash).replace('-', '.'); String methodName = n.substring(lastDash + 1); String displayName = (String) fo.getAttribute("displayName"); //NOI18N String icon = (String) fo.getAttribute("icon"); //NOI18N int position = (Integer) fo.getAttribute("position"); //NOI18N Type type = Type.valueOf((String) fo.getAttribute("type")); //NOI18N return new IntentHandler(className, methodName, displayName, icon, type, position); }
Example 4
Source Project: netbeans File: PropertiesDataNode.java License: Apache License 2.0 | 5 votes |
private static boolean containsLocale(PropertiesDataObject propertiesDataObject, Locale locale) { FileObject file = propertiesDataObject.getBundleStructure().getNthEntry(0).getFile(); // FileObject file = propertiesDataObject.getPrimaryFile(); String newName = file.getName() + PropertiesDataLoader.PRB_SEPARATOR_CHAR + locale; BundleStructure structure = propertiesDataObject.getBundleStructure(); for (int i = 0; i<structure.getEntryCount();i++) { FileObject f = structure.getNthEntry(i).getFile(); if (newName.startsWith(f.getName()) && f.getName().length() > file.getName().length()) file = f; } return file.getName().equals(newName); }
Example 5
Source Project: netbeans File: CssCompletionTest.java License: Apache License 2.0 | 5 votes |
public SuiteCreator() { super(); FileObjectFilter filter = new FileObjectFilter() { public boolean accept(FileObject fo) { String ext = fo.getExt(); String name = fo.getName(); return (name.startsWith("test") || name.startsWith("Test")) && (ext.equals("css")); } }; addTest(RecurrentSuiteFactory.createSuite(CssCompletionTest.class, new CssCompletionTest().getProjectsDir(), filter)); }
Example 6
Source Project: cakephp3-netbeans File: FilePathParameter.java License: Apache License 2.0 | 5 votes |
private List<String> getCategoryElements(CakePHP3Module cakeModule, ModuleInfo info, String subpath, String filter, String pluginName, Category category) { Base base = info.getBase(); if (StringUtils.isEmpty(pluginName)) { if (base == Base.PLUGIN) { pluginName = info.getPluginName(); } } else { if (base != Base.PLUGIN) { base = Base.PLUGIN; } } // app or plugin List<FileObject> directories = cakeModule.getDirectories(base, category, pluginName); List<FileObject> coreDirectories; if (!StringUtils.isEmpty(pluginName)) { coreDirectories = Collections.emptyList(); } else { coreDirectories = cakeModule.getDirectories(Base.CORE, category, null); } List<String> elements = new ArrayList<>(); for (List<FileObject> targets : Arrays.asList(directories, coreDirectories)) { for (FileObject directory : targets) { FileObject baseDirectory = directory.getFileObject(subpath); if (baseDirectory != null) { for (FileObject child : baseDirectory.getChildren()) { if (child.isFolder()) { continue; } String name = child.getName(); name = ModuleUtils.toCommonName(name, category); if (!elements.contains(name) && name.toLowerCase().startsWith(filter.toLowerCase())) { elements.add(name); } } } } } return elements; }
Example 7
Source Project: netbeans File: ConfigureFXMLControllerPanelVisual.java License: Apache License 2.0 | 5 votes |
public void initValues(FileObject template, FileObject preselectedFolder) { if (template == null) { throw new IllegalArgumentException( NbBundle.getMessage(ConfigureFXMLControllerPanelVisual.class, "MSG_ConfigureFXMLPanel_Template_Error")); // NOI18N } String displayName; try { DataObject templateDo = DataObject.find(template); displayName = templateDo.getNodeDelegate().getDisplayName(); } catch (DataObjectNotFoundException ex) { displayName = template.getName(); } putClientProperty("NewFileWizard_Title", displayName); // NOI18N createdLocationComboBox.setModel(new DefaultComboBoxModel(support.getSourceGroups().toArray())); SourceGroupSupport.SourceGroupProxy preselectedGroup = isMaven ? SourceGroupSupport.getContainingSourceGroup(support, preselectedFolder) : support.getParent().getCurrentSourceGroup(); ignoreRootCombo = true; createdLocationComboBox.setSelectedItem(preselectedGroup); ignoreRootCombo = false; if(isMaven) { Object preselectedPackage = FXMLTemplateWizardIterator.getPreselectedPackage(preselectedGroup, preselectedFolder); if (preselectedPackage != null) { createdPackageComboBox.getEditor().setItem(preselectedPackage); } } else { createdPackageComboBox.getEditor().setItem(support.getParent().getCurrentPackageName()); } updatePackages(); updateText(); updateResult(); }
Example 8
Source Project: netbeans File: RADComponent.java License: Apache License 2.0 | 5 votes |
Object createDefaultDeserializedInstance() throws Exception { FileObject formFile = FormEditor.getFormDataObject(getFormModel()).getFormFile(); String serFile = (String)getAuxValue(JavaCodeGenerator.AUX_SERIALIZE_TO); if (serFile == null) { serFile = formFile.getName() + "_" + getName(); // NOI18N } ClassPath sourcePath = ClassPath.getClassPath(formFile, ClassPath.SOURCE); String serName = sourcePath.getResourceName(formFile.getParent()); if (!"".equals(serName)) { // NOI18N serName += "."; // NOI18N } serName += serFile; Object instance = null; try { instance = Beans.instantiate(sourcePath.getClassLoader(true), serName); } catch (ClassNotFoundException cnfe) { org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, cnfe); ClassPath executionPath = ClassPath.getClassPath(formFile, ClassPath.EXECUTE); try { instance = Beans.instantiate(executionPath.getClassLoader(true), serName); } catch (ClassNotFoundException cnfex) { org.openide.ErrorManager.getDefault().notify(org.openide.ErrorManager.INFORMATIONAL, cnfex); instance = createBeanInstance(); } } return instance; }
Example 9
Source Project: netbeans File: WindowManagerParser.java License: Apache License 2.0 | 5 votes |
/** * Loads Mode configuration from the given file. * @param fo * @return * @throws IOException * @since 2.70 */ public static ModeConfig loadModeConfigFrom( FileObject fo ) throws IOException { String modeName = fo.getName(); ModeParser parser = ModeParser.parseFromFileObject(modeName, new HashSet(1)); parser.setInLocalFolder(true); parser.setLocalParentFolder(fo.getParent()); return parser.load(); }
Example 10
Source Project: netbeans File: DataObjectSaveAsTest.java License: Apache License 2.0 | 5 votes |
public void testSaveAsOverwriteExisting() throws IOException { FileObject fo = obj2.getPrimaryFile(); String newName = fo.getName(); String newExt = fo.getExt(); DataFolder folder = DataFolder.findFolder( fo.getParent() ); try { obj1.copyRename( folder, newName, newExt ); fail( "default implementation of copyRename cannot overwrite existing files" ); } catch( IOException e ) { //this is what we want } sfs.assertEvent(obj1, 0, null); }
Example 11
Source Project: netbeans File: ModelBuilder.java License: Apache License 2.0 | 5 votes |
String getUnigueNameForAnonymObject(ParserResult parserResult) { FileObject fo = parserResult.getSnapshot().getSource().getFileObject(); if (fo != null) { return fo.getName() + ANONYMOUS_OBJECT_NAME_START + anonymObjectCount++; } return ANONYMOUS_OBJECT_NAME_START + anonymObjectCount++; }
Example 12
Source Project: netbeans File: GenerateDTDSupport.java License: Apache License 2.0 | 5 votes |
/** * Performs a dialog with a user and generates the DTD */ public void generate() { try { //save the XML document before DTD generation SaveCookie save = (SaveCookie)template.getCookie(SaveCookie.class); if (save!=null) save.save(); FileObject primFile = template.getPrimaryFile(); String name = primFile.getName(); FileObject folder = primFile.getParent(); //use same name as the XML for default DTD name FileObject generFile = (new SelectFileDialog(folder, name, DTD_EXT, Util.NONEMPTY_CHECK)).getFileObject(); //new name as per user name = generFile.getName(); // get project's encoding String encoding = EncodingUtil.getProjectEncoding(primFile); //generate DTD content generateDTDContent(encoding, name, generFile); GuiUtil.performDefaultAction(generFile); } catch (UserCancelException e) { } catch (Exception exc) { GuiUtil.notifyException(exc); } }
Example 13
Source Project: netbeans File: JFXRunPanel.java License: Apache License 2.0 | 5 votes |
private void fillWebBrowsersCombo(List<String> list, String select) { // PENDING need to get rid of this filtering FileObject fo = FileUtil.getConfigFile (BROWSERS_FOLDER); if (fo != null) { DataFolder folder = DataFolder.findFolder (fo); DataObject [] dobjs = folder.getChildren (); for (int i = 0; i<dobjs.length; i++) { // Must not be hidden and have to provide instances (we assume instance is HtmlBrowser.Factory) if (Boolean.TRUE.equals(dobjs[i].getPrimaryFile().getAttribute(EA_HIDDEN)) || dobjs[i].getLookup().lookup(InstanceCookie.class) == null) { FileObject fo2 = dobjs[i].getPrimaryFile(); String n = fo2.getName(); try { n = fo2.getFileSystem().getDecorator().annotateName(n, dobjs[i].files()); } catch (FileStateInvalidException e) { // Never mind. } list.remove(n); } } } comboBoxWebBrowser.removeAllItems (); if (!list.isEmpty()) { for (String tag : list) { comboBoxWebBrowser.addItem(tag); } if(select != null) { comboBoxWebBrowser.setSelectedItem(select); } labelWebBrowser.setEnabled(true); comboBoxWebBrowser.setEnabled(true); jSeparator2.setEnabled(true); } else { labelWebBrowser.setEnabled(false); comboBoxWebBrowser.setEnabled(false); jSeparator2.setEnabled(false); } }
Example 14
Source Project: netbeans File: GlassfishConfiguration.java License: Apache License 2.0 | 5 votes |
protected void createDefaultSunDD(File sunDDFile) throws IOException { FileObject sunDDTemplate = Utils.getSunDDFromProjectsModuleVersion(module, sunDDFile.getName()); //FileUtil.getConfigFile(resource); if (sunDDTemplate != null) { FileObject configFolder = FileUtil.createFolder(sunDDFile.getParentFile()); FileSystem fs = configFolder.getFileSystem(); XmlFileCreator creator = new XmlFileCreator(sunDDTemplate, configFolder, sunDDTemplate.getName(), sunDDTemplate.getExt()); fs.runAtomicAction(creator); } }
Example 15
Source Project: netbeans File: Saas.java License: Apache License 2.0 | 5 votes |
public FileObject getSaasFile() throws IOException { if (saasFile == null) { FileObject folder = getSaasFolder(); String filename = folder.getName() + "-saas.xml"; //NOI18N saasFile = folder.getFileObject(filename); if (saasFile == null) { saasFile = getSaasFolder().createData(filename); } } return saasFile; }
Example 16
Source Project: netbeans File: EAWizardIterator.java License: Apache License 2.0 | 5 votes |
private void generateApplicationXML(Set<FileObject> projects) throws IOException { Set<Project> childProjects = new HashSet<>(); Project earProject = null; for (FileObject projectFile : projects) { Project project = ProjectManager.getDefault().findProject(projectFile); if (project == null) { continue; } // Collecting child subprojects to be able to correctly generate contain of application.xml String projectDirName = projectFile.getName(); if (projectDirName.endsWith("-web") || projectDirName.endsWith("-ejb")) { childProjects.add(project); } if (projectDirName.endsWith("-ear")) { earProject = project; } } if (earProject == null) { return; // This should not happen, just to be sure for HR 7.3.1 } J2eeModuleProvider moduleProvider = earProject.getLookup().lookup(J2eeModuleProvider.class); if (moduleProvider != null && moduleProvider.getConfigSupport().isDescriptorRequired()) { EarDDGenerator.setupDD(earProject, true); } }
Example 17
Source Project: netbeans File: FastDeploy.java License: Apache License 2.0 | 5 votes |
private void addDescriptorToDeployedDirectory(J2eeModule module, File sunDDFile) { FileObject sunDDTemplate = Utils.getSunDDFromProjectsModuleVersion(module, sunDDFile.getName()); //FileUtil.getConfigFile(resource); if (sunDDTemplate != null) { try { FileObject configFolder = FileUtil.createFolder(sunDDFile.getParentFile()); FileSystem fs = configFolder.getFileSystem(); XmlFileCreator creator = new XmlFileCreator(sunDDTemplate, configFolder, sunDDTemplate.getName(), sunDDTemplate.getExt()); fs.runAtomicAction(creator); } catch (IOException ioe) { Logger.getLogger("glassfish").log(Level.WARNING, "could not create {0}", sunDDTemplate.getPath()); } } }
Example 18
Source Project: netbeans File: Xsd2Java.java License: Apache License 2.0 | 4 votes |
private static String deriveJaxbSourceJarPath(FileObject file) { return file.getName() + "-src.jar"; //NOI18N }
Example 19
Source Project: netbeans File: PHPRenameFileRefactoringUI.java License: Apache License 2.0 | 4 votes |
public PHPRenameFileRefactoringUI(FileObject file) { this.file = file; this.newName = file.getName(); this.refactoring = new RenameRefactoring(Lookups.fixed(file)); }
Example 20
Source Project: netbeans File: GrailsSources.java License: Apache License 2.0 | 4 votes |
public SourceGroup[] getSourceGroups(String type) { List<Group> result = new ArrayList<Group>(); if (Sources.TYPE_GENERIC.equals(type)) { addGroup(projectDir, projectDir.getName(), result); } else if (JavaProjectConstants.SOURCES_TYPE_JAVA.equals(type)) { addGroup(SourceCategoryType.SRC_JAVA, "LBL_SrcJava", result); } else if (GroovySources.SOURCES_TYPE_GROOVY.equals(type)) { addGroup(SourceCategoryType.GRAILSAPP_CONF, "LBL_grails-app_conf", result); addGroup(SourceCategoryType.GRAILSAPP_CONTROLLERS, "LBL_grails-app_controllers", result); addGroup(SourceCategoryType.GRAILSAPP_DOMAIN, "LBL_grails-app_domain", result); addGroup(SourceCategoryType.GRAILSAPP_SERVICES, "LBL_grails-app_services", result); addGroup(SourceCategoryType.GRAILSAPP_TAGLIB, "LBL_grails-app_taglib", result); addGroup(SourceCategoryType.GRAILSAPP_UTILS, "LBL_grails-app_utils", result); addGroup(SourceCategoryType.SCRIPTS, "LBL_scripts", result); addGroup(SourceCategoryType.SRC_GROOVY, "LBL_SrcGroovy", result); addGroup(SourceCategoryType.TEST_INTEGRATION, "LBL_IntegrationTests", result); addGroup(SourceCategoryType.TEST_UNIT, "LBL_UnitTests", result); } else if (GroovySources.SOURCES_TYPE_GRAILS.equals(type)) { addGroup(SourceCategoryType.LIB, "LBL_lib", result); addGroup(SourceCategoryType.GRAILSAPP_I18N, "LBL_grails-app_i18n", result); addGroup(SourceCategoryType.WEBAPP, "LBL_web-app", result); addGroup(SourceCategoryType.GRAILSAPP_VIEWS, "LBL_grails-app_views", result); addGroup(SourceCategoryType.TEMPLATES, "LBL_grails-templates", result); } else if (GroovySources.SOURCES_TYPE_GRAILS_UNKNOWN.equals(type)) { // plugins may reside in project dir File pluginsDirFile = project.getBuildConfig().getProjectPluginsDir(); FileObject pluginsDir = pluginsDirFile == null ? null : FileUtil.toFileObject( FileUtil.normalizeFile(pluginsDirFile)); File globalPluginsDirFile = project.getBuildConfig().getGlobalPluginsDir(); FileObject globalPluginsDir = globalPluginsDirFile == null ? null : FileUtil.toFileObject( FileUtil.normalizeFile(globalPluginsDirFile)); for (FileObject child : projectDir.getChildren()) { if (child.isFolder() && VisibilityQuery.getDefault().isVisible(child) && !KNOWN_FOLDERS.contains(child.getName()) && !IGNORED_FOLDERS_IN_GRAILS_APP.contains(child.getName()) && child != pluginsDir && child != globalPluginsDir) { String name = child.getName(); addGroup(child, Character.toUpperCase(name.charAt(0)) + name.substring(1), result); } } addGroup(SourceCategoryType.SRC_GWT, "LBL_SrcGwt", result); addUnknownGroups(KNOWN_FOLDERS_IN_GRAILS_APP, result, "grails-app", null); addUnknownGroups(KNOWN_OR_IGNORED_FOLDERS_IN_TEST, result, "test", "LBL_SomeTests"); } return result.toArray(new SourceGroup[result.size()]); }