public static boolean isJar(File file){ return file.isFile() && "jar".equals(new Path(file.getAbsolutePath()).getFileExtension()); }
private static ExecutablesDescriptor createUnixDescriptor(String os, String executable, File location) { ExecutablesDescriptor result = new ExecutablesDescriptor(os, executable, location, null); File[] files = location.listFiles(); for (int i = 0; files != null && i < files.length; i++) { String extension = new Path(files[i].getName()).getFileExtension(); if (files[i].isFile() && (extension == null || extension.equals("so"))) //$NON-NLS-1$ result.addFile(files[i]); } result.iniFile = new File(location, executable + ".ini"); //$NON-NLS-1$ return result; }
private static ExecutablesDescriptor createUnixDescriptor(String os, String executable, File location) { ExecutablesDescriptor result = new ExecutablesDescriptor(os, executable, location, null); File[] files = location.listFiles(); for (int i = 0; files != null && i < files.length; i++) { String extension = new Path(files[i].getName()).getFileExtension(); if (files[i].isFile() && (extension == null || extension.equals("so"))) //$NON-NLS-1$ result.addFile(files[i]); } result.iniFile = new File(location, executable + ".ini"); //$NON-NLS-1$ return result; }
private static ExecutablesDescriptor createUnixDescriptor(String os, String executable, File location) { ExecutablesDescriptor result = new ExecutablesDescriptor(os, executable, location, null); File[] files = location.listFiles(); for (int i = 0; files != null && i < files.length; i++) { String extension = new Path(files[i].getName()).getFileExtension(); if (files[i].isFile() && (extension == null || extension.equals("so"))) //$NON-NLS-1$ result.addFile(files[i]); } result.iniFile = new File(location, executable + ".ini"); //$NON-NLS-1$ return result; }
public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) { Map<Locale, Map<String, String>> localizations; Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; if (hostBundleLocalization == null) return null; if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$ bundleLocation.isFile()) { localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); } else { localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); } return localizations; }
/** * Returns a URL describing a file inside a bundle. * * @param bundleLocation root location of the bundle. May be a directory or * a file (jar) * @param filePath bundle relative path to desired file * @return URL to the file * @throws MalformedURLException */ protected URL getFileInBundle(File bundleLocation, String filePath) throws MalformedURLException { String extension = new Path(bundleLocation.getName()).getFileExtension(); StringBuilder urlSt = new StringBuilder(); if (extension != null && extension.equals("jar") && bundleLocation.isFile()) { //$NON-NLS-1$ urlSt.append("jar:file:"); //$NON-NLS-1$ urlSt.append(bundleLocation.getAbsolutePath()); urlSt.append("!/"); //$NON-NLS-1$ urlSt.append(filePath); } else { urlSt.append("file:"); //$NON-NLS-1$ urlSt.append(bundleLocation.getAbsolutePath()); urlSt.append(File.separatorChar); urlSt.append(filePath); } return new URL(urlSt.toString()); }
public IPath removeFileExtension() { String extension = getFileExtension(); if (extension == null || extension.equals("")) { //$NON-NLS-1$ return this; } String lastSegment = lastSegment(); int index = lastSegment.lastIndexOf(extension) - 1; return removeLastSegments(1).append(lastSegment.substring(0, index)); }
public IPath removeFileExtension() { String extension = getFileExtension(); if (extension == null || extension.equals("")) { //$NON-NLS-1$ return this; } String lastSegment = lastSegment(); int index = lastSegment.lastIndexOf(extension) - 1; return removeLastSegments(1).append(lastSegment.substring(0, index)); }
public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) { Map<Locale, Map<String, String>> localizations; Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; if (hostBundleLocalization == null) return null; if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$ bundleLocation.isFile()) { localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); } else { localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); } return localizations; }
public static Map<Locale, Map<String, String>> getHostLocalizations(File bundleLocation, String[] hostBundleManifestValues) { Map<Locale, Map<String, String>> localizations; Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo String hostBundleLocalization = hostBundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; if (hostBundleLocalization == null) return null; if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$ bundleLocation.isFile()) { localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); //localizations = getJarManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); } else { localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); // localizations = getDirManifestLocalization(bundleLocation, hostBundleLocalization, defaultLocale, hostBundleManifestValues); } return localizations; }
@Override public IPath removeFileExtension() { String extension = getFileExtension(); if (extension == null || extension.equals("")) { //$NON-NLS-1$ return this; } String lastSegment = lastSegment(); int index = lastSegment.lastIndexOf(extension) - 1; return removeLastSegments(1).append(lastSegment.substring(0, index)); }
@Override public IPath removeFileExtension() { String extension = getFileExtension(); if (extension == null || extension.equals("")) { //$NON-NLS-1$ return this; } String lastSegment = lastSegment(); int index = lastSegment.lastIndexOf(extension) - 1; return removeLastSegments(1).append(lastSegment.substring(0, index)); }
/** * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy) */ @Override public boolean visit(IResourceProxy proxy) { if (proxy.getType() == IResource.FILE) { if (ICoreConstants.TARGET_FILE_EXTENSION.equalsIgnoreCase(new Path(proxy.getName()).getFileExtension())) { fList.add(proxy.requestResource()); } return false; } return true; } }
private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) { Map<Locale, Map<String, String>> localizations; Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo String[] bundleManifestValues = getManifestCachedValues(manifest); String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$ bundleLocation.isFile()) { localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); } else { localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); } return localizations; }
private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) { Map<Locale, Map<String, String>> localizations; Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo String[] bundleManifestValues = getManifestCachedValues(manifest); String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$ bundleLocation.isFile()) { localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); } else { localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); } return localizations; }
private static Map<Locale, Map<String, String>> getManifestLocalizations(Map<String, String> manifest, File bundleLocation) { Map<Locale, Map<String, String>> localizations; Locale defaultLocale = null; // = Locale.ENGLISH; // TODO: get this from GeneratorInfo String[] bundleManifestValues = getManifestCachedValues(manifest); String bundleLocalization = bundleManifestValues[BUNDLE_LOCALIZATION_INDEX]; // Bundle localization is the last one in the list if ("jar".equalsIgnoreCase(new Path(bundleLocation.getName()).getFileExtension()) && //$NON-NLS-1$ bundleLocation.isFile()) { localizations = LocalizationHelper.getJarPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); //localizations = getJarManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); } else { localizations = LocalizationHelper.getDirPropertyLocalizations(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); // localizations = getDirManifestLocalization(bundleLocation, bundleLocalization, defaultLocale, bundleManifestValues); } return localizations; }
InputStream stream = null; try { String extension = new Path(bundleLocation.getName()).getFileExtension(); if ("jar".equals(extension) && bundleLocation.isFile()) { //$NON-NLS-1$ jarFile = new ZipFile(bundleLocation, ZipFile.OPEN_READ);
/** * The framework calls this to see if the file is correct. */ @Override protected boolean validatePage() { if (super.validatePage()) { String extension = new Path(getFileName()).getFileExtension(); if (extension == null || !extension.equals("genmodel")) { setErrorMessage(ImporterPlugin.INSTANCE.getString("_UI_GeneratorModelFileNameMustEndWithGenModel_message")); return false; } else { genModelContainerPath = getContainerFullPath(); genModelFileName = getFileName(); return true; } } else { return false; } }
/** * Populates the children of the specified parent <code>FileSystemElement</code> * @param element * @param folderonly */ private void populateElementChildren() { FileSystemStructureProvider provider = FileSystemStructureProvider.INSTANCE; List<File> allchildren = provider.getChildren(this.getFileSystemObject()); DebugFileSystemElement newelement = null; for (File child : allchildren) { if(child.isFile()) { Path childpath = new Path(child.getAbsolutePath()); String extension = childpath.getFileExtension(); if (extension != null && (extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_FILE_EXTENSION) || extension.equals(ILaunchConfiguration.LAUNCH_CONFIGURATION_PROTOTYPE_FILE_EXTENSION))) { newelement = new DebugFileSystemElement(provider.getLabel(child), this, provider.isFolder(child)); newelement.setFileSystemObject(child); } } else { newelement = new DebugFileSystemElement(provider.getLabel(child), this, provider.isFolder(child)); newelement.setFileSystemObject(child); } } setPopulated(); } }
protected boolean validatePage() { Path newName = new Path(getFileName()); String fullFileName = getFileName(); String extension = newName.getFileExtension(); if (extension == null || !extension.equalsIgnoreCase("xsd")) { setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_FILENAME_MUST_END_XSD")); return false; } else { setErrorMessage(null); } // check for file should be case insensitive String sameName = existsFileAnyCase(fullFileName); if (sameName != null) { setErrorMessage(XSDEditorPlugin.getPlugin().getString("_ERROR_FILE_ALREADY_EXISTS", sameName)); //$NON-NLS-1$ return false; } return super.validatePage(); }