Example usage for java.util Locale setDefault

List of usage examples for java.util Locale setDefault

Introduction

In this page you can find the example usage for java.util Locale setDefault.

Prototype

public static synchronized void setDefault(Locale newLocale) 

Source Link

Document

Sets the default locale for this instance of the Java Virtual Machine.

Usage

From source file:dentex.youtube.downloader.utils.Utils.java

public static void langInit(Context context) {
    String lang = YTD.settings.getString("lang", "default");
    Locale locale;//from  ww  w . j  ava 2s.c  om
    if (!lang.equals("default")) {
        String[] fLang = filterLang(lang);
        locale = new Locale(fLang[0], fLang[1]);
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
    } else {
        locale = new Locale(YTD.settings.getString("DEF_LANG", ""));
        Locale.setDefault(locale);
    }

    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config, null);
}

From source file:org.yccheok.jstock.gui.JTableUtilities.java

public static void setJTableOptions(JTable jTable, GUIOptions.JTableOptions jTableOptions) {
    if (jTableOptions.getColumnSize() <= 0) {
        // A bug introduced in version 1.0.5p. Due to incorrect
        // implementation of Utils.toXML, we may get a table option with 0
        // column turned on. To avoid all columns being turned off, we will
        // return early.
        return;/*ww w  .  j av a  2  s .c om*/
    }

    final Locale locale = jTableOptions.getLocale();
    // HACKING!
    boolean first_column_hacking_required = false;

    // Remove unwanted column. MUST BE DONE FIRST!
    for (int i = 0; i < jTable.getColumnCount(); i++) {
        final String name = jTable.getColumnName(i);

        // In to avoid the following situation.
        // 1. GUIOptions is being saved when we are in Chinese locale.
        // 2. Application is restarted in English locale.
        // 3. We are trying to compare English wording with Chinese wording.
        //
        // Before performing comparison, we shall convert name, to the locale
        // of table options.
        final java.util.List<String> keys = getKeys(name, Locale.getDefault());

        // Ensure correct resource file is being loaded.
        // When ResourceBundle.getBundle(..., locale) is being called, the
        // system will try to search in the following sequence.
        // 1. gui_<locale>.properties.
        // 2. gui_<default_locale>.properties.
        // 3. gui.properties.
        final Locale oldLocale = Locale.getDefault();
        Locale.setDefault(locale);
        try {
            final ResourceBundle bundle = ResourceBundle.getBundle("org.yccheok.jstock.data.gui", locale);
            Locale.setDefault(oldLocale);

            // Try all the keys.
            boolean found = false;
            for (String key : keys) {
                final String translated_name = bundle.getString(key);
                if (jTableOptions.contains(translated_name)) {
                    found = true;
                    break;
                }
            }

            /* Remove any unwanted columns. */
            if (found == false) {
                // HACKING!
                // Some customers complain their first column of Watchlist,
                // or Portfolio are being hidden. I'm not sure why that
                // happen. YES! I have really no idea why that happen!
                // This is a hacking way "if (i > 0)" to prevent such 
                // problem. Shh...
                if (i > 0) {
                    removeTableColumn(jTable, name);
                    i--;
                } else {
                    first_column_hacking_required = true;
                }
            }
        } finally {
            Locale.setDefault(oldLocale);
        }
    }

    final int optionsCount = jTableOptions.getColumnSize();
    final int tableCount = jTable.getColumnCount();

    // HACKING!
    // jTableOptions doesn't have first column information if first_column_hacking_required
    // is true. When perform column moving, we will start from 2nd column if
    // first_column_hacking_required is true. Assume first column will always
    // stay in first column.
    int target = first_column_hacking_required ? 1 : 0;

    /* Sort the columns according to user preference. */
    for (int i = 0; i < optionsCount; i++) {
        final String name = jTableOptions.getColumnName(i);
        final java.util.List<String> keys = getKeys(name, locale);
        assert (keys != null);

        int index = -1;
        for (int j = 0; j < tableCount; j++) {
            // Try all the keys.
            boolean found = false;
            String translated_name = null;
            for (String key : keys) {
                translated_name = GUIBundle.getString(key);
                if (jTable.getColumnName(j).equals(translated_name)) {
                    found = true;
                    break;
                }
            }

            if (found) {
                /* Restore width. */
                jTable.getColumn(translated_name).setPreferredWidth(jTableOptions.getColumnWidth(i));

                index = j;
                break;
            }
        }

        if (index >= 0) {
            jTable.moveColumn(index, target++);
        }
    }
}

