Java Code Examples for org.eclipse.jdt.internal.corext.util.Strings#markLTR()
The following examples show how to use
org.eclipse.jdt.internal.corext.util.Strings#markLTR() .
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: JavaElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the styled label of the given object. The object must be of type {@link IJavaElement} or adapt to {@link IWorkbenchAdapter}. * If the element type is not known, the empty string is returned. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param obj object to get the label for * @param flags the rendering flags * @return the label or the empty string if the object type is not supported * * @since 3.4 */ public static StyledString getStyledTextLabel(Object obj, long flags) { if (obj instanceof IJavaElement) { return getStyledElementLabel((IJavaElement) obj, flags); } else if (obj instanceof IResource) { return getStyledResourceLabel((IResource) obj); } else if (obj instanceof ClassPathContainer) { ClassPathContainer container= (ClassPathContainer) obj; return getStyledContainerEntryLabel(container.getClasspathEntry().getPath(), container.getJavaProject()); } else if (obj instanceof IStorage) { return getStyledStorageLabel((IStorage) obj); } else if (obj instanceof IAdaptable) { IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class); if (wbadapter != null) { return Strings.markLTR(new StyledString(wbadapter.getLabel(obj))); } } return new StyledString(); }
Example 2
Source File: BindingLabelProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Returns the label for a Java element with the flags as defined by {@link JavaElementLabels}. * @param binding The binding to render. * @param flags The text flags as defined in {@link JavaElementLabels} * @return the label of the binding */ public static String getBindingLabel(IBinding binding, long flags) { StringBuffer buffer= new StringBuffer(60); if (binding instanceof ITypeBinding) { getTypeLabel(((ITypeBinding) binding), flags, buffer); } else if (binding instanceof IMethodBinding) { getMethodLabel(((IMethodBinding) binding), flags, buffer); } else if (binding instanceof IVariableBinding) { final IVariableBinding variable= (IVariableBinding) binding; if (variable.isField()) getFieldLabel(variable, flags, buffer); else getLocalVariableLabel(variable, flags, buffer); } return Strings.markLTR(buffer.toString()); }
Example 3
Source File: JavaElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the label of a classpath container. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param containerPath the path of the container * @param project the project the container is resolved in * @return the label of the classpath container * @throws JavaModelException when resolving of the container failed */ public static String getContainerEntryLabel(IPath containerPath, IJavaProject project) throws JavaModelException { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, project); if (container != null) { return Strings.markLTR(container.getDescription()); } ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { return Strings.markLTR(initializer.getDescription(containerPath, project)); } return BasicElementLabels.getPathLabel(containerPath, false); }
Example 4
Source File: JavaElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the styled label of a classpath container. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param containerPath the path of the container * @param project the project the container is resolved in * @return the label of the classpath container * * @since 3.4 */ public static StyledString getStyledContainerEntryLabel(IPath containerPath, IJavaProject project) { try { IClasspathContainer container= JavaCore.getClasspathContainer(containerPath, project); String description= null; if (container != null) { description= container.getDescription(); } if (description == null) { ClasspathContainerInitializer initializer= JavaCore.getClasspathContainerInitializer(containerPath.segment(0)); if (initializer != null) { description= initializer.getDescription(containerPath, project); } } if (description != null) { StyledString str= new StyledString(description); if (containerPath.segmentCount() > 0 && JavaRuntime.JRE_CONTAINER.equals(containerPath.segment(0))) { int index= description.indexOf('['); if (index != -1) { str.setStyle(index, description.length() - index, DECORATIONS_STYLE); } } return Strings.markLTR(str); } } catch (JavaModelException e) { // ignore } return new StyledString(BasicElementLabels.getPathLabel(containerPath, false)); }
Example 5
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the label of a path. * * @param path the path * @param isOSPath if <code>true</code>, the path represents an OS path, if <code>false</code> it is a workspace path. * @return the label of the path to be used in the UI. */ public static String getPathLabel(IPath path, boolean isOSPath) { String label; if (isOSPath) { label= path.toOSString(); } else { label= path.makeRelative().toString(); } return Strings.markLTR(label); }
Example 6
Source File: JavaElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the label of the given object. The object must be of type {@link IJavaElement} or adapt to {@link IWorkbenchAdapter}. * If the element type is not known, the empty string is returned. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param obj object to get the label for * @param flags the rendering flags * @return the label or the empty string if the object type is not supported */ public static String getTextLabel(Object obj, long flags) { if (obj instanceof IJavaElement) { return getElementLabel((IJavaElement) obj, flags); } else if (obj instanceof IResource) { return BasicElementLabels.getResourceName((IResource) obj); } else if (obj instanceof ClassPathContainer) { ClassPathContainer container= (ClassPathContainer) obj; IPath containerPath= container.getClasspathEntry().getPath(); try { return getContainerEntryLabel(containerPath, container.getJavaProject()); } catch (JavaModelException e) { return BasicElementLabels.getPathLabel(containerPath, false); } } else if (obj instanceof IStorage) { return BasicElementLabels.getResourceName(((IStorage) obj).getName()); } else if (obj instanceof IAdaptable) { IWorkbenchAdapter wbadapter= (IWorkbenchAdapter) ((IAdaptable)obj).getAdapter(IWorkbenchAdapter.class); if (wbadapter != null) { return Strings.markLTR(wbadapter.getLabel(obj)); } } return ""; //$NON-NLS-1$ }
Example 7
Source File: JavaElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the styled string for the given resource. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param resource the resource * @return the styled string * @since 3.4 */ private static StyledString getStyledResourceLabel(IResource resource) { StyledString result= new StyledString(resource.getName()); return Strings.markLTR(result); }
Example 8
Source File: JavaElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the styled string for the given storage. * The returned label is BiDi-processed with {@link TextProcessor#process(String, String)}. * * @param storage the storage * @return the styled string * @since 3.4 */ private static StyledString getStyledStorageLabel(IStorage storage) { StyledString result= new StyledString(storage.getName()); return Strings.markLTR(result); }
Example 9
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the label of the path of a file. * * @param file the file * @return the label of the file path to be used in the UI. */ public static String getPathLabel(File file) { return Strings.markLTR(file.getAbsolutePath()); }
Example 10
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the label for a file pattern like '*.java' * * @param name the pattern * @return the label of the pattern. */ public static String getFilePattern(String name) { return Strings.markLTR(name, FILE_PATTERN_DELIMITERS); }
Example 11
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns the label for a URL, URI or URL part. Example is 'http://www.x.xom/s.html#1' * * @param name the URL string * @return the label of the URL. */ public static String getURLPart(String name) { return Strings.markLTR(name, URL_DELIMITERS); }
Example 12
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a label for a resource name. * * @param resource the resource * @return the label of the resource name. */ public static String getResourceName(IResource resource) { return Strings.markLTR(resource.getName()); }
Example 13
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a label for a resource name. * * @param resourceName the resource name * @return the label of the resource name. */ public static String getResourceName(String resourceName) { return Strings.markLTR(resourceName); }
Example 14
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a label for a type root name which is a file name. * * @param typeRoot the typeRoot * @return the label of the resource name. */ public static String getFileName(ITypeRoot typeRoot) { return Strings.markLTR(typeRoot.getElementName()); }
Example 15
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a label for Java code snippet used in a label. Example is 'Test test= new Test<? extends List>() { ...}'. * * @param string the Java code snippet * @return the label for the Java code snippet */ public static String getJavaCodeString(String string) { return Strings.markLTR(string, CODE_DELIMITERS); }
Example 16
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a label for a version name. Example is '1.4.1' * * @param name the version string * @return the version label */ public static String getVersionName(String name) { return Strings.markLTR(name); }
Example 17
Source File: BasicElementLabels.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a label for a working set * * @param set the working set * @return the label of the working set */ public static String getWorkingSetLabel(IWorkingSet set) { return Strings.markLTR(set.getLabel()); }