private String getInitPath() { String initPath= fPathField.getText(); if (initPath.length() == 0) { initPath= fDialogSettings.get(IUIConstants.DIALOGSTORE_LASTEXTJAR); if (initPath == null) { initPath= ""; //$NON-NLS-1$ } } else { IPath entryPath= new Path(initPath); if (ArchiveFileFilter.isArchivePath(entryPath, true)) { entryPath.removeLastSegments(1); } initPath= entryPath.toOSString(); } return initPath; }
private static boolean isArchive(File file) { String name= file.getName(); int detIndex= name.lastIndexOf('.'); return (detIndex != -1 && ArchiveFileFilter.isArchiveFileExtension(name.substring(detIndex + 1))); } }
@Override public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { if (fExcludes != null && fExcludes.contains(element)) { return false; } return isArchivePath(((IFile)element).getFullPath(), fAllowAllArchives); } else if (element instanceof IContainer) { // IProject, IFolder if (!fRecursive) { return true; } // ignore closed projects if (element instanceof IProject && !((IProject)element).isOpen()) return false; try { IResource[] resources= ((IContainer)element).members(); for (int i= 0; i < resources.length; i++) { // recursive! Only show containers that contain an archive if (select(viewer, parent, resources[i])) { return true; } } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } return false; }
private String chooseWorkspaceArchive() { String initSelection= fArchiveField.getText(); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); Class[] acceptedClasses= new Class[] { IFile.class }; TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); IResource initSel= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (initSelection.length() > 0) { initSel= root.findMember(new Path(initSelection)); } ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp); dialog.addFilter(new ArchiveFileFilter((List) null, true)); dialog.setAllowMultiple(false); dialog.setValidator(validator); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_title); dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_description); dialog.setInput(root); dialog.setInitialSelection(initSel); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { IResource res= (IResource) dialog.getFirstResult(); return res.getFullPath().makeRelative().toString(); } return null; }
dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_description); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.addFilter(new ArchiveFileFilter(usedJars, true, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
private String getInitPath() { String initPath= fPathField.getText(); if (initPath.length() == 0) { initPath= fDialogSettings.get(IUIConstants.DIALOGSTORE_LASTEXTJAR); if (initPath == null) { initPath= ""; //$NON-NLS-1$ } } else { IPath entryPath= new Path(initPath); if (ArchiveFileFilter.isArchivePath(entryPath, true)) { entryPath.removeLastSegments(1); } initPath= entryPath.toOSString(); } return initPath; }
public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { if (fExcludes != null && fExcludes.contains(element)) { return false; } return isArchivePath(((IFile)element).getFullPath()); } else if (element instanceof IContainer) { // IProject, IFolder if (!fRecursive) { return true; } // Ignore closed projects if (element instanceof IProject && !((IProject)element).isOpen()) return false; try { IResource[] resources= ((IContainer)element).members(); for (int i= 0; i < resources.length; i++) { // recursive! Only show containers that contain an archive if (select(viewer, parent, resources[i])) { return true; } } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } return false; }
dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_title); dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_description); dialog.addFilter(new ArchiveFileFilter(usedJars, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
private static boolean isArchive(File file) { String name= file.getName(); int detIndex= name.lastIndexOf('.'); return (detIndex != -1 && ArchiveFileFilter.isArchiveFileExtension(name.substring(detIndex + 1))); }
private String getInitPath() { String initPath= fPathField.getText(); if (initPath.length() == 0) { initPath= fDialogSettings.get(IUIConstants.DIALOGSTORE_LASTEXTJAR); if (initPath == null) { initPath= ""; //$NON-NLS-1$ } } else { IPath entryPath= new Path(initPath); if (ArchiveFileFilter.isArchivePath(entryPath)) { entryPath.removeLastSegments(1); } initPath= entryPath.toOSString(); } return initPath; }
@Override public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { if (fExcludes != null && fExcludes.contains(element)) { return false; } return isArchivePath(((IFile)element).getFullPath(), fAllowAllArchives); } else if (element instanceof IContainer) { // IProject, IFolder if (!fRecursive) { return true; } // ignore closed projects if (element instanceof IProject && !((IProject)element).isOpen()) return false; try { IResource[] resources= ((IContainer)element).members(); for (int i= 0; i < resources.length; i++) { // recursive! Only show containers that contain an archive if (select(viewer, parent, resources[i])) { return true; } } } catch (CoreException e) { JavaPlugin.log(e.getStatus()); } } return false; }
dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_description); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.addFilter(new ArchiveFileFilter(usedJars, true, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
private static boolean isArchive(File file) { String name= file.getName(); int detIndex= name.lastIndexOf('.'); return (detIndex != -1 && ArchiveFileFilter.isArchiveFileExtension(name.substring(detIndex + 1))); } }
private String getPathString(IPath path, boolean isExternal) { if (ArchiveFileFilter.isArchivePath(path)) { IPath appendedPath= path.removeLastSegments(1); String appended= isExternal ? appendedPath.toOSString() : appendedPath.makeRelative().toString(); return Messages.format(NewWizardMessages.CPListLabelProvider_twopart, new String[] { path.lastSegment(), appended }); } else { return isExternal ? path.toOSString() : path.makeRelative().toString(); } }
dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_title); dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_description); dialog.addFilter(new ArchiveFileFilter(usedJars, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
public static boolean isArchivePath(IPath path) { String ext= path.getFileExtension(); if (ext != null && ext.length() != 0) { return isArchiveFileExtension(ext); } return false; }
/** * Check whether the provided file is an archive (.jar or .zip). * * @param file the file to be checked * @param project the Java project * @return <code>true</code> if the file is an archive, <code>false</code> * otherwise * @throws JavaModelException */ public static boolean isArchive(IFile file, IJavaProject project) throws JavaModelException { if (!ArchiveFileFilter.isArchivePath(file.getFullPath(), true)) return false; if (project != null && project.exists() && (project.findPackageFragmentRoot(file.getFullPath()) == null)) return true; return false; }
dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_description); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.addFilter(new ArchiveFileFilter(usedJars, true, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
public static boolean isArchivePath(IPath path, boolean allowAllAchives) { if (allowAllAchives) return true; String ext= path.getFileExtension(); if (ext != null && ext.length() != 0) { return isArchiveFileExtension(ext); } return false; }
/** * Check whether the provided file is an archive (.jar or .zip). * * @param file the file to be checked * @param project the Java project * @return <code>true</code> if the file is an archive, <code>false</code> * otherwise * @throws JavaModelException */ public static boolean isArchive(IFile file, IJavaProject project) throws JavaModelException { if (!ArchiveFileFilter.isArchivePath(file.getFullPath())) return false; if (project != null && project.exists() && (project.findPackageFragmentRoot(file.getFullPath()) == null)) return true; return false; }