From source file:com.sanbo.moveonapp.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    int savedVersionNumber;
    SharedPreferences myShared;/* w w  w .jav a2 s .  c  o  m*/
    PackageInfo pi;
    String initPrefs = "moveonapp_init_prefs";
    String versionNumber = "version_number";
    int currentVersionNumber = 0;
    super.onCreate(savedInstanceState);
    if (Config.DEBUG)
        Log.d(Config.LOGTAG, "MainActivity.onCreate()");
    // MoveOnApp Preferences
    pref = PreferenceManager.getDefaultSharedPreferences(this);
    myPublic.getmPreferences().setmContext(this);
    myShared = getSharedPreferences(initPrefs, Context.MODE_PRIVATE);
    savedVersionNumber = myShared.getInt(versionNumber, 0);

    try {
        pi = getPackageManager().getPackageInfo(getPackageName(), 0);
        currentVersionNumber = pi.versionCode;
    } catch (Exception e) {
    }
    if (currentVersionNumber > savedVersionNumber) {
        //Test data from SharedPreferences and first use

        Editor editor = pref.edit();
        editor.putString(Config.meter_options, Config.MyDISTANCE);
        editor.putString(Config.user_options, Config.MyUSER);
        editor.putString(Config.route_options, Config.MyROUTE);
        editor.putString(Config.language_options, Config.MyLANGUAGE);
        editor.putBoolean(Config.show_options, Config.isTRUE);
        editor.putBoolean(Config.transfer_options, Config.isTRUE);
        editor.commit();

        // Here we can show in next versions NEW FEATURES           
        //new NewFeaturesDialog(this).show();

        Editor editor0 = myShared.edit();
        editor0.putInt(versionNumber, 0);
        editor0.putInt(versionNumber, currentVersionNumber);
        editor0.commit();
    }
    // force to refresh preferences
    myPublic.getmPreferences().set_check();
    //getting the language from SharedPreferences, by default is "en"
    try {
        String tmp = pref.getString(Config.language_options, "");
        if (tmp == "") {
            myLang = TypeLanguage.ENGLISH;
        } else {
            myLang = TypeLanguage.typeOf(tmp);
        }
        Locale myLocale = new Locale(myLang.toString());
        Locale.setDefault(myLocale);
        android.content.res.Configuration config = new android.content.res.Configuration();
        config.locale = myLocale;
        getBaseContext().getResources().updateConfiguration(config,
                getBaseContext().getResources().getDisplayMetrics());
    } catch (Exception e) {
        Log.e(Config.LOGTAG, "MainActiviti.onCreate setting_language_preference");
    }
    // Tenemos una plantilla llamada activity_main.xml donde mostraremos la informacin que queramos (logotipo, etc.)
    setContentView(R.layout.activity_main);

    new Handler().postDelayed(new Runnable() {
        public void run() {
            // Cuando pasen los 1 segundo, pasamos a la actividad principal de la aplicacin
            Intent intent = new Intent(MainActivity.this, LoadingActivity.class);
            startActivity(intent);
            finish();
        };
    }, DURACION_SPLASH);
}

From source file:org.kordamp.ezmorph.object.BigIntegerMorpher.java

/**
 * Trims the String from the begining to the first "."
 *//*from w  w  w .  jav  a 2 s. c  o m*/
protected String getIntegerValue(Object obj) {
    // use en_US Locale
    Locale defaultLocale = Locale.getDefault();
    String str = null;
    try {
        Locale.setDefault(Locale.US);
        str = String.valueOf(obj).trim();
    } finally {
        Locale.setDefault(defaultLocale);
    }

    int index = str.indexOf(".");
    if (index != -1) {
        str = str.substring(0, index);
    }
    return str;
}

From source file:fitnesse.responders.files.FileResponderTest.java

