undoManager.setLimit(1000);
textArea.getDocument().addUndoableEditListener(undoManager);
textArea.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
Comment.this.workspace.notifyListeners(new WorkspaceEvent(Comment.this.workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_CHANGED));
if (e.isControlDown() || ((e.getModifiers() & Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) != 0)) {
if (e.getKeyCode() == KeyEvent.VK_Z) {
try {
undoManager.undo();
} catch (CannotUndoException exception) {
}
} else if (e.getKeyCode() == KeyEvent.VK_Y) {
try {
undoManager.redo();
} catch (CannotRedoException exception) {
}
}
}
}
});
//initialize scrollPane
scrollPane = new CTracklessScrollPane(textArea,
ScrollPolicy.VERTICAL_BAR_AS_NEEDED,
ScrollPolicy.HORIZONTAL_BAR_NEVER,
10, this.borderColor, Comment.background);
this.add(scrollPane, 0);
//set up listeners
CommentEventListener eventListener = new CommentEventListener();
this.jCompDH = new JComponentDragHandler(workspace, this);
this.addMouseListener(eventListener);
this.addMouseMotionListener(eventListener);
textArea.addMouseListener(new MouseAdapter() {
/**
* Implement MouseListener interface
*/
public void mouseEntered(MouseEvent e) {
Comment comment = Comment.this;
comment.setPressed(true);
comment.showOnTop();
}
});
textArea.addFocusListener(eventListener);
textArea.setEditable(true);
this.reformComment();
this.arrow = new CommentArrow(this);
commentLabel = new CommentLabel(workspace, source.getBlockID());
source.add(commentLabel);
commentLabel.setActive(true);
this.reformComment();
workspace.notifyListeners(new WorkspaceEvent(workspace, getCommentSource().getParentWidget(), WorkspaceEvent.BLOCK_COMMENT_ADDED));
}