Java Code Examples for java.util.MissingResourceException#printStackTrace()

The following examples show how to use java.util.MissingResourceException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Res.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static String get(String key) {
    try {
        return resourceBundle.getString(key)
                .replace("BTC", baseCurrencyCode)
                .replace("Bitcoin", baseCurrencyName)
                .replace("bitcoin", baseCurrencyNameLowerCase);
    } catch (MissingResourceException e) {
        log.warn("Missing resource for key: {}", key);
        e.printStackTrace();
        if (DevEnv.isDevMode())
            UserThread.runAfter(() -> {
                // We delay a bit to not throw while UI is not ready
                throw new RuntimeException("Missing resource for key: " + key);
            }, 1);

        return key;
    }
}
 
Example 2
Source File: SimpleContainerProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public String getDisplayName(Object containerType, String containerCtx) {
    try {
        return bundle.getString(containerCtx);
    } catch (MissingResourceException mre) {
        mre.printStackTrace();
        return containerCtx;
    }
}
 
Example 3
Source File: SimpleActionProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public String getDisplayName(String actionName, String containerCtx) {
    try {
        return bundle.getString(actionName);
    } catch (MissingResourceException mre) {
        mre.printStackTrace();
        return actionName;
    }
}
 
Example 4
Source File: RestoreDefaultValueTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private AbstractButton findResetToDefaultButton(JDialog jd) {
    String txt = null;
    try {
        txt = NbBundle.getMessage(PropertyDialogManager.class, "CTL_Default");
    } catch (MissingResourceException mre) {
        mre.printStackTrace();
        fail("Bundle key CTL_DEFAULT missing from org.openide.explorer.propertysheet.Bundle.properties");
    }
    return findButton(jd.getContentPane(), txt);
}
 
Example 5
Source File: Main.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    int errors = 0;
    for (String loctag : args) {
        Locale locale = Locale.forLanguageTag(loctag);
        if (locale.equals(Locale.ROOT)) {
            continue;
        }
        ResourceBundle rb = ResourceBundle.getBundle("jdk.test.resources.MyResources",
                                                     locale);
        String tag = locale.toLanguageTag(); // normalized
        String value = rb.getString("key");
        System.out.println(rb.getBaseBundleName() + ": locale = " + tag + ", value = " + value);
        if (!value.startsWith(tag + ':')) {
            System.out.println("ERROR: " + value + " expected: " + tag);
            errors++;
        }

        // inaccessible bundles
        try {
            ResourceBundle.getBundle("jdk.test.internal.resources.Foo", locale);
            System.out.println("ERROR: jdk.test.internal.resources.Foo should not be accessible");
            errors++;
        } catch (MissingResourceException e) {
            e.printStackTrace();

            Throwable cause = e.getCause();
            System.out.println("Expected: " +
                (cause != null ? cause.getMessage() : e.getMessage()));
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors + " errors");
    }
}
 
Example 6
Source File: AboutJPanel.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/** Loads an about image from its source */
private Image loadImage(String urlString) {
    try {
        URL u = getClass().getResource(urlString);
        return Toolkit.getDefaultToolkit().getImage(u);
    } catch (MissingResourceException exception) {
        exception.printStackTrace();
        return null;
    }
}
 
Example 7
Source File: Messages.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param key
 * @param oa
 * @param lcl
 */
public static String getString( String key, Object[] oa, ULocale lcl )
{
	try
	{
		return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
				oa );
	}
	catch ( MissingResourceException e )
	{
		e.printStackTrace( );
		return '!' + key + '!';
	}
}
 
Example 8
Source File: Messages.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param key
 * @param oa
 * @param lcl
 */
public static String getString( String key, Object[] oa, ULocale lcl )
{
	try
	{
		return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
				oa );
	}
	catch ( MissingResourceException e )
	{
		e.printStackTrace( );
		return '!' + key + '!';
	}
}
 
Example 9
Source File: Messages.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param key
 * @param oa
 * @param lcl
 */