@Test
public void test304IfNotModified() throws Exception {
    Locale.setDefault(Locale.US);
    Calendar now = new GregorianCalendar();
    now.add(Calendar.DATE, -1);/* w w  w  .j  av a 2  s  .co m*/
    String yesterday = SimpleResponse.makeStandardHttpDateFormat().format(now.getTime());
    now.add(Calendar.DATE, 2);
    String tomorrow = SimpleResponse.makeStandardHttpDateFormat().format(now.getTime());

    request.setResource("files/testFile1");
    request.addHeader("If-Modified-Since", yesterday);
    responder = (FileResponder) FileResponder.makeResponder(request, SampleFileUtility.base);
    response = responder.makeResponse(context, request);
    assertEquals(200, response.getStatus());

    request.setResource("files/testFile1");
    request.addHeader("If-Modified-Since", tomorrow);
    responder = (FileResponder) FileResponder.makeResponder(request, SampleFileUtility.base);
    SimpleResponse notModifiedResponse = (SimpleResponse) responder.makeResponse(context, request);
    assertEquals(304, notModifiedResponse.getStatus());
    assertEquals("", notModifiedResponse.getContent());
    assertMatches(HTTP_DATE_REGEXP, notModifiedResponse.getHeader("Date"));
    assertNotNull(notModifiedResponse.getHeader("Cache-Control"));
}

From source file:com.perm.DoomPlay.AbstractReceiver.java

private void prepareLang() {
    String lang = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance())
            .getString("languages", Locale.getDefault().getLanguage());

    Locale locale = new Locale(lang);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;//from w w w  .j  a  v  a 2 s . c o  m
    getBaseContext().getResources().updateConfiguration(config, null);
}

From source file:se.tillvaxtverket.ttsigvalws.ttwebservice.TTSigValServlet.java

@Override
public void init(ServletConfig config) throws ServletException {
    this.context = config.getServletContext();
    // Remove any occurance of the BC provider
    Security.removeProvider("BC");
    // Insert the BC provider in a preferred position
    Security.insertProviderAt(new BouncyCastleProvider(), 1);
    try {//from  w w  w.  java 2 s  .  com
        SecurityManager secMan = new SecurityManager();
        secMan.checkSetFactory();
        HttpURLConnection.setContentHandlerFactory(new OCSPContentHandlerFactory());
        LOG.info("Setting URL Content handler factory to OCSPContentHandlerFactory");
    } catch (Exception ex) {
        LOG.warning("Error when setting URL content handler factory");
    }
    infoText = ResourceBundle.getBundle("infoText");
    LOG.info(currentDir);
    String dataDir = context.getInitParameter("DataDirectory");
    ConfigData conf = new ConfigData(dataDir);
    baseModel = new SigValidationBaseModel(conf);
    Locale.setDefault(new Locale(baseModel.getConf().getLanguageCode()));
}

From source file:org.eclipse.jubula.tools.i18n.CompSystemI18n.java

/**
 * Sets an new language for the I18N./*from  ww  w  .  j  av  a2  s. c o m*/
 * @param lang a <code>String</code> value. The new language.
 */
public static void setLanguage(String lang) {
    Locale.setDefault(new Locale(lang, StringConstants.EMPTY));
}

From source file:edu.ku.brc.specify.utilapps.ERDVisualizer.java

