List of usage examples for org.eclipse.jdt.core IClasspathContainer getDescription
String getDescription();
From source file:com.codenvy.ide.ext.java.server.internal.core.JavaModelStatus.java
License:Open Source License
/** * Returns the message that is relevant to the code of this status. *//*from w ww.ja v a 2 s . c o m*/ public String getMessage() { Throwable exception = getException(); if (exception == null) { switch (getCode()) { case CORE_EXCEPTION: return Messages.status_coreException; case BUILDER_INITIALIZATION_ERROR: return Messages.build_initializationError; case BUILDER_SERIALIZATION_ERROR: return Messages.build_serializationError; case DEVICE_PATH: return Messages.bind(Messages.status_cannotUseDeviceOnPath, getPath().toString()); case DOM_EXCEPTION: return Messages.status_JDOMError; case ELEMENT_DOES_NOT_EXIST: return Messages.bind(Messages.element_doesNotExist, ((JavaElement) this.elements[0]).toStringWithAncestors()); case ELEMENT_NOT_ON_CLASSPATH: return Messages.bind(Messages.element_notOnClasspath, ((JavaElement) this.elements[0]).toStringWithAncestors()); case EVALUATION_ERROR: return Messages.bind(Messages.status_evaluationError, this.string); case INDEX_OUT_OF_BOUNDS: return Messages.status_indexOutOfBounds; case INVALID_CONTENTS: return Messages.status_invalidContents; case INVALID_DESTINATION: return Messages.bind(Messages.status_invalidDestination, ((JavaElement) this.elements[0]).toStringWithAncestors()); case INVALID_ELEMENT_TYPES: StringBuffer buff = new StringBuffer(Messages.operation_notSupported); for (int i = 0; i < this.elements.length; i++) { if (i > 0) { buff.append(", "); //$NON-NLS-1$ } buff.append(((JavaElement) this.elements[i]).toStringWithAncestors()); } return buff.toString(); case INVALID_NAME: return Messages.bind(Messages.status_invalidName, this.string); case INVALID_PACKAGE: return Messages.bind(Messages.status_invalidPackage, this.string); case INVALID_PATH: if (this.string != null) { return this.string; } else { return Messages.bind(Messages.status_invalidPath, new String[] { getPath() == null ? "null" : getPath().toString() } //$NON-NLS-1$ ); } case INVALID_PROJECT: return Messages.bind(Messages.status_invalidProject, this.string); case INVALID_RESOURCE: return Messages.bind(Messages.status_invalidResource, this.string); case INVALID_RESOURCE_TYPE: return Messages.bind(Messages.status_invalidResourceType, this.string); case INVALID_SIBLING: if (this.string != null) { return Messages.bind(Messages.status_invalidSibling, this.string); } else { return Messages.bind(Messages.status_invalidSibling, ((JavaElement) this.elements[0]).toStringWithAncestors()); } case IO_EXCEPTION: return Messages.status_IOException; case NAME_COLLISION: if (this.elements != null && this.elements.length > 0) { IJavaElement element = this.elements[0]; if (element instanceof org.eclipse.jdt.internal.core.PackageFragment && ((PackageFragment) element).isDefaultPackage()) { return Messages.operation_cannotRenameDefaultPackage; } } if (this.string != null) { return this.string; } else { return Messages.bind(Messages.status_nameCollision, ""); //$NON-NLS-1$ } case NO_ELEMENTS_TO_PROCESS: return Messages.operation_needElements; case NULL_NAME: return Messages.operation_needName; case NULL_PATH: return Messages.operation_needPath; case NULL_STRING: return Messages.operation_needString; case PATH_OUTSIDE_PROJECT: return Messages.bind(Messages.operation_pathOutsideProject, new String[] { this.string, ((JavaElement) this.elements[0]).toStringWithAncestors() }); case READ_ONLY: IJavaElement element = this.elements[0]; String name = element.getElementName(); if (element instanceof IPackageFragment && name.equals(IPackageFragment.DEFAULT_PACKAGE_NAME)) { return Messages.status_defaultPackageReadOnly; } return Messages.bind(Messages.status_readOnly, name); case RELATIVE_PATH: return Messages.bind(Messages.operation_needAbsolutePath, getPath().toString()); case TARGET_EXCEPTION: return Messages.status_targetException; case UPDATE_CONFLICT: return Messages.status_updateConflict; case NO_LOCAL_CONTENTS: return Messages.bind(Messages.status_noLocalContents, getPath().toString()); case CP_CONTAINER_PATH_UNBOUND: IJavaProject javaProject = (IJavaProject) this.elements[0]; ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(this.path.segment(0)); String description = null; if (initializer != null) description = initializer.getDescription(this.path, javaProject); if (description == null) description = this.path.makeRelative().toString(); return Messages.bind(Messages.classpath_unboundContainerPath, new String[] { description, javaProject.getElementName() }); case INVALID_CP_CONTAINER_ENTRY: javaProject = (IJavaProject) this.elements[0]; IClasspathContainer container = null; description = null; try { container = JavaCore.getClasspathContainer(this.path, javaProject); } catch (JavaModelException e) { // project doesn't exist: ignore } if (container == null) { initializer = JavaCore.getClasspathContainerInitializer(this.path.segment(0)); if (initializer != null) description = initializer.getDescription(this.path, javaProject); } else { description = container.getDescription(); } if (description == null) description = this.path.makeRelative().toString(); return Messages.bind(Messages.classpath_invalidContainer, new String[] { description, javaProject.getElementName() }); case CP_VARIABLE_PATH_UNBOUND: javaProject = (IJavaProject) this.elements[0]; return Messages.bind(Messages.classpath_unboundVariablePath, new String[] { this.path.makeRelative().toString(), javaProject.getElementName() }); case CLASSPATH_CYCLE: javaProject = (IJavaProject) this.elements[0]; return Messages.bind(Messages.classpath_cycle, new String[] { javaProject.getElementName(), this.string }); case DISABLED_CP_EXCLUSION_PATTERNS: javaProject = (IJavaProject) this.elements[0]; String projectName = javaProject.getElementName(); IPath newPath = this.path; if (this.path.segment(0).toString().equals(projectName)) { newPath = this.path.removeFirstSegments(1); } return Messages.bind(Messages.classpath_disabledInclusionExclusionPatterns, new String[] { newPath.makeRelative().toString(), projectName }); case DISABLED_CP_MULTIPLE_OUTPUT_LOCATIONS: javaProject = (IJavaProject) this.elements[0]; projectName = javaProject.getElementName(); newPath = this.path; if (this.path.segment(0).toString().equals(projectName)) { newPath = this.path.removeFirstSegments(1); } return Messages.bind(Messages.classpath_disabledMultipleOutputLocations, new String[] { newPath.makeRelative().toString(), projectName }); case CANNOT_RETRIEVE_ATTACHED_JAVADOC: if (this.elements != null && this.elements.length == 1) { if (this.string != null) { return Messages.bind(Messages.status_cannot_retrieve_attached_javadoc, ((JavaElement) this.elements[0]).toStringWithAncestors(), this.string); } return Messages.bind(Messages.status_cannot_retrieve_attached_javadoc, ((JavaElement) this.elements[0]).toStringWithAncestors(), ""); //$NON-NLS-1$ } if (this.string != null) { return Messages.bind(Messages.status_cannot_retrieve_attached_javadoc, this.string, "");//$NON-NLS-1$ } break; case CANNOT_RETRIEVE_ATTACHED_JAVADOC_TIMEOUT: if (this.elements != null && this.elements.length == 1) { if (this.string != null) { return Messages.bind(Messages.status_timeout_javadoc, ((JavaElement) this.elements[0]).toStringWithAncestors(), this.string); } return Messages.bind(Messages.status_timeout_javadoc, ((JavaElement) this.elements[0]).toStringWithAncestors(), ""); //$NON-NLS-1$ } if (this.string != null) { return Messages.bind(Messages.status_timeout_javadoc, this.string, "");//$NON-NLS-1$ } break; case UNKNOWN_JAVADOC_FORMAT: return Messages.bind(Messages.status_unknown_javadoc_format, ((JavaElement) this.elements[0]).toStringWithAncestors()); case DEPRECATED_VARIABLE: javaProject = (IJavaProject) this.elements[0]; return Messages.bind(Messages.classpath_deprecated_variable, new String[] { this.path.segment(0).toString(), javaProject.getElementName(), this.string }); } if (this.string != null) { return this.string; } else { return ""; //$NON-NLS-1$ } } else { String message = exception.getMessage(); if (message != null) { return message; } else { return exception.toString(); } } }
From source file:com.drgarbage.bytecodevisualizer.editors.NoSourceViewer.java
License:Apache License
private void createSourceAttachmentControls(Composite composite, IPackageFragmentRoot root) throws JavaModelException { IClasspathEntry entry;/* w w w.j av a 2 s.c o m*/ try { entry = root.getRawClasspathEntry(); } catch (JavaModelException ex) { if (ex.isDoesNotExist()) entry = null; else throw ex; } IPath containerPath = null; if (entry == null || root.getKind() != IPackageFragmentRoot.K_BINARY) { String s = CoreMessages.SourceAttachmentForm_message_noSource; createLabel(composite, MessageFormat.format(s, new Object[] { fFile.getElementName() })); return; } IJavaProject jproject = root.getJavaProject(); 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, MessageFormat.format(CoreMessages.SourceAttachmentForm_cannotconfigure, new Object[] { containerPath.toString() })); return; } String containerName = container.getDescription(); IStatus status = initializer.getSourceAttachmentStatus(containerPath, jproject); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { createLabel(composite, MessageFormat.format(CoreMessages.SourceAttachmentForm_notsupported, new Object[] { containerName })); return; } if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { createLabel(composite, MessageFormat.format(CoreMessages.SourceAttachmentForm_readonly, new Object[] { containerName })); return; } entry = JavaModelUtil.findEntryInContainer(container, root.getPath()); Assert.isNotNull(entry); } Button button; String msg = null; String btnText = null; IPath path = entry.getSourceAttachmentPath(); if (path == null || path.isEmpty()) { msg = MessageFormat.format(CoreMessages.SourceAttachmentForm_message_noSourceAttachment, new Object[] { root.getElementName() }); btnText = CoreMessages.SourceAttachmentForm_button_attachSource; } else { msg = MessageFormat.format(CoreMessages.SourceAttachmentForm_message_noSourceInAttachment, new Object[] { fFile.getElementName() }); btnText = CoreMessages.SourceAttachmentForm_button_changeAttachedSource; } createLabel(composite, msg); createLabel(composite, CoreMessages.SourceAttachmentForm_message_pressButtonToAttach); createLabel(composite, null); button = createButton(composite, btnText); button.addSelectionListener(createButtonListener(entry, containerPath, jproject)); }
From source file:com.google.gdt.eclipse.managedapis.impl.ManagedApiProjectImpl.java
License:Open Source License
public static String getAndroidSdk(IProject androidProject) throws JavaModelException { if (androidProject == null) { return null; }/* w ww. j ava 2 s. com*/ IJavaProject androidJavaProject = JavaCore.create(androidProject); List<IClasspathEntry> rawClasspathList = new ArrayList<IClasspathEntry>(); rawClasspathList.addAll(Arrays.asList(androidJavaProject.getRawClasspath())); for (IClasspathEntry e : rawClasspathList) { if (e.getEntryKind() != IClasspathEntry.CPE_CONTAINER) { continue; } IClasspathContainer c = JavaCore.getClasspathContainer(e.getPath(), androidJavaProject); if (c.getDescription().contains(ANDROID_2_CLASSPATH_CONTAINER)) { return ANDROID2_ENVIRONMENT; } else if (c.getDescription().contains(ANDROID_3_CLASSPATH_CONTAINER) || c.getDescription().contains(ANDROID_4_CLASSPATH_CONTAINER)) { return ANDROID3_ENVIRONMENT; } } return null; }
From source file:net.kbserve.pyjdt.properties.models.CPEContainer.java
License:Open Source License
@Override public void update(IClasspathEntry classpathEntry, IProject project) { super.update(classpathEntry, project); IJavaProject javaProject = JavaCore.create(project); try {// w w w . java 2 s . c o m IClasspathContainer classpathContainer = JavaCore.getClasspathContainer(classpathEntry.getPath(), javaProject); setDescription(classpathContainer.getDescription()); setAvailable(true); for (ICPEType child : getChildren()) { child.setAvailable(false); } for (IClasspathEntry containerChild : classpathContainer.getClasspathEntries()) { ICPEType child = this.updateChild(containerChild, project); child.setAvailable(true); child.update(containerChild, project); } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:org.eclipse.ant.internal.ui.datatransfer.EclipseClasspath.java
License:Open Source License
private void handleLibraries(IClasspathEntry entry) throws JavaModelException { if (entry.getContentKind() == IPackageFragmentRoot.K_SOURCE && entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { // found library IClasspathContainer container = JavaCore.getClasspathContainer(entry.getPath(), project); if (container == null) { // jar missing (project not compile clean) return; }//w w w . j ava2 s . c om String jar = entry.getPath().toString(); String refName; if (jar.startsWith(JavaRuntime.JRE_CONTAINER)) { // JRE System Library refName = "${jre.container}"; //$NON-NLS-1$ } else if (jar.startsWith(JavaCore.USER_LIBRARY_CONTAINER_ID)) { // User Library String libraryName = container.getDescription(); refName = "${" + libraryName + ".userclasspath}"; //$NON-NLS-1$ //$NON-NLS-2$ if (container.getKind() == IClasspathContainer.K_SYSTEM) { refName = "${" + libraryName + ".bootclasspath}"; //$NON-NLS-1$ //$NON-NLS-2$ } } else { // Library dependencies: e.g. Plug-in Dependencies String libraryName = container.getDescription(); refName = "${" + libraryName + ".libraryclasspath}"; //$NON-NLS-1$ //$NON-NLS-2$ } userLibraryCache.put(refName, container); srcDirs.add(refName); classDirs.add(refName); rawClassPathEntries.add(refName); rawClassPathEntriesAbsolute.add(refName); inclusionLists.add(new ArrayList<String>()); exclusionLists.add(new ArrayList<String>()); } }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
private void verbose_missbehaving_container(IPath containerPath, IJavaProject[] projects, IClasspathContainer[] respectiveContainers, final IClasspathContainer container, final IClasspathEntry[] newEntries, final IClasspathEntry[] oldEntries) { Util.verbose("CPContainer SET - missbehaving container\n" + //$NON-NLS-1$ " container path: " + containerPath + '\n' + //$NON-NLS-1$ " projects: {" + //$NON-NLS-1$ org.eclipse.jdt.internal.compiler.util.Util.toString(projects, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() { public String displayString(Object o) { return ((IJavaProject) o).getElementName(); }/* w w w . ja v a2 s . com*/ }) + "}\n values on previous session: {\n" + //$NON-NLS-1$ org.eclipse.jdt.internal.compiler.util.Util.toString(respectiveContainers, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() { public String displayString(Object o) { StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$ if (o == null) { buffer.append("<null>"); //$NON-NLS-1$ return buffer.toString(); } buffer.append(container.getDescription()); buffer.append(" {\n"); //$NON-NLS-1$ if (oldEntries == null) { buffer.append(" "); //$NON-NLS-1$ buffer.append("<null>\n"); //$NON-NLS-1$ } else { for (int j = 0; j < oldEntries.length; j++) { buffer.append(" "); //$NON-NLS-1$ buffer.append(oldEntries[j]); buffer.append('\n'); } } buffer.append(" }"); //$NON-NLS-1$ return buffer.toString(); } }) + "}\n new values: {\n" + //$NON-NLS-1$ org.eclipse.jdt.internal.compiler.util.Util.toString(respectiveContainers, new org.eclipse.jdt.internal.compiler.util.Util.Displayable() { public String displayString(Object o) { StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$ if (o == null) { buffer.append("<null>"); //$NON-NLS-1$ return buffer.toString(); } buffer.append(container.getDescription()); buffer.append(" {\n"); //$NON-NLS-1$ for (int j = 0; j < newEntries.length; j++) { buffer.append(" "); //$NON-NLS-1$ buffer.append(newEntries[j]); buffer.append('\n'); } buffer.append(" }"); //$NON-NLS-1$ return buffer.toString(); } }) + "\n }"); //$NON-NLS-1$ }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
private void verbose_reentering_project_container_access(IPath containerPath, IJavaProject project, IClasspathContainer previousContainer) { StringBuffer buffer = new StringBuffer(); buffer.append(//from www .j av a 2 s . com "CPContainer INIT - reentering access to project container during its initialization, will see previous value\n"); //$NON-NLS-1$ buffer.append(" project: " + project.getElementName() + '\n'); //$NON-NLS-1$ buffer.append(" container path: " + containerPath + '\n'); //$NON-NLS-1$ buffer.append(" previous value: "); //$NON-NLS-1$ buffer.append(previousContainer.getDescription()); buffer.append(" {\n"); //$NON-NLS-1$ IClasspathEntry[] entries = previousContainer.getClasspathEntries(); if (entries != null) { for (int j = 0; j < entries.length; j++) { buffer.append(" "); //$NON-NLS-1$ buffer.append(entries[j]); buffer.append('\n'); } } buffer.append(" }"); //$NON-NLS-1$ Util.verbose(buffer.toString()); new Exception("<Fake exception>").printStackTrace(System.out); //$NON-NLS-1$ }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
private void verbose_container_value_after_initialization(IJavaProject project, IPath containerPath, IClasspathContainer container) { StringBuffer buffer = new StringBuffer(); buffer.append("CPContainer INIT - after resolution\n"); //$NON-NLS-1$ buffer.append(" project: " + project.getElementName() + '\n'); //$NON-NLS-1$ buffer.append(" container path: " + containerPath + '\n'); //$NON-NLS-1$ if (container != null) { buffer.append(" container: " + container.getDescription() + " {\n"); //$NON-NLS-2$//$NON-NLS-1$ IClasspathEntry[] entries = container.getClasspathEntries(); if (entries != null) { for (int i = 0; i < entries.length; i++) { buffer.append(" " + entries[i] + '\n'); //$NON-NLS-1$ }/*from ww w . j a va 2 s . co m*/ } buffer.append(" }");//$NON-NLS-1$ } else { buffer.append(" container: {unbound}");//$NON-NLS-1$ } Util.verbose(buffer.toString()); }
From source file:org.eclipse.jst.j2ee.application.internal.operations.ClassPathSelection.java
License:Open Source License
private ClasspathElement createClasspathElementForEntry(final IProject project, final IClasspathEntry entry) { final IPath entryPath = entry.getPath(); final URI archiveURI = URI.createURI(entryPath.toString()); final int kind = entry.getEntryKind(); String elementName = entryPath.toString(); if (kind == IClasspathEntry.CPE_CONTAINER) { try {/* w w w . j a va2 s .c o m*/ final IClasspathContainer container = JavaCore.getClasspathContainer(entryPath, JavaCore.create(project)); if (container != null) { elementName = container.getDescription(); } } catch (CoreException ce) { } } ClasspathElement element = createClasspathEntryElement(project, archiveURI, elementName, entry); return element; }
From source file:org.eclipse.jst.j2ee.internal.ui.AddJavaBuildPathEntriesWizardFragment.java
License:Open Source License
public static String getClasspathEntryText(final IJavaProject jproj, final IClasspathEntry cpe) { final int type = cpe.getEntryKind(); if (type == IClasspathEntry.CPE_CONTAINER) { try {//from w w w. j a v a 2 s.com final IClasspathContainer container = JavaCore.getClasspathContainer(cpe.getPath(), jproj); return container.getDescription(); } catch (Exception e) { J2EEUIPlugin.logError(e); } } else if (type == IClasspathEntry.CPE_LIBRARY) { final IPath path = cpe.getPath(); final StringBuilder buf = new StringBuilder(); buf.append(path.lastSegment()); buf.append(" - "); //$NON-NLS-1$ buf.append(path.removeLastSegments(1).toOSString()); return buf.toString(); } return cpe.getPath().toPortableString(); }