Update of /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/config
In directory sc8-pr-cvs1:/tmp/cvs-serv18673/gui/src/com/babeldoc/gui/config
Modified Files:
ComplexConfigOptionComponent.java
ConfigOptionComponentFactory.java
ConfigOptionListenerBase.java
Log Message:
more documentation updates
Index: ComplexConfigOptionComponent.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/config/ComplexConfigOptionComponent.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ComplexConfigOptionComponent.java 16 Sep 2003 05:19:02 -0000 1.7
--- ComplexConfigOptionComponent.java 17 Sep 2003 21:11:56 -0000 1.8
***************
*** 66,412 ****
package com.babeldoc.gui.config;
- import com.babeldoc.core.option.ComplexConfigOptionType;
import com.babeldoc.core.option.ConfigOption;
- import com.babeldoc.core.option.IConfigOptionType;
- import com.babeldoc.core.option.MutableConfigValueException;
- import java.awt.*;
import java.awt.event.ActionEvent;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
-
- import java.util.Iterator;
- import java.util.Map;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
- import javax.swing.tree.DefaultTreeModel;
- import javax.swing.tree.MutableTreeNode;
- import javax.swing.tree.TreePath;
-
-
- /**
- * Handle the gui for complex components
- *
- * @author bmcdonald
- * @version 1.1
- */
- public class ComplexConfigOptionComponent extends ConfigOptionComponent {
- private DefaultMutableTreeNode rootNode;
- private DefaultTreeModel treeModel;
- private JTree tree;
-
- /**
- * Construct the configration option.
- *
- * @param option
- */
- public ComplexConfigOptionComponent(ConfigOption option) {
- super(option);
- }
-
- /**
- * Get the data as a map. This is used to write the data to the config
- * files.
- *
- * @return
- */
- public Map getConfigurationData() {
- return null;
- }
-
- /**
- * Get the currently selected node.
- *
- * @return
- */
- public DefaultMutableTreeNode getCurrentlySelectedNode() {
- DefaultMutableTreeNode parentNode = null;
- TreePath parentPath = tree.getSelectionPath();
-
- if (parentPath == null) {
- parentNode = rootNode;
- } else {
- parentNode = (DefaultMutableTreeNode) (parentPath.getLastPathComponent());
- }
-
- return parentNode;
- }
-
- /**
- * Set the focus
- */
- public void setFocus() {
- tree.requestFocus();
- }
-
- /**
- * Get the gui component that represents this complex configuration component
- *
- * @return
- */
- public JComponent getGuiComponent() {
- if (tree == null) {
- rootNode = new DefaultMutableTreeNode(getOption().getName());
- treeModel = new DefaultTreeModel(rootNode);
-
- tree = new JTree(treeModel);
- tree.setShowsRootHandles(false);
- tree.putClientProperty("JTree.lineStyle", "Angled");
- tree.setToolTipText(getOption().getDescription());
- tree.setPreferredSize(new Dimension(1000, 100));
- tree.setMinimumSize(new Dimension(50, 50));
- tree.addMouseListener(getMouseAdapterForTree());
-
- JScrollPane panel = new JScrollPane(tree);
- panel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- panel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
- panel.setPreferredSize(new Dimension(1000, 100));
- panel.setMinimumSize(new Dimension(50, 50));
- }
-
- // return tree;
- return new JLabel("dummy");
- }
-
- /**
- * Get the validity of the current state of the configuration of this
- * component.
- *
- * @return
- */
- public boolean isValid() {
- return false;
- }
-
- /**
- * Add child to the currently selected node.
- *
- * @param child DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public DefaultMutableTreeNode addObject(Object child) {
- DefaultMutableTreeNode parentNode = getCurrentlySelectedNode();
-
- return addObject(parentNode, child, true);
- }
-
- /**
- * Add an object
- *
- * @param parent DOCUMENT ME!
- * @param child DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
- Object child) {
- return addObject(parent, child, false);
- }
-
- /**
- * TODO: DOCUMENT ME!
- *
- * @param parent DOCUMENT ME!
- * @param child DOCUMENT ME!
- * @param shouldBeVisible DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
- Object child, boolean shouldBeVisible) {
- DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child);
-
- if (parent == null) {
- parent = rootNode;
- }
-
- treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
-
- // Make sure the user can see the lovely new node.
- if (shouldBeVisible) {
- tree.scrollPathToVisible(new TreePath(childNode.getPath()));
- }
-
- return childNode;
- }
-
- /**
- * Remove all nodes except the root node.
- */
- public void clear() {
- rootNode.removeAllChildren();
- treeModel.reload();
- }
-
- /**
- * TODO: DOCUMENT ME!
- */
- public void displayConfigValue() {
- }
-
- /**
- * Display the defaults for the configuration option
- */
- public void displayDefault() {
- displayDefault(rootNode, getOption());
- }
-
- /**
- * Nice recursive way to add options.
- *
- * @param parent
- * @param option
- */
- public void displayDefault(DefaultMutableTreeNode parent, ConfigOption option) {
- DefaultMutableTreeNode newParent = addObject(parent,
- new ComplexConfigTreeData(option));
-
- if (option.getSuboptionNames() != null) {
- for (Iterator i = option.getSuboptionNames().iterator(); i.hasNext();) {
- String name = (String) i.next();
- ConfigOption configOption = getOption().getSuboption(name);
-
- if ((configOption.getSuboptionNames() != null) &&
- (configOption.getSuboptionNames().size() > 0)) {
- displayDefault(newParent, configOption.getSuboption(name));
- }
- }
- }
- }
-
- /**
- * Remove the currently selected node.
- */
- public void removeCurrentNode() {
- TreePath currentSelection = tree.getSelectionPath();
-
- if (currentSelection != null) {
- DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) (currentSelection.getLastPathComponent());
- MutableTreeNode parent = (MutableTreeNode) (currentNode.getParent());
-
- if (parent != null) {
- treeModel.removeNodeFromParent(currentNode);
-
- return;
- }
- }
-
- // Either there was no selection, or the root was selected.
- Toolkit.getDefaultToolkit().beep();
- }
-
- /**
- * Remove this node from the tree.
- *
- * @param node
- */
- public void removeNode(DefaultMutableTreeNode node) {
- MutableTreeNode parent = (MutableTreeNode) (node.getParent());
-
- if (parent != null) {
- treeModel.removeNodeFromParent(node);
-
- return;
- }
- }
-
- /**
- * TODO: DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- private MouseAdapter getMouseAdapterForTree() {
- return new MouseAdapter() {
- public void mousePressed(MouseEvent e) {
- TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
- tree.setSelectionPath(selPath);
- maybeShowPopup(e);
- }
-
- public void mouseReleased(MouseEvent e) {
- maybeShowPopup(e);
- }
- };
- }
-
- /**
- * TODO: DOCUMENT ME!
- *
- * @param popup DOCUMENT ME!
- * @param node DOCUMENT ME!
- */
- private void addMenuItemsToPopup(JPopupMenu popup, DefaultMutableTreeNode node) {
- popup.add(new ComplexConfigAction("Add sub option...", node) {
- public void actionPerformed(ActionEvent e) {
- String config = null;
-
- do {
- config = JOptionPane.showInputDialog(tree,
- "Enter the name of the configuration suboption",
- "New configuration", JOptionPane.QUESTION_MESSAGE);
- } while ((config == null) || (config.length() == 0));
-
- IConfigOptionType dynComplexType = new ComplexConfigOptionType(new ConfigOption[] { new ConfigOption(
- config, IConfigOptionType.STRING, null, false,
- "Some description") });
- ConfigOption dynamic = new ConfigOption(config, dynComplexType, null,
- false, "Some description for dynamic stages");
-
- if (getActionOption() != null) {
- getActionOption().addSuboption(dynamic);
- } else {
- getOption().addSuboption(dynamic);
- }
-
- addObject(getNode(), new ComplexConfigTreeData(dynamic));
- }
- });
-
- if (!node.isRoot()) {
- popup.add(new ComplexConfigAction("Set option value", node) {
- public void actionPerformed(ActionEvent e) {
- String config = null;
-
- do {
- config = JOptionPane.showInputDialog(tree,
- "Enter the value for the configuration option",
- "New configuration", JOptionPane.QUESTION_MESSAGE);
- } while ((config == null) || (config.length() == 0));
-
- try {
- getActionOption().setValue(config);
- } catch (MutableConfigValueException e1) {
- e1.printStackTrace(); //To change body of catch statement use Options | File Templates.
- }
- tree.revalidate();
- }
- });
- popup.add(new ComplexConfigAction("Remove option", node) {
- public void actionPerformed(ActionEvent e) {
- int response = JOptionPane.showConfirmDialog(tree,
- "Are you sure you wish to remove this configuration option?",
- "Remove configuration", JOptionPane.YES_NO_OPTION);
-
- if (response == JOptionPane.YES_OPTION) {
- removeNode(getNode());
- getOption().removeSuboption(getActionOption().getName());
- }
- }
- });
- }
- }
-
- // Show the popup
- private void maybeShowPopup(MouseEvent e) {
- if (e.isPopupTrigger()) {
- DefaultMutableTreeNode node = getCurrentlySelectedNode();
- JPopupMenu popup = new JPopupMenu();
- addMenuItemsToPopup(popup, node);
- popup.show(tree, e.getX(), e.getY());
- }
- }
- }
--- 66,75 ----
***************
*** 428,432 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 91,95 ----
/**
! * Get option
*
* @return DOCUMENT ME!
***************
*** 437,441 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 100,104 ----
/**
! * Get the string
*
* @return DOCUMENT ME!
***************
*** 479,483 ****
/**
! * TODO: DOCUMENT ME!
*
* @param e DOCUMENT ME!
--- 142,146 ----
/**
! * action performed
*
* @param e DOCUMENT ME!
***************
*** 486,490 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 149,153 ----
/**
! * get the action option
*
* @return DOCUMENT ME!
***************
*** 495,499 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 158,162 ----
/**
! * Get the node
*
* @return DOCUMENT ME!
Index: ConfigOptionComponentFactory.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/config/ConfigOptionComponentFactory.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ConfigOptionComponentFactory.java 13 Sep 2003 15:33:10 -0000 1.6
--- ConfigOptionComponentFactory.java 17 Sep 2003 21:11:56 -0000 1.7
***************
*** 98,103 ****
} else if (otype instanceof MultiLineConfigOptionType) {
return new MultiLineConfigOptionComponent(option);
- // } else if (otype instanceof ComplexConfigOptionType) {
- // return new ComplexConfigOptionComponent(option);
} else {
return new StringConfigOptionComponent(option);
--- 98,101 ----
Index: ConfigOptionListenerBase.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/config/ConfigOptionListenerBase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConfigOptionListenerBase.java 27 Jun 2003 00:14:55 -0000 1.1
--- ConfigOptionListenerBase.java 17 Sep 2003 21:11:56 -0000 1.2
***************
*** 92,96 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 92,96 ----
/**
! * get the component
*
* @return DOCUMENT ME!
***************
*** 101,105 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 101,105 ----
/**
! * get the option
*
* @return DOCUMENT ME!
|