};
@Override
public void startup(Display display, Map<String, String> properties)
throws Exception {
WTKXSerializer wtkxSerializer = new WTKXSerializer();
frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("text_area_test.wtkx")));
frame.setTitle("TextArea Test");
frame.setPreferredSize(640, 480);
frame.setLocation(80, 40);
frame.open(display);
textArea = (TextArea)wtkxSerializer.get("textArea");
textArea.getTextAreaSelectionListeners().add(new TextAreaSelectionListener() {
@Override
public void selectionChanged(TextArea textArea,
int previousSelectionStart, int previousSelectionLength) {
updateSelection();
}
});
textArea.getTextAreaCharacterListeners().add(new TextAreaCharacterListener() {
@Override
public void charactersRemoved(TextArea textArea, int index, int count) {
updateSelection();
}
@Override
public void charactersInserted(TextArea textArea, int index, int count) {
updateSelection();
}
});
selectionStartLabel = (Label)wtkxSerializer.get("selectionStartLabel");
selectionLengthLabel = (Label)wtkxSerializer.get("selectionLengthLabel");
treeView = (TreeView)wtkxSerializer.get("treeView");
treeView.getTreeViewSelectionListeners().add(new TreeViewSelectionListener() {
@Override
public void selectedPathAdded(TreeView treeView, Path path) {
// No-op
}
@Override
public void selectedPathRemoved(TreeView treeView, Path path) {
// No-op
}
@Override
public void selectedPathsChanged(TreeView treeView,
Sequence<Path> previousSelectedPaths) {
Path selectedPath = treeView.getSelectedPath();
if (selectedNode != null) {
selectedNode.getNodeListeners().remove(selectedNodeListener);
}
if (selectedPath == null) {
selectedNode = null;
} else {
NodeAdapter nodeAdapter = Sequence.Tree.get(documentAdapter, selectedPath);
selectedNode = nodeAdapter.getNode();
}
if (selectedNode != null) {
selectedNode.getNodeListeners().add(selectedNodeListener);
}
updateSelectedNodeData();
}
});
offsetLabel = (Label)wtkxSerializer.get("offsetLabel");
charactersLabel = (Label)wtkxSerializer.get("charactersLabel");
documentAdapter = new DocumentAdapter(textArea.getDocument());
treeView.setTreeData(documentAdapter);
}