List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static final ResourceBundle getBundle(String baseName)
From source file:common.SwingGUI01.java
/** * Creates new form SwingGUI01//ww w .j a v a 2 s .com */ public SwingGUI01() { //init DB dataSource = prepareDataSource(); try { DBUtils.executeSqlScript(dataSource, Agency.class.getResource("/agencyDB.sql")); } catch (SQLException ex) { Logger.getLogger(SwingGUI01.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { errorMessage = "Error opening script files"; log.error(errorMessage, ex); showErrorDialog(errorMessage); } agentManager = new AgentManagerImpl(dataSource); missionManager = new MissionManagerImpl(dataSource); agencyManager = new AgencyManagerImpl(dataSource); initComponents(); getContentPane().setBackground(Color.GRAY); //title renaming setTitle(ResourceBundle.getBundle("strings").getString("agency")); //tabs renaming jTabbedPane2.setTitleAt(0, ResourceBundle.getBundle("strings").getString("agentsTable")); jTabbedPane2.setTitleAt(1, ResourceBundle.getBundle("strings").getString("missionTable")); //agents table inicialization AgentsTableModel agentsModel = (AgentsTableModel) agentsTable.getModel(); agentsTable.getColumnModel().getColumn(0).setPreferredWidth(200); agentsTable.getColumnModel().getColumn(1).setPreferredWidth(100); agentsTable.getColumnModel().getColumn(2).setPreferredWidth(43); agentsTable.getColumnModel().getColumn(3).setPreferredWidth(400); agentsTable.getColumnModel().getColumn(4).setPreferredWidth(200); //missions table inicialization MissionsTableModel missionsModel = (MissionsTableModel) missionsTable.getModel(); missionsTable.getColumnModel().getColumn(0).setPreferredWidth(200); missionsTable.getColumnModel().getColumn(1).setPreferredWidth(100); missionsTable.getColumnModel().getColumn(2).setPreferredWidth(100); missionsTable.getColumnModel().getColumn(3).setPreferredWidth(100); missionsTable.getColumnModel().getColumn(4).setPreferredWidth(100); missionsTable.getColumnModel().getColumn(5).setPreferredWidth(625 - 300); //disable column reorganization agentsTable.getTableHeader().setReorderingAllowed(false); missionsTable.getTableHeader().setReorderingAllowed(false); //add all agents via SwingWorker agentSwingWorker = new AgentSwingWorker(null, TableOperations.ADD_ALL); agentSwingWorker.execute(); missionSwingWorker = new MissionSwingWorker(null, TableOperations.ADD_ALL); missionSwingWorker.execute(); }
From source file:org.pegadi.client.ApplicationLauncher.java
public ApplicationLauncher() { log.debug("Inside applicationlauncher constructor"); try {//from ww w .j a va 2 s . c o m str = ResourceBundle.getBundle("org.pegadi.client.ClientStrings"); appStrings = ResourceBundle.getBundle("org.pegadi.client.ClientApp"); ClientContext.includeUnstable = Boolean.valueOf(appStrings.getString("pegadi.includeunstable")); log.debug("UNSTABLE:" + ClientContext.includeUnstable); jbInit(); setLocale("no_NO"); } catch (Exception e) { log.error("Error initialising strings", e); } version = str.getString("version"); setTitle(str.getString("app_title") + " " + version); registerOSXApplicationMenu(); }
From source file:edu.harvard.iq.dataverse.api.HarvestingServer.java
/** * create an OAI set from spec in path and other parameters from POST body * (as JSON). {"name":$set_name,/*from w w w .j a v a 2s. c o m*/ * "description":$optional_set_description,"definition":$set_search_query_string}. */ @POST @Path("{specname}") public Response createOaiSet(String jsonBody, @PathParam("specname") String spec, @QueryParam("key") String apiKey) throws IOException, JsonParseException { /* * authorization modeled after the UI (aka HarvestingSetsPage) */ AuthenticatedUser dvUser; try { dvUser = findAuthenticatedUserOrDie(); } catch (WrappedResponse wr) { return wr.getResponse(); } if (!dvUser.isSuperuser()) { return badRequest(ResourceBundle.getBundle("Bundle") .getString("harvestserver.newSetDialog.setspec.superUser.required")); } StringReader rdr = new StringReader(jsonBody); try (JsonReader jrdr = Json.createReader(rdr)) { JsonObject json = jrdr.readObject(); OAISet set = new OAISet(); //Validating spec if (!StringUtils.isEmpty(spec)) { if (spec.length() > 30) { return badRequest(ResourceBundle.getBundle("Bundle") .getString("harvestserver.newSetDialog.setspec.sizelimit")); } if (!Pattern.matches("^[a-zA-Z0-9\\_\\-]+$", spec)) { return badRequest(ResourceBundle.getBundle("Bundle") .getString("harvestserver.newSetDialog.setspec.invalid")); // If it passes the regex test, check } if (oaiSetService.findBySpec(spec) != null) { return badRequest(ResourceBundle.getBundle("Bundle") .getString("harvestserver.newSetDialog.setspec.alreadyused")); } } else { return badRequest(ResourceBundle.getBundle("Bundle") .getString("harvestserver.newSetDialog.setspec.required")); } set.setSpec(spec); String name, desc, defn; try { name = json.getString("name"); } catch (NullPointerException npe_name) { return badRequest(ResourceBundle.getBundle("Bundle") .getString("harvestserver.newSetDialog.setspec.required")); } try { defn = json.getString("definition"); } catch (NullPointerException npe_defn) { throw new JsonParseException("definition unspecified"); } try { desc = json.getString("description"); } catch (NullPointerException npe_desc) { desc = ""; //treating description as optional } set.setName(name); set.setDescription(desc); set.setDefinition(defn); oaiSetService.save(set); return created("/harvest/server/oaisets" + spec, oaiSetAsJson(set)); } }
From source file:eu.optimis.service_manager.rest.ServiceManagerREST.java
public ServiceManagerREST() { try {//from www . j av a2 s.c o m PropertyConfigurator.configure(ConfigManager.getConfigFilePath(ConfigManager.LOG4J_CONFIG_FILE)); LOGGER.debug("ServiceManagerREST: Constructor invoked"); PropertiesConfiguration config = ConfigManager.getPropertiesConfiguration(ConfigManager.SM_CONFIG_FILE); SD_URL = config.getString("sp.sd.url"); LOGGER.debug("ServiceManagerREST: SD_URL is: " + SD_URL); MANIFEST_REPO_URL = config.getString("sp.mr.url"); LOGGER.debug("ServiceManagerREST: MANIFEST_REPO_URL is: " + MANIFEST_REPO_URL); } catch (Exception e) { LOGGER.error("ServiceManagerREST: Error reading configuration file or getting properties"); e.printStackTrace(); throw new RuntimeException(e); } try { ResourceBundle rb = ResourceBundle.getBundle("services"); TREC_HOST = rb.getString("service.trec_host"); TREC_PORT = rb.getString("service.trec_port"); LOGGER.debug("ServiceManagerREST: TREC_HOST is: " + TREC_HOST + ", TREC_PORT is: " + TREC_PORT); // Django: Used for broker commented out // TREC_TABLE_URL = rb.getString("sp.trec.db.url"); // TREC_DB_USER = rb.getString("sp.trec.db.username"); // TREC_DB_PASSWORD = rb.getString("sp.trec.db.password"); // TREC_DB_DRIVER = rb.getString("sp.trec.db.driver"); SD_URL = rb.getString("sp.sd.url"); } catch (MissingResourceException e) { LOGGER.error("ServiceManagerREST: Error - cannot find the resource bundle path."); throw new RuntimeException(e); } if (serviceManager == null) { serviceManager = ServiceManager.getInstance(); } }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.forms.TfsLoginForm.java
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL//from w w w. j a v a 2 s. c o m */ private void $$$setupUI$$$() { createUIComponents(); contentPanel = new JPanel(); contentPanel.setLayout(new GridLayoutManager(7, 5, new Insets(0, 0, 0, 0), -1, -1)); final Spacer spacer1 = new Spacer(); contentPanel.add(spacer1, new GridConstraints(6, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); headerLabel = new JLabel(); this.$$$loadLabelText$$$(headerLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin") .getString("TfsLoginForm.Header")); contentPanel.add(headerLabel, new GridConstraints(0, 1, 1, 4, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label1 = new JLabel(); this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin") .getString("TfsLoginForm.ServerUrl")); contentPanel.add(label1, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); serverUrl = new JTextField(); contentPanel.add(serverUrl, new GridConstraints(2, 2, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); exampleLabel = new JLabel(); this.$$$loadLabelText$$$(exampleLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin") .getString("TfsLoginForm.ExampleUrl")); contentPanel.add(exampleLabel, new GridConstraints(3, 2, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); signInLink = new Hyperlink(); this.$$$loadLabelText$$$(signInLink, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin") .getString("TfsLoginForm.Connect")); contentPanel.add(signInLink, new GridConstraints(4, 2, 1, 3, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); contentPanel.add(vsIcon, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); loginProgressLabel = new JLabel(); loginProgressLabel.setText("Sample Text for Busy Spinner Message"); contentPanel.add(loginProgressLabel, new GridConstraints(5, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); busySpinner = new BusySpinnerPanel(); contentPanel.add(busySpinner, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); contentPanel.add(spacer2, new GridConstraints(5, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); descriptionLabel = new WrappingLabel(); descriptionLabel.setText(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin") .getString("TfsLoginForm.Description")); contentPanel.add(descriptionLabel, new GridConstraints(1, 1, 1, 4, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); }
From source file:JAXRQueryPostal.java
/** * Establishes a connection to a registry. *//from ww w . j a v a 2s. c o m * @param queryUrl the URL of the query registry * @param publishUrl the URL of the publish registry * @param uuidString the UUID string of the postal address scheme */ public void makeConnection(String queryUrl, String publishUrl, String uuidString) { /* * Specify proxy information in case you * are going beyond your firewall. */ ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); String httpProxyHost = bundle.getString("http.proxyHost"); String httpProxyPort = bundle.getString("http.proxyPort"); String userTaxonomyFilenames = bundle.getString("postal.taxonomy.filenames"); /* * Define connection configuration properties. * For simple queries, you need the query URL. */ Properties props = new Properties(); props.setProperty("javax.xml.registry.queryManagerURL", queryUrl); props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost); props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort); // Define the taxonomy XML file (postalconcepts.xml) props.setProperty("com.sun.xml.registry.userTaxonomyFilenames", userTaxonomyFilenames); // Set properties for postal address mapping: postal address // classification scheme and mapping to JAXR scheme props.setProperty("javax.xml.registry.postalAddressScheme", uuidString); props.setProperty("javax.xml.registry.semanticEquivalences", "urn:uuid:PostalAddressAttributes/StreetNumber," + "urn:" + uuidString + "/MyStreetNumber|" + "urn:uuid:PostalAddressAttributes/Street," + "urn:" + uuidString + "/MyStreet|" + "urn:uuid:PostalAddressAttributes/City," + "urn:" + uuidString + "/MyCity|" + "urn:uuid:PostalAddressAttributes/State," + "urn:" + uuidString + "/MyState|" + "urn:uuid:PostalAddressAttributes/PostalCode," + "urn:" + uuidString + "/MyPostalCode|" + "urn:uuid:PostalAddressAttributes/Country," + "urn:" + uuidString + "/MyCountry"); try { // Create the connection, passing it the // configuration properties ConnectionFactory factory = ConnectionFactory.newInstance(); factory.setProperties(props); connection = factory.createConnection(); System.out.println("Created connection to registry"); } catch (Exception e) { e.printStackTrace(); if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:JAXRPublishPostal.java
/** * Establishes a connection to a registry. *// w w w. j a v a2s. com * @param queryUrl the URL of the query registry * @param publishUrl the URL of the publish registry */ public void makeConnection(String queryUrl, String publishUrl, String uuidString) { /* * Specify proxy information in case you * are going beyond your firewall. */ ResourceBundle bundle = ResourceBundle.getBundle("JAXRExamples"); String httpProxyHost = bundle.getString("http.proxyHost"); String httpProxyPort = bundle.getString("http.proxyPort"); String httpsProxyHost = bundle.getString("https.proxyHost"); String httpsProxyPort = bundle.getString("https.proxyPort"); String userTaxonomyFilenames = bundle.getString("postal.taxonomy.filenames"); /* * Define connection configuration properties. * To publish, you need both the query URL and the * publish URL. */ Properties props = new Properties(); props.setProperty("javax.xml.registry.queryManagerURL", queryUrl); props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl); props.setProperty("com.sun.xml.registry.http.proxyHost", httpProxyHost); props.setProperty("com.sun.xml.registry.http.proxyPort", httpProxyPort); props.setProperty("com.sun.xml.registry.https.proxyHost", httpsProxyHost); props.setProperty("com.sun.xml.registry.https.proxyPort", httpsProxyPort); // Define the taxonomy XML file (postalconcepts.xml) props.setProperty("com.sun.xml.registry.userTaxonomyFilenames", userTaxonomyFilenames); // Set properties for postal address mapping using my scheme props.setProperty("javax.xml.registry.postalAddressScheme", uuidString); props.setProperty("javax.xml.registry.semanticEquivalences", "urn:uuid:PostalAddressAttributes/StreetNumber," + "urn:" + uuidString + "/MyStreetNumber|" + "urn:uuid:PostalAddressAttributes/Street," + "urn:" + uuidString + "/MyStreet|" + "urn:uuid:PostalAddressAttributes/City," + "urn:" + uuidString + "/MyCity|" + "urn:uuid:PostalAddressAttributes/State," + "urn:" + uuidString + "/MyState|" + "urn:uuid:PostalAddressAttributes/PostalCode," + "urn:" + uuidString + "/MyPostalCode|" + "urn:uuid:PostalAddressAttributes/Country," + "urn:" + uuidString + "/MyCountry"); try { // Create the connection, passing it the // configuration properties ConnectionFactory factory = ConnectionFactory.newInstance(); factory.setProperties(props); connection = factory.createConnection(); System.out.println("Created connection to registry"); } catch (Exception e) { e.printStackTrace(); if (connection != null) { try { connection.close(); } catch (JAXRException je) { } } } }
From source file:SplitPaneDemo2.java
public SplitPaneDemo() { //Read image names from a properties file. ResourceBundle imageResource; try {/*from ww w .ja va 2 s . c o m*/ imageResource = ResourceBundle.getBundle("imagenames"); String imageNamesString = imageResource.getString("images"); imageNames = parseList(imageNamesString); } catch (MissingResourceException e) { handleMissingResource(e); } //Create the list of images and put it in a scroll pane. list = new JList(imageNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0); list.addListSelectionListener(this); JScrollPane listScrollPane = new JScrollPane(list); //Set up the picture label and put it in a scroll pane. ImageIcon firstImage = createImageIcon("images/" + (String) imageNames.firstElement()); if (firstImage != null) { picture = new JLabel(firstImage); } else { picture = new JLabel((String) imageNames.firstElement()); } JScrollPane pictureScrollPane = new JScrollPane(picture); //Create a split pane with the two scroll panes in it. splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(150); //Provide minimum sizes for the two components in the split pane. Dimension minimumSize = new Dimension(100, 50); listScrollPane.setMinimumSize(minimumSize); pictureScrollPane.setMinimumSize(minimumSize); //Provide a preferred size for the split pane. splitPane.setPreferredSize(new Dimension(400, 200)); }
From source file:com.edgenius.core.util.WebUtil.java
/** * @param agent //from w w w .j a v a 2 s .co m * @return */ public static boolean isPublicSearchEngineRobot(String agent) { if (!agentListInit) { agentListInit = true; try { ResourceBundle ua = ResourceBundle.getBundle(USER_AGENET_BROWSER); Enumeration<String> em = ua.getKeys(); while (em.hasMoreElements()) { String regex = ua.getString(em.nextElement()); try { userAgentPatternList.add(Pattern.compile(regex)); } catch (Exception e) { log.error("Unable compile user agent pattern: " + regex); } } } catch (Throwable e) { log.error("Unable load user agent properties, use default instead"); } } if (userAgentPatternList.size() > 0) { // use User-Agent to detect if current request is from browser, search engine robot, web crawler etc. for (Pattern pattern : userAgentPatternList) { //so far, browser is small amount than robot, so for performance reason, use browser agent list //See our issue http://bug.edgenius.com/issues/34 //and SUN Java bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6337993 try { if (pattern.matcher(agent).matches()) return false; } catch (StackOverflowError e) { AuditLogger.error("StackOverflow Error in WebUtil.isPublicSearchEngineRobot. Input[" + agent + "] Pattern [" + pattern.pattern() + "]"); } catch (Throwable e) { AuditLogger.error("Unexpected error in WebUtil.isPublicSearchEngineRobot. Input[" + agent + "] Pattern [" + pattern.pattern() + "]", e); } } } else { //default very rough check String user = agent.toLowerCase(); if (user.indexOf("crawl") != -1 || user.indexOf("spider") != -1 || user.indexOf("check") != -1 || user.indexOf("bot") != -1) { return true; } else if (user.indexOf("mozilla") != -1 // ||user.indexOf("") != -1 || user.indexOf("opera") != -1) { return false; } } return true; }
From source file:jp.co.ctc_g.jfw.core.internal.InternalMessages.java
/** * ??????????/*from w w w .j a v a 2s . c om*/ * ??????????????? ?????? * {@link MissingResourceException}???? * * @param clazz * ????? * @return ???? * @throws MissingResourceException * ?????? * @see ResourceBundle */ public static ResourceBundle getBundle(Class<?> clazz) { return ResourceBundle.getBundle(clazz.getPackage().getName() + MESSAGE_FILE); }