List of usage examples for org.eclipse.jdt.core ClasspathContainerInitializer ATTRIBUTE_NOT_SUPPORTED
int ATTRIBUTE_NOT_SUPPORTED
To view the source code for org.eclipse.jdt.core ClasspathContainerInitializer ATTRIBUTE_NOT_SUPPORTED.
Click Source Link
From source file:at.bestsolution.javafx.ide.jdt.internal.jdt.CPListElementAttribute.java
License:Open Source License
/** * @return Returns <code>true</code> if the attribute a on a container child and is not supported *//*from w ww . ja va 2 s. c o m*/ public boolean isNotSupported() { return fStatus != null && fStatus.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED; }
From source file:com.drgarbage.bytecodevisualizer.editors.NoSourceViewer.java
License:Apache License
private void createSourceAttachmentControls(Composite composite, IPackageFragmentRoot root) throws JavaModelException { IClasspathEntry entry;//from ww w.ja v a2 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:org.jboss.tools.as.sourcelookup.ui.actions.AttachSourcesActionDelegate.java
License:Open Source License
private void attachSource(IPackageFragmentRoot fragment, IPath newSourcePath) { try {//from ww w. j av a2s .c o m if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) { return; } IPath containerPath = null; IJavaProject jproject = fragment.getJavaProject(); IClasspathEntry entry = fragment.getRawClasspathEntry(); if (entry == null) { entry = JavaCore.newLibraryEntry(fragment.getPath(), null, null); } else { 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; } IStatus status = initializer.getSourceAttachmentStatus(containerPath, jproject); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { return; } if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { return; } entry = JavaModelUtil.findEntryInContainer(container, fragment.getPath()); if (entry == null) { return; } } } IClasspathEntry entry1; CPListElement elem = CPListElement.createFromExisting(entry, null); elem.setAttribute(CPListElement.SOURCEATTACHMENT, newSourcePath); entry1 = elem.getClasspathEntry(); if (entry1.equals(entry)) { return; } IClasspathEntry newEntry = entry1; String[] changedAttributes = { CPListElement.SOURCEATTACHMENT }; BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, newEntry.getReferencingEntry() != null, new NullProgressMonitor()); } catch (CoreException e) { // ignore } }
From source file:org.jboss.tools.maven.sourcelookup.ui.internal.util.SourceLookupUtil.java
License:Open Source License
public static void attachSource(final IPackageFragmentRoot fragment, final IPath newSourcePath, boolean displayDialog) { try {/*from w w w .jav a2 s.c o m*/ if (fragment == null || fragment.getKind() != IPackageFragmentRoot.K_BINARY) { return; } String value = SourceLookupActivator.getDefault().getAutoAddSourceAttachment(); if (SourceLookupActivator.AUTO_ADD_JBOSS_SOURCE_ATTACHMENT_NEVER.equals(value)) { return; } if (displayDialog && SourceLookupActivator.AUTO_ADD_JBOSS_SOURCE_ATTACHMENT_PROMPT.equals(value)) { final boolean[] attach = new boolean[1]; Display.getDefault().syncExec(new Runnable() { @Override public void run() { attach[0] = promptToAddSourceAttachment(fragment.getElementName(), newSourcePath.toString()); } }); if (!attach[0]) { return; } ; } IPath containerPath = null; IJavaProject jproject = fragment.getJavaProject(); IClasspathEntry entry = fragment.getRawClasspathEntry(); if (entry == null) { entry = JavaCore.newLibraryEntry(fragment.getPath(), null, null); } else { 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; } IStatus status = initializer.getSourceAttachmentStatus(containerPath, jproject); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { return; } if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { return; } entry = JavaModelUtil.findEntryInContainer(container, fragment.getPath()); if (entry == null) { return; } } } IClasspathEntry entry1; CPListElement elem = CPListElement.createFromExisting(entry, null); elem.setAttribute(CPListElement.SOURCEATTACHMENT, newSourcePath); entry1 = elem.getClasspathEntry(); if (entry1.equals(entry)) { return; } IClasspathEntry newEntry = entry1; String[] changedAttributes = { CPListElement.SOURCEATTACHMENT }; BuildPathSupport.modifyClasspathEntry(null, newEntry, changedAttributes, jproject, containerPath, newEntry.getReferencingEntry() != null, new NullProgressMonitor()); } catch (CoreException e) { // ignore } }
From source file:org.org.eclipse.dws.core.internal.jobs.UpdateJavadocAndSourcesJob.java
License:Open Source License
/** * Handle container entry.//from w w w . ja v a 2 s. c om * * @param containerPath * the container path * @param jproject * the jproject * @param jarPath * the jar path * * @return the i classpath entry * * @throws JavaModelException * the java model exception */ @SuppressWarnings("restriction") private IClasspathEntry handleContainerEntry(IPath containerPath, IJavaProject jproject, IPath jarPath) throws JavaModelException { ClasspathContainerInitializer initializer = JavaCore .getClasspathContainerInitializer(containerPath.segment(0)); IClasspathContainer container = JavaCore.getClasspathContainer(containerPath, jproject); if (initializer == null || container == null) { logger.error("Container is not valid:" + containerPath); return null; } IStatus status = initializer.getAttributeStatus(containerPath, jproject, IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME); if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_NOT_SUPPORTED) { logger.error("Container does not support javadoc location attribute."); return null; } if (status.getCode() == ClasspathContainerInitializer.ATTRIBUTE_READ_ONLY) { logger.error("Container's javadoc location attribute is read only."); return null; } IClasspathEntry entry = JavaModelUtil.findEntryInContainer(container, jarPath); Assert.isNotNull(entry); return entry; }