public ERDVisualizer() {
    boolean showTreeHierarchy = false;

    Locale.setDefault(currLang);
    UIRegistry.setResourceLocale(currLang);

    Vector<DBTableInfo> tables = DBTableIdMgr.getInstance().getTables();
    Collections.sort(tables);/*from  w w  w  .ja  v a2s . co m*/

    SchemaLocalizerXMLHelper schemaXMLHelper = new SchemaLocalizerXMLHelper(SpLocaleContainer.CORE_SCHEMA,
            DBTableIdMgr.getInstance());
    schemaXMLHelper.load(true);
    schemaXMLHelper.setTitlesIntoSchema();

    ERDTable.setDisplayType(showTreeHierarchy ? ERDTable.DisplayType.Title : ERDTable.DisplayType.All);

    tblTracker = new TableTracker();

    String schemDirName = adjustFileNameForLocale("schema%s");

    final File localSchemaDir = new File(schemDirName);
    if (!localSchemaDir.exists()) {
        localSchemaDir.mkdir();
    } else {
        try {
            FileUtils.cleanDirectory(localSchemaDir);

        } catch (Exception ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
            ex.printStackTrace();
        }
    }

    this.schemaDir = localSchemaDir;

    JPanel p = new JPanel(new BorderLayout());
    p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    p.add(mainPanel = new ERDPanel(tblTracker), BorderLayout.CENTER);
    setContentPane(new JScrollPane(p));
    p.setBackground(Color.WHITE);
    mainPanel.setBackground(Color.WHITE);

    try {
        File templateFile = new File(
                UIRegistry.getDefaultWorkingPath() + File.separator + "site/template.html");
        mapTemplate = FileUtils.readFileToString(templateFile);

    } catch (IOException ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
        ex.printStackTrace();
    }

    if (StringUtils.isEmpty(mapTemplate)) {
        System.err.println("The template file is empty!");
    }

    try {
        File srcDir = new File(UIRegistry.getDefaultWorkingPath() + File.separator + "site");
        for (File f : srcDir.listFiles()) {
            if (!f.getName().startsWith(".")) {
                File dst = new File(UIRegistry.getDefaultWorkingPath() + File.separator + schemDirName
                        + File.separator + f.getName());
                if (!FilenameUtils.getExtension(f.getName()).toLowerCase().equals("html")) {
                    FileUtils.copyFile(f, dst);
                }
            }
        }
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
        ex.printStackTrace();
    }

    // Choose what to display

    if (!showTreeHierarchy) {
        advance();

        int period = isDoShadow() ? 10000 : 1000;
        int delay = isDoShadow() ? 5000 : 1000;
        timer = new Timer();

        if (true)

        {
            timer.scheduleAtFixedRate(new TimerTask() {
                public void run() {
                    advance();
                }
            }, period, delay);
        }
    } else {
        ERDTable.setDisplayType(ERDTable.DisplayType.Title);

        //this.tblTracker.setFont(this.tblTracker.getFont().deriveFont((float)10.0));
        ERDTable root = null;

        boolean doCollectionSchema = true;

        if (doCollectionSchema) {
            root = tblTracker.getTable("Discipline");

            //                                                skip,  processKids, alwaysAKid, processAnyRel, okWhenParent
            tblTracker.addNodeInfo("Agent", false, true, true, false, null);
            tblTracker.addNodeInfo("Determination", false, true, true, true, null);
            tblTracker.addNodeInfo("ConservDescription", false, true, true, true, null);

            tblTracker.addNodeInfo("Attachment", true, true, true, false, null);
            tblTracker.addNodeInfo("AttributeDef", true, true, true, false, null);
            tblTracker.addNodeInfo("SpAppResourceDir", true, true, true, false, null);
            tblTracker.addNodeInfo("SpLocaleContainer", true, true, true, false, null);
            tblTracker.addNodeInfo("DeaccessionPreparation", true, true, true, false, null);
            tblTracker.addNodeInfo("OtherIdentifier", true, true, true, false, null);
            tblTracker.addNodeInfo("CollectionRelationship", true, true, true, false, null);
            tblTracker.addNodeInfo("ProjectCollectionObject", true, true, true, false, null);
            tblTracker.addNodeInfo("CollectionObjectAttr", true, true, true, false, null);
            tblTracker.addNodeInfo("CollectionObjectAttachment", true, true, true, false, null);
            tblTracker.addNodeInfo("ConservDescriptionAttachment", true, true, true, false, null);
            tblTracker.addNodeInfo("ConservEventAttachment", true, true, true, false, null);

            // No Kids
            tblTracker.addNodeInfo("Discipline", false, false, true, false, null);
            tblTracker.addNodeInfo("Collection", false, false, true, false, null);
            tblTracker.addNodeInfo("Taxon", false, false, true, false, null);
            tblTracker.addNodeInfo("TaxonCitation", false, false, true, false, null);
            //                tblTracker.addNodeInfo("DeterminationCitation",  false, false, true,  false, null);
            tblTracker.addNodeInfo("ReferenceWork", false, false, true, false, null);
            tblTracker.addNodeInfo("Journal", false, false, true, false, null);
            tblTracker.addNodeInfo("CollectingEvent", false, false, true, false, null);
            tblTracker.addNodeInfo("Locality", false, false, true, false, null);
            tblTracker.addNodeInfo("Geography", false, false, true, false, null);
            tblTracker.addNodeInfo("PaleoContext", false, false, true, false, null);
            tblTracker.addNodeInfo("LithoStrat", false, false, true, false, null);
            tblTracker.addNodeInfo("GeologicTimePeriod", false, false, true, false, null);
            tblTracker.addNodeInfo("CollectionObjectCitation", false, false, true, false, null);
            tblTracker.addNodeInfo("Accession", false, false, true, false, null);
            tblTracker.addNodeInfo("AccessionAuthorization", false, false, true, false, null);
            tblTracker.addNodeInfo("AccessionAgent", false, false, true, false, null);
            tblTracker.addNodeInfo("Agent", false, false, true, false, null);
            tblTracker.addNodeInfo("Preparation", false, false, true, false, null);
            tblTracker.addNodeInfo("PrepType", false, false, true, false, null);
            tblTracker.addNodeInfo("RepositoryAgreement", false, false, true, false, null);
            tblTracker.addNodeInfo("ConservEvent", false, false, true, false, null);

            tblTracker.addNodeInfo("DNASequence", false, false, true, false, null);
            tblTracker.addNodeInfo("TreatmentEvent", false, false, true, false, null);
            tblTracker.addNodeInfo("Ipm", false, false, true, false, null);
            tblTracker.addNodeInfo("FieldNotebook", false, false, true, false, null);
            tblTracker.addNodeInfo("FieldNotebookPageSet", false, false, true, false, null);
            tblTracker.addNodeInfo("FieldNotebookPage", false, false, true, false, null);

            NodeInfo det = tblTracker.getNodeInfo("Determination");
            det.addKid(tblTracker.getTable("Taxon"));
            //                det.addKid(tblTracker.getTable("DeterminationStatus"));

            NodeInfo ni = tblTracker.getNodeInfo("Taxon");
            ni.addKid(tblTracker.getTable("TaxonCitation"));

            ni = tblTracker.getNodeInfo("Discipline");
            ni.addKid(tblTracker.getTable("Collection"));

            ni = tblTracker.getNodeInfo("Collection");
            ni.addKid(tblTracker.getTable("FieldNotebook"));
            ni.addKid(tblTracker.getTable("CollectionObject"));

            ni = tblTracker.getNodeInfo("CollectionObjectCitation");
            ni.addKid(tblTracker.getTable("ReferenceWork"));

            ni = tblTracker.getNodeInfo("TaxonCitation");
            ni.addKid(tblTracker.getTable("ReferenceWork"));

            ni = tblTracker.getNodeInfo("ReferenceWork");
            ni.setOkToDuplicate(true);
            ni.addKid(tblTracker.getTable("Journal"));

            ni = tblTracker.getNodeInfo("GeologicTimePeriod");
            ni.setOkToDuplicate(true);

            ni = tblTracker.getNodeInfo("Journal");
            ni.setOkToDuplicate(true);

            ni = tblTracker.getNodeInfo("CollectingEvent");
            ni.addKid(tblTracker.getTable("Locality"));

            ni = tblTracker.getNodeInfo("CollectionObject");
            ni.addKid(tblTracker.getTable("CollectingEvent"));
            ni.addKid(tblTracker.getTable("PaleoContext"));
            ni.addKid(tblTracker.getTable("Accession"));
            ni.addKid(tblTracker.getTable("DNASequence"));
            ni.addKid(tblTracker.getTable("TreatmentEvent"));
            ni.addKid(tblTracker.getTable("Ipm"));

            ni = tblTracker.getNodeInfo("Locality");
            ni.addKid(tblTracker.getTable("Geography"));

            ni = tblTracker.getNodeInfo("PaleoContext");
            ni.addKid(tblTracker.getTable("LithoStrat"));
            ni.addKid(tblTracker.getTable("GeologicTimePeriod"));

            ni = tblTracker.getNodeInfo("DeterminationCitation");
            ni.addKid(tblTracker.getTable("ReferenceWork"));

            ni = tblTracker.getNodeInfo("Preparation");
            ni.addKid(tblTracker.getTable("PrepType"));

            ni = tblTracker.getNodeInfo("Accession");
            ni.addKid(tblTracker.getTable("AccessionAuthorization"));
            ni.addKid(tblTracker.getTable("AccessionAgent"));
            ni.addKid(tblTracker.getTable("RepositoryAgreement"));
            //ni.addKid(tblTracker.getTable("Attachment"));
            //protected RepositoryAgreement repositoryAgreement;

            ni = tblTracker.getNodeInfo("ConservEvent");
            ni.addKid(tblTracker.getTable("ConservRecommendation"));

            ni = tblTracker.getNodeInfo("FieldNotebook");
            ni.addKid(tblTracker.getTable("FieldNotebookPageSet"));

            ni = tblTracker.getNodeInfo("FieldNotebookPageSet");
            ni.addKid(tblTracker.getTable("FieldNotebookPage"));

        } else {
            root = tblTracker.getTable("SpAppResourceDir");

            //                                           skip,  processKids, alwaysAKid, processAnyRel, okWhenParent
            //tblTracker.addNodeInfo("Agent",              false, true,        true,       false,         null);

            // No Kids
            tblTracker.addNodeInfo("SpAppResourceData", false, false, true, false, null);
            tblTracker.addNodeInfo("Collection", false, false, true, false, null);
            tblTracker.addNodeInfo("Discipline", false, false, true, false, null);
            tblTracker.addNodeInfo("SpecifyUser", false, false, true, false, null);
            tblTracker.addNodeInfo("SpAppResource", false, false, true, false, null);
            tblTracker.addNodeInfo("SpViewSetObj", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIViewSet", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIView", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIViewDef", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIAltView", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIColumn", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUIRow", false, false, true, false, null);
            tblTracker.addNodeInfo("SpUICell", false, false, true, false, null);

            NodeInfo ni = tblTracker.getNodeInfo("SpAppResourceDir");
            ni.addKid(tblTracker.getTable("SpAppResource"));
            ni.addKid(tblTracker.getTable("SpViewSetObj"));
            //ni.addKid(tblTracker.getTable("Collection"));
            //ni.addKid(tblTracker.getTable("Discipline"));
            //ni.addKid(tblTracker.getTable("SpecifyUser"));

            ni = tblTracker.getNodeInfo("SpAppResource");
            ni.addKid(tblTracker.getTable("SpAppResourceData"));

            ni = tblTracker.getNodeInfo("SpViewSetObj");
            ni.addKid(tblTracker.getTable("SpAppResourceData"));
            ni.addKid(tblTracker.getTable("SpUIViewSet"));

            ni = tblTracker.getNodeInfo("SpUIViewSet");
            ni.addKid(tblTracker.getTable("SpUIView"));
            ni.addKid(tblTracker.getTable("SpUIViewDef"));

            ni = tblTracker.getNodeInfo("SpUIView");
            ni.addKid(tblTracker.getTable("SpUIAltView"));

            ni = tblTracker.getNodeInfo("SpUIViewDef");
            ni.addKid(tblTracker.getTable("SpUIColumn"));
            ni.addKid(tblTracker.getTable("SpUIRow"));

            ni = tblTracker.getNodeInfo("SpUIRow");
            ni.addKid(tblTracker.getTable("SpUICell"));
            //ni.addKid(tblTracker.getTable("SpUIViewDef"));

            //ni = tblTracker.getNodeInfo("SpUIAltView");
            //ni.addKid(tblTracker.getTable("SpUIView"));
            //ni.addKid(tblTracker.getTable("SpUIViewDef"));

            ni = tblTracker.getNodeInfo("SpAppResourceData");
            ni.setOkToDuplicate(true);

            if (false) {
                NodeInfo det = tblTracker.getNodeInfo("Determination");
                det.addKid(tblTracker.getTable("Taxon"));
                //                    det.addKid(tblTracker.getTable("DeterminationStatus"));

                ni = tblTracker.getNodeInfo("Taxon");
                ni.addKid(tblTracker.getTable("TaxonCitation"));

                ni = tblTracker.getNodeInfo("CollectionObjectCitation");
                ni.addKid(tblTracker.getTable("ReferenceWork"));

                ni = tblTracker.getNodeInfo("TaxonCitation");
                ni.addKid(tblTracker.getTable("ReferenceWork"));

                ni = tblTracker.getNodeInfo("ReferenceWork");
                ni.setOkToDuplicate(true);
                ni.addKid(tblTracker.getTable("Journal"));

                ni = tblTracker.getNodeInfo("GeologicTimePeriod");
                ni.setOkToDuplicate(true);

                ni = tblTracker.getNodeInfo("Journal");
                ni.setOkToDuplicate(true);

                ni = tblTracker.getNodeInfo("CollectingEvent");
                ni.addKid(tblTracker.getTable("Locality"));

                ni = tblTracker.getNodeInfo("CollectionObject");
                ni.addKid(tblTracker.getTable("CollectingEvent"));
                ni.addKid(tblTracker.getTable("PaleoContext"));
                ni.addKid(tblTracker.getTable("Accession"));

                ni = tblTracker.getNodeInfo("Locality");
                ni.addKid(tblTracker.getTable("Geography"));

                ni = tblTracker.getNodeInfo("PaleoContext");
                ni.addKid(tblTracker.getTable("LithoStrat"));
                ni.addKid(tblTracker.getTable("GeologicTimePeriod"));

                ni = tblTracker.getNodeInfo("DeterminationCitation");
                ni.addKid(tblTracker.getTable("ReferenceWork"));

                ni = tblTracker.getNodeInfo("Preparation");
                ni.addKid(tblTracker.getTable("PrepType"));

                ni = tblTracker.getNodeInfo("Accession");
                ni.addKid(tblTracker.getTable("AccessionAuthorization"));
                ni.addKid(tblTracker.getTable("AccessionAgent"));
                ni.addKid(tblTracker.getTable("RepositoryAgreement"));
            }

        }

        if (false) {
            NodeInfo ni = tblTracker.getNodeInfo("Agent");
            ni.setOkToDuplicate(true);

            String[] toAddAgent = { "CollectionObject", "Accession", "Determination", "Preparation", };
            for (String name : toAddAgent) {
                ni = tblTracker.getNodeInfo(name);
                ni.addKid(tblTracker.getTable("Agent"));
            }
        }

        processAsTree(root, 0);
        mainPanel.addTree(root);

        final SwingWorker worker = new SwingWorker() {
            public Object construct() {
                try {
                    Thread.sleep(3000);

                } catch (Exception ex) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ERDVisualizer.class, ex);
                    ex.printStackTrace();
                }
                return null;
            }

            //Runs on the event-dispatching thread.
            public void finished() {
                generate();
                System.out.println("Done.");
            }
        };
        worker.start();
    }

    createIndexFile();
}

