1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.viewsupport;
13 import net.sourceforge.phpdt.core.ICompilationUnit;
14 import net.sourceforge.phpdt.core.IField;
15 import net.sourceforge.phpdt.core.IJavaElement;
16 import net.sourceforge.phpdt.core.IMethod;
17 import net.sourceforge.phpdt.core.IPackageFragment;
18 import net.sourceforge.phpdt.core.IPackageFragmentRoot;
19 import net.sourceforge.phpdt.core.IType;
20 import net.sourceforge.phpdt.core.JavaModelException;
21 import net.sourceforge.phpdt.core.Signature;
22 import net.sourceforge.phpdt.internal.corext.util.JavaModelUtil;
23 import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
24 import net.sourceforge.phpdt.ui.PreferenceConstants;
25 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
27 import org.eclipse.core.resources.IResource;
28 import org.eclipse.core.runtime.IAdaptable;
29 import org.eclipse.core.runtime.IPath;
30 import org.eclipse.jface.preference.IPreferenceStore;
31 import org.eclipse.ui.model.IWorkbenchAdapter;
33 public class JavaElementLabels {
36 * Method names contain parameter types.
37 * e.g. <code>foo(int)</code>
39 public final static int M_PARAMETER_TYPES = 1 << 0;
42 * Method names contain parameter names.
43 * e.g. <code>foo(index)</code>
45 public final static int M_PARAMETER_NAMES = 1 << 1;
48 * Method names contain thrown exceptions.
49 * e.g. <code>foo throws IOException</code>
51 public final static int M_EXCEPTIONS = 1 << 2;
54 * Method names contain return type (appended)
55 * e.g. <code>foo : int</code>
57 public final static int M_APP_RETURNTYPE = 1 << 3;
60 * Method names contain return type (appended)
61 * e.g. <code>int foo</code>
63 public final static int M_PRE_RETURNTYPE = 1 << 4;
66 * Method names are fully qualified.
67 * e.g. <code>java.util.Vector.size</code>
69 public final static int M_FULLY_QUALIFIED = 1 << 5;
72 * Method names are post qualified.
73 * e.g. <code>size - java.util.Vector</code>
75 public final static int M_POST_QUALIFIED = 1 << 6;
78 * Initializer names are fully qualified.
79 * e.g. <code>java.util.Vector.{ ... }</code>
81 public final static int I_FULLY_QUALIFIED = 1 << 7;
84 * Type names are post qualified.
85 * e.g. <code>{ ... } - java.util.Map</code>
87 public final static int I_POST_QUALIFIED = 1 << 8;
90 * Field names contain the declared type (appended)
91 * e.g. <code>int fHello</code>
93 public final static int F_APP_TYPE_SIGNATURE = 1 << 9;
96 * Field names contain the declared type (prepended)
97 * e.g. <code>fHello : int</code>
99 public final static int F_PRE_TYPE_SIGNATURE = 1 << 10;
102 * Fields names are fully qualified.
103 * e.g. <code>java.lang.System.out</code>
105 public final static int F_FULLY_QUALIFIED = 1 << 11;
108 * Fields names are post qualified.
109 * e.g. <code>out - java.lang.System</code>
111 public final static int F_POST_QUALIFIED = 1 << 12;
114 * Type names are fully qualified.
115 * e.g. <code>java.util.Map.MapEntry</code>
117 public final static int T_FULLY_QUALIFIED = 1 << 13;
120 * Type names are type container qualified.
121 * e.g. <code>Map.MapEntry</code>
123 public final static int T_CONTAINER_QUALIFIED = 1 << 14;
126 * Type names are post qualified.
127 * e.g. <code>MapEntry - java.util.Map</code>
129 public final static int T_POST_QUALIFIED = 1 << 15;
132 * Declarations (import container / declarartion, package declarartion) are qualified.
133 * e.g. <code>java.util.Vector.class/import container</code>
135 public final static int D_QUALIFIED = 1 << 16;
138 * Declarations (import container / declarartion, package declarartion) are post qualified.
139 * e.g. <code>import container - java.util.Vector.class</code>
141 public final static int D_POST_QUALIFIED = 1 << 17;
144 * Class file names are fully qualified.
145 * e.g. <code>java.util.Vector.class</code>
147 public final static int CF_QUALIFIED = 1 << 18;
150 * Class file names are post qualified.
151 * e.g. <code>Vector.class - java.util</code>
153 public final static int CF_POST_QUALIFIED = 1 << 19;
156 * Compilation unit names are fully qualified.
157 * e.g. <code>java.util.Vector.java</code>
159 public final static int CU_QUALIFIED = 1 << 20;
162 * Compilation unit names are post qualified.
163 * e.g. <code>Vector.java - java.util</code>
165 public final static int CU_POST_QUALIFIED = 1 << 21;
168 * Package names are qualified.
169 * e.g. <code>MyProject/src/java.util</code>
171 public final static int P_QUALIFIED = 1 << 22;
174 * Package names are post qualified.
175 * e.g. <code>java.util - MyProject/src</code>
177 public final static int P_POST_QUALIFIED = 1 << 23;
180 * Package Fragment Roots contain variable name if from a variable.
181 * e.g. <code>JRE_LIB - c:\java\lib\rt.jar</code>
183 public final static int ROOT_VARIABLE = 1 << 24;
186 * Package Fragment Roots contain the project name if not an archive (prepended).
187 * e.g. <code>MyProject/src</code>
189 public final static int ROOT_QUALIFIED = 1 << 25;
192 * Package Fragment Roots contain the project name if not an archive (appended).
193 * e.g. <code>src - MyProject</code>
195 public final static int ROOT_POST_QUALIFIED = 1 << 26;
198 * Add root path to all elements except Package Fragment Roots and Java projects.
199 * e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
200 * Option only applies to getElementLabel
202 public final static int APPEND_ROOT_PATH = 1 << 27;
205 * Add root path to all elements except Package Fragment Roots and Java projects.
206 * e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
207 * Option only applies to getElementLabel
209 public final static int PREPEND_ROOT_PATH = 1 << 28;
212 * Package names are compressed.
213 * e.g. <code>o*.e*.search</code>
215 public final static int P_COMPRESSED = 1 << 29;
218 * Post qualify referenced package fragement roots. For example
219 * <code>jdt.jar - org.eclipse.jdt.ui</code> if the jar is referenced
220 * from another project.
222 public final static int REFERENCED_ROOT_POST_QUALIFIED = 1 << 30;
225 * Qualify all elements
227 public final static int ALL_FULLY_QUALIFIED =
239 * Post qualify all elements
241 public final static int ALL_POST_QUALIFIED =
250 | ROOT_POST_QUALIFIED;
253 * Default options (M_PARAMETER_TYPES enabled)
255 public final static int ALL_DEFAULT = M_PARAMETER_TYPES;
258 * Default qualify options (All except Root and Package)
260 public final static int DEFAULT_QUALIFIED =
261 F_FULLY_QUALIFIED | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED;
264 * Default post qualify options (All except Root and Package)
266 public final static int DEFAULT_POST_QUALIFIED =
275 public final static String CONCAT_STRING = PHPUIMessages.getString("JavaElementLabels.concat_string"); // " - "; //$NON-NLS-1$
276 public final static String COMMA_STRING = PHPUIMessages.getString("JavaElementLabels.comma_string"); // ", "; //$NON-NLS-1$
277 public final static String DECL_STRING = PHPUIMessages.getString("JavaElementLabels.declseparator_string"); // " "; // use for return type //$NON-NLS-1$
280 * Package name compression
282 private static String fgPkgNamePattern = ""; //$NON-NLS-1$
283 private static String fgPkgNamePrefix;
284 private static String fgPkgNamePostfix;
285 private static int fgPkgNameChars;
286 private static int fgPkgNameLength = -1;
288 private JavaElementLabels() {
291 private static boolean getFlag(int flags, int flag) {
292 return (flags & flag) != 0;
295 public static String getTextLabel(Object obj, int flags) {
296 if (obj instanceof IJavaElement) {
297 return getElementLabel((IJavaElement) obj, flags);
298 } else if (obj instanceof IAdaptable) {
299 IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) obj).getAdapter(IWorkbenchAdapter.class);
300 if (wbadapter != null) {
301 return wbadapter.getLabel(obj);
304 return ""; //$NON-NLS-1$
308 * Returns the label for a Java element. Flags as defined above.
310 public static String getElementLabel(IJavaElement element, int flags) {
311 StringBuffer buf = new StringBuffer(60);
312 getElementLabel(element, flags, buf);
313 return buf.toString();
317 * Returns the label for a Java element. Flags as defined above.
319 public static void getElementLabel(IJavaElement element, int flags, StringBuffer buf) {
320 int type = element.getElementType();
321 IPackageFragmentRoot root = null;
323 if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT && type != IJavaElement.PACKAGE_FRAGMENT_ROOT)
324 root = JavaModelUtil.getPackageFragmentRoot(element);
325 if (root != null && getFlag(flags, PREPEND_ROOT_PATH)) {
326 getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
327 buf.append(CONCAT_STRING);
331 case IJavaElement.METHOD :
332 getMethodLabel((IMethod) element, flags, buf);
334 case IJavaElement.FIELD :
335 getFieldLabel((IField) element, flags, buf);
337 // case IJavaElement.INITIALIZER:
338 // getInitializerLabel((IInitializer) element, flags, buf);
340 case IJavaElement.TYPE :
341 getTypeLabel((IType) element, flags, buf);
343 // case IJavaElement.CLASS_FILE:
344 // getClassFileLabel((IClassFile) element, flags, buf);
346 case IJavaElement.COMPILATION_UNIT :
347 getCompilationUnitLabel((ICompilationUnit) element, flags, buf);
349 case IJavaElement.PACKAGE_FRAGMENT :
350 getPackageFragmentLabel((IPackageFragment) element, flags, buf);
352 case IJavaElement.PACKAGE_FRAGMENT_ROOT :
353 getPackageFragmentRootLabel((IPackageFragmentRoot) element, flags, buf);
355 case IJavaElement.IMPORT_CONTAINER :
356 case IJavaElement.IMPORT_DECLARATION :
357 case IJavaElement.PACKAGE_DECLARATION :
358 getDeclararionLabel(element, flags, buf);
360 case IJavaElement.JAVA_PROJECT :
361 case IJavaElement.JAVA_MODEL :
362 buf.append(element.getElementName());
365 buf.append(element.getElementName());
368 if (root != null && getFlag(flags, APPEND_ROOT_PATH)) {
369 buf.append(CONCAT_STRING);
370 getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
375 * Appends the label for a method to a StringBuffer. Considers the M_* flags.
377 public static void getMethodLabel(IMethod method, int flags, StringBuffer buf) {
380 if (getFlag(flags, M_PRE_RETURNTYPE) && method.exists() && !method.isConstructor()) {
381 buf.append(Signature.getSimpleName(Signature.toString(method.getReturnType())));
386 if (getFlag(flags, M_FULLY_QUALIFIED)) {
387 getTypeLabel(method.getDeclaringType(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
391 buf.append(method.getElementName());
394 if (getFlag(flags, M_PARAMETER_TYPES | M_PARAMETER_NAMES)) {
397 String[] types = getFlag(flags, M_PARAMETER_TYPES) ? method.getParameterTypes() : null;
398 String[] names = (getFlag(flags, M_PARAMETER_NAMES) && method.exists()) ? method.getParameterNames() : null;
399 int nParams = types != null ? types.length : names.length;
401 for (int i = 0; i < nParams; i++) {
403 buf.append(COMMA_STRING); //$NON-NLS-1$
406 buf.append(Signature.getSimpleName(Signature.toString(types[i])));
412 buf.append(names[i]);
418 if (getFlag(flags, M_EXCEPTIONS) && method.exists()) {
419 String[] types = method.getExceptionTypes();
420 if (types.length > 0) {
421 buf.append(" throws "); //$NON-NLS-1$
422 for (int i = 0; i < types.length; i++) {
424 buf.append(COMMA_STRING);
426 buf.append(Signature.getSimpleName(Signature.toString(types[i])));
431 if (getFlag(flags, M_APP_RETURNTYPE) && method.exists() && !method.isConstructor()) {
432 buf.append(DECL_STRING);
433 buf.append(Signature.getSimpleName(Signature.toString(method.getReturnType())));
436 // post qualification
437 if (getFlag(flags, M_POST_QUALIFIED)) {
438 buf.append(CONCAT_STRING);
439 getTypeLabel(method.getDeclaringType(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
442 } catch (JavaModelException e) {
443 PHPeclipsePlugin.log(e); // NotExistsException will not reach this point
448 * Appends the label for a field to a StringBuffer. Considers the F_* flags.
450 public static void getFieldLabel(IField field, int flags, StringBuffer buf) {
452 if (getFlag(flags, F_PRE_TYPE_SIGNATURE) && field.exists()) {
453 buf.append(Signature.toString(field.getTypeSignature()));
458 if (getFlag(flags, F_FULLY_QUALIFIED)) {
459 getTypeLabel(field.getDeclaringType(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
462 buf.append(field.getElementName());
464 if (getFlag(flags, F_APP_TYPE_SIGNATURE) && field.exists()) {
465 buf.append(DECL_STRING);
466 buf.append(Signature.toString(field.getTypeSignature()));
469 // post qualification
470 if (getFlag(flags, F_POST_QUALIFIED)) {
471 buf.append(CONCAT_STRING);
472 getTypeLabel(field.getDeclaringType(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
475 } catch (JavaModelException e) {
476 PHPeclipsePlugin.log(e); // NotExistsException will not reach this point
481 * Appends the label for a initializer to a StringBuffer. Considers the I_* flags.
483 // public static void getInitializerLabel(IInitializer initializer, int flags, StringBuffer buf) {
485 // if (getFlag(flags, I_FULLY_QUALIFIED)) {
486 // getTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
489 // buf.append(JavaUIMessages.getString("JavaElementLabels.initializer")); //$NON-NLS-1$
491 // // post qualification
492 // if (getFlag(flags, I_POST_QUALIFIED)) {
493 // buf.append(CONCAT_STRING);
494 // getTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
499 * Appends the label for a type to a StringBuffer. Considers the T_* flags.
501 public static void getTypeLabel(IType type, int flags, StringBuffer buf) {
502 if (getFlag(flags, T_FULLY_QUALIFIED)) {
503 if (type != null) { // jsurfer INSERT
504 IPackageFragment pack = type.getPackageFragment();
505 if (!pack.isDefaultPackage()) {
506 getPackageFragmentLabel(pack, (flags & P_COMPRESSED), buf);
509 buf.append(JavaModelUtil.getTypeQualifiedName(type));
511 } else if (getFlag(flags, T_CONTAINER_QUALIFIED)) {
512 buf.append(JavaModelUtil.getTypeQualifiedName(type));
514 buf.append(type.getElementName());
516 // post qualification
517 if (getFlag(flags, T_POST_QUALIFIED)) {
518 buf.append(CONCAT_STRING);
519 IType declaringType = type.getDeclaringType();
520 if (declaringType != null) {
521 getTypeLabel(declaringType, T_FULLY_QUALIFIED | (flags & P_COMPRESSED), buf);
523 getPackageFragmentLabel(type.getPackageFragment(), (flags & P_COMPRESSED), buf);
529 * Appends the label for a declaration to a StringBuffer. Considers the D_* flags.
531 public static void getDeclararionLabel(IJavaElement declaration, int flags, StringBuffer buf) {
532 if (getFlag(flags, D_QUALIFIED)) {
533 IJavaElement openable = (IJavaElement) declaration.getOpenable();
534 if (openable != null) {
535 buf.append(getElementLabel(openable, CF_QUALIFIED | CU_QUALIFIED));
539 if (declaration.getElementType() == IJavaElement.IMPORT_CONTAINER) {
540 buf.append(PHPUIMessages.getString("JavaElementLabels.import_container")); //$NON-NLS-1$
542 buf.append(declaration.getElementName());
544 // post qualification
545 if (getFlag(flags, D_POST_QUALIFIED)) {
546 IJavaElement openable = (IJavaElement) declaration.getOpenable();
547 if (openable != null) {
548 buf.append(CONCAT_STRING);
549 buf.append(getElementLabel(openable, CF_QUALIFIED | CU_QUALIFIED));
555 * Appends the label for a class file to a StringBuffer. Considers the CF_* flags.
557 // public static void getClassFileLabel(IClassFile classFile, int flags, StringBuffer buf) {
558 // if (getFlag(flags, CF_QUALIFIED)) {
559 // IPackageFragment pack= (IPackageFragment) classFile.getParent();
560 // if (!pack.isDefaultPackage()) {
561 // buf.append(pack.getElementName());
565 // buf.append(classFile.getElementName());
567 // if (getFlag(flags, CF_POST_QUALIFIED)) {
568 // buf.append(CONCAT_STRING);
569 // getPackageFragmentLabel((IPackageFragment) classFile.getParent(), 0, buf);
574 * Appends the label for a compilation unit to a StringBuffer. Considers the CU_* flags.
576 public static void getCompilationUnitLabel(ICompilationUnit cu, int flags, StringBuffer buf) {
577 if (getFlag(flags, CU_QUALIFIED)) {
578 IPackageFragment pack = (IPackageFragment) cu.getParent();
579 if (!pack.isDefaultPackage()) {
580 buf.append(pack.getElementName());
584 buf.append(cu.getElementName());
586 if (getFlag(flags, CU_POST_QUALIFIED)) {
587 buf.append(CONCAT_STRING);
588 getPackageFragmentLabel((IPackageFragment) cu.getParent(), 0, buf);
593 * Appends the label for a package fragment to a StringBuffer. Considers the P_* flags.
595 public static void getPackageFragmentLabel(IPackageFragment pack, int flags, StringBuffer buf) {
596 if (getFlag(flags, P_QUALIFIED)) {
597 getPackageFragmentRootLabel((IPackageFragmentRoot) pack.getParent(), ROOT_QUALIFIED, buf);
600 refreshPackageNamePattern();
601 if (pack.isDefaultPackage()) {
602 buf.append(PHPUIMessages.getString("JavaElementLabels.default_package")); //$NON-NLS-1$
603 } else if (getFlag(flags, P_COMPRESSED) && fgPkgNameLength >= 0) {
604 String name = pack.getElementName();
606 int dot = name.indexOf('.', start);
608 if (dot - start > fgPkgNameLength - 1) {
609 buf.append(fgPkgNamePrefix);
610 if (fgPkgNameChars > 0)
611 buf.append(name.substring(start, Math.min(start + fgPkgNameChars, dot)));
612 buf.append(fgPkgNamePostfix);
614 buf.append(name.substring(start, dot + 1));
616 dot = name.indexOf('.', start);
618 buf.append(name.substring(start));
620 buf.append(pack.getElementName());
622 if (getFlag(flags, P_POST_QUALIFIED)) {
623 buf.append(CONCAT_STRING);
624 getPackageFragmentRootLabel((IPackageFragmentRoot) pack.getParent(), ROOT_QUALIFIED, buf);
629 * Appends the label for a package fragment root to a StringBuffer. Considers the ROOT_* flags.
631 public static void getPackageFragmentRootLabel(IPackageFragmentRoot root, int flags, StringBuffer buf) {
632 if (root.isArchive())
633 getArchiveLabel(root, flags, buf);
635 getFolderLabel(root, flags, buf);
638 private static void getArchiveLabel(IPackageFragmentRoot root, int flags, StringBuffer buf) {
639 // Handle variables different
640 if (getFlag(flags, ROOT_VARIABLE) && getVariableLabel(root, flags, buf))
642 boolean external = root.isExternal();
644 getExternalArchiveLabel(root, flags, buf);
646 getInternalArchiveLabel(root, flags, buf);
649 private static boolean getVariableLabel(IPackageFragmentRoot root, int flags, StringBuffer buf) {
651 // IClasspathEntry rawEntry= root.getRawClasspathEntry();
652 // if (rawEntry != null) {
653 // if (rawEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
654 // buf.append(rawEntry.getPath().makeRelative());
655 // buf.append(CONCAT_STRING);
656 // if (root.isExternal())
657 // buf.append(root.getPath().toOSString());
659 // buf.append(root.getPath().makeRelative().toString());
663 // } catch (JavaModelException e) {
664 // PHPeclipsePlugin.log(e); // problems with class path
669 private static void getExternalArchiveLabel(IPackageFragmentRoot root, int flags, StringBuffer buf) {
670 IPath path = root.getPath();
671 if (getFlag(flags, REFERENCED_ROOT_POST_QUALIFIED)) {
672 int segements = path.segmentCount();
674 buf.append(path.segment(segements - 1));
675 if (segements > 1 || path.getDevice() != null) {
676 buf.append(CONCAT_STRING);
677 buf.append(path.removeLastSegments(1).toOSString());
680 buf.append(path.toOSString());
683 buf.append(path.toOSString());
687 private static void getInternalArchiveLabel(IPackageFragmentRoot root, int flags, StringBuffer buf) {
688 IResource resource = root.getResource();
689 boolean rootQualified = getFlag(flags, ROOT_QUALIFIED);
690 boolean referencedQualified =
691 getFlag(flags, REFERENCED_ROOT_POST_QUALIFIED) && JavaModelUtil.isReferenced(root) && resource != null;
693 buf.append(root.getPath().makeRelative().toString());
695 buf.append(root.getElementName());
696 if (referencedQualified) {
697 buf.append(CONCAT_STRING);
698 buf.append(resource.getParent().getFullPath().makeRelative().toString());
699 } else if (getFlag(flags, ROOT_POST_QUALIFIED)) {
700 buf.append(CONCAT_STRING);
701 buf.append(root.getParent().getPath().makeRelative().toString());
706 private static void getFolderLabel(IPackageFragmentRoot root, int flags, StringBuffer buf) {
707 IResource resource = root.getResource();
708 boolean rootQualified = getFlag(flags, ROOT_QUALIFIED);
709 boolean referencedQualified =
710 getFlag(flags, REFERENCED_ROOT_POST_QUALIFIED) && JavaModelUtil.isReferenced(root) && resource != null;
712 buf.append(root.getPath().makeRelative().toString());
714 if (resource != null)
715 buf.append(resource.getProjectRelativePath().toString());
717 buf.append(root.getElementName());
718 if (referencedQualified) {
719 buf.append(CONCAT_STRING);
720 buf.append(resource.getProject().getName());
721 } else if (getFlag(flags, ROOT_POST_QUALIFIED)) {
722 buf.append(CONCAT_STRING);
723 buf.append(root.getParent().getElementName());
728 private static void refreshPackageNamePattern() {
729 String pattern = getPkgNamePatternForPackagesView();
730 if (pattern.equals(fgPkgNamePattern))
732 else if (pattern.equals("")) { //$NON-NLS-1$
733 fgPkgNamePattern = ""; //$NON-NLS-1$
734 fgPkgNameLength = -1;
737 fgPkgNamePattern = pattern;
740 fgPkgNamePrefix = ""; //$NON-NLS-1$
741 fgPkgNamePostfix = ""; //$NON-NLS-1$
742 while (i < pattern.length()) {
743 char ch = pattern.charAt(i);
744 if (Character.isDigit(ch)) {
745 fgPkgNameChars = ch - 48;
747 fgPkgNamePrefix = pattern.substring(0, i);
749 fgPkgNamePostfix = pattern.substring(i + 1);
750 fgPkgNameLength = fgPkgNamePrefix.length() + fgPkgNameChars + fgPkgNamePostfix.length();
755 fgPkgNamePrefix = pattern;
756 fgPkgNameLength = pattern.length();
759 private static String getPkgNamePatternForPackagesView() {
760 IPreferenceStore store = PreferenceConstants.getPreferenceStore();
761 if (!store.getBoolean(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES))
762 return ""; //$NON-NLS-1$
763 return store.getString(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW);