1 11 12 package org.eclipse.pde.internal.ui.util; 13 14 import org.eclipse.swt.widgets.Control; 15 import org.eclipse.swt.widgets.Label; 16 17 21 public class PDELabelUtility { 22 23 31 public static String getFieldLabel(Control control) { 32 34 Control[] controls = control.getParent().getChildren(); 38 if (controls.length == 0) { 40 return null; 41 } 42 int myIndex = -1; 45 for (int i = 0; i < controls.length; i++) { 47 if (controls[i] == control) { 48 myIndex = i; 50 break; 51 } 52 } 53 if (myIndex <= 0) { 55 return null; 56 } 57 int labelIndex = myIndex - 1; 59 if ((controls[labelIndex] instanceof Label) == false) { 61 return null; 62 } 63 String labelText = ((Label)controls[labelIndex]).getText(); 65 int colonIndex = labelText.indexOf(':'); 67 if (colonIndex >= 0) { 68 labelText = labelText.replaceAll(":", ""); } 70 int ampIndex = labelText.indexOf('&'); 72 if (ampIndex >= 0) { 73 labelText = labelText.replaceAll("&", ""); } 75 76 return labelText; 77 } 78 79 84 public static String qualifyMessage(String qualification, String message) { 85 StringBuffer buffer = new StringBuffer (); 86 buffer.append(qualification); 87 buffer.append(':'); 88 buffer.append(' '); 89 buffer.append(message); 90 return buffer.toString(); 91 } 92 93 } 94 | Popular Tags |