|
From: <dgl...@us...> - 2003-08-19 05:11:41
|
Update of /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/journal/browser
In directory sc8-pr-cvs1:/tmp/cvs-serv22667/modules/gui/src/com/babeldoc/gui/journal/browser
Modified Files:
JournalBrowserFrame.java JournalTree.java
Log Message:
Added menu, set color for steps that have statusUpdate="fail", or any journalUpdate operation
Index: JournalBrowserFrame.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/journal/browser/JournalBrowserFrame.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** JournalBrowserFrame.java 11 Jun 2003 23:35:38 -0000 1.2
--- JournalBrowserFrame.java 19 Aug 2003 05:11:38 -0000 1.3
***************
*** 66,71 ****
--- 66,74 ----
package com.babeldoc.gui.journal.browser;
+ import com.babeldoc.core.config.ConfigService;
import com.babeldoc.core.journal.query.QueryTicket;
+ import java.awt.event.ActionEvent;
+ import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
***************
*** 75,85 ****
import javax.swing.event.TreeModelListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
/**
! * This is the main window to the the PipelineBuilder.
*/
public class JournalBrowserFrame extends JFrame {
--- 78,90 ----
import javax.swing.event.TreeModelListener;
import javax.swing.tree.DefaultMutableTreeNode;
+ import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
+ import org.apache.batik.apps.svgbrowser.Application;
/**
! * This is the main window to the the JournalBrowser
*/
public class JournalBrowserFrame extends JFrame {
***************
*** 87,90 ****
--- 92,101 ----
private JournalTree tree;
+ private String version = ConfigService.getString("env/build", "babeldoc_version");
+ private String TITLE_MESSAGE = "JournalBrowser v" + version;
+ private String ABOUT_MESSAGE = TITLE_MESSAGE + "\n\n" +
+ "(C)opyright 2000-2003 The Apache Software Foundation\n" +
+ "All rights reserved";
+ private String COMING_SOON_MESSAGE = "This feature will soon be implemented.\nPlease be patient!";
/**
* Construct the main UI.
***************
*** 115,119 ****
--- 126,233 ----
});
+ // build the menu options
+ this.setJMenuBar(buildMenu());
+
+ // finish setting up the frame
+ this.setTitle(TITLE_MESSAGE);
this.getContentPane().add(new JScrollPane(tree));
+ }
+
+ /**
+ * Builds the menu for the JournalBrowser
+ * @return JMenuBar the menu for the JournalBrowser
+ */
+ protected JMenuBar buildMenu() {
+ // Menu
+ JMenuBar jMenuBar = new JMenuBar();
+
+ // ====== File menu items ======
+ JMenu jMenuFile = new JMenu("File");
+ jMenuFile.setMnemonic('F');
+ jMenuBar.add(jMenuFile);
+
+ // File | Exit
+ JMenuItem jMenuFileExit = new JMenuItem("Exit");
+ jMenuFileExit.setMnemonic('x');
+ jMenuFileExit.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ System.exit(0);
+ }
+ });
+ jMenuFile.add(jMenuFileExit);
+
+ // ====== Edit menu items ======
+ JMenu jMenuEdit = new JMenu("Edit");
+ jMenuEdit.setMnemonic('E');
+ jMenuBar.add(jMenuEdit);
+
+ // Edit | Replay
+ JMenuItem jMenuEditReplay = new JMenuItem("Replay");
+ jMenuEditReplay.setMnemonic('R');
+ jMenuEditReplay.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(
+ null,
+ COMING_SOON_MESSAGE,
+ "Coming Soon!",
+ JOptionPane.PLAIN_MESSAGE);
+ }
+ });
+ jMenuEdit.add(jMenuEditReplay);
+
+ // ====== View menu items ======
+ JMenu jMenuView = new JMenu("View");
+ jMenuView.setMnemonic('V');
+ jMenuBar.add(jMenuView);
+
+ // View | Color
+ JMenuItem jMenuViewColor = new JMenuItem("Color");
+ jMenuViewColor.setMnemonic('C');
+ jMenuViewColor.setSelected(true); // default to on
+ jMenuViewColor.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(
+ null,
+ COMING_SOON_MESSAGE,
+ "Coming Soon to JournalBrowser",
+ JOptionPane.PLAIN_MESSAGE);
+ }
+ });
+ jMenuView.add(jMenuViewColor);
+
+ // View | Records
+ JMenuItem jMenuViewRecords = new JMenuItem("Records");
+ jMenuViewRecords.setMnemonic('R');
+ jMenuViewRecords.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(
+ null,
+ COMING_SOON_MESSAGE,
+ "Coming Soon to JournalBrowser",
+ JOptionPane.PLAIN_MESSAGE);
+ }
+ });
+ jMenuView.add(jMenuViewRecords);
+
+ // ====== Help menu items ======
+ JMenu jMenuHelp = new JMenu("Help");
+ jMenuHelp.setMnemonic('H');
+ jMenuBar.add(jMenuHelp);
+
+ // Help | About
+ JMenuItem jMenuHelpAbout = new JMenuItem("About");
+ jMenuHelpAbout.setMnemonic('A');
+ jMenuHelpAbout.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(
+ null,
+ ABOUT_MESSAGE,
+ "About JournalBrowser",
+ JOptionPane.PLAIN_MESSAGE);
+ }
+ });
+ jMenuHelp.add(jMenuHelpAbout);
+
+ return jMenuBar;
}
Index: JournalTree.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/gui/src/com/babeldoc/gui/journal/browser/JournalTree.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** JournalTree.java 11 Jun 2003 23:35:38 -0000 1.2
--- JournalTree.java 19 Aug 2003 05:11:38 -0000 1.3
***************
*** 68,74 ****
--- 68,80 ----
import com.babeldoc.core.journal.query.QueryTicket;
+ import java.awt.Color;
+ import java.awt.Dimension;
+ import java.awt.Font;
+
import javax.swing.*;
+ import javax.swing.plaf.ColorUIResource;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
+ import javax.swing.tree.TreeCellRenderer;
***************
*** 95,102 ****
this.populateTree();
super.setModel(this.journalTreeModel);
}
/**
! */
private void populateTree() {
QueryTicket[] qts = this.browserModel.getTickets(0, 100);
--- 101,112 ----
this.populateTree();
super.setModel(this.journalTreeModel);
+
+ // set the custom renderer so that we can control the colors
+ this.setCellRenderer(new JournalBrowserCellRenderer());
}
/**
! * Populate the tree (duh!)
! */
private void populateTree() {
QueryTicket[] qts = this.browserModel.getTickets(0, 100);
***************
*** 125,128 ****
--- 135,253 ----
}
}
+
+ /**
+ * Cell renderer to show error steps in red
+ */
+ class JournalBrowserCellRenderer extends JPanel implements TreeCellRenderer {
+ protected JLabel icon;
+ protected JTextArea text;
+ protected Color defaultColor;
+ protected Color defaultBackgroundColor;
+ protected Font defaultFont;
+ protected Font boldFont;
+
+ private final Color FAIL_COLOR=Color.WHITE;
+ private final Color FAIL_BCOLOR=Color.RED;
+ private final Color MSG_COLOR=Color.WHITE;
+ private final Color MSG_BCOLOR=Color.BLUE;
+ private final int STRUT_WIDTH=4;
+
+ /**
+ * Constructor
+ */
+ public JournalBrowserCellRenderer() {
+ setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
+ icon = new JLabel() {
+ public void setBackground(java.awt.Color color) {
+ if (color instanceof ColorUIResource) {
+ color = null;
+ }
+ super.setBackground(color);
+ }
+ };
+ add(icon);
+ add(Box.createHorizontalStrut(STRUT_WIDTH));
+ add(text = new JTextArea());
+ defaultColor = text.getForeground();
+ defaultBackgroundColor = text.getBackground();
+ defaultFont = text.getFont();
+
+ // create a bold font to use for emphasis
+ boldFont = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize());
+ }
+
+ /**
+ * Override getPreferredSize to make room for modified display string
+ * @return java.awt.Dimension
+ */
+ public java.awt.Dimension getPreferredSize() {
+ Dimension iconD = icon.getPreferredSize();
+ Dimension textD = text.getPreferredSize();
+ return new Dimension(iconD.width + textD.width + STRUT_WIDTH, textD.height);
+ }
+
+ /**
+ * Return the TreeCellRenderComponent, modified for background color
+ * @return java.awt.Component
+ */
+ public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree,
+ Object value, boolean selected, boolean expanded, boolean leaf, int row,
+ boolean hasFocus) {
+ // setup initial state
+ setEnabled(tree.isEnabled());
+
+ if (leaf) {
+ icon.setIcon(UIManager.getIcon("Tree.leafIcon"));
+ }
+ else if (expanded) {
+ icon.setIcon(UIManager.getIcon("Tree.openIcon"));
+ }
+ else {
+ icon.setIcon(UIManager.getIcon("Tree.closedIcon"));
+ }
+ text.setText(value.toString());
+ text.setForeground(defaultColor);
+ text.setBackground(defaultBackgroundColor);
+ text.setFont(defaultFont);
+
+ // do a bit of sanity checking here
+ if (value instanceof DefaultMutableTreeNode) {
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
+ if (node.getUserObject() instanceof JournalTreeTicketStep) {
+ // Use the following color scheme:
+ // failure = red background, white text
+ // message = green background, white text
+ QueryTicket ticket = (QueryTicket)((JournalTreeTicketStep)node.getUserObject()).getQTicket();
+ if (leaf) {
+ if (ticket.getOperation().equals("updateStatus") && ticket.getOther().equals("fail")) {
+ text.setForeground(FAIL_COLOR);
+ text.setBackground(FAIL_BCOLOR);
+ text.setFont(boldFont);
+ }
+ else if (ticket.getOperation().equals("updateJournal")) {
+ text.setForeground(MSG_COLOR);
+ text.setBackground(MSG_BCOLOR);
+ text.setFont(boldFont);
+ }
+ }
+ }
+ }
+
+ return this;
+ }
+
+ /**
+ * Set the background color. This override will ensure that the parent (tree)
+ * container matches the node background color
+ * @param color java.awt.Color
+ */
+ public void setBackground(Color color) {
+ if (color instanceof ColorUIResource) {
+ color = null;
+ }
+ super.setBackground(color);
+ }
+ }
}
***************
*** 218,222 ****
return "Step: " + getQTicket().getStep() + ", stage: " +
getQTicket().getStage() + ", date: " + getQTicket().getDate() +
! ", operation: " + getQTicket().getOperation();
}
}
--- 343,348 ----
return "Step: " + getQTicket().getStep() + ", stage: " +
getQTicket().getStage() + ", date: " + getQTicket().getDate() +
! ", operation: " + getQTicket().getOperation() +
! ", other: " + getQTicket().getOther();
}
}
|
|
From: Bruce M. <br...@mc...> - 2003-08-20 03:37:36
|
Looking good!! |