use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class UITextChanger method createDisplayedComponents.
private Component[] createDisplayedComponents(ArrayList<JTextField> textFields) {
final Box[] components = new Box[textFields.size()];
final UrlCreator urlCreator = new UrlCreator();
for (int i = 0; i < textFields.size(); i++) {
final Box box = Box.createHorizontalBox();
final JTextField textField = textFields.get(i);
box.add(textField);
final String textKey = (String) textField.getClientProperty(TEXT_FIELD_TRANSLATION_KEY);
final boolean isTranslationKeyDefined = TextUtils.getRawText(textKey, null) != null;
final JComponent weblateButton;
if (isTranslationKeyDefined) {
final String url = urlCreator.createWeblateUrl(textKey);
weblateButton = createGoToUrlButton(url, WEBLATE_ICON);
} else {
weblateButton = new JButton(WEBLATE_ICON);
TranslatedElement.TOOLTIP.setKey(weblateButton, ORIGINAL_TEXT_IS_NOT_DEFINED);
weblateButton.setToolTipText(TextUtils.getText(ORIGINAL_TEXT_IS_NOT_DEFINED));
weblateButton.setEnabled(false);
final ResourceController resourceController = ResourceController.getResourceController();
if (!resourceController.getDefaultLanguageCode().equals(resourceController.getLanguageCode()))
textField.setEnabled(false);
}
box.add(weblateButton);
components[i] = box;
}
return components;
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class FormatController method getDefaultDateTimeFormat.
public SimpleDateFormat getDefaultDateTimeFormat() {
if (defaultDateTimeFormat != null)
return defaultDateTimeFormat;
final ResourceController resourceController = ResourceController.getResourceController();
// DateFormatParser cannot handle empty date format!
fixEmptyDataFormatProperty(resourceController, RESOURCES_DATETIME_FORMAT, "SHORT,SHORT");
String datetimePattern = resourceController.getProperty(RESOURCES_DATETIME_FORMAT);
defaultDateTimeFormat = createDefaultDateTimeFormat(datetimePattern);
return defaultDateTimeFormat;
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class CloudController method getStandardColor.
public static Color getStandardColor() {
final ResourceController resourceController = ResourceController.getResourceController();
final String colorCode = resourceController.getProperty(CloudController.RESOURCES_CLOUD_COLOR);
return ColorUtils.stringToColor(colorCode);
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class UITools method getScaleFactor.
private static float getScaleFactor() {
final ResourceController resourceController = ResourceController.getResourceController();
int windowX = resourceController.getIntProperty("appwindow_x", 0);
int windowY = resourceController.getIntProperty("appwindow_y", 0);
final GraphicsConfiguration graphicsConfiguration = findGraphicsConfiguration(windowX, windowY);
final int userDefinedScreenResolution;
if (graphicsConfiguration != null) {
final Rectangle screenBounds = graphicsConfiguration.getBounds();
final int w = screenBounds.width;
final int h = screenBounds.height;
final double diagonalPixels = Math.sqrt(w * w + h * h);
final double monitorSize = resourceController.getDoubleProperty("monitor_size_inches", 0);
if (monitorSize >= 1 && diagonalPixels >= 1) {
userDefinedScreenResolution = (int) Math.round(diagonalPixels / monitorSize);
resourceController.setProperty("user_defined_screen_resolution", userDefinedScreenResolution);
} else {
userDefinedScreenResolution = resourceController.getIntProperty("user_defined_screen_resolution", 96);
final double effectiveMonitorSize = Math.round(diagonalPixels / userDefinedScreenResolution * 10) / 10;
resourceController.setDefaultProperty("monitor_size_inches", Double.toString(effectiveMonitorSize));
}
} else {
userDefinedScreenResolution = resourceController.getIntProperty("user_defined_screen_resolution", 96);
resourceController.setDefaultProperty("monitor_size_inches", Double.toString(0));
}
return userDefinedScreenResolution / 72f;
}
use of org.freeplane.core.resources.ResourceController in project freeplane by freeplane.
the class MFileManager method chosenTemplateFile.
protected File chosenTemplateFile() {
final ResourceController resourceController = ResourceController.getResourceController();
boolean skipTemplateSelection = resourceController.getBooleanProperty("skip_template_selection");
if (skipTemplateSelection)
return defaultTemplateFile();
final String standardTemplatePath = resourceController.getProperty(STANDARD_TEMPLATE);
final TreeSet<String> availableMapTemplates = collectAvailableMapTemplates();
availableMapTemplates.add(standardTemplatePath);
final Box verticalBox = Box.createVerticalBox();
final JComboBox<String> templateComboBox = new JComboBox<>(new Vector<>(availableMapTemplates));
templateComboBox.setSelectedItem(standardTemplatePath);
templateComboBox.setAlignmentX(0f);
verticalBox.add(templateComboBox);
final String checkBoxText = TextUtils.getRawText("OptionalDontShowMeAgainDialog.rememberMyDescision");
final JCheckBox mDontShowAgainBox = new JCheckBox();
mDontShowAgainBox.setAlignmentX(0f);
LabelAndMnemonicSetter.setLabelAndMnemonic(mDontShowAgainBox, checkBoxText);
verticalBox.add(mDontShowAgainBox);
JOptionPane.showMessageDialog(UITools.getCurrentFrame(), verticalBox, TextUtils.getText("select_template"), JOptionPane.PLAIN_MESSAGE);
final String selectedTemplate = (String) templateComboBox.getSelectedItem();
if (mDontShowAgainBox.isSelected()) {
resourceController.setProperty("skip_template_selection", true);
resourceController.setProperty(STANDARD_TEMPLATE, selectedTemplate);
}
return templateFile(selectedTemplate);
}
Aggregations