1 19 package org.netbeans.modules.apisupport.project.metainf; 20 21 import java.awt.Component ; 22 import java.awt.Dimension ; 23 import java.awt.Toolkit ; 24 import java.io.IOException ; 25 import java.util.Collections ; 26 import java.util.Set ; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 import org.netbeans.modules.apisupport.project.NbModuleProject; 30 import org.netbeans.modules.apisupport.project.Util; 31 import org.openide.filesystems.FileObject; 32 33 38 class SUtil { 39 static final String LOG_SET_KEYS = "setting keys"; 40 static final String LOG_COMPUTE_KEYS = "computing services keys"; 41 static final String LOG_END_COMPUTE_KEYS = "compute keys finished"; 42 static final String LOG_SERVICE_NODE_HANDLER_ADD_NOTIFY = "ServiceNodeHandler.addNotify()"; 43 static Logger logger ; 44 45 static FileObject projectDir; 46 static Set platformJars; 47 48 public SUtil() { 49 } 50 51 static Logger getLogger() { 52 if (logger == null) { 53 logger = Logger.getLogger("apisupport.meta-inf"); logger.setLevel(Level.OFF); 55 } 56 return logger; 57 } 58 59 static void log(String message) { 60 getLogger().log(Level.INFO, message); 61 } 62 63 69 76 static FileObject getServicesFolder(NbModuleProject project,boolean create) throws IOException { 77 FileObject srcDir = project.getSourceDirectory(); 78 if (srcDir != null) { 79 FileObject services = srcDir.getFileObject("META-INF/services"); if (services == null && create) { 81 FileObject fo = srcDir.getFileObject("META-INF"); if (fo == null) { 83 fo = srcDir.createFolder("META-INF"); } 85 services = fo.createFolder("services"); } 87 return services; 88 } else { 89 Util.err.log(project.getProjectDirectory().getPath() + " doesn't contain source directory."); 90 return null; 91 } 92 } 93 94 static Set getPlatformJars() { 95 return (platformJars == null) ? 96 Collections.EMPTY_SET: 97 platformJars; 98 } 99 100 106 public static void centerComponent(Component c) { 107 centerComponent(c, null); 108 } 109 110 119 public static void centerComponent(Component c, Component p) { 120 if(c == null) { 121 return; 122 } 123 Dimension d = (p != null ? p.getSize() : 124 Toolkit.getDefaultToolkit().getScreenSize() 125 ); 126 c.setLocation( 127 Math.max(0, (d.getSize().width/2) - (c.getSize().width/2)), 128 Math.max(0, (d.getSize().height/2) - (c.getSize().height/2)) 129 ); 130 } 131 132 151 } 152 | Popular Tags |