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);
}
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();
}
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();
}
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();
}
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;
}
Aggregations