public static String getString( String key, Object[] oa, ULocale lcl )
{
	try
	{
		return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
				oa );
	}
	catch ( MissingResourceException e )
	{
		e.printStackTrace( );
		return '!' + key + '!';
	}
}
 
Example 10
Source File: Messages.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param key
 * @param oa
 * @param lcl
 */
public static String getString( String key, Object[] oa, ULocale lcl )
{
	try
	{
		return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
				oa );
	}
	catch ( MissingResourceException e )
	{
		e.printStackTrace( );
		return '!' + key + '!';
	}
}
 
Example 11
Source File: LabeledTextFieldDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Creates new form LabeledTextFieldDialog */
public LabeledTextFieldDialog(String notes) 
{
    String title = NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableRenameTable"); // NOI18N
    String lab = NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableNewName"); // NOI18N
    original_notes = notes;
    
    initComponents();
    
    try
    {
        Mnemonics.setLocalizedText(titleLabel, lab);
        titleLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableNewNameA11yDesc"));  // NOI18N

        Mnemonics.setLocalizedText(descLabel, NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableRenameNotes")); // NOI18N
        descLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableRenameNotesA11yDesc"));  // NOI18N
        Mnemonics.setLocalizedText(editButton, NbBundle.getMessage (LabeledTextFieldDialog.class, "EditCommand")); // NOI18N
        editButton.setToolTipText(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_EditCommandA11yDesc"));  // NOI18N

        updateState();

        ActionListener listener = new ActionListener() 
        {
            public void actionPerformed(ActionEvent event) 
            {
                result = event.getSource() == DialogDescriptor.OK_OPTION;
            }
        };

        getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableDialogA11yDesc")); // NOI18N

        DialogDescriptor descriptor = new DialogDescriptor(this, title, true, listener);
        dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.setResizable(true);
    }
    catch (MissingResourceException e)
    {
        e.printStackTrace();
    }

}
 
Example 12
Source File: SaiyTextToSpeech.java    From Saiy-PS with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Attempt to resolve the voice that most suits the conditions and the user's preferences.
 *
 * @param language   the {@link Locale} language
 * @param region     the {@link Locale} region
 * @param conditions the {@link SelfAwareConditions}
 * @param params     the {@link SelfAwareParameters}
 * @return one of {@link #SUCCESS} or {@link #ERROR}
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private int resolveVoice(@NonNull final String language, @NonNull final String region,
                         @NonNull final SelfAwareConditions conditions, @NonNull final SelfAwareParameters params,
                         @Nullable final SaiyVoice currentVoice) {
    if (DEBUG) {
        MyLog.i(CLS_NAME, "resolveVoice");
    }

    final Pair<SaiyVoice, Locale> voicePair = new TTSVoice(language, region, conditions, params,
            currentVoice).buildVoice();

    if (voicePair.first != null) {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "resolveVoice: Setting Voice: " + voicePair.first.toString());
            MyLog.i(CLS_NAME, "resolveVoice: Setting Voice loc: " + voicePair.first.getLocale());
            try {
                MyLog.i(CLS_NAME, "resolveVoice: Setting Voice: isLanguageAvailable: "
                        + resolveSuccess(isLanguageAvailable(new Locale(voicePair.first.getLocale().getLanguage(),
                        voicePair.first.getLocale().getCountry()))));
            } catch (final MissingResourceException e) {
                MyLog.w(CLS_NAME, "MissingResourceException: isLanguageAvailable failed");
                e.printStackTrace();
            }
        }

        return super.setVoice(voicePair.first);
    } else {
        if (voicePair.second != null) {
            if (DEBUG) {
                MyLog.i(CLS_NAME, "resolveVoice: Setting Locale deprecated");
            }
            return setVoiceDeprecated(voicePair.second.getLanguage(), voicePair.second.getCountry());
        } else {
            if (DEBUG) {
                MyLog.w(CLS_NAME, "resolveVoice: voicePair.second null: falling back");
            }
            return resolveSuccess(super.setLanguage(new Locale(language, region)));
        }
    }
}