Search in sources :

Example 1 with FreeplaneVersion

use of org.freeplane.core.util.FreeplaneVersion in project freeplane by freeplane.

the class NodeStyleBuilder method registerAttributeHandlers.

private void registerAttributeHandlers(final ReadManager reader) {
    final IAttributeHandler colorHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            if (value.length() == 7) {
                final NodeModel node = (NodeModel) userObject;
                NodeStyleModel.setColor(node, ColorUtils.stringToColor(value));
            }
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "COLOR", colorHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "COLOR", colorHandler);
    final IAttributeHandler bgHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            if (value.length() == 7) {
                final NodeModel node = (NodeModel) userObject;
                NodeStyleModel.setBackgroundColor(node, ColorUtils.stringToColor(value));
            }
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "BACKGROUND_COLOR", bgHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "BACKGROUND_COLOR", bgHandler);
    final IAttributeHandler styleHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            NodeStyleModel.setShape(node, value);
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "STYLE", styleHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "STYLE", styleHandler);
    reader.addAttributeHandler("font", "SIZE", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final FontProperties fp = (FontProperties) userObject;
            fp.fontSize = Integer.parseInt(value.toString());
        }
    });
    reader.addAttributeHandler("font", "NAME", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final FontProperties fp = (FontProperties) userObject;
            fp.fontName = value;
        }
    });
    reader.addAttributeHandler("font", "BOLD", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final FontProperties fp = (FontProperties) userObject;
            fp.isBold = value.equals("true");
        }
    });
    reader.addAttributeHandler("font", "ITALIC", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final FontProperties fp = (FontProperties) userObject;
            fp.isItalic = value.equals("true");
        }
    });
    final IAttributeHandler nodenumberingHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            NodeStyleModel.setNodeNumbering(node, value.equals("true"));
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "NUMBERED", nodenumberingHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "NUMBERED", nodenumberingHandler);
    final IAttributeHandler formatHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            NodeStyleModel.setNodeFormat(node, value);
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "FORMAT", formatHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "FORMAT", formatHandler);
    if (FreeplaneVersion.getVersion().isOlderThan(new FreeplaneVersion(1, 3, 0))) {
        // compatibility for a view 1.2.X preview versions - remove after release 1.3
        reader.addAttributeHandler(NodeBuilder.XML_NODE, "TEMPLATE", formatHandler);
        reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "TEMPLATE", formatHandler);
    }
    final IAttributeHandler nodeMaxNodeWidthHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            NodeSizeModel.setNodeMaxNodeWidth(node, Integer.valueOf(value));
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "MAX_WIDTH", nodeMaxNodeWidthHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "MAX_WIDTH", nodeMaxNodeWidthHandler);
    final IAttributeHandler nodeMinWidthHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            NodeSizeModel.setNodeMinWidth(node, Integer.valueOf(value));
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, "MIN_WIDTH", nodeMinWidthHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, "MIN_WIDTH", nodeMinWidthHandler);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IAttributeHandler(org.freeplane.core.io.IAttributeHandler) FreeplaneVersion(org.freeplane.core.util.FreeplaneVersion)

Example 2 with FreeplaneVersion

use of org.freeplane.core.util.FreeplaneVersion in project freeplane by freeplane.

the class HttpVersionClient method parseHistory.

private void parseHistory(FreeplaneVersion currentVersion, BufferedReader in, String firstLine) throws IOException {
    final StringBuilder historyBuffer = new StringBuilder();
    historyBuffer.append(firstLine);
    historyBuffer.append('\n');
    for (String line = in.readLine(); line != null; line = in.readLine()) {
        try {
            final FreeplaneVersion version = FreeplaneVersion.getVersion(line);
            if (version.compareTo(currentVersion) <= 0) {
                break;
            }
        } catch (final IllegalArgumentException e) {
        }
        historyBuffer.append(line);
        historyBuffer.append('\n');
    }
    history = historyBuffer.toString();
}
Also used : FreeplaneVersion(org.freeplane.core.util.FreeplaneVersion)

Example 3 with FreeplaneVersion

use of org.freeplane.core.util.FreeplaneVersion in project freeplane by freeplane.

the class UpdateCheckAction method setTimer.

private void setTimer() {
    if (autorunEnabled == false) {
        return;
    }
    autorunEnabled = ResourceController.getResourceController().getBooleanProperty(CHECK_UPDATES_AUTOMATICALLY);
    if (autorunEnabled == false) {
        return;
    }
    autorunEnabled = false;
    final Date now = new Date();
    final long nextCheckMillis = ResourceController.getResourceController().getLongProperty(LAST_UPDATE_CHECK_TIME, 0) + TWO_DAYS;
    final Date nextCheckDate = new Date(nextCheckMillis);
    if (now.before(nextCheckDate)) {
        final FreeplaneVersion knownNewVersion = getKnownNewVersion();
        addUpdateButton(knownNewVersion);
        return;
    }
    autorunTimer = new Timer(CHECK_TIME, this);
    autorunTimer.setRepeats(false);
    autorunTimer.start();
}
Also used : Timer(javax.swing.Timer) FreeplaneVersion(org.freeplane.core.util.FreeplaneVersion) Date(java.util.Date)

Example 4 with FreeplaneVersion

use of org.freeplane.core.util.FreeplaneVersion in project freeplane by freeplane.

the class HttpVersionClient method parseHistory.

private void parseHistory(FreeplaneVersion currentVersion, BufferedReader in, String firstLine) throws IOException {
    final StringBuilder historyBuffer = new StringBuilder();
    historyBuffer.append(firstLine);
    historyBuffer.append('\n');
    for (String line = in.readLine(); line != null; line = in.readLine()) {
        try {
            final FreeplaneVersion version = FreeplaneVersion.getVersion(line);
            if (version.compareTo(currentVersion) <= 0) {
                break;
            }
        } catch (final IllegalArgumentException e) {
        }
        historyBuffer.append(line);
        historyBuffer.append('\n');
    }
    history = historyBuffer.toString();
}
Also used : FreeplaneVersion(org.freeplane.core.util.FreeplaneVersion)

Example 5 with FreeplaneVersion

use of org.freeplane.core.util.FreeplaneVersion in project freeplane by freeplane.

the class UpdateCheckAction method getKnownNewVersion.

private FreeplaneVersion getKnownNewVersion() {
    final FreeplaneVersion localVersion = FreeplaneVersion.getVersion();
    final String property = ResourceController.getResourceController().getProperty(LAST_UPDATE_VERSION);
    if (property.equals("")) {
        return null;
    }
    FreeplaneVersion lastVersion = FreeplaneVersion.getVersion(property);
    if (lastVersion.compareTo(localVersion) <= 0) {
        lastVersion = null;
    }
    return lastVersion;
}
Also used : FreeplaneVersion(org.freeplane.core.util.FreeplaneVersion)

Aggregations

FreeplaneVersion (org.freeplane.core.util.FreeplaneVersion)13 Date (java.util.Date)4 AddOnProperties (org.freeplane.main.addons.AddOnProperties)4 Font (java.awt.Font)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 URL (java.net.URL)2 Locale (java.util.Locale)2 Box (javax.swing.Box)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 Timer (javax.swing.Timer)2 Border (javax.swing.border.Border)2 JScrollPane (javax.swing.JScrollPane)1 JTextArea (javax.swing.JTextArea)1 IAttributeHandler (org.freeplane.core.io.IAttributeHandler)1 NodeModel (org.freeplane.features.map.NodeModel)1