private static void configControls( String optionName, int value, boolean highlight, JLabel sizeLabel, JTextField sizeField, JLabel unitsLabel, JLabel currentValueLabel) { sizeLabel.setText(optionName); String formatted = value == -1 ? DiagnosticBundle.message("diagnostic.out.of.memory.currentValue.unknown") : String.valueOf(value); sizeField.setText(formatted); currentValueLabel.setText( DiagnosticBundle.message("diagnostic.out.of.memory.currentValue", formatted)); if (highlight) { sizeLabel.setForeground(Color.RED); sizeField.setForeground(Color.RED); unitsLabel.setForeground(Color.RED); currentValueLabel.setForeground(Color.RED); } }
public OutOfMemoryDialog(MemoryKind memoryKind) { super(false); myMemoryKind = memoryKind; setTitle(DiagnosticBundle.message("diagnostic.out.of.memory.title")); myMessageLabel.setIcon(Messages.getErrorIcon()); myMessageLabel.setText( DiagnosticBundle.message( "diagnostic.out.of.memory.error", memoryKind == MemoryKind.HEAP ? VMOptions.XMX_OPTION_NAME : memoryKind == MemoryKind.PERM_GEN ? VMOptions.PERM_GEN_OPTION_NAME : VMOptions.CODE_CACHE_OPTION_NAME, ApplicationNamesInfo.getInstance().getProductName())); final String path = VMOptions.getSettingsFilePath(); if (path != null) { mySettingsFileHintLabel.setText( DiagnosticBundle.message("diagnostic.out.of.memory.willBeSavedTo", path)); } else { mySettingsFileHintLabel.setVisible(false); } myIgnoreAction = new AbstractAction(DiagnosticBundle.message("diagnostic.out.of.memory.ignore")) { public void actionPerformed(ActionEvent e) { save(); close(0); } }; myShutdownAction = new AbstractAction(DiagnosticBundle.message("diagnostic.out.of.memory.shutdown")) { public void actionPerformed(ActionEvent e) { save(); System.exit(0); } }; myShutdownAction.putValue(DialogWrapper.DEFAULT_ACTION, true); configControls( VMOptions.XMX_OPTION_NAME, VMOptions.readXmx(), memoryKind == MemoryKind.HEAP, myHeapSizeLabel, myHeapSizeField, myHeapUnitsLabel, myHeapCurrentValueLabel); configControls( VMOptions.PERM_GEN_OPTION_NAME, VMOptions.readMaxPermGen(), memoryKind == MemoryKind.PERM_GEN, myPermGenSizeLabel, myPermGenSizeField, myPermGenUnitsLabel, myPermGenCurrentValueLabel); configControls( VMOptions.CODE_CACHE_OPTION_NAME, VMOptions.readCodeCache(), memoryKind == MemoryKind.CODE_CACHE, myCodeCacheSizeLabel, myCodeCacheSizeField, myCodeCacheUnitsLabel, myCodeCacheCurrentValueLabel); init(); }