private Map promptForOverwrite(List plugins, List locales) { Map overwrites = new HashMap(); if (overwriteWithoutAsking) return overwrites; for (Iterator iter = plugins.iterator(); iter.hasNext(); ) { IPluginModelBase plugin = (IPluginModelBase) iter.next(); for (Iterator it = locales.iterator(); it.hasNext(); ) { Locale locale = (Locale) it.next(); IProject project = getNLProject(plugin, locale); if (project.exists() && !overwrites.containsKey(project.getName())) { boolean overwrite = MessageDialog.openConfirm( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteTitle, NLS.bind( PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteMessage, pluginName(plugin, locale))); overwrites.put(project.getName(), overwrite ? OVERWRITE : null); } } } return overwrites; }
private boolean isDerivedEncodingStoredSeparately(IProject project) { // be careful looking up for our node so not to create any nodes as side effect Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); try { // TODO once bug 90500 is fixed, should be as simple as this: // String path = project.getName() + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES; // return node.nodeExists(path) ? // node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false; // for now, take the long way if (!node.nodeExists(project.getName())) return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS; node = node.node(project.getName()); if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES)) return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS; node = node.node(ResourcesPlugin.PI_RESOURCES); return node.getBoolean( ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS); } catch (BackingStoreException e) { // nodeExists failed String message = Messages.resources_readingEncoding; Policy.log( new ResourceStatus( IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e)); return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS; } }
/** * Creates an NL fragment project along with the locale specific properties files. * * @throws CoreException * @throws IOException * @throws InvocationTargetException * @throws InterruptedException */ private void internationalizePlugins(List plugins, List locales, Map overwrites) throws CoreException, IOException, InvocationTargetException, InterruptedException { Set created = new HashSet(); for (Iterator it = plugins.iterator(); it.hasNext(); ) { IPluginModelBase plugin = (IPluginModelBase) it.next(); for (Iterator iter = locales.iterator(); iter.hasNext(); ) { Locale locale = (Locale) iter.next(); IProject project = getNLProject(plugin, locale); if (created.contains(project) || overwriteWithoutAsking || !project.exists() || OVERWRITE == overwrites.get(project.getName())) { if (!created.contains(project) && project.exists()) { project.delete(true, getProgressMonitor()); } if (!created.contains(project)) { createNLFragment(plugin, project, locale); created.add(project); project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor()); } project .getFolder(RESOURCE_FOLDER_PARENT) .getFolder(locale.toString()) .create(true, true, getProgressMonitor()); createLocaleSpecificPropertiesFile(project, plugin, locale); } } } }
Preferences getPreferences( IProject project, boolean create, boolean isDerived, boolean isDerivedEncodingStoredSeparately) { boolean localIsDerived = isDerivedEncodingStoredSeparately ? isDerived : false; String qualifier = localIsDerived ? ProjectPreferences.PREFS_DERIVED_QUALIFIER : ProjectPreferences.PREFS_REGULAR_QUALIFIER; if (create) // create all nodes down to the one we are interested in return new ProjectScope(project).getNode(qualifier).node(ResourcesPlugin.PREF_ENCODING); // be careful looking up for our node so not to create any nodes as side effect Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); try { // TODO once bug 90500 is fixed, should be as simple as this: // String path = project.getName() + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES + // IPath.SEPARATOR + ENCODING_PREF_NODE; // return node.nodeExists(path) ? node.node(path) : null; // for now, take the long way if (!node.nodeExists(project.getName())) return null; node = node.node(project.getName()); if (!node.nodeExists(qualifier)) return null; node = node.node(qualifier); if (!node.nodeExists(ResourcesPlugin.PREF_ENCODING)) return null; return node.node(ResourcesPlugin.PREF_ENCODING); } catch (BackingStoreException e) { // nodeExists failed String message = Messages.resources_readingEncoding; Policy.log( new ResourceStatus( IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e)); } return null; }
/* * Instruct the build manager that this project is involved in a cycle and * needs to propagate structural changes to the other projects in the cycle. */ void mustPropagateStructuralChanges() { LinkedHashSet cycleParticipants = new LinkedHashSet(3); this.javaProject.updateCycleParticipants( new ArrayList(), cycleParticipants, this.workspaceRoot, new HashSet(3), null); IPath currentPath = this.javaProject.getPath(); Iterator i = cycleParticipants.iterator(); while (i.hasNext()) { IPath participantPath = (IPath) i.next(); if (participantPath != currentPath) { IProject project = this.workspaceRoot.getProject(participantPath.segment(0)); if (hasBeenBuilt(project)) { if (DEBUG) System.out.println( "JavaBuilder: Requesting another build iteration since cycle participant " + project.getName() // $NON-NLS-1$ + " has not yet seen some structural changes"); //$NON-NLS-1$ needRebuild(); return; } } } }
private IProject getUninitializedTargetProject(IProject project) { return WorkspaceUtilities.getWorkspaceRoot() .getProject(project.getName() + SharpenConstants.SHARPENED_PROJECT_SUFFIX); }
private boolean isWorthBuilding() throws CoreException { boolean abortBuilds = JavaCore.ABORT.equals( this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true)); if (!abortBuilds) { if (DEBUG) System.out.println("JavaBuilder: Ignoring invalid classpath"); // $NON-NLS-1$ return true; } // Abort build only if there are classpath errors if (isClasspathBroken(this.javaProject, true)) { if (DEBUG) System.out.println( "JavaBuilder: Aborted build because project has classpath errors (incomplete or involved in cycle)"); //$NON-NLS-1$ removeProblemsAndTasksFor(this.currentProject); // remove all compilation problems IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID }, new Object[] { Messages.build_abortDueToClasspathProblems, new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID }); return false; } if (JavaCore.WARNING.equals( this.javaProject.getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true))) return true; // make sure all prereq projects have valid build states... only when aborting builds since // projects in cycles do not have build states // except for projects involved in a 'warning' cycle (see below) IProject[] requiredProjects = getRequiredProjects(false); for (int i = 0, l = requiredProjects.length; i < l; i++) { IProject p = requiredProjects[i]; if (getLastState(p) == null) { // The prereq project has no build state: if this prereq project has a 'warning' cycle // marker then allow build (see bug id 23357) JavaProject prereq = (JavaProject) JavaCore.create(p); if (prereq.hasCycleMarker() && JavaCore.WARNING.equals( this.javaProject.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) { if (DEBUG) System.out.println( "JavaBuilder: Continued to build even though prereq project " + p.getName() // $NON-NLS-1$ + " was not built since its part of a cycle"); //$NON-NLS-1$ continue; } if (!hasJavaBuilder(p)) { if (DEBUG) System.out.println( "JavaBuilder: Continued to build even though prereq project " + p.getName() // $NON-NLS-1$ + " is not built by JavaBuilder"); //$NON-NLS-1$ continue; } if (DEBUG) System.out.println( "JavaBuilder: Aborted build because prereq project " + p.getName() // $NON-NLS-1$ + " was not built"); //$NON-NLS-1$ removeProblemsAndTasksFor( this.currentProject); // make this the only problem for this project IMarker marker = this.currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); marker.setAttributes( new String[] { IMarker.MESSAGE, IMarker.SEVERITY, IJavaModelMarker.CATEGORY_ID, IMarker.SOURCE_ID }, new Object[] { isClasspathBroken(prereq, true) ? Messages.bind(Messages.build_prereqProjectHasClasspathProblems, p.getName()) : Messages.bind(Messages.build_prereqProjectMustBeRebuilt, p.getName()), new Integer(IMarker.SEVERITY_ERROR), new Integer(CategorizedProblem.CAT_BUILDPATH), JavaBuilder.SOURCE_ID }); return false; } } return true; }
private SimpleLookupTable findDeltas() { this.notifier.subTask( Messages.bind(Messages.build_readingDelta, this.currentProject.getName())); IResourceDelta delta = getDelta(this.currentProject); SimpleLookupTable deltas = new SimpleLookupTable(3); if (delta != null) { if (delta.getKind() != IResourceDelta.NO_CHANGE) { if (DEBUG) System.out.println( "JavaBuilder: Found source delta for: " + this.currentProject.getName()); // $NON-NLS-1$ deltas.put(this.currentProject, delta); } } else { if (DEBUG) System.out.println( "JavaBuilder: Missing delta for: " + this.currentProject.getName()); // $NON-NLS-1$ this.notifier.subTask(""); // $NON-NLS-1$ return null; } Object[] keyTable = this.binaryLocationsPerProject.keyTable; Object[] valueTable = this.binaryLocationsPerProject.valueTable; nextProject: for (int i = 0, l = keyTable.length; i < l; i++) { IProject p = (IProject) keyTable[i]; if (p != null && p != this.currentProject) { State s = getLastState(p); if (!this.lastState.wasStructurallyChanged(p, s)) { // see if we can skip its delta if (s.wasNoopBuild()) continue nextProject; // project has no source folders and can be skipped ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) valueTable[i]; boolean canSkip = true; for (int j = 0, m = classFoldersAndJars.length; j < m; j++) { if (classFoldersAndJars[j].isOutputFolder()) classFoldersAndJars[j] = null; // can ignore output folder since project was not structurally changed else canSkip = false; } if (canSkip) continue nextProject; // project has no structural changes in its output folders } this.notifier.subTask(Messages.bind(Messages.build_readingDelta, p.getName())); delta = getDelta(p); if (delta != null) { if (delta.getKind() != IResourceDelta.NO_CHANGE) { if (DEBUG) System.out.println( "JavaBuilder: Found binary delta for: " + p.getName()); // $NON-NLS-1$ deltas.put(p, delta); } } else { if (DEBUG) System.out.println("JavaBuilder: Missing delta for: " + p.getName()); // $NON-NLS-1$ this.notifier.subTask(""); // $NON-NLS-1$ return null; } } } this.notifier.subTask(""); // $NON-NLS-1$ return deltas; }