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. e.g. <code>foo(int)</code>
38 public final static int M_PARAMETER_TYPES = 1 << 0;
41 * Method names contain parameter names. e.g. <code>foo(index)</code>
43 public final static int M_PARAMETER_NAMES = 1 << 1;
46 * Method names contain thrown exceptions. e.g.
47 * <code>foo throws IOException</code>
49 public final static int M_EXCEPTIONS = 1 << 2;
52 * Method names contain return type (appended) e.g. <code>foo : int</code>
54 public final static int M_APP_RETURNTYPE = 1 << 3;
57 * Method names contain return type (appended) e.g. <code>int foo</code>
59 public final static int M_PRE_RETURNTYPE = 1 << 4;
62 * Method names are fully qualified. e.g. <code>java.util.Vector.size</code>
64 public final static int M_FULLY_QUALIFIED = 1 << 5;
67 * Method names are post qualified. e.g.
68 * <code>size - java.util.Vector</code>
70 public final static int M_POST_QUALIFIED = 1 << 6;
73 * Initializer names are fully qualified. e.g.
74 * <code>java.util.Vector.{ ... }</code>
76 public final static int I_FULLY_QUALIFIED = 1 << 7;
79 * Type names are post qualified. e.g. <code>{ ... } - java.util.Map</code>
81 public final static int I_POST_QUALIFIED = 1 << 8;
84 * Field names contain the declared type (appended) e.g.
85 * <code>int fHello</code>
87 public final static int F_APP_TYPE_SIGNATURE = 1 << 9;
90 * Field names contain the declared type (prepended) e.g.
91 * <code>fHello : int</code>
93 public final static int F_PRE_TYPE_SIGNATURE = 1 << 10;
96 * Fields names are fully qualified. e.g. <code>java.lang.System.out</code>
98 public final static int F_FULLY_QUALIFIED = 1 << 11;
101 * Fields names are post qualified. e.g. <code>out - java.lang.System</code>
103 public final static int F_POST_QUALIFIED = 1 << 12;
106 * Type names are fully qualified. e.g. <code>java.util.Map.MapEntry</code>
108 public final static int T_FULLY_QUALIFIED = 1 << 13;
111 * Type names are type container qualified. e.g. <code>Map.MapEntry</code>
113 public final static int T_CONTAINER_QUALIFIED = 1 << 14;
116 * Type names are post qualified. e.g. <code>MapEntry - java.util.Map</code>
118 public final static int T_POST_QUALIFIED = 1 << 15;
121 * Declarations (import container / declarartion, package declarartion) are
122 * qualified. e.g. <code>java.util.Vector.class/import container</code>
124 public final static int D_QUALIFIED = 1 << 16;
127 * Declarations (import container / declarartion, package declarartion) are
128 * post qualified. e.g.
129 * <code>import container - java.util.Vector.class</code>
131 public final static int D_POST_QUALIFIED = 1 << 17;
134 * Class file names are fully qualified. e.g.
135 * <code>java.util.Vector.class</code>
137 public final static int CF_QUALIFIED = 1 << 18;
140 * Class file names are post qualified. e.g.
141 * <code>Vector.class - java.util</code>
143 public final static int CF_POST_QUALIFIED = 1 << 19;
146 * Compilation unit names are fully qualified. e.g.
147 * <code>java.util.Vector.java</code>
149 public final static int CU_QUALIFIED = 1 << 20;
152 * Compilation unit names are post qualified. e.g.
153 * <code>Vector.java - java.util</code>
155 public final static int CU_POST_QUALIFIED = 1 << 21;
158 * Package names are qualified. e.g. <code>MyProject/src/java.util</code>
160 public final static int P_QUALIFIED = 1 << 22;
163 * Package names are post qualified. e.g.
164 * <code>java.util - MyProject/src</code>
166 public final static int P_POST_QUALIFIED = 1 << 23;
169 * Package Fragment Roots contain variable name if from a variable. e.g.
170 * <code>JRE_LIB - c:\java\lib\rt.jar</code>
172 public final static int ROOT_VARIABLE = 1 << 24;
175 * Package Fragment Roots contain the project name if not an archive
176 * (prepended). e.g. <code>MyProject/src</code>
178 public final static int ROOT_QUALIFIED = 1 << 25;
181 * Package Fragment Roots contain the project name if not an archive
182 * (appended). e.g. <code>src - MyProject</code>
184 public final static int ROOT_POST_QUALIFIED = 1 << 26;
187 * Add root path to all elements except Package Fragment Roots and Java
188 * projects. e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
189 * Option only applies to getElementLabel
191 public final static int APPEND_ROOT_PATH = 1 << 27;
194 * Add root path to all elements except Package Fragment Roots and Java
195 * projects. e.g. <code>java.lang.Vector - c:\java\lib\rt.jar</code>
196 * Option only applies to getElementLabel
198 public final static int PREPEND_ROOT_PATH = 1 << 28;
201 * Package names are compressed. e.g. <code>o*.e*.search</code>
203 public final static int P_COMPRESSED = 1 << 29;
206 * Post qualify referenced package fragement roots. For example
207 * <code>jdt.jar - net.sourceforge.phpdt.ui</code> if the jar is
208 * referenced from another project.
210 public final static int REFERENCED_ROOT_POST_QUALIFIED = 1 << 30;
213 * Qualify all elements
215 public final static int ALL_FULLY_QUALIFIED = F_FULLY_QUALIFIED
216 | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED
217 | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED | P_QUALIFIED
221 * Post qualify all elements
223 public final static int ALL_POST_QUALIFIED = F_POST_QUALIFIED
224 | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED
225 | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED
226 | P_POST_QUALIFIED | ROOT_POST_QUALIFIED;
229 * Default options (M_PARAMETER_TYPES enabled)
231 public final static int ALL_DEFAULT = M_PARAMETER_TYPES;
234 * Default qualify options (All except Root and Package)
236 public final static int DEFAULT_QUALIFIED = F_FULLY_QUALIFIED
237 | M_FULLY_QUALIFIED | I_FULLY_QUALIFIED | T_FULLY_QUALIFIED
238 | D_QUALIFIED | CF_QUALIFIED | CU_QUALIFIED;
241 * Default post qualify options (All except Root and Package)
243 public final static int DEFAULT_POST_QUALIFIED = F_POST_QUALIFIED
244 | M_POST_QUALIFIED | I_POST_QUALIFIED | T_POST_QUALIFIED
245 | D_POST_QUALIFIED | CF_POST_QUALIFIED | CU_POST_QUALIFIED;
247 public final static String CONCAT_STRING = PHPUIMessages
248 .getString("JavaElementLabels.concat_string"); // " - ";
251 public final static String COMMA_STRING = PHPUIMessages
252 .getString("JavaElementLabels.comma_string"); // ", ";
255 public final static String DECL_STRING = PHPUIMessages
256 .getString("JavaElementLabels.declseparator_string"); // " "; //
263 * Package name compression
265 private static String fgPkgNamePattern = ""; //$NON-NLS-1$
267 private static String fgPkgNamePrefix;
269 private static String fgPkgNamePostfix;
271 private static int fgPkgNameChars;
273 private static int fgPkgNameLength = -1;
275 private JavaElementLabels() {
278 private static boolean getFlag(int flags, int flag) {
279 return (flags & flag) != 0;
282 public static String getTextLabel(Object obj, int flags) {
283 if (obj instanceof IJavaElement) {
284 return getElementLabel((IJavaElement) obj, flags);
285 } else if (obj instanceof IAdaptable) {
286 IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) obj)
287 .getAdapter(IWorkbenchAdapter.class);
288 if (wbadapter != null) {
289 return wbadapter.getLabel(obj);
292 return ""; //$NON-NLS-1$
296 * Returns the label for a Java element. Flags as defined above.
298 public static String getElementLabel(IJavaElement element, int flags) {
299 StringBuffer buf = new StringBuffer(60);
300 getElementLabel(element, flags, buf);
301 return buf.toString();
305 * Returns the label for a Java element. Flags as defined above.
307 public static void getElementLabel(IJavaElement element, int flags,
309 int type = element.getElementType();
310 IPackageFragmentRoot root = null;
312 if (type != IJavaElement.JAVA_MODEL
313 && type != IJavaElement.JAVA_PROJECT
314 && type != IJavaElement.PACKAGE_FRAGMENT_ROOT)
315 root = JavaModelUtil.getPackageFragmentRoot(element);
316 if (root != null && getFlag(flags, PREPEND_ROOT_PATH)) {
317 getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
318 buf.append(CONCAT_STRING);
322 case IJavaElement.METHOD:
323 getMethodLabel((IMethod) element, flags, buf);
325 case IJavaElement.FIELD:
326 getFieldLabel((IField) element, flags, buf);
328 // case IJavaElement.INITIALIZER:
329 // getInitializerLabel((IInitializer) element, flags, buf);
331 case IJavaElement.TYPE:
332 getTypeLabel((IType) element, flags, buf);
334 // case IJavaElement.CLASS_FILE:
335 // getClassFileLabel((IClassFile) element, flags, buf);
337 case IJavaElement.COMPILATION_UNIT:
338 getCompilationUnitLabel((ICompilationUnit) element, flags, buf);
340 case IJavaElement.PACKAGE_FRAGMENT:
341 getPackageFragmentLabel((IPackageFragment) element, flags, buf);
343 case IJavaElement.PACKAGE_FRAGMENT_ROOT:
344 getPackageFragmentRootLabel((IPackageFragmentRoot) element, flags,
347 case IJavaElement.IMPORT_CONTAINER:
348 case IJavaElement.IMPORT_DECLARATION:
349 case IJavaElement.PACKAGE_DECLARATION:
350 getDeclararionLabel(element, flags, buf);
352 case IJavaElement.JAVA_PROJECT:
353 case IJavaElement.JAVA_MODEL:
354 buf.append(element.getElementName());
357 buf.append(element.getElementName());
360 if (root != null && getFlag(flags, APPEND_ROOT_PATH)) {
361 buf.append(CONCAT_STRING);
362 getPackageFragmentRootLabel(root, ROOT_QUALIFIED, buf);
367 * Appends the label for a method to a StringBuffer. Considers the M_*
370 public static void getMethodLabel(IMethod method, int flags,
374 if (getFlag(flags, M_PRE_RETURNTYPE) && method.exists()
375 && !method.isConstructor()) {
376 buf.append(Signature.getSimpleName(Signature.toString(method
382 if (getFlag(flags, M_FULLY_QUALIFIED)) {
383 getTypeLabel(method.getDeclaringType(), T_FULLY_QUALIFIED
384 | (flags & P_COMPRESSED), buf);
388 buf.append(method.getElementName());
391 if (getFlag(flags, M_PARAMETER_TYPES | M_PARAMETER_NAMES)) {
394 String[] types = getFlag(flags, M_PARAMETER_TYPES) ? method
395 .getParameterTypes() : null;
396 String[] names = (getFlag(flags, M_PARAMETER_NAMES) && method
397 .exists()) ? method.getParameterNames() : null;
398 int nParams = types != null ? types.length : names.length;
400 for (int i = 0; i < nParams; i++) {
402 buf.append(COMMA_STRING); //$NON-NLS-1$
405 buf.append(Signature.getSimpleName(Signature
406 .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
427 .toString(types[i])));
432 if (getFlag(flags, M_APP_RETURNTYPE) && method.exists()
433 && !method.isConstructor()) {
434 buf.append(DECL_STRING);
435 buf.append(Signature.getSimpleName(Signature.toString(method
439 // post qualification
440 if (getFlag(flags, M_POST_QUALIFIED)) {
441 buf.append(CONCAT_STRING);
442 getTypeLabel(method.getDeclaringType(), T_FULLY_QUALIFIED
443 | (flags & P_COMPRESSED), buf);
446 } catch (JavaModelException e) {
447 PHPeclipsePlugin.log(e); // NotExistsException will not reach
453 * Appends the label for a field to a StringBuffer. Considers the F_* flags.
455 public static void getFieldLabel(IField field, int flags, StringBuffer buf) {
457 if (getFlag(flags, F_PRE_TYPE_SIGNATURE) && field.exists()) {
458 buf.append(Signature.toString(field.getTypeSignature()));
463 if (getFlag(flags, F_FULLY_QUALIFIED)) {
464 getTypeLabel(field.getDeclaringType(), T_FULLY_QUALIFIED
465 | (flags & P_COMPRESSED), buf);
468 buf.append(field.getElementName());
470 if (getFlag(flags, F_APP_TYPE_SIGNATURE) && field.exists()) {
471 buf.append(DECL_STRING);
472 buf.append(Signature.toString(field.getTypeSignature()));
475 // post qualification
476 if (getFlag(flags, F_POST_QUALIFIED)) {
477 buf.append(CONCAT_STRING);
478 getTypeLabel(field.getDeclaringType(), T_FULLY_QUALIFIED
479 | (flags & P_COMPRESSED), buf);
482 } catch (JavaModelException e) {
483 PHPeclipsePlugin.log(e); // NotExistsException will not reach
489 * Appends the label for a initializer to a StringBuffer. Considers the I_*
492 // public static void getInitializerLabel(IInitializer initializer, int
493 // flags, StringBuffer buf) {
495 // if (getFlag(flags, I_FULLY_QUALIFIED)) {
496 // getTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED | (flags &
497 // P_COMPRESSED), buf);
500 // buf.append(JavaUIMessages.getString("JavaElementLabels.initializer"));
503 // // post qualification
504 // if (getFlag(flags, I_POST_QUALIFIED)) {
505 // buf.append(CONCAT_STRING);
506 // getTypeLabel(initializer.getDeclaringType(), T_FULLY_QUALIFIED | (flags &
507 // P_COMPRESSED), buf);
511 * Appends the label for a type to a StringBuffer. Considers the T_* flags.
513 public static void getTypeLabel(IType type, int flags, StringBuffer buf) {
514 if (getFlag(flags, T_FULLY_QUALIFIED)) {
515 if (type != null) { // jsurfer INSERT
516 IPackageFragment pack = type.getPackageFragment();
517 if (!pack.isDefaultPackage()) {
518 getPackageFragmentLabel(pack, (flags & P_COMPRESSED), buf);
521 buf.append(JavaModelUtil.getTypeQualifiedName(type));
523 } else if (getFlag(flags, T_CONTAINER_QUALIFIED)) {
524 buf.append(JavaModelUtil.getTypeQualifiedName(type));
526 buf.append(type.getElementName());
528 // post qualification
529 if (getFlag(flags, T_POST_QUALIFIED)) {
530 buf.append(CONCAT_STRING);
531 IType declaringType = type.getDeclaringType();
532 if (declaringType != null) {
533 getTypeLabel(declaringType, T_FULLY_QUALIFIED
534 | (flags & P_COMPRESSED), buf);
536 getPackageFragmentLabel(type.getPackageFragment(),
537 (flags & P_COMPRESSED), buf);
543 * Appends the label for a declaration to a StringBuffer. Considers the D_*
546 public static void getDeclararionLabel(IJavaElement declaration, int flags,
548 if (getFlag(flags, D_QUALIFIED)) {
549 IJavaElement openable = (IJavaElement) declaration.getOpenable();
550 if (openable != null) {
551 buf.append(getElementLabel(openable, CF_QUALIFIED
556 if (declaration.getElementType() == IJavaElement.IMPORT_CONTAINER) {
557 buf.append(PHPUIMessages
558 .getString("JavaElementLabels.import_container")); //$NON-NLS-1$
560 buf.append(declaration.getElementName());
562 // post qualification
563 if (getFlag(flags, D_POST_QUALIFIED)) {
564 IJavaElement openable = (IJavaElement) declaration.getOpenable();
565 if (openable != null) {
566 buf.append(CONCAT_STRING);
567 buf.append(getElementLabel(openable, CF_QUALIFIED
574 * Appends the label for a class file to a StringBuffer. Considers the CF_*
577 // public static void getClassFileLabel(IClassFile classFile, int flags,
578 // StringBuffer buf) {
579 // if (getFlag(flags, CF_QUALIFIED)) {
580 // IPackageFragment pack= (IPackageFragment) classFile.getParent();
581 // if (!pack.isDefaultPackage()) {
582 // buf.append(pack.getElementName());
586 // buf.append(classFile.getElementName());
588 // if (getFlag(flags, CF_POST_QUALIFIED)) {
589 // buf.append(CONCAT_STRING);
590 // getPackageFragmentLabel((IPackageFragment) classFile.getParent(), 0,
595 * Appends the label for a compilation unit to a StringBuffer. Considers the
598 public static void getCompilationUnitLabel(ICompilationUnit cu, int flags,
600 if (getFlag(flags, CU_QUALIFIED)) {
601 IPackageFragment pack = (IPackageFragment) cu.getParent();
602 if (!pack.isDefaultPackage()) {
603 buf.append(pack.getElementName());
607 buf.append(cu.getElementName());
609 if (getFlag(flags, CU_POST_QUALIFIED)) {
610 buf.append(CONCAT_STRING);
611 getPackageFragmentLabel((IPackageFragment) cu.getParent(), 0, buf);
616 * Appends the label for a package fragment to a StringBuffer. Considers the
619 public static void getPackageFragmentLabel(IPackageFragment pack,
620 int flags, StringBuffer buf) {
621 if (getFlag(flags, P_QUALIFIED)) {
622 getPackageFragmentRootLabel(
623 (IPackageFragmentRoot) pack.getParent(), ROOT_QUALIFIED,
627 refreshPackageNamePattern();
628 if (pack.isDefaultPackage()) {
629 buf.append(PHPUIMessages
630 .getString("JavaElementLabels.default_package")); //$NON-NLS-1$
631 } else if (getFlag(flags, P_COMPRESSED) && fgPkgNameLength >= 0) {
632 String name = pack.getElementName();
634 int dot = name.indexOf('.', start);
636 if (dot - start > fgPkgNameLength - 1) {
637 buf.append(fgPkgNamePrefix);
638 if (fgPkgNameChars > 0)
639 buf.append(name.substring(start, Math.min(start
640 + fgPkgNameChars, dot)));
641 buf.append(fgPkgNamePostfix);
643 buf.append(name.substring(start, dot + 1));
645 dot = name.indexOf('.', start);
647 buf.append(name.substring(start));
649 buf.append(pack.getElementName());
651 if (getFlag(flags, P_POST_QUALIFIED)) {
652 buf.append(CONCAT_STRING);
653 getPackageFragmentRootLabel(
654 (IPackageFragmentRoot) pack.getParent(), ROOT_QUALIFIED,
660 * Appends the label for a package fragment root to a StringBuffer.
661 * Considers the ROOT_* flags.
663 public static void getPackageFragmentRootLabel(IPackageFragmentRoot root,
664 int flags, StringBuffer buf) {
665 if (root.isArchive())
666 getArchiveLabel(root, flags, buf);
668 getFolderLabel(root, flags, buf);
671 private static void getArchiveLabel(IPackageFragmentRoot root, int flags,
673 // Handle variables different
674 if (getFlag(flags, ROOT_VARIABLE) && getVariableLabel(root, flags, buf))
676 boolean external = root.isExternal();
678 getExternalArchiveLabel(root, flags, buf);
680 getInternalArchiveLabel(root, flags, buf);
683 private static boolean getVariableLabel(IPackageFragmentRoot root,
684 int flags, StringBuffer buf) {
686 // IClasspathEntry rawEntry= root.getRawClasspathEntry();
687 // if (rawEntry != null) {
688 // if (rawEntry.getEntryKind() == IClasspathEntry.CPE_VARIABLE) {
689 // buf.append(rawEntry.getPath().makeRelative());
690 // buf.append(CONCAT_STRING);
691 // if (root.isExternal())
692 // buf.append(root.getPath().toOSString());
694 // buf.append(root.getPath().makeRelative().toString());
698 // } catch (JavaModelException e) {
699 // PHPeclipsePlugin.log(e); // problems with class path
704 private static void getExternalArchiveLabel(IPackageFragmentRoot root,
705 int flags, StringBuffer buf) {
706 IPath path = root.getPath();
707 if (getFlag(flags, REFERENCED_ROOT_POST_QUALIFIED)) {
708 int segements = path.segmentCount();
710 buf.append(path.segment(segements - 1));
711 if (segements > 1 || path.getDevice() != null) {
712 buf.append(CONCAT_STRING);
713 buf.append(path.removeLastSegments(1).toOSString());
716 buf.append(path.toOSString());
719 buf.append(path.toOSString());
723 private static void getInternalArchiveLabel(IPackageFragmentRoot root,
724 int flags, StringBuffer buf) {
725 IResource resource = root.getResource();
726 boolean rootQualified = getFlag(flags, ROOT_QUALIFIED);
727 boolean referencedQualified = getFlag(flags,
728 REFERENCED_ROOT_POST_QUALIFIED)
729 && JavaModelUtil.isReferenced(root) && resource != null;
731 buf.append(root.getPath().makeRelative().toString());
733 buf.append(root.getElementName());
734 if (referencedQualified) {
735 buf.append(CONCAT_STRING);
736 buf.append(resource.getParent().getFullPath().makeRelative()
738 } else if (getFlag(flags, ROOT_POST_QUALIFIED)) {
739 buf.append(CONCAT_STRING);
741 .append(root.getParent().getPath().makeRelative()
747 private static void getFolderLabel(IPackageFragmentRoot root, int flags,
749 IResource resource = root.getResource();
750 boolean rootQualified = getFlag(flags, ROOT_QUALIFIED);
751 boolean referencedQualified = getFlag(flags,
752 REFERENCED_ROOT_POST_QUALIFIED)
753 && JavaModelUtil.isReferenced(root) && resource != null;
755 buf.append(root.getPath().makeRelative().toString());
757 if (resource != null)
758 buf.append(resource.getProjectRelativePath().toString());
760 buf.append(root.getElementName());
761 if (referencedQualified) {
762 buf.append(CONCAT_STRING);
763 buf.append(resource.getProject().getName());
764 } else if (getFlag(flags, ROOT_POST_QUALIFIED)) {
765 buf.append(CONCAT_STRING);
766 buf.append(root.getParent().getElementName());
771 private static void refreshPackageNamePattern() {
772 String pattern = getPkgNamePatternForPackagesView();
773 if (pattern.equals(fgPkgNamePattern))
775 else if (pattern.equals("")) { //$NON-NLS-1$
776 fgPkgNamePattern = ""; //$NON-NLS-1$
777 fgPkgNameLength = -1;
780 fgPkgNamePattern = pattern;
783 fgPkgNamePrefix = ""; //$NON-NLS-1$
784 fgPkgNamePostfix = ""; //$NON-NLS-1$
785 while (i < pattern.length()) {
786 char ch = pattern.charAt(i);
787 if (Character.isDigit(ch)) {
788 fgPkgNameChars = ch - 48;
790 fgPkgNamePrefix = pattern.substring(0, i);
792 fgPkgNamePostfix = pattern.substring(i + 1);
793 fgPkgNameLength = fgPkgNamePrefix.length() + fgPkgNameChars
794 + fgPkgNamePostfix.length();
799 fgPkgNamePrefix = pattern;
800 fgPkgNameLength = pattern.length();
803 private static String getPkgNamePatternForPackagesView() {
804 IPreferenceStore store = PreferenceConstants.getPreferenceStore();
806 .getBoolean(PreferenceConstants.APPEARANCE_COMPRESS_PACKAGE_NAMES))
807 return ""; //$NON-NLS-1$
809 .getString(PreferenceConstants.APPEARANCE_PKG_NAME_PATTERN_FOR_PKG_VIEW);