public BundleModuleRegistry(String bundleSymbolicName, Collection<IPath> paths) { if (bundleSymbolicName == null || bundleSymbolicName.length() == 0) { throw new IllegalArgumentException("Invalid bundle symbolic name"); // $NON-NLS-1$ } for (IPath nextPath : paths) { if (nextPath == null || nextPath.isEmpty() || !nextPath.isValidPath(nextPath.toString())) { throw new IllegalArgumentException("Invalid resource path:" + nextPath); // $NON-NLS-1$ } } this.bundleID = bundleSymbolicName; this.defaultFolderItems = Collections.emptySet(); this.filePaths = new HashSet<IPath>(); this.folderPaths = new HashSet<IPath>(); for (IPath filePath : paths) { if (filePath.segmentCount() > 1) { extractFolderPaths(folderPaths, filePath); filePaths.add(filePath); } else { if (defaultFolderItems.isEmpty()) { defaultFolderItems = new HashSet<IPath>(); } defaultFolderItems.add(filePath); } } }
/** * Returns whether this page's controls currently all contain valid values. * * @return <code>true</code> if all controls are valid, and <code>false</code> if at least one is * invalid */ private boolean validatePage() { String locationFieldContents = getProjectLocationFieldValue(); if (locationFieldContents.equals("")) { // $NON-NLS-1$ setErrorMessage(null); setMessage(DataTransferMessages.WizardExternalProjectImportPage_projectLocationEmpty); return false; } IPath path = new Path(""); // $NON-NLS-1$ if (!path.isValidPath(locationFieldContents)) { setErrorMessage(DataTransferMessages.WizardExternalProjectImportPage_locationError); return false; } File projectFile = projectFile(locationFieldContents); if (projectFile == null) { setErrorMessage( NLS.bind( DataTransferMessages.WizardExternalProjectImportPage_notAProject, locationFieldContents)); return false; } setProjectName(projectFile); if (getProjectHandle().exists()) { setErrorMessage(DataTransferMessages.WizardExternalProjectImportPage_projectExistsMessage); return false; } setErrorMessage(null); setMessage(null); return true; }
private IStatus validateLocation() { String location = projectLocationField.getText(); IPath locationPath = new Path(location); if (!locationPath.isValidPath(getProjectName())) { return new Status( IStatus.ERROR, DartToolsPlugin.PLUGIN_ID, ProjectMessages.NewProjectCreationPage_invalid_loc); } // TODO(scheglov) check after Pub issue fixed // https://code.google.com/p/dart/issues/detail?id=10439 if (locationPath.isUNC()) { return new Status( IStatus.ERROR, DartToolsPlugin.PLUGIN_ID, ProjectMessages.NewProjectCreationPage_invalid_loc_unc); } if (doesProjectExist()) { return new Status( IStatus.ERROR, DartToolsPlugin.PLUGIN_ID, NLS.bind(ProjectMessages.NewApplicationWizardPage_error_existing, getProjectName())); } IStatus status = DirectoryVerification.getOpenDirectoryLocationStatus(new File(location)); if (!status.isOK()) { return status; } return Status.OK_STATUS; }
/* (non-Javadoc) * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) */ public String getText(Object element) { IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry) element; switch (entry.getType()) { case IRuntimeClasspathEntry.PROJECT: IResource res = entry.getResource(); IJavaElement proj = JavaCore.create(res); if (proj == null) { return entry.getPath().lastSegment(); } else { return lp.getText(proj); } case IRuntimeClasspathEntry.ARCHIVE: IPath path = entry.getPath(); if (path == null) { return MessageFormat.format("Invalid path: {0}", new Object[] {"null"}); // $NON-NLS-1$ } if (!path.isAbsolute() || !path.isValidPath(path.toString())) { return MessageFormat.format("Invalid path: {0}", new Object[] {path.toOSString()}); } String[] segments = path.segments(); StringBuffer displayPath = new StringBuffer(); if (segments.length > 0) { String device = path.getDevice(); if (device != null) { displayPath.append(device); displayPath.append(File.separator); } for (int i = 0; i < segments.length - 1; i++) { displayPath.append(segments[i]).append(File.separator); } displayPath.append(segments[segments.length - 1]); // getDevice means that's a absolute path. if (path.getDevice() != null && !path.toFile().exists()) { displayPath.append(" (missing) "); } } else { displayPath.append(path.toOSString()); } return displayPath.toString(); case IRuntimeClasspathEntry.VARIABLE: path = entry.getPath(); IPath srcPath = entry.getSourceAttachmentPath(); StringBuffer buf = new StringBuffer(path.toString()); if (srcPath != null) { buf.append(" ["); // $NON-NLS-1$ buf.append(srcPath.toString()); IPath rootPath = entry.getSourceAttachmentRootPath(); if (rootPath != null) { buf.append(IPath.SEPARATOR); buf.append(rootPath.toString()); } buf.append(']'); } // append JRE name if we can compute it if (path.equals(new Path(JavaRuntime.JRELIB_VARIABLE)) && fLaunchConfiguration != null) { try { IVMInstall vm = JavaRuntime.computeVMInstall(fLaunchConfiguration); buf.append(" - "); // $NON-NLS-1$ buf.append(vm.getName()); } catch (CoreException e) { } } return buf.toString(); case IRuntimeClasspathEntry.CONTAINER: path = entry.getPath(); if (fLaunchConfiguration != null) { try { IJavaProject project = null; try { project = JavaRuntime.getJavaProject(fLaunchConfiguration); } catch (CoreException e) { } if (project == null) { } else { IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project); if (container != null) { if (container.getDescription().startsWith("Persisted container")) { return container.getPath().toString(); } else { return container.getDescription(); } } } } catch (CoreException e) { } } return entry.getPath().toString(); case IRuntimeClasspathEntry.OTHER: IRuntimeClasspathEntry delegate = entry; if (entry instanceof ClasspathEntry) { delegate = ((ClasspathEntry) entry).getDelegate(); } String name = lp.getText(delegate); if (name == null || name.length() == 0) { return ((IRuntimeClasspathEntry2) delegate).getName(); } return name; } return ""; //$NON-NLS-1$ }