use of org.apache.pivot.wtk.text.Block in project pivot by apache.
the class TextPaneSkinBlockView method detach.
@Override
protected void detach() {
super.detach();
Block block = (Block) getNode();
block.getBlockListeners().remove(this);
}
use of org.apache.pivot.wtk.text.Block in project pivot by apache.
the class TextPane method insertComponent.
public void insertComponent(Component component) {
Utils.checkNull(component, "component");
checkDocumentExists();
if (selectionLength > 0) {
removeDocumentRange(selectionStart, selectionLength);
}
// If the insertion is at the end of the document, then just add
if (selectionStart >= document.getCharacterCount() - 1) {
document.add(new ComponentNode(component));
} else {
// Walk up the tree until we find a block
Node descendant = document.getDescendantAt(selectionStart);
while (!(descendant instanceof Block)) {
descendant = descendant.getParent();
}
Element parent = descendant.getParent();
if (parent != null) {
int index = parent.indexOf(descendant);
parent.insert(new ComponentNode(component), index + 1);
}
}
// Set the selection start to the character following the insertion
setSelection(selectionStart + 1, selectionLength);
}
use of org.apache.pivot.wtk.text.Block in project pivot by apache.
the class TextPane method insertImage.
public void insertImage(Image image) {
Utils.checkNull(image, "image");
checkDocumentExists();
if (selectionLength > 0) {
removeDocumentRange(selectionStart, selectionLength);
}
// If the insertion is at the end of the document, then just add
if (selectionStart >= document.getCharacterCount() - 1) {
document.add(new ImageNode(image));
} else {
// Walk up the tree until we find a block
Node descendant = document.getDescendantAt(selectionStart);
while (!(descendant instanceof Block)) {
descendant = descendant.getParent();
}
Element parent = descendant.getParent();
if (parent != null) {
int index = parent.indexOf(descendant);
parent.insert(new ImageNode(image), index + 1);
}
}
// Set the selection start to the character following the insertion
setSelection(selectionStart + 1, selectionLength);
}
use of org.apache.pivot.wtk.text.Block in project pivot by apache.
the class TextPaneSkinBlockView method attach.
@Override
protected void attach() {
super.attach();
Block block = (Block) getNode();
block.getBlockListeners().add(this);
}