List of usage examples for java.util Locale getDisplayName
public final String getDisplayName()
From source file:com.hichinaschool.flashcards.anki.Preferences.java
private void initializeLanguageDialog() { TreeMap<String, String> items = new TreeMap<String, String>(); for (String localeCode : mAppLanguages) { Locale loc; if (localeCode.length() > 2) { loc = new Locale(localeCode.substring(0, 2), localeCode.substring(3, 5)); } else {//from w w w .j ava2 s .co m loc = new Locale(localeCode); } items.put(loc.getDisplayName(), loc.toString()); } mLanguageDialogLabels = new CharSequence[items.size() + 1]; mLanguageDialogValues = new CharSequence[items.size() + 1]; mLanguageDialogLabels[0] = getResources().getString(R.string.language_system); mLanguageDialogValues[0] = ""; int i = 1; for (Map.Entry<String, String> e : items.entrySet()) { mLanguageDialogLabels[i] = e.getKey(); mLanguageDialogValues[i] = e.getValue(); i++; } mLanguageSelection = (ListPreference) getPreferenceScreen().findPreference("language"); mLanguageSelection.setEntries(mLanguageDialogLabels); mLanguageSelection.setEntryValues(mLanguageDialogValues); }
From source file:com.aurel.track.dbase.InitDatabase.java
private static void addResourceToDatabase(Locale loc, String locCode, Boolean useProjects) { String pfix = "_" + locCode; String lang = loc.getDisplayName(); if (locCode == null || "".equals(locCode.trim())) { pfix = ""; lang = "Standard"; }//from w w w.java2s . com try { LOGGER.info("Synchronizing resources for " + lang); URL propURL = ApplicationBean.getInstance().getServletContext().getResource( "/WEB-INF/classes/resources/UserInterface/ApplicationResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.UI_TEXT, false); } catch (Exception e) { LOGGER.warn("Can't read ApplicationResources.properties from context for " + lang); LOGGER.debug(e); try { LOGGER.info("Trying to use class loader to synchronize resources for " + lang); ClassLoader cl = InitDatabase.class.getClassLoader(); URL propURL = cl.getResource("resources/UserInterface/ApplicationResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.UI_TEXT, false); } catch (Exception ee) { LOGGER.error("No chance to get ApplicationResources.properties for " + lang); LOGGER.debug(STACKTRACE, ee); } } try { URL propURL = ApplicationBean.getInstance().getServletContext() .getResource("/WEB-INF/classes/resources/UserInterface/BoxResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.DB_ENTITY, true); } catch (Exception e) { LOGGER.warn("Can't read BoxResources.properties from context for " + lang); try { LOGGER.info("Trying to use class loader to synchronize resources for " + lang, e); ClassLoader cl = InitDatabase.class.getClassLoader(); URL propURL = cl.getResource("resources/UserInterface/BoxResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.DB_ENTITY, true); } catch (Exception ee) { LOGGER.error("No chance to read BoxResources.properties for " + lang); LOGGER.debug(STACKTRACE, ee); } } // Now overwrite the "spaces" with "projects" if this is an upgraded installation if (useProjects) { try { URL propURL = ApplicationBean.getInstance().getServletContext().getResource( "/WEB-INF/classes/resources/UserInterfaceProj/ApplicationResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.UI_TEXT, false); } catch (Exception e) { LOGGER.warn("Can't read UserInterfaceProj/ApplicationResources.properties for " + lang); try { ClassLoader cl = InitDatabase.class.getClassLoader(); URL propURL = cl.getResource("/WEB-INF/classes/resources/UserInterfaceProj/ApplicationResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.UI_TEXT, false); } catch (Exception ee) { LOGGER.error("Can't read UserInterfaceProj/ApplicationResources.properties for " + lang); LOGGER.debug(STACKTRACE, ee); } } } }
From source file:org.tdl.vireo.search.impl.LuceneAbstractJobImpl.java
/** * Write a the provided submission and all associated action logs to the * index writer. This method expects that the submission and action logs * have been removed from the index, either through a specific delete, * or a delete all in the case of rebuilding the index. * /* w w w .jav a 2s . co m*/ * This method is used to share code between the various index job * implementations so that submissions are written the same no matter * who indexes them first. * * @param writer * The index writer. * @param sub * The submission to index. */ public void indexSubmission(IndexWriter writer, Submission sub) throws CorruptIndexException, IOException { StringBuilder searchText = new StringBuilder(); long subId = sub.getId(); String state = sub.getState().getDisplayName(); searchText.append(state).append(" "); long searchAssigned = 0; String sortAssigned = ""; if (sub.getAssignee() != null) { searchAssigned = sub.getAssignee().getId(); sortAssigned = sub.getAssignee().getFormattedName(NameFormat.LAST_FIRST_MIDDLE_BIRTH); searchText.append(sortAssigned).append(" "); } Date graduationSemester = null; if (sub.getGraduationYear() != null) { Calendar cal = Calendar.getInstance(); cal.clear(); cal.set(Calendar.YEAR, sub.getGraduationYear()); if (sub.getGraduationMonth() != null) cal.set(Calendar.MONTH, sub.getGraduationMonth()); graduationSemester = cal.getTime(); } Date defenseDate = sub.getDefenseDate(); String department = sub.getDepartment(); String program = sub.getProgram(); String college = sub.getCollege(); String major = sub.getMajor(); searchText.append(department).append(" ").append(program).append(" ").append(college).append(" ") .append(major).append(" "); String embargo = null; if (sub.getEmbargoType() != null) { embargo = sub.getEmbargoType().getName(); searchText.append(embargo).append(" "); } String degree = sub.getDegree(); String documentType = sub.getDocumentType(); searchText.append(degree).append(" ").append(documentType).append(" "); Date submissionDate = sub.getSubmissionDate(); String studentName = ""; if (sub.getStudentLastName() != null) studentName += sub.getStudentLastName() + " "; if (sub.getStudentFirstName() != null) studentName += sub.getStudentFirstName() + " "; if (sub.getStudentMiddleName() != null) studentName += sub.getStudentMiddleName() + " "; searchText.append(studentName).append(" "); searchText.append(sub.getStudentFormattedName(NameFormat.LAST_FIRST_BIRTH)).append(" "); searchText.append(sub.getStudentFormattedName(NameFormat.FIRST_LAST_BIRTH)).append(" "); String studentEmail = sub.getSubmitter().getEmail(); searchText.append(studentEmail).append(" "); String institutionalIdentifier = sub.getSubmitter().getInstitutionalIdentifier(); searchText.append(institutionalIdentifier).append(" "); String documentTitle = sub.getDocumentTitle(); String documentAbstract = sub.getDocumentAbstract(); String documentKeywords = sub.getDocumentKeywords(); searchText.append(documentTitle).append(" ").append(documentAbstract).append(" ").append(documentKeywords) .append(" "); String documentSubjects = ""; for (String subject : sub.getDocumentSubjects()) { documentSubjects += subject + " "; } searchText.append(documentSubjects).append(" "); String documentLanguage = null; if (sub.getDocumentLanguageLocale() != null) { Locale locale = sub.getDocumentLanguageLocale(); searchText.append(locale.getDisplayName()).append(" "); searchText.append(locale.getDisplayLanguage()).append(" "); searchText.append(locale.getDisplayCountry()).append(" "); searchText.append(locale.getDisplayVariant()).append(" "); documentLanguage = locale.getDisplayName(); } String publishedMaterial = sub.getPublishedMaterial(); searchText.append(publishedMaterial).append(" "); String primaryDocument = null; if (sub.getPrimaryDocument() != null) { primaryDocument = sub.getPrimaryDocument().getName(); searchText.append(primaryDocument).append(" "); } Date licenseAgreementDate = sub.getLicenseAgreementDate(); Date approvalDate = sub.getApprovalDate(); Date committeeApprovalDate = sub.getCommitteeApprovalDate(); Date committeeEmbargoApprovalDate = sub.getCommitteeEmbargoApprovalDate(); String committeeMembers = ""; for (CommitteeMember member : sub.getCommitteeMembers()) { // TODO: sort by display order? committeeMembers += member.getFormattedName(NameFormat.LAST_FIRST) + " " + member.getFormattedRoles(); } searchText.append(committeeMembers).append(" "); String committeeContactEmail = sub.getCommitteeContactEmail(); searchText.append(committeeContactEmail).append(" "); String umiRelease; if (sub.getUMIRelease() == null) { umiRelease = ""; } else if (sub.getUMIRelease()) { umiRelease = "yes"; } else { umiRelease = "no"; } int customActions = 0; for (CustomActionValue action : sub.getCustomActions()) { if (action.getValue()) customActions++; } String degreeLevel = null; if (sub.getDegreeLevel() != null) degreeLevel = sub.getDegreeLevel().name(); searchText.append(degreeLevel).append(" "); String depositId = sub.getDepositId(); searchText.append(depositId).append(" "); String reviewerNotes = sub.getReviewerNotes(); searchText.append(reviewerNotes).append(" "); String lastEventEntry = null; Date lastEventTime = null; List<ActionLog> logs = indexer.subRepo.findActionLog(sub); if (logs.size() > 0) { lastEventEntry = logs.get(0).getEntry(); lastEventTime = logs.get(0).getActionDate(); searchText.append(lastEventEntry); } Document doc = new Document(); doc.add(new NumericField("subId", Field.Store.YES, true).setLongValue(subId)); doc.add(new Field("type", "submission", Field.Store.YES, Index.NOT_ANALYZED)); doc.add(new Field("searchText", searchText.toString(), Field.Store.NO, Index.ANALYZED_NO_NORMS)); if (state != null) doc.add(new Field("state", state, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("searchAssigned", Field.Store.NO, true).setLongValue(searchAssigned)); if (sortAssigned != null) doc.add(new Field("sortAssigned", sortAssigned, Field.Store.NO, Index.NOT_ANALYZED)); if (graduationSemester != null) doc.add(new NumericField("graduationSemester", Field.Store.NO, true) .setLongValue(graduationSemester.getTime())); if (defenseDate != null) doc.add(new NumericField("defenseDate", Field.Store.NO, true).setLongValue(defenseDate.getTime())); if (department != null) doc.add(new Field("department", department, Field.Store.NO, Index.NOT_ANALYZED)); if (program != null) doc.add(new Field("program", program, Field.Store.NO, Index.NOT_ANALYZED)); if (college != null) doc.add(new Field("college", college, Field.Store.NO, Index.NOT_ANALYZED)); if (major != null) doc.add(new Field("major", major, Field.Store.NO, Index.NOT_ANALYZED)); if (embargo != null) doc.add(new Field("embargo", embargo, Field.Store.NO, Index.NOT_ANALYZED)); if (degree != null) doc.add(new Field("degree", degree, Field.Store.NO, Index.NOT_ANALYZED)); if (documentType != null) doc.add(new Field("documentType", documentType, Field.Store.NO, Index.NOT_ANALYZED)); if (submissionDate != null) doc.add(new NumericField("submissionDate", Field.Store.NO, true) .setLongValue(submissionDate.getTime())); if (studentName != null) doc.add(new Field("studentName", studentName, Field.Store.NO, Index.NOT_ANALYZED)); if (studentEmail != null) doc.add(new Field("studentEmail", studentEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (institutionalIdentifier != null) doc.add(new Field("institutionalIdentifier", institutionalIdentifier, Field.Store.NO, Index.NOT_ANALYZED)); if (documentTitle != null) doc.add(new Field("documentTitle", documentTitle, Field.Store.NO, Index.NOT_ANALYZED)); if (documentAbstract != null) doc.add(new Field("documentAbstract", documentAbstract, Field.Store.NO, Index.NOT_ANALYZED)); if (documentKeywords != null) doc.add(new Field("documentKeywords", documentKeywords, Field.Store.NO, Index.NOT_ANALYZED)); if (documentSubjects != null) doc.add(new Field("documentSubjects", documentSubjects, Field.Store.NO, Index.NOT_ANALYZED)); if (documentLanguage != null) doc.add(new Field("documentLanguage", documentLanguage, Field.Store.NO, Index.NOT_ANALYZED)); if (publishedMaterial != null) doc.add(new Field("publishedMaterial", publishedMaterial, Field.Store.NO, Index.NOT_ANALYZED)); if (primaryDocument != null) doc.add(new Field("primaryDocument", primaryDocument, Field.Store.NO, Index.NOT_ANALYZED)); if (licenseAgreementDate != null) doc.add(new NumericField("licenseAgreementDate", Field.Store.NO, true) .setLongValue(licenseAgreementDate.getTime())); if (approvalDate != null) doc.add(new NumericField("approvalDate", Field.Store.NO, true).setLongValue(approvalDate.getTime())); if (committeeApprovalDate != null) doc.add(new NumericField("committeeApprovalDate", Field.Store.NO, true) .setLongValue(committeeApprovalDate.getTime())); if (committeeEmbargoApprovalDate != null) doc.add(new NumericField("committeeEmbargoApprovalDate", Field.Store.NO, true) .setLongValue(committeeEmbargoApprovalDate.getTime())); if (committeeMembers != null) doc.add(new Field("committeeMembers", committeeMembers, Field.Store.NO, Index.NOT_ANALYZED)); if (committeeContactEmail != null) doc.add(new Field("committeeContactEmail", committeeContactEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (umiRelease != null) doc.add(new Field("umiRelease", umiRelease, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("customActions", Field.Store.NO, true).setIntValue(customActions)); if (degreeLevel != null) doc.add(new Field("degreeLevel", degreeLevel, Field.Store.NO, Index.NOT_ANALYZED)); if (depositId != null) doc.add(new Field("depositId", depositId, Field.Store.NO, Index.NOT_ANALYZED)); if (reviewerNotes != null) doc.add(new Field("reviewerNotes", reviewerNotes, Field.Store.NO, Index.NOT_ANALYZED)); if (lastEventEntry != null) doc.add(new Field("lastEventEntry", lastEventEntry, Field.Store.NO, Index.NOT_ANALYZED)); if (lastEventTime != null) doc.add(new NumericField("lastEventTime", Field.Store.NO, true).setLongValue(lastEventTime.getTime())); writer.addDocument(doc); for (ActionLog log : logs) { Long logId = log.getId(); String logEntry = log.getEntry(); String logState = log.getSubmissionState().getDisplayName(); long logSearchAssigned = 0; String logSortAssigned = null; if (log.getPerson() != null) { logSearchAssigned = log.getPerson().getId(); logSortAssigned = log.getPerson().getFormattedName(NameFormat.FIRST_LAST); } Date logTime = log.getActionDate(); // The new special things for action logs. doc = new Document(); doc.add(new NumericField("subId", Field.Store.YES, true).setLongValue(subId)); doc.add(new NumericField("logId", Field.Store.YES, true).setLongValue(logId)); doc.add(new Field("type", "actionlog", Field.Store.YES, Index.NOT_ANALYZED)); if (logEntry != null) doc.add(new Field("searchText", logEntry, Field.Store.NO, Index.ANALYZED_NO_NORMS)); if (logState != null) doc.add(new Field("state", logState, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("searchAssigned", Field.Store.NO, true).setLongValue(logSearchAssigned)); if (logSortAssigned != null) doc.add(new Field("sortAssigned", logSortAssigned, Field.Store.NO, Index.NOT_ANALYZED)); if (logEntry != null) doc.add(new Field("lastEventEntry", logEntry, Field.Store.NO, Index.NOT_ANALYZED)); if (logTime != null) doc.add(new NumericField("lastEventTime", Field.Store.NO, true).setLongValue(logTime.getTime())); // Stuff that is the same as the submission. if (graduationSemester != null) doc.add(new NumericField("graduationSemester", Field.Store.NO, true) .setLongValue(graduationSemester.getTime())); if (defenseDate != null) doc.add(new NumericField("defenseDate", Field.Store.NO, true).setLongValue(defenseDate.getTime())); if (department != null) doc.add(new Field("department", department, Field.Store.NO, Index.NOT_ANALYZED)); if (program != null) doc.add(new Field("program", program, Field.Store.NO, Index.NOT_ANALYZED)); if (college != null) doc.add(new Field("college", college, Field.Store.NO, Index.NOT_ANALYZED)); if (major != null) doc.add(new Field("major", major, Field.Store.NO, Index.NOT_ANALYZED)); if (embargo != null) doc.add(new Field("embargo", embargo, Field.Store.NO, Index.NOT_ANALYZED)); if (degree != null) doc.add(new Field("degree", degree, Field.Store.NO, Index.NOT_ANALYZED)); if (documentType != null) doc.add(new Field("documentType", documentType, Field.Store.NO, Index.NOT_ANALYZED)); if (submissionDate != null) doc.add(new NumericField("submissionDate", Field.Store.NO, true) .setLongValue(submissionDate.getTime())); if (studentName != null) doc.add(new Field("studentName", studentName, Field.Store.NO, Index.NOT_ANALYZED)); if (studentEmail != null) doc.add(new Field("studentEmail", studentEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (institutionalIdentifier != null) doc.add(new Field("institutionalIdentifier", institutionalIdentifier, Field.Store.NO, Index.NOT_ANALYZED)); if (documentAbstract != null) doc.add(new Field("documentAbstract", documentAbstract, Field.Store.NO, Index.NOT_ANALYZED)); if (documentKeywords != null) doc.add(new Field("documentKeywords", documentKeywords, Field.Store.NO, Index.NOT_ANALYZED)); if (documentSubjects != null) doc.add(new Field("documentSubjects", documentSubjects, Field.Store.NO, Index.NOT_ANALYZED)); if (documentLanguage != null) doc.add(new Field("documentLanguage", documentLanguage, Field.Store.NO, Index.NOT_ANALYZED)); if (publishedMaterial != null) doc.add(new Field("publishedMaterial", publishedMaterial, Field.Store.NO, Index.NOT_ANALYZED)); if (primaryDocument != null) doc.add(new Field("primaryDocument", primaryDocument, Field.Store.NO, Index.NOT_ANALYZED)); if (licenseAgreementDate != null) doc.add(new NumericField("licenseAgreementDate", Field.Store.NO, true) .setLongValue(licenseAgreementDate.getTime())); if (approvalDate != null) doc.add(new NumericField("approvalDate", Field.Store.NO, true) .setLongValue(approvalDate.getTime())); if (committeeApprovalDate != null) doc.add(new NumericField("committeeApprovalDate", Field.Store.NO, true) .setLongValue(committeeApprovalDate.getTime())); if (committeeEmbargoApprovalDate != null) doc.add(new NumericField("committeeEmbargoApprovalDate", Field.Store.NO, true) .setLongValue(committeeEmbargoApprovalDate.getTime())); if (committeeMembers != null) doc.add(new Field("committeeMembers", committeeMembers, Field.Store.NO, Index.NOT_ANALYZED)); if (committeeContactEmail != null) doc.add(new Field("committeeContactEmail", committeeContactEmail, Field.Store.NO, Index.NOT_ANALYZED)); if (umiRelease != null) doc.add(new Field("umiRelease", umiRelease, Field.Store.NO, Index.NOT_ANALYZED)); doc.add(new NumericField("customActions", Field.Store.NO, true).setIntValue(customActions)); if (degreeLevel != null) doc.add(new Field("degreeLevel", degreeLevel, Field.Store.NO, Index.NOT_ANALYZED)); if (depositId != null) doc.add(new Field("depositId", depositId, Field.Store.NO, Index.NOT_ANALYZED)); if (reviewerNotes != null) doc.add(new Field("reviewerNotes", reviewerNotes, Field.Store.NO, Index.NOT_ANALYZED)); writer.addDocument(doc); // Detach the log so it dosn't keep stacking up in memory. log.detach(); } // for logs }
From source file:com.jvms.i18neditor.editor.Editor.java
public void updateUI() { TranslationTreeNode selectedNode = translationTree.getSelectionNode(); resourcesPanel.removeAll();/*from ww w . ja v a 2 s . c om*/ resourceFields = resourceFields.stream().sorted().collect(Collectors.toList()); resourceFields.forEach(field -> { Locale locale = field.getResource().getLocale(); String label = locale != null ? locale.getDisplayName() : MessageBundle.get("resources.locale.default"); field.setEnabled(selectedNode != null && selectedNode.isEditable()); field.setRows(settings.getDefaultInputHeight()); resourcesPanel.add(Box.createVerticalStrut(5)); resourcesPanel.add(new JLabel(label)); resourcesPanel.add(Box.createVerticalStrut(5)); resourcesPanel.add(field); resourcesPanel.add(Box.createVerticalStrut(10)); }); Container container = getContentPane(); if (project != null) { container.add(contentPane); container.remove(introText); List<Resource> resources = project.getResources(); editorMenu.setEnabled(true); editorMenu.setEditable(!resources.isEmpty()); translationField.setEditable(!resources.isEmpty()); } else { container.add(introText); container.remove(contentPane); editorMenu.setEnabled(false); editorMenu.setEditable(false); translationField.setEditable(false); } translationField.setVisible(settings.isKeyFieldEnabled()); translationTree.setToggleClickCount(settings.isDoubleClickTreeToggling() ? 2 : 1); updateTitle(); validate(); repaint(); }
From source file:com.aurel.track.ApplicationStarter.java
private void printSystemInfo() { LOGGER.info("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version")); LOGGER.info("Operating System: " + System.getProperty("os.name") + " " + System.getProperty("os.arch")); Locale loc = Locale.getDefault(); LOGGER.info("Default locale: " + loc.getDisplayName()); ServletContext application = ApplicationBean.getInstance().getServletContext(); try {//w ww . j a v a 2 s . c o m LOGGER.info("Servlet real path: " + application.getRealPath(File.separator)); } catch (Exception ex) { LOGGER.error("Error trying to obtain getRealPath()"); } LOGGER.info("Servlet container: " + application.getServerInfo()); Connection conn = null; try { PropertiesConfiguration pc = ApplicationBean.getInstance().getDbConfig(); LOGGER.info("Configured database type: " + pc.getProperty("torque.database.track.adapter")); LOGGER.info( "Configured database driver: " + pc.getProperty("torque.dsfactory.track.connection.driver")); LOGGER.info("Configured JDBC URL: " + pc.getProperty("torque.dsfactory.track.connection.url")); conn = Torque.getConnection(BaseTSitePeer.DATABASE_NAME); DatabaseMetaData dbm = conn.getMetaData(); LOGGER.info("Database type: " + dbm.getDatabaseProductName() + " " + dbm.getDatabaseProductVersion()); LOGGER.info("Driver info: " + dbm.getDriverName() + " " + dbm.getDriverVersion()); Statement stmt = conn.createStatement(); Date d1 = new Date(); stmt.executeQuery("SELECT * FROM TSTATE"); Date d2 = new Date(); stmt.close(); LOGGER.info("Database test query done in " + (d2.getTime() - d1.getTime()) + " milliseconds "); } catch (Exception e) { System.err.println("Problem retrieving meta data"); LOGGER.error("Problem retrieving meta data"); } finally { if (conn != null) { Torque.closeConnection(conn); } } }
From source file:com.aurel.track.dbase.InitDatabase.java
private static void addCustomResourceToDatabase(Locale loc, String locCode) { ClassLoader cl = HandleHome.class.getClassLoader(); File res = new File(HandleHome.getTrackplus_Home() + File.separator + HandleHome.XRESOURCES_DIR); if (res.exists() && res.isDirectory() && res.canWrite()) { String pfix = "_" + locCode; String lang = loc.getDisplayName(); if (locCode == null) { pfix = ""; lang = "Standard"; }// w ww . j av a2 s .c om try { URL propURL = cl.getResource("MyApplicationResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.UI_TEXT, false); LOGGER.info("Synchronized custom user interface resources for " + lang); } catch (Exception e) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } try { URL propURL = cl.getResource("MyBoxResources" + pfix + propertiesStr); InputStream in = propURL.openStream(); LocalizeBL.saveResources(in, locCode, false, LocalizeBL.RESOURCE_CATEGORIES.DB_ENTITY, false); LOGGER.info("Synchronized custom database entity resources for " + lang); } catch (Exception e) { LOGGER.debug(ExceptionUtils.getStackTrace(e), e); } } }
From source file:com.landenlabs.all_devtool.SystemFragment.java
public void updateList() { // Time today = new Time(Time.getCurrentTimezone()); // today.setToNow(); // today.format(" %H:%M:%S") Date dt = new Date(); m_titleTime.setText(m_timeFormat.format(dt)); boolean expandAll = m_list.isEmpty(); m_list.clear();/*w w w . j a v a 2 s .co m*/ // Swap colors int color = m_rowColor1; m_rowColor1 = m_rowColor2; m_rowColor2 = color; ActivityManager actMgr = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); try { String androidIDStr = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID); addBuild("Android ID", androidIDStr); try { AdvertisingIdClient.Info adInfo = AdvertisingIdClient.getAdvertisingIdInfo(getContext()); final String adIdStr = adInfo.getId(); final boolean isLAT = adInfo.isLimitAdTrackingEnabled(); addBuild("Ad ID", adIdStr); } catch (IOException e) { // Unrecoverable error connecting to Google Play services (e.g., // the old version of the service doesn't support getting AdvertisingId). } catch (GooglePlayServicesNotAvailableException e) { // Google Play services is not available entirely. } /* try { InstanceID instanceID = InstanceID.getInstance(getContext()); if (instanceID != null) { // Requires a Google Developer project ID. String authorizedEntity = "<need to make this on google developer site>"; instanceID.getToken(authorizedEntity, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); addBuild("Instance ID", instanceID.getId()); } } catch (Exception ex) { } */ ConfigurationInfo info = actMgr.getDeviceConfigurationInfo(); addBuild("OpenGL", info.getGlEsVersion()); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { long heapSize = Debug.getNativeHeapSize(); // long maxHeap = Runtime.getRuntime().maxMemory(); // ConfigurationInfo cfgInfo = actMgr.getDeviceConfigurationInfo(); int largHeapMb = actMgr.getLargeMemoryClass(); int heapMb = actMgr.getMemoryClass(); MemoryInfo memInfo = new MemoryInfo(); actMgr.getMemoryInfo(memInfo); final String sFmtMB = "%.2f MB"; Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("Mem Available (now)", String.format(sFmtMB, (double) memInfo.availMem / MB)); listStr.put("Mem LowWhenOnlyAvail", String.format(sFmtMB, (double) memInfo.threshold / MB)); if (Build.VERSION.SDK_INT >= 16) { listStr.put("Mem Installed", String.format(sFmtMB, (double) memInfo.totalMem / MB)); } listStr.put("Heap (this app)", String.format(sFmtMB, (double) heapSize / MB)); listStr.put("HeapMax (default)", String.format(sFmtMB, (double) heapMb)); listStr.put("HeapMax (large)", String.format(sFmtMB, (double) largHeapMb)); addBuild("Memory...", listStr); } catch (Exception ex) { m_log.e(ex.getMessage()); } try { List<ProcessErrorStateInfo> procErrList = actMgr.getProcessesInErrorState(); int errCnt = (procErrList == null ? 0 : procErrList.size()); procErrList = null; // List<RunningAppProcessInfo> procList = actMgr.getRunningAppProcesses(); int procCnt = actMgr.getRunningAppProcesses().size(); int srvCnt = actMgr.getRunningServices(100).size(); Map<String, String> listStr = new TreeMap<String, String>(); listStr.put("#Processes", String.valueOf(procCnt)); listStr.put("#Proc With Err", String.valueOf(errCnt)); listStr.put("#Services", String.valueOf(srvCnt)); // Requires special permission // int taskCnt = actMgr.getRunningTasks(100).size(); // listStr.put("#Tasks", String.valueOf(taskCnt)); addBuild("Processes...", listStr); } catch (Exception ex) { m_log.e("System-Processes %s", ex.getMessage()); } try { Map<String, String> listStr = new LinkedHashMap<String, String>(); listStr.put("LargeIconDensity", String.valueOf(actMgr.getLauncherLargeIconDensity())); listStr.put("LargeIconSize", String.valueOf(actMgr.getLauncherLargeIconSize())); putIf(listStr, "isRunningInTestHarness", "Yes", ActivityManager.isRunningInTestHarness()); putIf(listStr, "isUserAMonkey", "Yes", ActivityManager.isUserAMonkey()); addBuild("Misc...", listStr); } catch (Exception ex) { m_log.e("System-Misc %s", ex.getMessage()); } // --------------- Locale / Timezone ------------- try { Locale ourLocale = Locale.getDefault(); Date m_date = new Date(); TimeZone tz = TimeZone.getDefault(); Map<String, String> localeListStr = new LinkedHashMap<String, String>(); localeListStr.put("Locale Name", ourLocale.getDisplayName()); localeListStr.put(" Variant", ourLocale.getVariant()); localeListStr.put(" Country", ourLocale.getCountry()); localeListStr.put(" Country ISO", ourLocale.getISO3Country()); localeListStr.put(" Language", ourLocale.getLanguage()); localeListStr.put(" Language ISO", ourLocale.getISO3Language()); localeListStr.put(" Language Dsp", ourLocale.getDisplayLanguage()); localeListStr.put("TimeZoneID", tz.getID()); localeListStr.put(" DayLightSavings", tz.useDaylightTime() ? "Yes" : "No"); localeListStr.put(" In DLS", tz.inDaylightTime(m_date) ? "Yes" : "No"); localeListStr.put(" Short Name", tz.getDisplayName(false, TimeZone.SHORT, ourLocale)); localeListStr.put(" Long Name", tz.getDisplayName(false, TimeZone.LONG, ourLocale)); addBuild("Locale TZ...", localeListStr); } catch (Exception ex) { m_log.e("Locale/TZ %s", ex.getMessage()); } // --------------- Location Services ------------- try { Map<String, String> listStr = new LinkedHashMap<String, String>(); final LocationManager locMgr = (LocationManager) getActivity() .getSystemService(Context.LOCATION_SERVICE); GpsStatus gpsStatus = locMgr.getGpsStatus(null); if (gpsStatus != null) { listStr.put("Sec ToGetGPS", String.valueOf(gpsStatus.getTimeToFirstFix())); Iterable<GpsSatellite> satellites = gpsStatus.getSatellites(); Iterator<GpsSatellite> sat = satellites.iterator(); while (sat.hasNext()) { GpsSatellite satellite = sat.next(); putIf(listStr, String.format("Azm:%.0f, Elev:%.0f", satellite.getAzimuth(), satellite.getElevation()), String.format("%.2f Snr", satellite.getSnr()), satellite.usedInFix()); } } Location location = null; if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) { location = locMgr.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (null == location) location = locMgr.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); } if (null != location) { listStr.put(location.getProvider() + " lat,lng", String.format("%.3f, %.3f", location.getLatitude(), location.getLongitude())); } if (listStr.size() != 0) { List<String> gpsProviders = locMgr.getAllProviders(); int idx = 1; for (String providerName : gpsProviders) { LocationProvider provider = locMgr.getProvider(providerName); if (null != provider) { listStr.put(providerName, (locMgr.isProviderEnabled(providerName) ? "On " : "Off ") + String.format("Accuracy:%d Pwr:%d", provider.getAccuracy(), provider.getPowerRequirement())); } } addBuild("GPS...", listStr); } else addBuild("GPS", "Off"); } catch (Exception ex) { m_log.e(ex.getMessage()); } // --------------- Application Info ------------- ApplicationInfo appInfo = getActivity().getApplicationInfo(); if (null != appInfo) { Map<String, String> appList = new LinkedHashMap<String, String>(); try { appList.put("ProcName", appInfo.processName); appList.put("PkgName", appInfo.packageName); appList.put("DataDir", appInfo.dataDir); appList.put("SrcDir", appInfo.sourceDir); // appList.put("PkgResDir", getActivity().getPackageResourcePath()); // appList.put("PkgCodeDir", getActivity().getPackageCodePath()); String[] dbList = getActivity().databaseList(); if (dbList != null && dbList.length != 0) appList.put("DataBase", dbList[0]); // getActivity().getComponentName(). } catch (Exception ex) { } addBuild("AppInfo...", appList); } // --------------- Account Services ------------- final AccountManager accMgr = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE); if (null != accMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); try { for (Account account : accMgr.getAccounts()) { strList.put(account.name, account.type); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Accounts...", strList); } // --------------- Package Features ------------- PackageManager pm = getActivity().getPackageManager(); FeatureInfo[] features = pm.getSystemAvailableFeatures(); if (features != null) { Map<String, String> strList = new LinkedHashMap<String, String>(); for (FeatureInfo featureInfo : features) { strList.put(featureInfo.name, ""); } addBuild("Features...", strList); } // --------------- Sensor Services ------------- final SensorManager senMgr = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE); if (null != senMgr) { Map<String, String> strList = new LinkedHashMap<String, String>(); // Sensor accelerometer = senMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); // senMgr.registerListener(foo, accelerometer, SensorManager.SENSOR_DELAY_NORMAL); List<Sensor> listSensor = senMgr.getSensorList(Sensor.TYPE_ALL); try { for (Sensor sensor : listSensor) { strList.put(sensor.getName(), sensor.getVendor()); } } catch (Exception ex) { m_log.e(ex.getMessage()); } addBuild("Sensors...", strList); } try { if (Build.VERSION.SDK_INT >= 17) { final UserManager userMgr = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); if (null != userMgr) { try { addBuild("UserName", userMgr.getUserName()); } catch (Exception ex) { m_log.e(ex.getMessage()); } } } } catch (Exception ex) { } try { Map<String, String> strList = new LinkedHashMap<String, String>(); int screenTimeout = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT); strList.put("ScreenTimeOut", String.valueOf(screenTimeout / 1000)); int rotate = Settings.System.getInt(getActivity().getContentResolver(), Settings.System.ACCELEROMETER_ROTATION); strList.put("RotateEnabled", String.valueOf(rotate)); if (Build.VERSION.SDK_INT >= 17) { // Global added in API 17 int adb = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED); strList.put("AdbEnabled", String.valueOf(adb)); } addBuild("Settings...", strList); } catch (Exception ex) { } if (expandAll) { // updateList(); int count = m_list.size(); for (int position = 0; position < count; position++) m_listView.expandGroup(position); } m_adapter.notifyDataSetChanged(); }
From source file:org.sakaiproject.component.section.SectionManagerHibernateImpl.java
/** * {@inheritDoc}/*from w w w . ja v a2 s . co m*/ */ public String getCategoryName(String categoryId, Locale locale) { ResourceBundle bundle = ResourceBundle.getBundle(CATEGORY_BUNDLE, locale); String name; try { name = bundle.getString(categoryId); } catch (MissingResourceException mre) { if (log.isDebugEnabled()) log.debug("Could not find the name for category id = " + categoryId + " in locale " + locale.getDisplayName()); name = null; } return name; }
From source file:org.apache.logging.log4j.core.util.datetime.FastDateParserTest.java
@Test public void testTzParses() throws Exception { // Check that all Locales can parse the time formats we use for (final Locale locale : Locale.getAvailableLocales()) { final FastDateParser fdp = new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale); for (final TimeZone tz : new TimeZone[] { NEW_YORK, REYKJAVIK, GMT }) { final Calendar cal = Calendar.getInstance(tz, locale); cal.clear();/*ww w. jav a2 s .c om*/ cal.set(Calendar.YEAR, 2000); cal.set(Calendar.MONTH, 1); cal.set(Calendar.DAY_OF_MONTH, 10); final Date expected = cal.getTime(); final Date actual = fdp.parse("2000/02/10 " + tz.getDisplayName(locale)); Assert.assertEquals("tz:" + tz.getID() + " locale:" + locale.getDisplayName(), expected, actual); } } }
From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java
/** * Export data /*from w w w. ja v a 2 s. c o m*/ */ protected void exportSingleLocale() { statusBar.setText(getResourceString("SchemaLocalizerFrame.EXPORTING")); //$NON-NLS-1$ statusBar.paintImmediately(statusBar.getBounds()); schemaLocPanel.getAllDataFromUI(); if (localizableIO.hasChanged()) { if (UIRegistry.askYesNoLocalized("SAVE", "CANCEL", UIRegistry.getResourceString("SchemaLocalizerFrame.NEEDS_SAVING"), "SAVE") == JOptionPane.YES_NO_OPTION) { localizableIO.save(); } else { return; } } Vector<Locale> stdLocales = SchemaI18NService.getInstance().getStdLocaleList(false); final JList list = new JList(stdLocales); list.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { setText(((Locale) value).getDisplayName()); } return this; } }); PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "f:p:g")); pb.add(UIHelper.createScrollPane(list), (new CellConstraints()).xy(1, 1)); pb.setDefaultDialogBorder(); final CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), getResourceString("SchemaLocalizerFrame.CHOOSE_LOCALE"), true, pb.getPanel()); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { dlg.getOkBtn().setEnabled(list.getSelectedValue() != null); } } }); dlg.createUI(); dlg.getOkBtn().setEnabled(false); UIHelper.centerAndShow(dlg); if (!dlg.isCancelled()) { Locale locale = (Locale) list.getSelectedValue(); if (locale != null) { FileDialog fileDlg = new FileDialog((Frame) UIRegistry.getTopWindow(), getResourceString("SchemaLocalizerFrame.SVFILENAME"), FileDialog.SAVE); fileDlg.setVisible(true); String fileName = fileDlg.getFile(); if (StringUtils.isNotEmpty(fileName)) { File outFile = new File(fileDlg.getDirectory() + File.separator + fileName); boolean savedOK = localizableIO.exportSingleLanguageToDirectory(outFile, locale); if (savedOK) { String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTEDTO", locale.getDisplayName(), outFile.getAbsolutePath()); UIRegistry.displayInfoMsgDlg(msg); } else { String msg = UIRegistry.getLocalizedMessage("SchemaLocalizerFrame.EXPORTING_ERR", outFile.getAbsolutePath()); UIRegistry.showError(msg); } } } } }