Java Code Examples for org.eclipse.jdt.core.search.TypeNameMatch#getPackageFragmentRoot()

The following examples show how to use org.eclipse.jdt.core.search.TypeNameMatch#getPackageFragmentRoot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeInfoViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private String getContainerName(TypeNameMatch type) {
	IPackageFragmentRoot root= type.getPackageFragmentRoot();
	if (root.isExternal()) {
		String name= root.getPath().toOSString();
		for (int i= 0; i < fInstallLocations.length; i++) {
			if (name.startsWith(fInstallLocations[i])) {
				return fVMNames[i];
			}
		}
		String lib= (String)fLib2Name.get(name);
		if (lib != null)
			return lib;
	}
	StringBuffer buf= new StringBuffer();
	JavaElementLabels.getPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED | JavaElementLabels.ROOT_VARIABLE, buf);
	return buf.toString();
}
 
Example 2
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void setResult(List newResult) {

	List<IType> resultToReturn= new ArrayList<IType>();

	for (int i= 0; i < newResult.size(); i++) {
		if (newResult.get(i) instanceof TypeNameMatch) {
			IType type= ((TypeNameMatch) newResult.get(i)).getType();
			if (type.exists()) {
				// items are added to history in the
				// org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#computeResult()
				// method
				resultToReturn.add(type);
			} else {
				TypeNameMatch typeInfo= (TypeNameMatch) newResult.get(i);
				IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
				String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED);
				String message= Messages.format(JavaUIMessages.FilteredTypesSelectionDialog_dialogMessage, new String[] { TypeNameMatchLabelProvider.getText(typeInfo, TypeNameMatchLabelProvider.SHOW_FULLYQUALIFIED), containerName });
				MessageDialog.openError(getShell(), fTitle, message);
				getSelectionHistory().remove(typeInfo);
			}
		}
	}

	super.setResult(resultToReturn);
}
 
Example 3
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private String getContainerName(TypeNameMatch type) {
	IPackageFragmentRoot root= type.getPackageFragmentRoot();
	if (root.isExternal()) {
		IPath path= root.getPath();
		for (int i= 0; i < fInstallLocations.length; i++) {
			if (fInstallLocations[i].isPrefixOf(path)) {
				return fVMNames[i];
			}
		}
		String lib= fLib2Name.get(path);
		if (lib != null)
			return lib;
	}
	StringBuffer buf= new StringBuffer();
	JavaElementLabels.getPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED | JavaElementLabels.ROOT_VARIABLE, buf);
	return buf.toString();
}
 
Example 4
Source File: FilteredTypesSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private String getContainerName(TypeNameMatch type) {
	IPackageFragmentRoot root= type.getPackageFragmentRoot();
	if (root.isExternal()) {
		String name= root.getPath().toOSString();
		for (int i= 0; i < fInstallLocations.length; i++) {
			if (name.startsWith(fInstallLocations[i])) {
				return fVMNames[i];
			}
		}
		String lib= fLib2Name.get(name);
		if (lib != null)
			return lib;
	}
	StringBuffer buf= new StringBuffer();
	JavaElementLabels.getPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED | JavaElementLabels.ROOT_VARIABLE, buf);
	return buf.toString();
}
 
Example 5
Source File: TypeSelectionDialog2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void computeResult() {
	TypeNameMatch[] selected= fContent.getSelection();
	if (selected == null || selected.length == 0) {
		setResult(null);
		return;
	}
	
	// If the scope is null then it got computed by the type selection component.
	if (fScope == null) {
		fScope= fContent.getScope();
	}
	
	OpenTypeHistory history= OpenTypeHistory.getInstance();
	List result= new ArrayList(selected.length);
	for (int i= 0; i < selected.length; i++) {
		TypeNameMatch typeInfo= selected[i];
		IType type= typeInfo.getType();
		if (!type.exists()) {
			String title= JavaUIMessages.TypeSelectionDialog_errorTitle; 
			IPackageFragmentRoot root= typeInfo.getPackageFragmentRoot();
			String containerName= JavaElementLabels.getElementLabel(root, JavaElementLabels.ROOT_QUALIFIED);
			String message= Messages.format(JavaUIMessages.TypeSelectionDialog_dialogMessage, new String[] { typeInfo.getFullyQualifiedName(), containerName }); 
			MessageDialog.openError(getShell(), title, message);
			history.remove(typeInfo);
			setResult(null);
		} else {
			history.accessed(typeInfo);
			result.add(type);
		}
	}
	setResult(result);
}