本文整理汇总了Java中org.eclipse.jdt.internal.corext.util.JavaModelUtil.getClasspathEntry方法的典型用法代码示例。如果您正苦于以下问题:Java JavaModelUtil.getClasspathEntry方法的具体用法?Java JavaModelUtil.getClasspathEntry怎么用?Java JavaModelUtil.getClasspathEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.corext.util.JavaModelUtil
的用法示例。
在下文中一共展示了JavaModelUtil.getClasspathEntry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendVariableLabel
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private boolean appendVariableLabel(IPackageFragmentRoot root, long flags) {
try {
IClasspathEntry rawEntry= root.getRawClasspathEntry();
if (rawEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
IClasspathEntry entry= JavaModelUtil.getClasspathEntry(root);
if (entry.getReferencingEntry() != null) {
return false; // not the variable entry itself, but a referenced entry
}
IPath path= rawEntry.getPath().makeRelative();
if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
int segements= path.segmentCount();
if (segements > 0) {
fBuilder.append(path.segment(segements - 1));
if (segements > 1) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
fBuilder.append(path.removeLastSegments(1).toOSString());
}
} else {
fBuilder.append(path.toString());
}
} else {
fBuilder.append(path.toString());
}
fBuilder.append(JavaElementLabels.CONCAT_STRING);
if (root.isExternal()) {
fBuilder.append(root.getPath().toOSString());
} else {
fBuilder.append(root.getPath().makeRelative().toString());
}
return true;
}
} catch (JavaModelException e) {
// problems with class path, ignore (bug 202792)
return false;
}
return false;
}
示例2: appendExternalArchiveLabel
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void appendExternalArchiveLabel(IPackageFragmentRoot root, long flags) {
IPath path;
IClasspathEntry classpathEntry= null;
try {
classpathEntry= JavaModelUtil.getClasspathEntry(root);
IPath rawPath= classpathEntry.getPath();
if (classpathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && !rawPath.isAbsolute()) {
path= rawPath;
} else {
path= root.getPath();
}
} catch (JavaModelException e) {
path= root.getPath();
}
if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
int segments= path.segmentCount();
if (segments > 0) {
fBuilder.append(path.segment(segments - 1));
if (segments > 1 || path.getDevice() != null) {
fBuilder.append(JavaElementLabels.CONCAT_STRING);
fBuilder.append(path.removeLastSegments(1).toOSString());
}
if (classpathEntry != null) {
IClasspathEntry referencingEntry= classpathEntry.getReferencingEntry();
if (referencingEntry != null) {
fBuilder.append(NLS.bind(" (from {0} of {1})", new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
}
}
} else {
fBuilder.append(path.toOSString());
}
} else {
fBuilder.append(path.toOSString());
}
}
示例3: appendExternalArchiveLabel
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void appendExternalArchiveLabel(IPackageFragmentRoot root, long flags) {
IPath path;
IClasspathEntry classpathEntry= null;
try {
classpathEntry= JavaModelUtil.getClasspathEntry(root);
IPath rawPath= classpathEntry.getPath();
if (classpathEntry.getEntryKind() != IClasspathEntry.CPE_CONTAINER && !rawPath.isAbsolute())
path= rawPath;
else
path= root.getPath();
} catch (JavaModelException e) {
path= root.getPath();
}
if (getFlag(flags, JavaElementLabels.REFERENCED_ROOT_POST_QUALIFIED)) {
int segements= path.segmentCount();
if (segements > 0) {
fBuffer.append(path.segment(segements - 1));
int offset= fBuffer.length();
if (segements > 1 || path.getDevice() != null) {
fBuffer.append(JavaElementLabels.CONCAT_STRING);
fBuffer.append(path.removeLastSegments(1).toOSString());
}
if (classpathEntry != null) {
IClasspathEntry referencingEntry= classpathEntry.getReferencingEntry();
if (referencingEntry != null) {
fBuffer.append(Messages.format(JavaUIMessages.JavaElementLabels_onClassPathOf, new Object[] { Name.CLASS_PATH.toString(), referencingEntry.getPath().lastSegment() }));
}
}
if (getFlag(flags, JavaElementLabels.COLORIZE)) {
fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
}
} else {
fBuffer.append(path.toOSString());
}
} else {
fBuffer.append(path.toOSString());
}
}
示例4: createControl
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
IJavaElement elem= getJavaElement();
try {
if (elem instanceof IPackageFragmentRoot && ((IPackageFragmentRoot) elem).getKind() == IPackageFragmentRoot.K_BINARY) {
IPackageFragmentRoot root= (IPackageFragmentRoot) elem;
IClasspathEntry entry= JavaModelUtil.getClasspathEntry(root);
if (entry == null) {
fIsValidElement= false;
setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsIncorrectElement_description);
} else {
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
fContainerPath= entry.getPath();
fEntry= handleContainerEntry(fContainerPath, elem.getJavaProject(), root.getPath());
fIsValidElement= fEntry != null;
} else {
fContainerPath= null;
fEntry= entry;
fIsValidElement= true;
setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsPackageFragmentRoot_description);
}
}
} else if (elem instanceof IJavaProject) {
fIsValidElement= true;
setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsJavaProject_description);
} else {
fIsValidElement= false;
setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsIncorrectElement_description);
}
} catch (JavaModelException e) {
fIsValidElement= false;
setDescription(PreferencesMessages.JavadocConfigurationPropertyPage_IsIncorrectElement_description);
}
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaHelpContextIds.JAVADOC_CONFIGURATION_PROPERTY_PAGE);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:42,代码来源:JavadocConfigurationPropertyPage.java
示例5: createControl
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
/**
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
IJavaElement elem= getJavaElement();
try {
if (elem instanceof IPackageFragmentRoot) {
IPackageFragmentRoot root= (IPackageFragmentRoot) elem;
IClasspathEntry entry= JavaModelUtil.getClasspathEntry(root);
if (entry == null) {
fIsValidElement= false;
setDescription(PreferencesMessages.NativeLibrariesPropertyPage_invalidElementSelection_desription);
} else {
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
fContainerPath= entry.getPath();
fEntry= handleContainerEntry(fContainerPath, elem.getJavaProject(), root.getPath());
fIsValidElement= fEntry != null && !fIsReadOnly;
} else {
fContainerPath= null;
fEntry= entry;
fIsValidElement= true;
}
}
} else {
fIsValidElement= false;
setDescription(PreferencesMessages.NativeLibrariesPropertyPage_invalidElementSelection_desription);
}
} catch (JavaModelException e) {
fIsValidElement= false;
setDescription(PreferencesMessages.NativeLibrariesPropertyPage_invalidElementSelection_desription);
}
super.createControl(parent);
}
示例6: canHandle
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
@Override
protected boolean canHandle(IStructuredSelection elements) {
if (elements.size() == 0)
return false;
try {
for (Iterator<?> iter= elements.iterator(); iter.hasNext();) {
Object element= iter.next();
if (element instanceof IJavaProject) {
IJavaProject project= (IJavaProject)element;
if (!ClasspathModifier.isSourceFolder(project))
return false;
} else if (element instanceof IPackageFragmentRoot) {
IClasspathEntry entry= JavaModelUtil.getClasspathEntry((IPackageFragmentRoot) element);
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER)
return false;
if (entry.getReferencingEntry() != null)
return false;
} else if (element instanceof ClassPathContainer) {
return true;
} else {
return false;
}
}
return true;
} catch (JavaModelException e) {
}
return false;
}
示例7: createSourceAttachmentControls
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private void createSourceAttachmentControls(Composite composite, IPackageFragmentRoot root) throws JavaModelException {
IClasspathEntry entry;
try {
entry= JavaModelUtil.getClasspathEntry(root);
} catch (JavaModelException ex) {
if (ex.isDoesNotExist())
entry= null;
else
throw ex;
}
IPath containerPath= null;
if (entry == null || root.getKind() != IPackageFragmentRoot.K_BINARY) {
createLabel(composite, Messages.format(JavaEditorMessages.SourceAttachmentForm_message_noSource, BasicElementLabels.getFileName( fFile)));
return;
}
IJavaProject jproject= root.getJavaProject();
boolean canEditEncoding= true;
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
containerPath= entry.getPath();
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject);
if (initializer == null || container == null) {
createLabel(composite, Messages.format(JavaEditorMessages.ClassFileEditor_SourceAttachmentForm_cannotconfigure, BasicElementLabels.getPathLabel(containerPath, false)));
return;
}
String containerName= container.getDescription();
IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject);
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
createLabel(composite, Messages.format(JavaEditorMessages.ClassFileEditor_SourceAttachmentForm_notsupported, containerName));
return;
}
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) {
createLabel(composite, Messages.format(JavaEditorMessages.ClassFileEditor_SourceAttachmentForm_readonly, containerName));
return;
}
IStatus attributeStatus= initializer.getAttributeStatus(containerPath, jproject, IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING);
canEditEncoding= !(attributeStatus.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED || attributeStatus.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY);
entry= JavaModelUtil.findEntryInContainer(container, root.getPath());
Assert.isNotNull(entry);
}
Button button;
IPath path= entry.getSourceAttachmentPath();
if (path == null || path.isEmpty()) {
String rootLabel= JavaElementLabels.getElementLabel(root, JavaElementLabels.ALL_DEFAULT);
createLabel(composite, Messages.format(JavaEditorMessages.SourceAttachmentForm_message_noSourceAttachment, rootLabel));
createLabel(composite, JavaEditorMessages.SourceAttachmentForm_message_pressButtonToAttach);
createLabel(composite, null);
button= createButton(composite, JavaEditorMessages.SourceAttachmentForm_button_attachSource);
} else {
createLabel(composite, Messages.format(JavaEditorMessages.SourceAttachmentForm_message_noSourceInAttachment, BasicElementLabels.getFileName(fFile)));
createLabel(composite, JavaEditorMessages.SourceAttachmentForm_message_pressButtonToChange);
createLabel(composite, null);
button= createButton(composite, JavaEditorMessages.SourceAttachmentForm_button_changeAttachedSource);
}
button.addSelectionListener(getButtonListener(entry, containerPath, jproject, canEditEncoding));
}
示例8: createPageContent
import org.eclipse.jdt.internal.corext.util.JavaModelUtil; //导入方法依赖的package包/类
private Control createPageContent(Composite composite) {
try {
fContainerPath= null;
fEntry= null;
fRoot= getJARPackageFragmentRoot();
if (fRoot == null || fRoot.getKind() != IPackageFragmentRoot.K_BINARY) {
return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message, null);
}
IPath containerPath= null;
IJavaProject jproject= fRoot.getJavaProject();
IClasspathEntry entry= JavaModelUtil.getClasspathEntry(fRoot);
boolean canEditEncoding= true;
if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
containerPath= entry.getPath();
ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0));
IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, jproject);
if (initializer == null || container == null) {
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_invalid_container, BasicElementLabels.getPathLabel(containerPath, false)), fRoot);
}
String containerName= container.getDescription();
IStatus status= initializer.getSourceAttachmentStatus(containerPath, jproject);
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) {
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_not_supported, containerName), null);
}
if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) {
return createMessageContent(composite, Messages.format(PreferencesMessages.SourceAttachmentPropertyPage_read_only, containerName), fRoot);
}
IStatus attributeStatus= initializer.getAttributeStatus(containerPath, jproject, IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING);
canEditEncoding= !(attributeStatus.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED || attributeStatus.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY);
entry= JavaModelUtil.findEntryInContainer(container, fRoot.getPath());
}
fContainerPath= containerPath;
fEntry= entry;
fSourceAttachmentBlock= new SourceAttachmentBlock(this, entry, canEditEncoding);
return fSourceAttachmentBlock.createControl(composite);
} catch (CoreException e) {
JavaPlugin.log(e);
return createMessageContent(composite, PreferencesMessages.SourceAttachmentPropertyPage_noarchive_message, null);
}
}