Update of /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder In directory sc8-pr-cvs1:/tmp/cvs-serv16008/gui/src/com/babeldoc/gui/pipeline/builder Modified Files: AddPipelineAction.java AddPipelineStageAction.java AddPipelineStageConfigAction.java BuilderAction.java Command.java PipelineBuilder.java PipelineBuilderController.java PipelineBuilderModel.java RemovePipelineAction.java RemovePipelineStageAction.java SetEntryStageAction.java Added Files: PipelineBuilderPanel.java Removed Files: PipelineBuilderFrame.java Log Message: Updates to the GUI code. --- NEW FILE: PipelineBuilderPanel.java --- /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. 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. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact ap...@ap.... * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR * ITS 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. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. * ==================================================================== * * Babeldoc: The Universal Document Processor * * $Header: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/PipelineBuilderPanel.java,v 1.1 2003/08/26 22:23:32 triphop Exp $ * $DateTime$ * $Author: triphop $ * */ package com.babeldoc.gui.pipeline.builder; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Iterator; import java.util.Properties; import javax.swing.*; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.tree.*; /** * This is the main window to the the PipelineBuilder. */ public class PipelineBuilderPanel extends JPanel implements ActionListener { public static final String ACTION_REMOVE_PIPELINE = "remove pipeline"; public static final String ACTION_REMOVE_STAGE = "remove stage"; public static final String ACTION_ADD_CONFIG = "add config"; public static final String ACTION_REMOVE_CONFIG = "remove config"; public static final String ACTION_SET_ENTRY_STAGE = "set entry stage"; private PipelineBuilderController controller = null; private PipelineTree tree; /** * Construct the main UI. * * @param controller */ public PipelineBuilderPanel(PipelineBuilderController controller) { this.controller = controller; // Link the controller to this frame. controller.setFrame(this); tree = new PipelineTree(); getTree().getModel().addTreeModelListener(new MyTreeModelListener()); getTree().setPreferredSize(new Dimension(640, 480)); getTree().setEditable(true); getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); getTree().setShowsRootHandles(true); getTree().putClientProperty("JTree.lineStyle", "Angled"); getTree().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { TreePath selPath = getTree().getPathForLocation(e.getX(), e.getY()); getTree().setSelectionPath(selPath); maybeShowPopup(e); } public void mouseReleased(MouseEvent e) { maybeShowPopup(e); } }); this.setLayout(new BorderLayout()); this.add(new JScrollPane(getTree())); renderTree(); } /** * TODO: DOCUMENT ME! * * @return DOCUMENT ME! */ public PipelineBuilderController getController() { return controller; } /** * TODO: DOCUMENT ME! * * @return DOCUMENT ME! */ public PipelineTree getTree() { return tree; } /** * TODO: DOCUMENT ME! * * @param e DOCUMENT ME! */ public void actionPerformed(ActionEvent e) { } /** * TODO: DOCUMENT ME! */ public void renderTree() { getTree().clear(); String[] pipes = getController().getModel().getAllPipelineNames(); for (int i = 0; i < pipes.length; ++i) { DefaultMutableTreeNode pipenode = getTree().addObject(null, PipelineTreeNode.pipelineNode(pipes[i])); String[] stages = new String[0]; stages = getController().getModel().getAllPipelineStages(pipes[i]); if(stages!=null) { for (int j = 0; j < stages.length; ++j) { DefaultMutableTreeNode stagenode = getTree().addObject(pipenode, PipelineTreeNode.stageNode(stages[j])); Properties properties = getController().getModel() .getPipelineStageProperties(pipes[i], stages[j]); for (Iterator k = properties.keySet().iterator(); k.hasNext();) { String config = (String) k.next(); String value = properties.getProperty(config); DefaultMutableTreeNode confignode = getTree().addObject(stagenode, PipelineTreeNode.configNode(config + "=" + value)); } } } } } // Show the popup private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { JMenuItem menuItem; DefaultMutableTreeNode node = getTree().getCurrentlySelectedNode(); JPopupMenu popup = new JPopupMenu(); if (node.equals(getTree().getPipelineRootNode())) { popup.add(new JMenuItem( new AddPipelineAction(getController().getModel(), this))); } else { PipelineTreeNode currentNode = (PipelineTreeNode) node.getUserObject(); if (currentNode.isPipeline()) { popup.add(new JMenuItem( new RemovePipelineAction(getController().getModel(), this, currentNode))); popup.add(new JMenuItem( new AddPipelineStageAction(getController().getModel(), this, currentNode))); popup.add(new JMenuItem( new SetEntryStageAction(getController().getModel(), this, currentNode))); } else if (currentNode.isStage()) { PipelineTreeNode parentNode = (PipelineTreeNode) (((DefaultMutableTreeNode) (node.getParent())).getUserObject()); popup.add(new RemovePipelineStageAction(getController().getModel(), this, parentNode, currentNode)); popup.add(new AddPipelineStageConfigAction(getController().getModel(), this, parentNode, currentNode)); menuItem = new JMenuItem(ACTION_SET_ENTRY_STAGE); popup.add(menuItem); } else if (currentNode.isConfig()) { menuItem = new JMenuItem(ACTION_REMOVE_CONFIG); menuItem.addActionListener(this); popup.add(menuItem); } } popup.show(e.getComponent(), e.getX(), e.getY()); } } /** * TODO: DOCUMENT ME! * * @author $author$ * @version $Revision: 1.1 $ */ class MyTreeModelListener implements TreeModelListener { /** * TODO: DOCUMENT ME! * * @param e DOCUMENT ME! */ public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node; node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent()); /* * If the event lists children, then the changed * node is the child of the node we've already * gotten. Otherwise, the changed node and the * specified node are the same. */ try { int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); } catch (NullPointerException exc) { } System.out.println("The user has finished editing the node."); System.out.println("New value: " + node.getUserObject()); } /** * TODO: DOCUMENT ME! * * @param e DOCUMENT ME! */ public void treeNodesInserted(TreeModelEvent e) { } /** * TODO: DOCUMENT ME! * * @param e DOCUMENT ME! */ public void treeNodesRemoved(TreeModelEvent e) { } /** * TODO: DOCUMENT ME! * * @param e DOCUMENT ME! */ public void treeStructureChanged(TreeModelEvent e) { } } } Index: AddPipelineAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/AddPipelineAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AddPipelineAction.java 11 Jun 2003 23:35:38 -0000 1.4 --- AddPipelineAction.java 26 Aug 2003 22:23:32 -0000 1.5 *************** *** 84,88 **** */ public AddPipelineAction(PipelineBuilderModel model, ! PipelineBuilderFrame frame) { super(ACTION_ADD_PIPELINE, null, model, frame); } --- 84,88 ---- */ public AddPipelineAction(PipelineBuilderModel model, ! PipelineBuilderPanel frame) { super(ACTION_ADD_PIPELINE, null, model, frame); } Index: AddPipelineStageAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/AddPipelineStageAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AddPipelineStageAction.java 11 Jun 2003 23:35:38 -0000 1.4 --- AddPipelineStageAction.java 26 Aug 2003 22:23:32 -0000 1.5 *************** *** 86,90 **** */ public AddPipelineStageAction(PipelineBuilderModel model, ! PipelineBuilderFrame frame, PipelineTreeNode treenode) { super(ACTION_ADD_STAGE, null, model, frame); this.treenode = treenode; --- 86,90 ---- */ public AddPipelineStageAction(PipelineBuilderModel model, ! PipelineBuilderPanel frame, PipelineTreeNode treenode) { super(ACTION_ADD_STAGE, null, model, frame); this.treenode = treenode; Index: AddPipelineStageConfigAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/AddPipelineStageConfigAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AddPipelineStageConfigAction.java 11 Jun 2003 23:35:38 -0000 1.2 --- AddPipelineStageConfigAction.java 26 Aug 2003 22:23:32 -0000 1.3 *************** *** 90,94 **** */ public AddPipelineStageConfigAction(PipelineBuilderModel model, ! PipelineBuilderFrame frame, PipelineTreeNode pipeline, PipelineTreeNode stage) { super(ACTION_ADD_CONFIG, null, model, frame); --- 90,94 ---- */ public AddPipelineStageConfigAction(PipelineBuilderModel model, ! PipelineBuilderPanel frame, PipelineTreeNode pipeline, PipelineTreeNode stage) { super(ACTION_ADD_CONFIG, null, model, frame); Index: BuilderAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/BuilderAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BuilderAction.java 11 Jun 2003 23:35:38 -0000 1.3 --- BuilderAction.java 26 Aug 2003 22:23:32 -0000 1.4 *************** *** 73,77 **** */ public abstract class BuilderAction extends AbstractAction { ! private PipelineBuilderFrame frame; private PipelineBuilderModel model; --- 73,77 ---- */ public abstract class BuilderAction extends AbstractAction { ! private PipelineBuilderPanel frame; private PipelineBuilderModel model; *************** *** 85,89 **** */ public BuilderAction(String name, Icon icon, PipelineBuilderModel model, ! PipelineBuilderFrame frame) { super(name, icon); this.model = model; --- 85,89 ---- */ public BuilderAction(String name, Icon icon, PipelineBuilderModel model, ! PipelineBuilderPanel frame) { super(name, icon); this.model = model; *************** *** 96,100 **** * @return DOCUMENT ME! */ ! public PipelineBuilderFrame getFrame() { return frame; } --- 96,100 ---- * @return DOCUMENT ME! */ ! public PipelineBuilderPanel getFrame() { return frame; } Index: Command.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/Command.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Command.java 11 Jun 2003 23:35:38 -0000 1.3 --- Command.java 26 Aug 2003 22:23:32 -0000 1.4 *************** *** 76,82 **** * Run the Property builder */ ! public class Command extends BabeldocCommand { /** ! * Creates a new Command object. */ public Command() { --- 76,83 ---- * Run the Property builder */ ! public class Command ! extends BabeldocCommand { /** ! * Creates a new LightConfigCommand object. */ public Command() { *************** *** 98,102 **** */ public void execute(CommandLine commandLine) { ! PipelineBuilder.run(); System.out.println("Application has finished"); } --- 99,103 ---- */ public void execute(CommandLine commandLine) { ! PipelineBuilder.runAsFrame(); System.out.println("Application has finished"); } Index: PipelineBuilder.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/PipelineBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PipelineBuilder.java 11 Jun 2003 23:35:38 -0000 1.2 --- PipelineBuilder.java 26 Aug 2003 22:23:32 -0000 1.3 *************** *** 67,70 **** --- 67,73 ---- import javax.swing.*; + import java.awt.*; + import java.awt.event.ActionListener; + import java.awt.event.ActionEvent; *************** *** 91,105 **** * @return */ ! public static PipelineBuilder run() { ! PipelineBuilderModel model = new PipelineBuilderModel(); JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); PipelineBuilder builder = new PipelineBuilder(model); PipelineBuilderController controller = new PipelineBuilderController(model); ! PipelineBuilderFrame frame = new PipelineBuilderFrame(controller); ! frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); return builder; --- 94,153 ---- * @return */ ! public static PipelineBuilder runAsFrame() { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); + PipelineBuilderModel model = new PipelineBuilderModel(); PipelineBuilder builder = new PipelineBuilder(model); PipelineBuilderController controller = new PipelineBuilderController(model); ! PipelineBuilderPanel panel = new PipelineBuilderPanel(controller); ! ! JFrame frame = new JFrame(); ! frame.setContentPane(panel); ! frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setVisible(true); + + return builder; + } + + public static PipelineBuilder runAsDialog() { + JFrame.setDefaultLookAndFeelDecorated(true); + JDialog.setDefaultLookAndFeelDecorated(true); + + PipelineBuilderModel model = new PipelineBuilderModel(); + PipelineBuilder builder = new PipelineBuilder(model); + PipelineBuilderController controller = new PipelineBuilderController(model); + PipelineBuilderPanel panel = new PipelineBuilderPanel(controller); + + final JDialog dialog = new JDialog(); + JPanel contents = new JPanel(); + contents.setLayout(new BorderLayout()); + contents.add(panel); + + JButton button = new JButton("close"); + button.addActionListener(new ActionListener() { + /** + * Invoked when an action occurs. + */ + public void actionPerformed(ActionEvent e) { + dialog.dispose(); + } + }); + + JPanel buttons = new JPanel(); + buttons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + buttons.setLayout(new BoxLayout(buttons, BoxLayout.LINE_AXIS)); + buttons.add(Box.createHorizontalGlue()); + buttons.add(button); + buttons.add(Box.createHorizontalGlue()); + + contents.add(buttons, BorderLayout.SOUTH); + + + dialog.setContentPane(contents); + + dialog.pack(); + dialog.show(); return builder; Index: PipelineBuilderController.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/PipelineBuilderController.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PipelineBuilderController.java 11 Jun 2003 23:35:38 -0000 1.3 --- PipelineBuilderController.java 26 Aug 2003 22:23:32 -0000 1.4 *************** *** 78,82 **** */ public class PipelineBuilderController { ! private PipelineBuilderFrame frame; private PipelineBuilderModel model; --- 78,82 ---- */ public class PipelineBuilderController { ! private PipelineBuilderPanel frame; private PipelineBuilderModel model; *************** *** 95,99 **** * @param frame */ ! public void setFrame(PipelineBuilderFrame frame) { this.frame = frame; } --- 95,99 ---- * @param frame */ ! public void setFrame(PipelineBuilderPanel frame) { this.frame = frame; } *************** *** 105,109 **** * @return */ ! public PipelineBuilderFrame getFrame() { return frame; } --- 105,109 ---- * @return */ ! public PipelineBuilderPanel getFrame() { return frame; } Index: PipelineBuilderModel.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/PipelineBuilderModel.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PipelineBuilderModel.java 12 Aug 2003 23:44:45 -0000 1.7 --- PipelineBuilderModel.java 26 Aug 2003 22:23:32 -0000 1.8 *************** *** 111,116 **** for (Iterator i = config.keys().iterator(); i.hasNext();) { String key = (String) i.next(); ! if (key.endsWith(DOT_TYPE)) { String pipeline = key.substring(0, key.length() - DOT_TYPE.length()); pipes.add(pipeline); --- 111,117 ---- for (Iterator i = config.keys().iterator(); i.hasNext();) { String key = (String) i.next(); + String value = config.getString(key); ! if (key.endsWith(DOT_TYPE)&&value.equals("simple")) { String pipeline = key.substring(0, key.length() - DOT_TYPE.length()); pipes.add(pipeline); *************** *** 392,395 **** --- 393,399 ---- // Create the entries in the pipeline/config.properties file IConfig config = ConfigService.getInstance().getConfig(PIPELINE_CONFIG_NAME); + + // Delete all information in this configuration file - we do not want + // previously defined config.setString(pipeline + DOT_TYPE, type); config.setString(pipeline + DOT_CONFIGFILE, configName); *************** *** 479,483 **** */ private static void saveConfig(IConfig config) { ! // System.out.println("Saving: "+name+"; "+config.getName()); ConfigService.getInstance().saveConfig(config.getName(), config); ConfigService.clearCache(); --- 483,487 ---- */ private static void saveConfig(IConfig config) { ! System.out.println("Saving: "+config.getName()); ConfigService.getInstance().saveConfig(config.getName(), config); ConfigService.clearCache(); Index: RemovePipelineAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/RemovePipelineAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RemovePipelineAction.java 11 Jun 2003 23:35:38 -0000 1.4 --- RemovePipelineAction.java 26 Aug 2003 22:23:32 -0000 1.5 *************** *** 86,90 **** */ public RemovePipelineAction(PipelineBuilderModel model, ! PipelineBuilderFrame frame, PipelineTreeNode treenode) { super(ACTION_REMOVE_PIPELINE, null, model, frame); this.treenode = treenode; --- 86,90 ---- */ public RemovePipelineAction(PipelineBuilderModel model, ! PipelineBuilderPanel frame, PipelineTreeNode treenode) { super(ACTION_REMOVE_PIPELINE, null, model, frame); this.treenode = treenode; Index: RemovePipelineStageAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/RemovePipelineStageAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RemovePipelineStageAction.java 11 Jun 2003 23:35:38 -0000 1.2 --- RemovePipelineStageAction.java 26 Aug 2003 22:23:32 -0000 1.3 *************** *** 88,92 **** */ public RemovePipelineStageAction(PipelineBuilderModel model, ! PipelineBuilderFrame frame, PipelineTreeNode pipeline, PipelineTreeNode stage) { super(ACTION_REMOVE_STAGE, null, model, frame); --- 88,92 ---- */ public RemovePipelineStageAction(PipelineBuilderModel model, ! PipelineBuilderPanel frame, PipelineTreeNode pipeline, PipelineTreeNode stage) { super(ACTION_REMOVE_STAGE, null, model, frame); Index: SetEntryStageAction.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/pipeline/builder/SetEntryStageAction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SetEntryStageAction.java 11 Jun 2003 23:35:38 -0000 1.2 --- SetEntryStageAction.java 26 Aug 2003 22:23:32 -0000 1.3 *************** *** 86,90 **** */ public SetEntryStageAction(PipelineBuilderModel model, ! PipelineBuilderFrame frame, PipelineTreeNode treenode) { super(ACTION_SET_ENTRY_STAGE, null, model, frame); this.pipeline = treenode.toString(); --- 86,90 ---- */ public SetEntryStageAction(PipelineBuilderModel model, ! PipelineBuilderPanel frame, PipelineTreeNode treenode) { super(ACTION_SET_ENTRY_STAGE, null, model, frame); this.pipeline = treenode.toString(); --- PipelineBuilderFrame.java DELETED --- |