use of org.freeplane.features.text.TransformationException in project freeplane by freeplane.
the class AttributeConditionController method getValuesForProperty.
public ComboBoxModel getValuesForProperty(final Object selectedItem, TranslatedObject simpleCond) {
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
try {
final AttributeRegistryElement element = registry.getElement(selectedItem.toString());
final SortedComboBoxModel list = element.getValues();
SortedComboBoxModel linkedList = new SortedComboBoxModel();
for (int i = 0; i < list.getSize(); i++) {
final Object value = list.getElementAt(i);
final TextController textController = TextController.getController();
if (!textController.isFormula(value, null, null)) {
try {
final Object transformedValue = textController.getTransformedObject(value, map.getRootNode(), null);
linkedList.add(transformedValue);
} catch (TransformationException e) {
LogUtils.severe(e);
}
}
}
values.setExtensionList(linkedList);
} catch (NoSuchElementException e) {
values.setExtensionList(null);
}
return values;
}
use of org.freeplane.features.text.TransformationException in project freeplane by freeplane.
the class SplitToWordsAction method actionPerformed.
@Override
protected void actionPerformed(ActionEvent e, NodeModel node) {
final ModeController modeController = Controller.getCurrentModeController();
MTextController textController = (MTextController) modeController.getExtension(TextController.class);
final MMapController mapController = (MMapController) modeController.getMapController();
String details;
try {
details = textController.getTransformedObject(node).toString();
} catch (TransformationException e1) {
return;
}
String plainText = HtmlUtils.htmlToPlain(details).trim();
int nodeCountInLine;
boolean newNode;
if (leaveOriginalNodeEmpty) {
nodeCountInLine = 0;
newNode = true;
textController.setNodeText(node, "");
} else {
nodeCountInLine = -1;
newNode = false;
}
NodeModel currentNode = node;
final Matcher matcher = compiledWordPattern.matcher(plainText);
while (matcher.find()) {
String word = matcher.group();
final String currentText;
if (newNode) {
if (nodeCountInLine == nodeNumberInLine) {
nodeCountInLine = 0;
currentNode = node;
}
currentNode = mapController.addNewNode(currentNode, currentNode.getChildCount(), currentNode.isLeft());
nodeCountInLine++;
currentText = "";
} else if (nodeCountInLine == -1) {
nodeCountInLine = 0;
currentNode = node;
currentText = "";
} else
currentText = currentNode.getText() + ' ';
boolean auxiliaryWord = auxiliaryWords.contains(word.toLowerCase());
if (!auxiliaryWord) {
textController.setNodeText(currentNode, currentText + capitalize(word));
newNode = true;
} else {
textController.setNodeText(currentNode, currentText + word);
newNode = false;
}
}
if (saveOriginalTextAsDetails) {
textController.setDetails(currentNode, HtmlUtils.isHtmlNode(details) ? details : HtmlUtils.plainToHTML(details));
textController.setIsMinimized(currentNode, true);
}
}
Aggregations