From source file:io.github.mkjung.ivi.VLCApplication.java

@Override
public void onCreate() {
    super.onCreate();

    // Are we using advanced debugging - locale?
    mSettings = PreferenceManager.getDefaultSharedPreferences(this);
    String p = mSettings.getString("set_locale", "");
    if (!p.equals("")) {
        Locale locale;/*from w w  w . j a  va2 s .  c om*/
        // workaround due to region code
        if (p.equals("zh-TW")) {
            locale = Locale.TRADITIONAL_CHINESE;
        } else if (p.startsWith("zh")) {
            locale = Locale.CHINA;
        } else if (p.equals("pt-BR")) {
            locale = new Locale("pt", "BR");
        } else if (p.equals("bn-IN") || p.startsWith("bn")) {
            locale = new Locale("bn", "IN");
        } else {
            /**
             * Avoid a crash of
             * java.lang.AssertionError: couldn't initialize LocaleData for locale
             * if the user enters nonsensical region codes.
             */
            if (p.contains("-"))
                p = p.substring(0, p.indexOf('-'));
            locale = new Locale(p);
        }
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        config.locale = locale;
        getResources().updateConfiguration(config, getResources().getDisplayMetrics());
    }

    instance = this;

    // Initialize the database soon enough to avoid any race condition and crash
    MediaDatabase.getInstance();
    // Prepare cache folder constants
    AudioUtil.prepareCacheFolder(this);

    sTV = AndroidDevices.isAndroidTv() || !AndroidDevices.hasTsp();

    Dialog.setCallbacks(VLCInstance.get(), mDialogCallbacks);

    // Disable remote control receiver on Fire TV.
    //        if (!AndroidDevices.hasTsp())
    //            AndroidDevices.setRemoteControlReceiverEnabled(false);
}