User: ko5tik
Date: 02/04/12 10:01:17
Modified: src/java/xdocletgui/swing/editor UnknownTagsPanel.java
Added: src/java/xdocletgui/swing/editor
TagParameterEditorPanel.java
Log:
created GUI for tag parameter editor.
works at most, but setting / validation
will require tweaking on xtags
Revision Changes Path
1.3 +1 -4
xdocletgui/src/java/xdocletgui/swing/editor/UnknownTagsPanel.java
Index: UnknownTagsPanel.java
===================================================================
RCS file:
/cvsroot/xdoclet/xdocletgui/src/java/xdocletgui/swing/editor/UnknownTagsPanel.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- UnknownTagsPanel.java 11 Apr 2002 16:31:43 -0000 1.2
+++ UnknownTagsPanel.java 12 Apr 2002 17:01:17 -0000 1.3
@@ -137,10 +137,7 @@
XDoc doc = _progNode.getProgramElement().doc();
XTagFactory xTagFactory = XTagFactory.getInstance();
-
- XTag tag = xTagFactory.createTag(_tagName.getText(), "");
-
- doc.addTag(tag);
+ XTag tag = doc.addTag(_tagName.getText(), "");
UnknownTagTreeNode newNode = new UnknownTagTreeNode(tag);
((DefaultTreeModel)_tree.getModel()).insertNodeInto(newNode,
_node, _node.getChildCount());
1.1
xdocletgui/src/java/xdocletgui/swing/editor/TagParameterEditorPanel.java
Index: TagParameterEditorPanel.java
===================================================================
/*
* Copyright (c) 2001, Aslak Helles�y, BEKK Consulting
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of BEKK Consulting nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
/*
* Change log
*
*/
package xdocletgui.swing.editor;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
import xdocletgui.swing.TagParameterTreeNode;
import xdocletgui.swing.ProgramElementTreeNode;
import xdocletgui.swing.TagTreeNode;
import xtags.*;
import xjavadoc.*;
/**
* Describe what this class does
*
* @author kostik
* @created April 12, 2002
* @todo-javadoc Write javadocs
*/
public class TagParameterEditorPanel extends JPanel {
/**
* reference to the tree
*/
JTree _tree;
/**
* node containingtag parameter
*/
TagParameterTreeNode _node;
/**
* formal parameter description
*/
TagParameter _tagParameter;
/**
* panel for editing string value representation
*/
JPanel _stringEditorPanel;
/**
* panel to select choice
*/
JPanel _choicePanel;
/**
* text field for string entry
*/
JTextArea _stringValue;
/**
* combo box for choice selection
*/
JComboBox _valueChoice;
/**
* label describing parameter
*/
JLabel _description;
/**
* usage description text
*/
JTextArea _usage;
/**
* save button
*/
JButton _saveButton;
/**
* revert button
*/
JButton _revertButton;
/**
* remove button
*/
JButton _removeButton;
/**
* split pane fot the middle
*/
JSplitPane _splitPane;
/**
* xtag in question
*/
XTag _xtag;
/**
* XDoc in question
*/
XDoc _xdoc;
/**
* XProgramElement in question
*/
XProgramElement _programElement;
/**
* Describe what the TagParameterEditorPanel constructor does
*
* @param tree Describe what the parameter does
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for constructor
*/
public TagParameterEditorPanel(JTree tree) {
super(new BorderLayout());
_tree = tree;
setBorder(BorderFactory.createTitledBorder("Tag parameter"));
_stringValue = new JTextArea();
_valueChoice = new JComboBox();
_description = new JLabel();
add(_description, BorderLayout.NORTH);
_usage = new JTextArea();
_usage.setEditable(false);
_saveButton = new JButton("save");
_saveButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
save();
}
});
_removeButton = new JButton("remove");
_removeButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
remove();
}
});
_revertButton = new JButton("cancel");
_revertButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
revert();
}
});
// setup butotn panel
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
buttonPanel.add(_removeButton);
buttonPanel.add(Box.createHorizontalGlue());
buttonPanel.add(_revertButton);
buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPanel.add(_saveButton);
add(buttonPanel, BorderLayout.SOUTH);
// create split pane for edit / usage
_splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
_stringEditorPanel = new JPanel(new BorderLayout());
JScrollPane scp = new JScrollPane(_stringValue);
_stringEditorPanel.add(scp, BorderLayout.CENTER);
_choicePanel = new JPanel(new BorderLayout());
_choicePanel.add(_valueChoice, BorderLayout.NORTH);
JPanel usagePanel = new JPanel(new BorderLayout());
JLabel usageLabel = new JLabel("Parameter usage:");
usagePanel.add(usageLabel, BorderLayout.NORTH);
scp = new JScrollPane(_usage);
usagePanel.add(scp, BorderLayout.CENTER);
_splitPane.setTopComponent(_stringEditorPanel);
_splitPane.setBottomComponent(usagePanel);
add(_splitPane, BorderLayout.CENTER);
}
/**
* Sets the Node attribute of the TagParameterEditorPanel object
*
* @param node The new Node value
*/
public void setNode(TagParameterTreeNode node) {
_node = node;
_tagParameter = _node.getTagParameter();
// set corresponding xtag
TagTreeNode ttn = (TagTreeNode)node.getParent();
_programElement =
(XProgramElement)((ProgramElementTreeNode)(ttn.getParent().getParent())).getProgramElement();
_xtag = ttn.getXTag();
_xdoc = _programElement.doc();
_description.setText("value of \"" + _tagParameter.getName() + "\"
parameter");
_removeButton.setEnabled(!_tagParameter.isMandatory());
revert();
}
/**
* Describe what the method does
*
* @todo-javadoc Write javadocs for method
*/
public void save() {
}
/**
* Describe what the method does
*
* @todo-javadoc Write javadocs for method
*/
public void remove() {
}
/**
* Describe what the method does
*
* @todo-javadoc Write javadocs for method
*/
public void revert() {
_usage.setText(_tagParameter.getUsage());
if (_tagParameter.hasOptions()) {
// this bean has option sets, so provide user with predefined
choice
_splitPane.setTopComponent(_choicePanel);
// fill choice with data
try {
String[] validOptions =
_tagParameter.getOptions(_programElement);
_valueChoice.removeAllItems();
for (int i = 0; i < validOptions.length; i++) {
_valueChoice.addItem(validOptions[i]);
if
(validOptions[i].equals(_xtag.attributeValue(_tagParameter.getName()))) {
_valueChoice.setSelectedItem(validOptions[i]);
}
}
} catch (IllegalStateException ex) {
// swallow silently.
}
}
else {
_splitPane.setTopComponent(_stringEditorPanel);
_stringValue.setText(_xtag.attributeValue(_tagParameter.getName()));
}
enableButtons(false);
}
/**
* Describe what the method does
*
* @param enable Describe what the parameter does
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for method parameter
*/
public void enableButtons(boolean enable) {
_saveButton.setEnabled(enable);
_revertButton.setEnabled(enable);
}
}
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel