use of org.eclipse.core.resources.IProjectNatureDescriptor in project translationstudio8 by heartsome.
the class NewFolderDialogOfHs method isValidContainer.
/**
* Returns whether the container specified in the constructor is
* a valid parent for creating linked resources.
*
* @return boolean <code>true</code> if the container specified in
* the constructor is a valid parent for creating linked resources.
* <code>false</code> if no linked resources may be created with the
* specified container as a parent.
*/
private boolean isValidContainer() {
if (container.getType() != IResource.PROJECT && container.getType() != IResource.FOLDER) {
return false;
}
try {
IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
IProject project = container.getProject();
String[] natureIds = project.getDescription().getNatureIds();
for (int i = 0; i < natureIds.length; i++) {
IProjectNatureDescriptor descriptor = workspace.getNatureDescriptor(natureIds[i]);
if (descriptor != null && descriptor.isLinkingAllowed() == false) {
return false;
}
}
} catch (CoreException exception) {
// project does not exist or is closed
return false;
}
return true;
}
use of org.eclipse.core.resources.IProjectNatureDescriptor in project eclipse.platform.text by eclipse.
the class NatureLabelHoverProvider method getHoverInfo.
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
String contents = textViewer.getDocument().get();
int offset = hoverRegion.getOffset();
int endIndex = contents.indexOf("</nature>", offset);
if (endIndex == -1)
return "";
int startIndex = contents.substring(0, offset).lastIndexOf("<nature>");
if (startIndex == -1)
return "";
String selection = contents.substring(startIndex + "<nature>".length(), endIndex);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectNatureDescriptor[] natureDescriptors = workspace.getNatureDescriptors();
for (int i = 0; i < natureDescriptors.length; i++) {
if (natureDescriptors[i].getNatureId().equals(selection))
return natureDescriptors[i].getLabel();
}
return null;
}
use of org.eclipse.core.resources.IProjectNatureDescriptor in project eclipse.platform.text by eclipse.
the class NaturesAndProjectsContentAssistProcessor method computeCompletionProposals.
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
String text = viewer.getDocument().get();
String natureTag = "<nature>";
String projectReferenceTag = "<project>";
IWorkspace workspace = ResourcesPlugin.getWorkspace();
int natureTagLength = natureTag.length();
if (text.length() >= natureTagLength && offset >= natureTagLength && text.substring(offset - natureTagLength, offset).equals(natureTag)) {
IProjectNatureDescriptor[] natureDescriptors = workspace.getNatureDescriptors();
ICompletionProposal[] proposals = new ICompletionProposal[natureDescriptors.length];
for (int i = 0; i < natureDescriptors.length; i++) {
IProjectNatureDescriptor descriptor = natureDescriptors[i];
proposals[i] = new CompletionProposal(descriptor.getNatureId(), offset, 0, descriptor.getNatureId().length());
}
return proposals;
}
int projectReferenceTagLength = projectReferenceTag.length();
if (text.length() >= projectReferenceTagLength && offset >= projectReferenceTagLength && text.substring(offset - projectReferenceTagLength, offset).equals(projectReferenceTag)) {
IProject[] projects = workspace.getRoot().getProjects();
// TODO - filter out the project this file is in
ICompletionProposal[] proposals = new ICompletionProposal[projects.length];
for (int i = 0; i < projects.length; i++) {
proposals[i] = new CompletionProposal(projects[i].getName(), offset, 0, projects[i].getName().length());
}
return proposals;
}
return new ICompletionProposal[0];
}
Aggregations