public static IMarker[] getProblemsFor(IResource resource) { try { if (resource != null && resource.exists()) { IMarker[] markers = resource.findMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); Set markerTypes = JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes(); if (markerTypes.isEmpty()) return markers; ArrayList markerList = new ArrayList(5); for (int i = 0, length = markers.length; i < length; i++) { markerList.add(markers[i]); } Iterator iterator = markerTypes.iterator(); while (iterator.hasNext()) { markers = resource.findMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE); for (int i = 0, length = markers.length; i < length; i++) { markerList.add(markers[i]); } } IMarker[] result; markerList.toArray(result = new IMarker[markerList.size()]); return result; } } catch (CoreException e) { // assume there are no problems } return new IMarker[0]; }
/** * Recursively gets the ID of required features of this feature and adds them to the list * * @param model feature model to get requirements of * @param requiredFeatureList collector for the required features */ private void getFeatureDependencies( IFeatureModel model, IFeatureModel[] allFeatures, ArrayList requiredFeatureList) { IFeature feature = model.getFeature(); IFeatureImport[] featureImports = feature.getImports(); for (int i = 0; i < featureImports.length; i++) { if (featureImports[i].getType() == IFeatureImport.FEATURE) { for (int j = 0; j < allFeatures.length; j++) { if (allFeatures[j].getFeature().getId().equals(featureImports[i].getId())) { requiredFeatureList.add(allFeatures[j]); getFeatureDependencies(allFeatures[j], allFeatures, requiredFeatureList); break; } } } } IFeatureChild[] featureIncludes = feature.getIncludedFeatures(); for (int i = 0; i < featureIncludes.length; i++) { requiredFeatureList.add(featureIncludes[i].getId()); for (int j = 0; j < allFeatures.length; j++) { if (allFeatures[j].getFeature().getId().equals(featureIncludes[i].getId())) { requiredFeatureList.add(allFeatures[j]); getFeatureDependencies(allFeatures[j], allFeatures, requiredFeatureList); break; } } } }
private void removeBuildPath(IResource resource, IProject project) { IScriptProject projrct = DLTKCore.create(project); IPath filePath = resource.getFullPath(); oldBuildEntries = Arrays.asList(projrct.readRawBuildpath()); newBuildEntries = new ArrayList<IBuildpathEntry>(); newBuildEntries.addAll(oldBuildEntries); for (int i = 0; i < oldBuildEntries.size(); i++) { IBuildpathEntry fEntryToChange = oldBuildEntries.get(i); IPath entryPath = fEntryToChange.getPath(); int mattchedPath = entryPath.matchingFirstSegments(filePath); if (mattchedPath == filePath.segmentCount()) { newBuildEntries.remove(fEntryToChange); } else { IBuildpathEntry newEntry = RefactoringUtility.createNewBuildpathEntry( fEntryToChange, fEntryToChange.getPath(), filePath, ""); // $NON-NLS-1$ newBuildEntries.remove(fEntryToChange); newBuildEntries.add(newEntry); } } oldIncludePath = new ArrayList<IBuildpathEntry>(); newIncludePathEntries = new ArrayList<IBuildpathEntry>(); List<IncludePath> includePathEntries = Arrays.asList(IncludePathManager.getInstance().getIncludePaths(project)); for (IncludePath entry : includePathEntries) { Object includePathEntry = entry.getEntry(); IResource includeResource = null; if (!(includePathEntry instanceof IBuildpathEntry)) { includeResource = (IResource) includePathEntry; IPath entryPath = includeResource.getFullPath(); IBuildpathEntry oldEntry = RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath); oldIncludePath.add((IBuildpathEntry) oldEntry); if (filePath.isPrefixOf(entryPath) || entryPath.equals(filePath)) { } else { IBuildpathEntry newEntry = RefactoringUtility.createNewBuildpathEntry(IBuildpathEntry.BPE_SOURCE, entryPath); newIncludePathEntries.add(newEntry); } } else { newIncludePathEntries.add((IBuildpathEntry) includePathEntry); oldIncludePath.add((IBuildpathEntry) includePathEntry); } } }
private void addProjectSourceContainers(IProject project, ArrayList result) throws CoreException { if (project == null || !project.hasNature(JavaCore.NATURE_ID)) return; IJavaProject jProject = JavaCore.create(project); result.add(JavaRuntime.newProjectRuntimeClasspathEntry(jProject)); IClasspathEntry[] entries = jProject.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry entry = entries[i]; if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { IRuntimeClasspathEntry rte = convertClasspathEntry(entry); if (rte != null) result.add(rte); } } }
private int initializeBuilder(int kind, boolean forBuild) throws CoreException { // some calls just need the nameEnvironment initialized so skip the rest this.javaProject = (JavaProject) JavaCore.create(this.currentProject); this.workspaceRoot = this.currentProject.getWorkspace().getRoot(); if (forBuild) { // cache the known participants for this project this.participants = JavaModelManager.getJavaModelManager() .compilationParticipants .getCompilationParticipants(this.javaProject); if (this.participants != null) for (int i = 0, l = this.participants.length; i < l; i++) if (this.participants[i].aboutToBuild(this.javaProject) == CompilationParticipant.NEEDS_FULL_BUILD) kind = FULL_BUILD; // Flush the existing external files cache if this is the beginning of a build cycle String projectName = this.currentProject.getName(); if (builtProjects == null || builtProjects.contains(projectName)) { builtProjects = new ArrayList(); } builtProjects.add(projectName); } this.binaryLocationsPerProject = new SimpleLookupTable(3); this.nameEnvironment = new NameEnvironment( this.workspaceRoot, this.javaProject, this.binaryLocationsPerProject, this.notifier); if (forBuild) { String filterSequence = this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true); char[][] filters = filterSequence != null && filterSequence.length() > 0 ? CharOperation.splitAndTrimOn(',', filterSequence.toCharArray()) : null; if (filters == null) { this.extraResourceFileFilters = null; this.extraResourceFolderFilters = null; } else { int fileCount = 0, folderCount = 0; for (int i = 0, l = filters.length; i < l; i++) { char[] f = filters[i]; if (f.length == 0) continue; if (f[f.length - 1] == '/') folderCount++; else fileCount++; } this.extraResourceFileFilters = new char[fileCount][]; this.extraResourceFolderFilters = new String[folderCount]; for (int i = 0, l = filters.length; i < l; i++) { char[] f = filters[i]; if (f.length == 0) continue; if (f[f.length - 1] == '/') this.extraResourceFolderFilters[--folderCount] = new String(f, 0, f.length - 1); else this.extraResourceFileFilters[--fileCount] = f; } } } return kind; }
protected void finishedWith( String sourceLocator, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames, ArrayList duplicateTypeNames) { char[][] previousTypeNames = this.newState.getDefinedTypeNamesFor(sourceLocator); if (previousTypeNames == null) previousTypeNames = new char[][] {mainTypeName}; IPath packagePath = null; next: for (int i = 0, l = previousTypeNames.length; i < l; i++) { char[] previous = previousTypeNames[i]; for (int j = 0, m = definedTypeNames.size(); j < m; j++) if (CharOperation.equals(previous, (char[]) definedTypeNames.get(j))) continue next; SourceFile sourceFile = (SourceFile) result.getCompilationUnit(); if (packagePath == null) { int count = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount(); packagePath = sourceFile.resource.getFullPath().removeFirstSegments(count).removeLastSegments(1); } if (this.secondaryTypesToRemove == null) this.secondaryTypesToRemove = new SimpleLookupTable(); ArrayList types = (ArrayList) this.secondaryTypesToRemove.get(sourceFile.sourceLocation.binaryFolder); if (types == null) types = new ArrayList(definedTypeNames.size()); types.add(packagePath.append(new String(previous))); this.secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types); } super.finishedWith(sourceLocator, result, mainTypeName, definedTypeNames, duplicateTypeNames); }
private void computeRemedyDetails(Remedy remedy) { ArrayList<String> updateIds = new ArrayList<String>(); for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) { for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) { if (removedIU.getId().equals(addedIU.getId())) { createModificationRemedyDetail(addedIU, removedIU, remedy); updateIds.add(addedIU.getId()); break; } } if (!updateIds.contains(addedIU.getId())) { createAdditionRemedyDetail(addedIU, remedy); } } for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) { if (!updateIds.contains(removedIU.getId())) { createRemovalRemedyDetail(removedIU, remedy); } } for (IInstallableUnit addedIUinOriginalRequest : originalRequest.getAdditions()) { boolean found = false; for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) { if (addedIU.getId().equals(addedIUinOriginalRequest.getId())) { found = true; break; } } if (!found) { createNotAddedRemedyDetail(addedIUinOriginalRequest, remedy); found = false; } } }
protected void handleAdd() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new StyledBundleLabelProvider(false, false)); try { dialog.setElements(getValidBundles()); } catch (CoreException e) { dialog.setMessage(e.getMessage()); } dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title); dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message); dialog.setMultipleSelection(true); if (dialog.open() == Window.OK) { Object[] models = dialog.getResult(); ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<NameVersionDescriptor>(); for (int i = 0; i < models.length; i++) { BundleInfo desc = ((BundleInfo) models[i]); pluginsToAdd.add(new NameVersionDescriptor(desc.getSymbolicName(), null)); } Set<NameVersionDescriptor> allDependencies = new HashSet<NameVersionDescriptor>(); allDependencies.addAll(pluginsToAdd); NameVersionDescriptor[] currentBundles = getTargetDefinition().getImplicitDependencies(); if (currentBundles != null) { allDependencies.addAll(Arrays.asList(currentBundles)); } getTargetDefinition() .setImplicitDependencies( allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()])); fElementViewer.refresh(); updateImpButtons(); } }
protected void compile( SourceFile[] units, SourceFile[] additionalUnits, boolean compilingFirstGroup) { if (compilingFirstGroup && additionalUnits != null) { // add any source file from additionalUnits to units if it defines secondary types // otherwise its possible during testing with MAX_AT_ONCE == 1 that a secondary type // can cause an infinite loop as it alternates between not found and defined, see bug 146324 ArrayList extras = null; for (int i = 0, l = additionalUnits.length; i < l; i++) { SourceFile unit = additionalUnits[i]; if (unit != null && this.newState.getDefinedTypeNamesFor(unit.typeLocator()) != null) { if (JavaBuilder.DEBUG) System.out.println( "About to compile file with secondary types " + unit.typeLocator()); // $NON-NLS-1$ if (extras == null) extras = new ArrayList(3); extras.add(unit); } } if (extras != null) { int oldLength = units.length; int toAdd = extras.size(); System.arraycopy(units, 0, units = new SourceFile[oldLength + toAdd], 0, oldLength); for (int i = 0; i < toAdd; i++) units[oldLength++] = (SourceFile) extras.get(i); } } super.compile(units, additionalUnits, compilingFirstGroup); }
ISourceContainer[] getSourceContainers(String location, String id) throws CoreException { ISourceContainer[] containers = (ISourceContainer[]) fSourceContainerMap.get(location); if (containers != null) { return containers; } ArrayList result = new ArrayList(); ModelEntry entry = MonitorRegistry.findEntry(id); boolean match = false; IMonitorModelBase[] models = entry.getWorkspaceModels(); for (int i = 0; i < models.length; i++) { if (isPerfectMatch(models[i], new Path(location))) { IResource resource = models[i].getUnderlyingResource(); // if the plug-in matches a workspace model, // add the project and any libraries not coming via a container // to the list of source containers, in that order if (resource != null) { addProjectSourceContainers(resource.getProject(), result); } match = true; break; } } if (!match) { File file = new File(location); if (file.isFile()) { // in case of linked plug-in projects that map to an external JARd plug-in, // use source container that maps to the library in the linked project. ISourceContainer container = getArchiveSourceContainer(location); if (container != null) { containers = new ISourceContainer[] {container}; fSourceContainerMap.put(location, containers); return containers; } } models = entry.getExternalModels(); for (int i = 0; i < models.length; i++) { if (isPerfectMatch(models[i], new Path(location))) { // try all source zips found in the source code locations IClasspathEntry[] entries = MDEClasspathContainer.getExternalEntries(models[i]); for (int j = 0; j < entries.length; j++) { IRuntimeClasspathEntry rte = convertClasspathEntry(entries[j]); if (rte != null) result.add(rte); } break; } } } IRuntimeClasspathEntry[] entries = (IRuntimeClasspathEntry[]) result.toArray(new IRuntimeClasspathEntry[result.size()]); containers = JavaRuntime.getSourceContainers(entries); fSourceContainerMap.put(location, containers); return containers; }
protected boolean findSourceFiles(IResourceDelta delta) throws CoreException { ArrayList visited = this.makeOutputFolderConsistent ? new ArrayList(this.sourceLocations.length) : null; for (int i = 0, l = this.sourceLocations.length; i < l; i++) { ClasspathMultiDirectory md = this.sourceLocations[i]; if (this.makeOutputFolderConsistent && md.hasIndependentOutputFolder && !visited.contains(md.binaryFolder)) { // even a project which acts as its own source folder can have an independent/nested output // folder visited.add(md.binaryFolder); IResourceDelta binaryDelta = delta.findMember(md.binaryFolder.getProjectRelativePath()); if (binaryDelta != null) { int segmentCount = binaryDelta.getFullPath().segmentCount(); IResourceDelta[] children = binaryDelta.getAffectedChildren(); for (int j = 0, m = children.length; j < m; j++) if (!checkForClassFileChanges(children[j], md, segmentCount)) return false; } } if (md.sourceFolder.equals(this.javaBuilder.currentProject)) { // skip nested source & output folders when the project is a source folder int segmentCount = delta.getFullPath().segmentCount(); IResourceDelta[] children = delta.getAffectedChildren(); for (int j = 0, m = children.length; j < m; j++) if (!isExcludedFromProject(children[j].getFullPath())) if (!findSourceFiles(children[j], md, segmentCount)) return false; } else { IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath()); if (sourceDelta != null) { if (sourceDelta.getKind() == IResourceDelta.REMOVED) { if (JavaBuilder.DEBUG) System.out.println( "ABORTING incremental build... found removed source folder"); //$NON-NLS-1$ return false; // removed source folder should not make it here, but handle anyways // (ADDED is supported) } int segmentCount = sourceDelta.getFullPath().segmentCount(); IResourceDelta[] children = sourceDelta.getAffectedChildren(); try { for (int j = 0, m = children.length; j < m; j++) if (!findSourceFiles(children[j], md, segmentCount)) return false; } catch (CoreException e) { // catch the case that a package has been renamed and collides on disk with an // as-yet-to-be-deleted package if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) { if (JavaBuilder.DEBUG) System.out.println( "ABORTING incremental build... found renamed package"); //$NON-NLS-1$ return false; } throw e; // rethrow } } } this.notifier.checkCancel(); } return true; }
private String[] getDirectoryCandidates() { double version = getTargetVersion(); ArrayList result = new ArrayList(); if (version >= 3.6) result.add( "templates_3.6" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (version >= 3.5) result.add( "templates_3.5" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (version >= 3.4) result.add( "templates_3.4" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (version >= 3.3) result.add( "templates_3.3" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (version >= 3.2) result.add( "templates_3.2" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (version >= 3.1) result.add( "templates_3.1" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (version >= 3.0) result.add( "templates_3.0" + "/" + getSectionId() + "/"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return (String[]) result.toArray(new String[result.size()]); }
private IResource[] removeDuplicateResources(IResource[] sourceResources) { // ignore empty array if (sourceResources == null || sourceResources.length == 0) { return sourceResources; } ArrayList<IResource> result = new ArrayList<IResource>(); for (IResource source : sourceResources) { if (result.size() == 0) { result.add(source); } else { // check if the resource is parent of any item in the result for (IResource existing : result) { // if the resource is parent of an existing item in the // result. // remove the existing item, add the new one. if (source.getFullPath().isPrefixOf(existing.getFullPath())) { result.remove(existing); result.add(source); } } boolean noNeedAdded = false; for (IResource existing : result) { // if the resource is parent of an existing item in the // result. // remove the existing item, add the new one. if (existing.getFullPath().isPrefixOf(source.getFullPath())) { noNeedAdded = true; } } // the source is not in the result after loop if (!result.contains(source) && !noNeedAdded) { result.add(source); } } } IResource[] ret = new IResource[result.size()]; return result.toArray(ret); }
public static String[] getFeaturePaths() { IFeatureModel[] models = MDECore.getDefault().getFeatureModelManager().getModels(); ArrayList list = new ArrayList(); for (int i = 0; i < models.length; i++) { String location = models[i].getInstallLocation(); if (location != null) list.add(location + IPath.SEPARATOR + ICoreConstants.FEATURE_FILENAME_DESCRIPTOR); } return (String[]) list.toArray(new String[list.size()]); }
private void handleExistingProjects() { ArrayList<Object> result = new ArrayList<>(); for (int i = 0; i < fModels.length; i++) { String id = fModels[i].getPluginBase().getId(); IProject project = (IProject) PDEPlugin.getWorkspace().getRoot().findMember(id); if (project != null && project.isOpen() && WorkspaceModelManager.isPluginProject(project)) { result.add(fModels[i]); } } handleSetImportSelection(result); }
private void handleAddAll() { TableItem[] items = fAvailableListViewer.getTable().getItems(); ArrayList<Object> data = new ArrayList<>(); for (int i = 0; i < items.length; i++) { data.add(items[i].getData()); } if (data.size() > 0) { doAdd(data); pageChanged(true, false); } }
private void handleSwap() { TableItem[] aItems = fAvailableListViewer.getTable().getItems(); TableItem[] iItems = fImportListViewer.getTable().getItems(); ArrayList<Object> data = new ArrayList<>(); for (int i = 0; i < iItems.length; i++) { data.add(iItems[i].getData()); } if (data.size() > 0) { doRemove(data); } data.clear(); for (int i = 0; i < aItems.length; i++) { data.add(aItems[i].getData()); } if (data.size() > 0) { doAdd(data); } pageChanged(); }
private void handleRemoveAll() { TableItem[] items = fImportListViewer.getTable().getItems(); ArrayList<Object> data = new ArrayList<>(); for (int i = 0; i < items.length; i++) { data.add(items[i].getData()); } if (data.size() > 0) { doRemove(data); pageChanged(false, true); } }
@Override public void transferListenersTo( IModelChangeProviderExtension target, IModelChangedListenerFilter filter) { ArrayList<IModelChangedListener> removed = new ArrayList<>(); for (int i = 0; i < fListeners.size(); i++) { IModelChangedListener listener = fListeners.get(i); if (filter == null || filter.accept(listener)) { target.addModelChangedListener(listener); removed.add(listener); } } fListeners.removeAll(removed); }
/* * (non-Javadoc) * @see org.eclipse.pde.ui.launcher.AbstractPDELaunchConfiguration#getProgramArguments(org.eclipse.debug.core.ILaunchConfiguration) */ public String[] getProgramArguments(ILaunchConfiguration configuration) throws CoreException { ArrayList programArgs = new ArrayList(); programArgs.add("-dev"); // $NON-NLS-1$ programArgs.add( ClasspathHelper.getDevEntriesProperties( getConfigDir(configuration).toString() + "/dev.properties", fAllBundles)); //$NON-NLS-1$ saveConfigurationFile(configuration); programArgs.add("-configuration"); // $NON-NLS-1$ programArgs.add( "file:" + new Path(getConfigDir(configuration).getPath()) .addTrailingSeparator() .toString()); //$NON-NLS-1$ String[] args = super.getProgramArguments(configuration); for (int i = 0; i < args.length; i++) { programArgs.add(args[i]); } return (String[]) programArgs.toArray(new String[programArgs.size()]); }
/* Return the list of projects for which it requires a resource delta. This builder's project * is implicitly included and need not be specified. Builders must re-specify the list * of interesting projects every time they are run as this is not carried forward * beyond the next build. Missing projects should be specified but will be ignored until * they are added to the workspace. */ private IProject[] getRequiredProjects(boolean includeBinaryPrerequisites) { if (this.javaProject == null || this.workspaceRoot == null) return new IProject[0]; ArrayList projects = new ArrayList(); ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); try { IClasspathEntry[] entries = this.javaProject.getExpandedClasspath(); for (int i = 0, l = entries.length; i < l; i++) { IClasspathEntry entry = entries[i]; IPath path = entry.getPath(); IProject p = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_PROJECT: p = this.workspaceRoot.getProject( path.lastSegment()); // missing projects are considered too if (((ClasspathEntry) entry).isOptional() && !JavaProject.hasJavaNature(p)) // except if entry is optional p = null; break; case IClasspathEntry.CPE_LIBRARY: if (includeBinaryPrerequisites && path.segmentCount() > 0) { // some binary resources on the class path can come from projects that are not // included in the project references IResource resource = this.workspaceRoot.findMember(path.segment(0)); if (resource instanceof IProject) { p = (IProject) resource; } else { resource = externalFoldersManager.getFolder(path); if (resource != null) p = resource.getProject(); } } } if (p != null && !projects.contains(p)) projects.add(p); } } catch (JavaModelException e) { return new IProject[0]; } IProject[] result = new IProject[projects.size()]; projects.toArray(result); return result; }
public static void handleAddRequired(IProductPlugin[] plugins, boolean includeOptional) { if (plugins.length == 0) return; ArrayList<BundleDescription> list = new ArrayList<BundleDescription>(plugins.length); for (int i = 0; i < plugins.length; i++) { list.add(TargetPlatformHelper.getState().getBundle(plugins[i].getId(), null)); } DependencyCalculator calculator = new DependencyCalculator(includeOptional); calculator.findDependencies(list.toArray()); BundleDescription[] bundles = TargetPlatformHelper.getState().getBundles(); for (int i = 0; i < bundles.length; i++) { HostSpecification host = bundles[i].getHost(); if (host != null && !("org.eclipse.ui.workbench.compatibility" .equals(bundles[i].getSymbolicName())) // $NON-NLS-1$ && calculator.containsPluginId(host.getName())) { calculator.findDependency(bundles[i]); } } Collection<?> dependencies = calculator.getBundleIDs(); IProduct product = plugins[0].getProduct(); IProductModelFactory factory = product.getModel().getFactory(); IProductPlugin[] requiredPlugins = new IProductPlugin[dependencies.size()]; int i = 0; Iterator<?> iter = dependencies.iterator(); while (iter.hasNext()) { String id = iter.next().toString(); IProductPlugin plugin = factory.createPlugin(); plugin.setId(id); requiredPlugins[i++] = plugin; } product.addPlugins(requiredPlugins); }
private void handleAddWorkingSet() { IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager(); IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(PDEPlugin.getActiveWorkbenchShell(), true); if (dialog.open() == Window.OK) { IWorkingSet[] workingSets = dialog.getSelection(); IProduct product = getProduct(); IProductModelFactory factory = product.getModel().getFactory(); ArrayList<IProductPlugin> pluginList = new ArrayList<IProductPlugin>(); for (int i = 0; i < workingSets.length; i++) { IAdaptable[] elements = workingSets[i].getElements(); for (int j = 0; j < elements.length; j++) { IPluginModelBase model = findModel(elements[j]); if (model != null) { IProductPlugin plugin = factory.createPlugin(); IPluginBase base = model.getPluginBase(); plugin.setId(base.getId()); pluginList.add(plugin); } } } product.addPlugins(pluginList.toArray(new IProductPlugin[pluginList.size()])); } }
public static Dictionary[] getPlatformProperties(String[] profiles, MinimalState state) { if (profiles == null || profiles.length == 0) return new Dictionary[] {getTargetEnvironment(state)}; // add java profiles for those EE's that have a .profile file in the current system bundle ArrayList result = new ArrayList(profiles.length); for (int i = 0; i < profiles.length; i++) { IExecutionEnvironment environment = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment(profiles[i]); if (environment != null) { Properties profileProps = environment.getProfileProperties(); if (profileProps != null) { Dictionary props = TargetPlatformHelper.getTargetEnvironment(state); String systemPackages = profileProps.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); if (systemPackages != null) props.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages); String ee = profileProps.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT); if (ee != null) props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee); result.add(props); } } } if (result.size() > 0) return (Dictionary[]) result.toArray(new Dictionary[result.size()]); return new Dictionary[] {TargetPlatformHelper.getTargetEnvironment(state)}; }
private ArrayList convertPkgList(ArrayList pkgList) { ArrayList conList = new ArrayList(); Iterator it = pkgList.iterator(); while (it.hasNext()) { CallData cd = (CallData) it.next(); TestNode tn = null; if (alreadyDone.containsKey(cd)) { tn = (TestNode) alreadyDone.get(cd); } else { tn = new TestNode(); tn.setData(cd.getData()); alreadyDone.put(cd, tn); if (cd.getChildren().size() != 0) { tn.setChildren(convertPkgList(cd.getChildren())); } if (cd.getOutputs().size() != 0) { tn.setOutputs(convertPkgList(cd.getOutputs())); } } conList.add(tn); } return conList; }
private boolean resourceExists(String location) { String bundleJar = null; IPath path = new Path(location); if ("platform:".equals(path.getDevice()) && path.segmentCount() > 2) { // $NON-NLS-1$ if ("plugin".equals(path.segment(0))) { // $NON-NLS-1$ String id = path.segment(1); IMonitorModelBase model = MonitorRegistry.findModel(id); if (model != null && model.isEnabled()) { path = path.setDevice(null).removeFirstSegments(2); String bundleLocation = model.getInstallLocation(); if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$ bundleJar = bundleLocation; } else { path = new Path(model.getInstallLocation()).append(path); } location = path.toString(); } } } else if (path.getDevice() == null && path.segmentCount() > 3 && "platform:".equals(path.segment(0))) { // $NON-NLS-1$ if ("plugin".equals(path.segment(1))) { // $NON-NLS-1$ String id = path.segment(2); IMonitorModelBase model = MonitorRegistry.findModel(id); if (model != null && model.isEnabled()) { path = path.removeFirstSegments(3); String bundleLocation = model.getInstallLocation(); if (bundleLocation.endsWith(".jar")) { // $NON-NLS-1$ bundleJar = bundleLocation; } else { path = new Path(model.getInstallLocation()).append(path); } location = path.toString(); } } } ArrayList paths = new ArrayList(); if (location.indexOf("$nl$") != -1) { // $NON-NLS-1$ StringTokenizer tokenizer = new StringTokenizer(TargetPlatform.getNL(), "_"); // $NON-NLS-1$ String language = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null; String country = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null; if (language != null && country != null) paths.add( location.replaceAll( "\\$nl\\$", "nl" + IPath.SEPARATOR + language + IPath.SEPARATOR + country)); //$NON-NLS-1$ //$NON-NLS-2$ if (language != null) paths.add( location.replaceAll( "\\$nl\\$", "nl" + IPath.SEPARATOR + language)); // $NON-NLS-1$ //$NON-NLS-2$ paths.add(location.replaceAll("\\$nl\\$", "")); // $NON-NLS-1$ //$NON-NLS-2$ } else { paths.add(location); } for (int i = 0; i < paths.size(); i++) { if (bundleJar == null) { IPath currPath = new Path(paths.get(i).toString()); if (currPath.isAbsolute() && currPath.toFile().exists()) return true; if (PDEProject.getBundleRoot(fFile.getProject()).findMember(currPath) != null) return true; if (fBuildModel != null && fBuildModel.getEntry("source." + paths.get(i)) != null) // $NON-NLS-1$ return true; } else { if (CoreUtility.jarContainsResource(new File(bundleJar), paths.get(i).toString(), false)) return true; } } return false; }
protected void cleanOutputFolders(boolean copyBack) throws CoreException { boolean deleteAll = JavaCore.CLEAN.equals( this.javaBuilder.javaProject.getOption( JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true)); if (deleteAll) { if (this.javaBuilder.participants != null) for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++) this.javaBuilder.participants[i].cleanStarting(this.javaBuilder.javaProject); ArrayList visited = new ArrayList(this.sourceLocations.length); for (int i = 0, l = this.sourceLocations.length; i < l; i++) { this.notifier.subTask( Messages.bind( Messages.build_cleaningOutput, this.javaBuilder.currentProject.getName())); ClasspathMultiDirectory sourceLocation = this.sourceLocations[i]; if (sourceLocation.hasIndependentOutputFolder) { IContainer outputFolder = sourceLocation.binaryFolder; if (!visited.contains(outputFolder)) { visited.add(outputFolder); IResource[] members = outputFolder.members(); for (int j = 0, m = members.length; j < m; j++) { IResource member = members[j]; if (!member.isDerived()) { member.accept( new IResourceVisitor() { public boolean visit(IResource resource) throws CoreException { resource.setDerived(true, null); return resource.getType() != IResource.FILE; } }); } member.delete(IResource.FORCE, null); } } this.notifier.checkCancel(); if (copyBack) copyExtraResourcesBack(sourceLocation, true); } else { boolean isOutputFolder = sourceLocation.sourceFolder.equals(sourceLocation.binaryFolder); final char[][] exclusionPatterns = isOutputFolder ? sourceLocation.exclusionPatterns : null; // ignore exclusionPatterns if output folder == another source folder... // not this one final char[][] inclusionPatterns = isOutputFolder ? sourceLocation.inclusionPatterns : null; // ignore inclusionPatterns if output folder == another source folder... // not this one sourceLocation.binaryFolder.accept( new IResourceProxyVisitor() { public boolean visit(IResourceProxy proxy) throws CoreException { if (proxy.getType() == IResource.FILE) { if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName( proxy.getName())) { IResource resource = proxy.requestResource(); if (exclusionPatterns != null || inclusionPatterns != null) if (Util.isExcluded( resource.getFullPath(), inclusionPatterns, exclusionPatterns, false)) return false; if (!resource.isDerived()) resource.setDerived(true, null); resource.delete(IResource.FORCE, null); } return false; } if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null if (Util.isExcluded(proxy.requestFullPath(), null, exclusionPatterns, true)) return false; BatchImageBuilder.this.notifier.checkCancel(); return true; } }, IResource.NONE); this.notifier.checkCancel(); } this.notifier.checkCancel(); } } else if (copyBack) { for (int i = 0, l = this.sourceLocations.length; i < l; i++) { ClasspathMultiDirectory sourceLocation = this.sourceLocations[i]; if (sourceLocation.hasIndependentOutputFolder) copyExtraResourcesBack(sourceLocation, false); this.notifier.checkCancel(); } } // GROOVY start LanguageSupportFactory.getEventHandler() .handle(this.javaBuilder.javaProject, "cleanOutputFolders"); // GROOVY end }
public void fill(Menu menu, int index) { final IFileRevision fileRevision = getFileRevision(); if (fileRevision == null) { return; } IEditorDescriptor defaultTextEditor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); // $NON-NLS-1$ IEditorDescriptor preferredEditor = Utils.getDefaultEditor(fileRevision); Object[] editors = Utils.getEditors(fileRevision); Collections.sort(Arrays.asList(editors), comparer); boolean defaultFound = false; // Check that we don't add it twice. This is possible // if the same editor goes to two mappings. ArrayList alreadyMapped = new ArrayList(); for (int i = 0; i < editors.length; i++) { IEditorDescriptor editor = (IEditorDescriptor) editors[i]; if (!alreadyMapped.contains(editor)) { createMenuItem(menu, editor, preferredEditor); if (defaultTextEditor != null && editor.getId().equals(defaultTextEditor.getId())) { defaultFound = true; } alreadyMapped.add(editor); } } // Only add a separator if there is something to separate if (editors.length > 0) { new MenuItem(menu, SWT.SEPARATOR); } // Add default editor. Check it if it is saved as the preference. if (!defaultFound && defaultTextEditor != null) { createMenuItem(menu, defaultTextEditor, preferredEditor); } // TODO : We might perhaps enable inplace and system external editors menu items /*// Add system editor IEditorDescriptor descriptor = registry .findEditor(IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID); final MenuItem systemEditorMenuItem = createMenuItem(menu, descriptor, preferredEditor); systemEditorMenuItem.setEnabled(false); // Add system in-place editor descriptor = registry .findEditor(IEditorRegistry.SYSTEM_INPLACE_EDITOR_ID); final MenuItem inPlaceEditorMenuItem = (descriptor != null) ? createMenuItem( menu, descriptor, preferredEditor) : null; if (inPlaceEditorMenuItem != null) inPlaceEditorMenuItem.setEnabled(false); Job job = new Job("updateOpenWithMenu") { //$NON-NLS-1$ protected IStatus run(IProgressMonitor monitor) { try { final boolean isFile = fileRevision.getStorage(monitor) instanceof IFile; Display.getDefault().asyncExec(new Runnable() { public void run() { if (inPlaceEditorMenuItem != null && !inPlaceEditorMenuItem.isDisposed()) inPlaceEditorMenuItem.setEnabled(isFile); if (!systemEditorMenuItem.isDisposed()) systemEditorMenuItem.setEnabled(isFile); } }); return Status.OK_STATUS; } catch (CoreException e) { return new Status(IStatus.WARNING, TeamUIPlugin.ID, null, e); } }; }; job.setSystem(true); job.schedule();*/ createDefaultMenuItem(menu, fileRevision); // add Other... menu item createOtherMenuItem(menu); }