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


Java CPListElement.createFromExisting方法代码示例

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


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

示例1: 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-Juno38,代码行数:23,代码来源:ResetAllOutputFoldersAction.java

示例2: configureJavadocLocation

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Shows the UI for configuring a javadoc location attribute of the classpath entry. <code>null</code> is returned
 * if the user cancels the dialog. The dialog does not apply any changes.
 *
 * @param shell The parent shell for the dialog.
 * @param initialEntry The entry to edit. The kind of the classpath entry must be either
 * <code>IClasspathEntry.CPE_LIBRARY</code> or <code>IClasspathEntry.CPE_VARIABLE</code>.
 * @return Returns the resulting classpath entry containing a potentially modified javadoc location attribute
 * The resulting entry can be used to replace the original entry on the classpath.
 * Note that the dialog does not make any changes on the passed entry nor on the classpath that
 * contains it.
 *
 * @since 3.1
 */
public static IClasspathEntry configureJavadocLocation(Shell shell, IClasspathEntry initialEntry) {
	if (initialEntry == null) {
		throw new IllegalArgumentException();
	}
	int entryKind= initialEntry.getEntryKind();
	if (entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE) {
		throw new IllegalArgumentException();
	}

	URL location= JavaUI.getLibraryJavadocLocation(initialEntry);
	JavadocLocationDialog dialog=  new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location);
	if (dialog.open() == Window.OK) {
		CPListElement element= CPListElement.createFromExisting(initialEntry, null);
		URL res= dialog.getResult();
		element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null);
		return element.getClasspathEntry();
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:BuildPathDialogAccess.java

示例3: createControl

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createControl(Composite parent) {
	IAdaptable adaptable= getElement();
	IJavaElement elem= (IJavaElement) adaptable.getAdapter(IJavaElement.class);
	try {
		if (elem instanceof IPackageFragmentRoot) {
			fProject= elem.getJavaProject();
			fElement= CPListElement.createFromExisting(((IPackageFragmentRoot) elem).getRawClasspathEntry(), fProject);
			fIsValidElement= fElement != null;
		} else {
			fIsValidElement= false;
			setDescription(PreferencesMessages.JavaCompilerPropertyPage_invalid_element_selection);
		}
	} catch (JavaModelException e) {
		fIsValidElement= false;
		setDescription(PreferencesMessages.JavaCompilerPropertyPage_invalid_element_selection);
	}
	super.createControl(parent);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaCompilerPropertyPage.java

示例4: getRunnable

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final URL javadocLocation, final IClasspathEntry entry, final IPath containerPath) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				IJavaProject project= elem.getJavaProject();
				if (elem instanceof IPackageFragmentRoot) {
					CPListElement cpElem= CPListElement.createFromExisting(entry, project);
					String loc= javadocLocation != null ? javadocLocation.toExternalForm() : null;
					cpElem.setAttribute(CPListElement.JAVADOC, loc);
					IClasspathEntry newEntry= cpElem.getClasspathEntry();
					String[] changedAttributes= { CPListElement.JAVADOC };
					BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, entry.getReferencingEntry() != null, monitor);
				} else {
					JavaUI.setProjectJavadocLocation(project, javadocLocation);
				}
			} catch (CoreException e) {
				throw new InvocationTargetException(e);
			}
		}
	};
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:22,代码来源:JavadocConfigurationPropertyPage.java

