1 19 20 package org.netbeans.modules.j2ee.clientproject; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import javax.swing.JComponent ; 25 import org.netbeans.modules.j2ee.api.ejbjar.Car; 26 import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties; 27 import org.netbeans.modules.j2ee.dd.api.client.AppClient; 28 import org.netbeans.modules.j2ee.dd.api.client.DDProvider; 29 import org.openide.ErrorManager; 30 import org.openide.WizardDescriptor; 31 32 35 public class Utils { 36 37 private static final String WIZARD_PANEL_CONTENT_DATA = "WizardPanel_contentData"; private static final String WIZARD_PANEL_CONTENT_SELECTED_INDEX = "WizardPanel_contentSelectedIndex"; 40 public static String toClasspathString(File [] classpathEntries) { 41 if (classpathEntries == null) { 42 return ""; 43 } 44 StringBuffer classpath = new StringBuffer (); 45 for (int i = 0; i < classpathEntries.length; i++) { 46 classpath.append(classpathEntries[i].getAbsolutePath()); 47 if (i + 1 < classpathEntries.length) { 48 classpath.append(':'); 49 } 50 } 51 return classpath.toString(); 52 } 53 54 59 public static AppClient getAppClient(final AppClientProject project) { 60 AppClient result = null; 61 try { 62 Car apiCar = project.getAPICar(); 63 if (apiCar.getDeploymentDescriptor() != null 64 || apiCar.getJ2eePlatformVersion().equals(AppClientProjectProperties.JAVA_EE_5)) { 65 result = DDProvider.getDefault().getMergedDDRoot(apiCar); 66 } 67 } catch (IOException e) { 68 ErrorManager.getDefault().log(e.getLocalizedMessage()); 69 } 70 return result; 71 } 72 73 private static void setSteps(WizardDescriptor.Panel[] panels, String [] steps, String [] resultSteps, int offset) { 100 int n = steps == null ? 0 : steps.length; 101 for (int i = 0; i < panels.length; i++) { 102 final JComponent component = (JComponent ) panels[i].getComponent(); 103 String step = i < n ? steps[i] : null; 104 if (step == null) { 105 step = component.getName(); 106 } 107 component.putClientProperty(WIZARD_PANEL_CONTENT_DATA, resultSteps); 108 component.putClientProperty(WIZARD_PANEL_CONTENT_SELECTED_INDEX, i); 109 component.getAccessibleContext().setAccessibleDescription(step); 110 resultSteps[i + offset] = step; 111 } 112 } 113 114 public static void setSteps(WizardDescriptor.Panel[] panels, String [] steps) { 115 setSteps(panels, steps, steps, 0); 116 } 117 118 } 238 | Popular Tags |