Search in sources :

Example 21 with ResourceController

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;
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) Box(javax.swing.Box) JTextField(javax.swing.JTextField) Point(java.awt.Point)

Example 22 with ResourceController

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;
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController)

Example 23 with ResourceController

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);
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController)

Example 24 with ResourceController

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;
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController) Rectangle(java.awt.Rectangle) Point(java.awt.Point) GraphicsConfiguration(java.awt.GraphicsConfiguration)

Example 25 with ResourceController

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);
}
Also used : JCheckBox(javax.swing.JCheckBox) JComboBox(javax.swing.JComboBox) ResourceController(org.freeplane.core.resources.ResourceController) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox)

Aggregations

ResourceController (org.freeplane.core.resources.ResourceController)31 File (java.io.File)8 IOException (java.io.IOException)7 URL (java.net.URL)6 MalformedURLException (java.net.MalformedURLException)4 URISyntaxException (java.net.URISyntaxException)3 Point (java.awt.Point)2 BufferedInputStream (java.io.BufferedInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 StringReader (java.io.StringReader)2 Box (javax.swing.Box)2 Controller (org.freeplane.features.mode.Controller)2 ModeController (org.freeplane.features.mode.ModeController)2 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)2 FileUserDictionary (com.inet.jortho.FileUserDictionary)1 LanguageChangeEvent (com.inet.jortho.LanguageChangeEvent)1 LanguageChangeListener (com.inet.jortho.LanguageChangeListener)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1