User: ko5tik Date: 02/04/07 09:15:55 Modified: src/java/xdocletgui/swing/editor CommentaryEditorPanel.java Log: resolved weird class path dependency with xjavadoc editing now works very fine with save/cancel Maybe produce undo capability? Revision Changes Path 1.2 +126 -5 xdocletgui/src/java/xdocletgui/swing/editor/CommentaryEditorPanel.java Index: CommentaryEditorPanel.java =================================================================== RCS file: /cvsroot/xdoclet/xdocletgui/src/java/xdocletgui/swing/editor/CommentaryEditorPanel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- CommentaryEditorPanel.java 7 Apr 2002 13:49:14 -0000 1.1 +++ CommentaryEditorPanel.java 7 Apr 2002 16:15:55 -0000 1.2 @@ -36,7 +36,10 @@ package xdocletgui.swing.editor; import javax.swing.*; +import javax.swing.text.*; +import javax.swing.event.*; import java.awt.*; +import java.awt.event.*; import xjavadoc.XDoc; import xdocletgui.swing.DocTreeNode; @@ -48,7 +51,12 @@ * @created April 7, 2002 */ -public class CommentaryEditorPanel extends JPanel { +public class CommentaryEditorPanel extends JPanel implements DocumentListener { + + /** + * XDoc we are editing + */ + XDoc _xdoc; /** * text area for text editing @@ -59,6 +67,26 @@ * label for program element description */ JLabel _description; + + /** + * pointer to set button + */ + JButton _setButton; + + /** + * pointer to cancel button + */ + JButton _cancelButton; + + /** + * string for Set button + */ + final static String BUTTON_SET = "Set"; + + /** + * string for cancel button + */ + final static String BUTTON_CANCEL = "Cancel"; /** * Get static reference to Log4J Logger */ @@ -77,23 +105,116 @@ _description = new JLabel(); add(_description, BorderLayout.NORTH); _docText = new JTextArea(); + _docText.getDocument().addDocumentListener(this); JScrollPane _scp = new JScrollPane(_docText); add(_scp, BorderLayout.CENTER); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + _setButton = new JButton(BUTTON_SET); + + _setButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + save(); + } + }); + _cancelButton = new JButton(BUTTON_CANCEL); + + _cancelButton.addActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + revert(); + } + }); + + buttonPanel.add(Box.createHorizontalGlue()); + buttonPanel.add(_cancelButton); + buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); + buttonPanel.add(_setButton); + + add(buttonPanel, BorderLayout.SOUTH); + } /** * Sets the Doc attribute of the CommentaryEditorPanel object * - * @param node The new Doc value + * @param node XDoc to be edited */ public void setDoc(DocTreeNode node) { - XDoc xdoc = node.getXDoc(); - _log.debug("set text: " + xdoc.commentText()); - _docText.setText(xdoc.commentText()); + _xdoc = node.getXDoc(); + _log.debug("set text: " + _xdoc.commentText()); + revert(); // get parent _description.setText("Description for " + node.getParent().toString()); } + + /** + * insert notificator + * + * @param e Describe what the parameter does + * @todo-javadoc Write javadocs for method parameter + */ + public void insertUpdate(DocumentEvent e) { + enableButtons(true); + } + + + /** + * remove notificator + * + * @param e Describe what the parameter does + * @todo-javadoc Write javadocs for method parameter + */ + public void removeUpdate(DocumentEvent e) { + enableButtons(true); + } + + + /** + * change notificator + * + * @param e Describe what the parameter does + * @todo-javadoc Write javadocs for method parameter + */ + public void changedUpdate(DocumentEvent e) { + enableButtons(true); + } + + + /** + * enable buttons + * + * @param enable Describe what the parameter does + * @todo-javadoc Write javadocs for method parameter + */ + + void enableButtons(boolean enable) { + _cancelButton.setEnabled(enable); + _setButton.setEnabled(enable); + } + + + /** + * save changed commentary into XDoc + */ + private void save() { + _xdoc.setCommentText(_docText.getText()); + enableButtons(false); + } + + + /** + * revert changes + */ + private void revert() { + _docText.setText(_xdoc.commentText()); + enableButtons(false); + } }
_______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel