当前位置: 首页>>代码示例>>Java>>正文


Java CPListElement.getAttribute方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java CPListElement.getAttribute方法的具体用法?Java CPListElement.getAttribute怎么用?Java CPListElement.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement的用法示例。


在下文中一共展示了CPListElement.getAttribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: exclude

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Exclude an element with a given name and absolute path
 * from the build path.
 *
 * @param name the name of the element to be excluded
 * @param fullPath the absolute path of the element
 * @param entry the build path entry to be modified
 * @param project the Java project
 * @param monitor progress monitor, can be <code>null</code>
 * @return a <code>IResource</code> corresponding to the excluded element
 * @throws JavaModelException
 */
private static IResource exclude(String name, IPath fullPath, CPListElement entry, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
	if (monitor == null)
		monitor= new NullProgressMonitor();
	IResource result;
	try {
		monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_Excluding, 6);
		IPath[] excludedPath= (IPath[]) entry.getAttribute(CPListElement.EXCLUSION);
		IPath[] newExcludedPath= new IPath[excludedPath.length + 1];
		name= completeName(name);
		IPath path= new Path(name);
		if (!contains(path, excludedPath, new SubProgressMonitor(monitor, 2))) {
			System.arraycopy(excludedPath, 0, newExcludedPath, 0, excludedPath.length);
			newExcludedPath[excludedPath.length]= path;
			entry.setAttribute(CPListElement.EXCLUSION, newExcludedPath);
			entry.setAttribute(CPListElement.INCLUSION, remove(path, (IPath[]) entry.getAttribute(CPListElement.INCLUSION), new SubProgressMonitor(monitor, 4)));
		}
		result= fullPath == null ? null : getResource(fullPath, project);
	} finally {
		monitor.done();
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:35,代码来源:ClasspathModifier.java

示例2: resetFilters

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Resets inclusion and exclusion filters for the given
 * <code>IJavaElement</code>
 *
 * @param element element to reset it's filters
 * @param entry the <code>CPListElement</code> to reset its filters for
 * @param project the Java project
 * @param monitor progress monitor, can be <code>null</code>
 * @throws JavaModelException
 */
public static void resetFilters(IJavaElement element, CPListElement entry, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
	if (monitor == null)
		monitor= new NullProgressMonitor();
	try {
		monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ResetFilters, 3);

		List<Path> exclusionList= getFoldersOnCP(element.getPath(), project, new SubProgressMonitor(monitor, 2));
		IPath outputLocation= (IPath) entry.getAttribute(CPListElement.OUTPUT);
		if (outputLocation != null) {
			IPath[] exclusionPatterns= (IPath[]) entry.getAttribute(CPListElement.EXCLUSION);
			if (contains(new Path(completeName(outputLocation.lastSegment())), exclusionPatterns, null)) {
				exclusionList.add(new Path(completeName(outputLocation.lastSegment())));
			}
		}
		IPath[] exclusions= exclusionList.toArray(new IPath[exclusionList.size()]);

		entry.setAttribute(CPListElement.INCLUSION, new IPath[0]);
		entry.setAttribute(CPListElement.EXCLUSION, exclusions);
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:33,代码来源:ClasspathModifier.java

示例3: resetOutputFolders

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
private List<Object> resetOutputFolders(IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
	if (monitor == null)
		monitor= new NullProgressMonitor();
	try {
		IPackageFragmentRoot[] roots= project.getPackageFragmentRoots();
		monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_ResetOutputFolder, roots.length + 10);
		List<CPListElementAttribute> entries= new ArrayList<CPListElementAttribute>();
		for (int i= 0; i < roots.length; i++) {
			monitor.worked(1);
			IPackageFragmentRoot root= roots[i];
			if (root.isArchive() || root.isExternal())
				continue;
			IClasspathEntry entry= root.getRawClasspathEntry();
			CPListElement element= CPListElement.createFromExisting(entry, project);
			CPListElementAttribute outputFolder= new CPListElementAttribute(element, CPListElement.OUTPUT, element.getAttribute(CPListElement.OUTPUT), true);
			entries.add(outputFolder);
		}
		return reset(entries, project, new SubProgressMonitor(monitor, 10));
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:ResetAllOutputFoldersAction.java

示例4: setOutputLocation

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
public static BuildpathDelta setOutputLocation(CPListElement elementToChange, IPath outputPath, boolean allowInvalidCP, CPJavaProject cpProject) throws CoreException {
	BuildpathDelta result= new BuildpathDelta(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_EditOutput_tooltip);

	IJavaProject javaProject= cpProject.getJavaProject();
	IProject project= javaProject.getProject();
	IWorkspace workspace= project.getWorkspace();

	IPath projectPath= project.getFullPath();

	if (!allowInvalidCP && cpProject.getDefaultOutputLocation().segmentCount() == 1 && !projectPath.equals(elementToChange.getPath())) {
		String outputFolderName= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME);
		cpProject.setDefaultOutputLocation(cpProject.getDefaultOutputLocation().append(outputFolderName));
		List<CPListElement> existingEntries= cpProject.getCPListElements();
		CPListElement elem= ClasspathModifier.getListElement(javaProject.getPath(), existingEntries);
           if (elem != null) {
           	existingEntries.remove(elem);
           	result.removeEntry(elem);
           }
	}

	if (outputPath != null)
		exclude(outputPath, cpProject.getCPListElements(), new ArrayList<CPListElement>(), cpProject.getJavaProject(), null);

	IPath oldOutputLocation= (IPath)elementToChange.getAttribute(CPListElement.OUTPUT);
       if (oldOutputLocation != null && oldOutputLocation.segmentCount() > 1 && !oldOutputLocation.equals(cpProject.getDefaultOutputLocation())) {
		include(cpProject, oldOutputLocation);
       	result.addDeletedResource(workspace.getRoot().getFolder(oldOutputLocation));
       }
	elementToChange.setAttribute(CPListElement.OUTPUT, outputPath);

	result.setDefaultOutputLocation(cpProject.getDefaultOutputLocation());
	result.setNewEntries(cpProject.getCPListElements().toArray(new CPListElement[cpProject.getCPListElements().size()]));
	if (outputPath != null && outputPath.segmentCount() > 1) {
		result.addCreatedResource(workspace.getRoot().getFolder(outputPath));
	}

	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:39,代码来源:ClasspathModifier.java

示例5: getChildren

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
       * Get the children of the current <code>element</code>. If the
       * element is of type <code>IPackageFragmentRoot</code> and
       * displaying the output folders is selected, then an icon for
       * the output folder is created and displayed additionally.
       *
       * @param element the current element to get the children from
       * @return an array of children
       */
      @Override
public Object[] getChildren(Object element) {
          Object[] children= super.getChildren(element);
          if (((element instanceof IPackageFragmentRoot && !ClasspathModifier.isInExternalOrArchive((IPackageFragmentRoot) element)) ||
                  (element instanceof IJavaProject && fCurrJProject.isOnClasspath(fCurrJProject))) && fShowOutputFolders) {
              try {
                  IClasspathEntry entry;
                  if (element instanceof IPackageFragmentRoot)
                      entry= ((IPackageFragmentRoot) element).getRawClasspathEntry();
                  else
                      entry= ClasspathModifier.getClasspathEntryFor(fCurrJProject.getPath(), fCurrJProject, IClasspathEntry.CPE_SOURCE);
                  CPListElement parent= CPListElement.createFromExisting(entry, fCurrJProject);
                  CPListElementAttribute outputFolder= new CPListElementAttribute(parent, CPListElement.OUTPUT,
                          parent.getAttribute(CPListElement.OUTPUT), true);
                  Object[] extendedChildren= new Object[children.length + 1];
                  System.arraycopy(children, 0, extendedChildren, 1, children.length);
                  extendedChildren[0]= outputFolder;
                  return extendedChildren;
              } catch (JavaModelException e) {
                  JavaPlugin.log(e);
              }
              return null;
          }
          else
              return children;
      }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:36,代码来源:DialogPackageExplorer.java

示例6: doUpdateUI

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
private void doUpdateUI() {
      fPackageExplorer.setInput(fJavaProject);

boolean useFolderOutputs= false;
List<CPListElement> cpelements= fClassPathList.getElements();
for (int i= 0; i < cpelements.size() && !useFolderOutputs; i++) {
	CPListElement cpe= cpelements.get(i);
	if (cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
		if (cpe.getAttribute(CPListElement.OUTPUT) != null) {
			useFolderOutputs= true;
		}
	}
}
fUseFolderOutputs.setSelection(useFolderOutputs);
  }
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:NewSourceContainerWorkbookPage.java

示例7: removeFilters

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Remove <code>path</code> from inclusion/exlusion filters in all <code>existingEntries</code>
 *
 * @param path the path to remove
 * @param project the Java project
 * @param existingEntries a list of <code>CPListElement</code> representing the build path
 * entries of the project.
 * @return returns a <code>List</code> of <code>CPListElement</code> of modified elements, not null.
 */
public static List<CPListElement> removeFilters(IPath path, IJavaProject project, List<CPListElement> existingEntries) {
	if (path == null)
		return Collections.emptyList();

	IPath projPath= project.getPath();
	if (projPath.isPrefixOf(path)) {
		path= path.removeFirstSegments(projPath.segmentCount()).addTrailingSeparator();
	}

	List<CPListElement> result= new ArrayList<CPListElement>();
	for (Iterator<CPListElement> iter= existingEntries.iterator(); iter.hasNext();) {
		CPListElement element= iter.next();
		boolean hasChange= false;
		IPath[] exlusions= (IPath[])element.getAttribute(CPListElement.EXCLUSION);
		if (exlusions != null) {
			List<IPath> exlusionList= new ArrayList<IPath>(exlusions.length);
			for (int i= 0; i < exlusions.length; i++) {
				if (!exlusions[i].equals(path)) {
					exlusionList.add(exlusions[i]);
				} else {
					hasChange= true;
				}
			}
			element.setAttribute(CPListElement.EXCLUSION, exlusionList.toArray(new IPath[exlusionList.size()]));
		}

		IPath[] inclusion= (IPath[])element.getAttribute(CPListElement.INCLUSION);
		if (inclusion != null) {
			List<IPath> inclusionList= new ArrayList<IPath>(inclusion.length);
			for (int i= 0; i < inclusion.length; i++) {
				if (!inclusion[i].equals(path)) {
					inclusionList.add(inclusion[i]);
				} else {
					hasChange= true;
				}
			}
			element.setAttribute(CPListElement.INCLUSION, inclusionList.toArray(new IPath[inclusionList.size()]));
		}
		if (hasChange) {
			result.add(element);
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:54,代码来源:ClasspathModifier.java

示例8: unExclude

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Inverse operation to <code>exclude</code>.
 * The resource removed from it's fragment roots exlusion filter.
 *
 * Note: the <code>IJavaElement</code>'s fragment (if there is one)
 * is not allowed to be excluded! However, inclusion (or simply no
 * filter) on the parent fragment is allowed.
 *
 * @param resource the resource to be unexcluded
 * @param entry the <code>CPListElement</code> representing the
 * <code>IClasspathEntry</code> of the resource's root.
 * @param project the Java project
 * @param monitor progress monitor, can be <code>null</code>
 * @throws JavaModelException
 *
 */
public static void unExclude(IResource resource, CPListElement entry, IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
	if (monitor == null)
		monitor= new NullProgressMonitor();
	try {
		monitor.beginTask(NewWizardMessages.ClasspathModifier_Monitor_RemoveExclusion, 10);
		String name= getName(resource.getFullPath(), entry.getPath());
		IPath[] excludedPath= (IPath[]) entry.getAttribute(CPListElement.EXCLUSION);
		IPath[] newExcludedPath= remove(new Path(completeName(name)), excludedPath, new SubProgressMonitor(monitor, 3));
		entry.setAttribute(CPListElement.EXCLUSION, newExcludedPath);
	} finally {
		monitor.done();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:ClasspathModifier.java

示例9: resetOutputFolder

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Reset the output folder for the given entry to the default output folder
 *
 * @param entry the <code>CPListElement</code> to be edited
 * @param project the Java project
 * @return an attribute representing the modified output folder
 * @throws JavaModelException
 */
public static CPListElementAttribute resetOutputFolder(CPListElement entry, IJavaProject project) throws JavaModelException {
	entry.setAttribute(CPListElement.OUTPUT, null);
	CPListElementAttribute outputFolder= new CPListElementAttribute(entry, CPListElement.OUTPUT, entry.getAttribute(CPListElement.OUTPUT), true);
	return outputFolder;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:ClasspathModifier.java


注:本文中的org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。