示例5: getRunnable

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
private static IRunnableWithProgress getRunnable(final Shell shell, final IJavaElement elem, final String nativeLibraryPath, final IClasspathEntry entry, final IPath containerPath, final boolean isReferencedEntry) {
	return new IRunnableWithProgress() {
		public void run(IProgressMonitor monitor) throws InvocationTargetException {
			try {
				IJavaProject project= elem.getJavaProject();
				if (elem instanceof IPackageFragmentRoot) {
					CPListElement cpElem= CPListElement.createFromExisting(entry, project);
					cpElem.setAttribute(CPListElement.NATIVE_LIB_PATH, nativeLibraryPath);
					IClasspathEntry newEntry= cpElem.getClasspathEntry();
					String[] changedAttributes= { CPListElement.NATIVE_LIB_PATH };
					BuildPathSupport.modifyClasspathEntry(shell, newEntry, changedAttributes, project, containerPath, isReferencedEntry,  monitor);
				}
			} catch (CoreException e) {
				throw new InvocationTargetException(e);
			}
		}
	};
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:NativeLibrariesPropertyPage.java

示例6: setURL

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
public void setURL(URL url, IProgressMonitor monitor) throws CoreException {
	if (isProjectRef()) {
		JavaUI.setProjectJavadocLocation(fProject, url);
	} else {
		CPListElement element= CPListElement.createFromExisting(fClasspathEntry, fProject);
		String location= url != null ? url.toExternalForm() : null;
		element.setAttribute(CPListElement.JAVADOC, location);
		String[] changedAttributes= { CPListElement.JAVADOC };
		BuildPathSupport.modifyClasspathEntry(null, element.getClasspathEntry(), changedAttributes, fProject, fContainerPath, fClasspathEntry.getReferencingEntry() != null, monitor);
		fClasspathEntry= element.getClasspathEntry();
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:JavadocLinkRef.java

示例7: 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-Juno38,代码行数:36,代码来源:DialogPackageExplorer.java

示例8: createWizard

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
private EditFilterWizard createWizard() throws CoreException {
	IJavaProject javaProject= null;
	Object firstElement= getSelectedElements().get(0);
	if (firstElement instanceof IJavaProject) {
		javaProject= (IJavaProject)firstElement;
	} else {
		javaProject= ((IPackageFragmentRoot)firstElement).getJavaProject();
	}
	CPListElement[] existingEntries= CPListElement.createFromExisting(javaProject);
	CPListElement elementToEdit= findElement((IJavaElement)firstElement, existingEntries);
	return new EditFilterWizard(existingEntries, elementToEdit, getOutputLocation(javaProject));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:13,代码来源:EditFilterAction.java

示例9: getConvertedEntry

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
private static IClasspathEntry getConvertedEntry(IClasspathEntry entry, IJavaProject project, Map<IPath, String> oldLocationMap) {
	IPath path= null;
	switch (entry.getEntryKind()) {
		case IClasspathEntry.CPE_SOURCE:
		case IClasspathEntry.CPE_PROJECT:
			return null;
		case IClasspathEntry.CPE_CONTAINER:
			convertContainer(entry, project, oldLocationMap);
			return null;
		case IClasspathEntry.CPE_LIBRARY:
			path= entry.getPath();
			break;
		case IClasspathEntry.CPE_VARIABLE:
			path= JavaCore.getResolvedVariablePath(entry.getPath());
			break;
		default:
			return null;
	}
	if (path == null) {
		return null;
	}
	IClasspathAttribute[] extraAttributes= entry.getExtraAttributes();
	for (int i= 0; i < extraAttributes.length; i++) {
		if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(extraAttributes[i].getName())) {
			return null;
		}
	}
	String libraryJavadocLocation= oldLocationMap.get(path);
	if (libraryJavadocLocation != null) {
		CPListElement element= CPListElement.createFromExisting(entry, project);
		element.setAttribute(CPListElement.JAVADOC, libraryJavadocLocation);
		return element.getClasspathEntry();
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:36,代码来源:JavaDocLocations.java

示例10: run

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
@Override
public void run() {
	Shell shell= getShell();

	try {
		IJavaProject javaProject= (IJavaProject)getSelectedElements().get(0);

		CPListElement newEntrie= new CPListElement(javaProject, IClasspathEntry.CPE_SOURCE);
           CPListElement[] existing= CPListElement.createFromExisting(javaProject);
           boolean isProjectSrcFolder= CPListElement.isProjectSourceFolder(existing, javaProject);

		AddSourceFolderWizard wizard= new AddSourceFolderWizard(existing, newEntrie, getOutputLocation(javaProject), true, false, false, isProjectSrcFolder, isProjectSrcFolder);
		wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(javaProject));

		WizardDialog dialog= new WizardDialog(shell, wizard);
		PixelConverter converter= new PixelConverter(JFaceResources.getDialogFont());
		dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
		dialog.create();
		int res= dialog.open();
		if (res == Window.OK) {

			BuildpathDelta delta= new BuildpathDelta(getToolTipText());

			ArrayList<CPListElement> newEntries= wizard.getExistingEntries();
			delta.setNewEntries(newEntries.toArray(new CPListElement[newEntries.size()]));

			IResource resource= wizard.getCreatedElement().getCorrespondingResource();
			delta.addCreatedResource(resource);

			delta.setDefaultOutputLocation(wizard.getOutputLocation());

			informListeners(delta);

			selectAndReveal(new StructuredSelection(wizard.getCreatedElement()));
		}

		notifyResult(res == Window.OK);
	} catch (CoreException e) {
		String title= NewWizardMessages.AbstractOpenWizardAction_createerror_title;
		String message= NewWizardMessages.AbstractOpenWizardAction_createerror_message;
		ExceptionHandler.handle(e, shell, title, message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:CreateLinkedSourceFolderAction.java

示例11: run

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
@Override
public void run() {
	Shell shell= getShell();

	try {
		IJavaProject javaProject= (IJavaProject)getSelectedElements().get(0);

           CPListElement newEntrie= new CPListElement(javaProject, IClasspathEntry.CPE_SOURCE);
           CPListElement[] existing= CPListElement.createFromExisting(javaProject);
           boolean isProjectSrcFolder= CPListElement.isProjectSourceFolder(existing, javaProject);

           AddSourceFolderWizard wizard= new AddSourceFolderWizard(existing, newEntrie, getOutputLocation(javaProject), false, false, false, isProjectSrcFolder, isProjectSrcFolder);
		wizard.init(PlatformUI.getWorkbench(), new StructuredSelection(javaProject));

		WizardDialog dialog= new WizardDialog(shell, wizard);
		PixelConverter converter= new PixelConverter(JFaceResources.getDialogFont());
		dialog.setMinimumPageSize(converter.convertWidthInCharsToPixels(70), converter.convertHeightInCharsToPixels(20));
		dialog.create();
		int res= dialog.open();
		if (res == Window.OK) {
			BuildpathDelta delta= new BuildpathDelta(getToolTipText());

			ArrayList<CPListElement> newEntries= wizard.getExistingEntries();
			delta.setNewEntries(newEntries.toArray(new CPListElement[newEntries.size()]));

			IResource resource= wizard.getCreatedElement().getCorrespondingResource();
			delta.addCreatedResource(resource);

			delta.setDefaultOutputLocation(wizard.getOutputLocation());

			informListeners(delta);

			selectAndReveal(new StructuredSelection(wizard.getCreatedElement()));
		}

		notifyResult(res == Window.OK);
	} catch (CoreException e) {
		String title= NewWizardMessages.AbstractOpenWizardAction_createerror_title;
		String message= NewWizardMessages.AbstractOpenWizardAction_createerror_message;
		ExceptionHandler.handle(e, shell, title, message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:43,代码来源:CreateSourceFolderAction.java

示例12: getClasspathEntry

import org.eclipse.jdt.internal.ui.wizards.buildpaths.CPListElement; //导入方法依赖的package包/类
/**
 * Try to find the corresponding and modified <code>CPListElement</code> for the root
 * in the list of elements and return it.
 * If no one can be found, the roots <code>ClasspathEntry</code> is converted to a
 * <code>CPListElement</code> and returned.
 *
 * @param elements a list of <code>CPListElements</code>
 * @param root the root to find the <code>ClasspathEntry</code> for represented by
 * a <code>CPListElement</code>
 * @return the <code>CPListElement</code> found in the list (matching by using the path) or
 * the roots own <code>IClasspathEntry</code> converted to a <code>CPListElement</code>.
 * @throws JavaModelException
 */
public static CPListElement getClasspathEntry(List<CPListElement> elements, IPackageFragmentRoot root) throws JavaModelException {
	IClasspathEntry entry= root.getRawClasspathEntry();
	for (int i= 0; i < elements.size(); i++) {
		CPListElement element= elements.get(i);
		if (element.getPath().equals(root.getPath()) && element.getEntryKind() == entry.getEntryKind())
			return elements.get(i);
	}
	CPListElement newElement= CPListElement.createFromExisting(entry, root.getJavaProject());
	elements.add(newElement);
	return newElement;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:ClasspathModifier.java


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