tkormann    01/11/29 01:17:41

  Modified:    resources/org/apache/batik/util/gui/resources
                        JErrorPane.properties
               sources/org/apache/batik/apps/svgbrowser
                        JSVGViewerFrame.java
               sources/org/apache/batik/swing JSVGCanvas.java
               sources/org/apache/batik/util/gui JErrorPane.java
  Log:
  change the layout
  
  Revision  Changes    Path
  1.2       +7 -1      
xml-batik/resources/org/apache/batik/util/gui/resources/JErrorPane.properties
  
  Index: JErrorPane.properties
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/resources/org/apache/batik/util/gui/resources/JErrorPane.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JErrorPane.properties     2001/11/28 16:07:47     1.1
  +++ JErrorPane.properties     2001/11/29 09:17:41     1.2
  @@ -9,10 +9,16 @@
   # The resources for the JErrorPane
   #
   # Author: [EMAIL PROTECTED]
  -# $Id: JErrorPane.properties,v 1.1 2001/11/28 16:07:47 tkormann Exp $
  +# $Id: JErrorPane.properties,v 1.2 2001/11/29 09:17:41 tkormann Exp $
   #
   
   ShowDetailButton.text     = Show Details
   ShowDetailButton.text2     = Hide Details
   ShowDetailButton.mnemonic = D
   ShowDetailButton.action   = ShowDetailButtonAction
  +
  +OKButton.text     = OK
  +OKButton.mnemonic = O
  +OKButton.action   = OKButtonAction
  +
  +
  
  
  
  1.66      +2 -2      
xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
  
  Index: JSVGViewerFrame.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- JSVGViewerFrame.java      2001/11/28 16:07:47     1.65
  +++ JSVGViewerFrame.java      2001/11/29 09:17:41     1.66
  @@ -154,7 +154,7 @@
    * This class represents a SVG viewer swing frame.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: JSVGViewerFrame.java,v 1.65 2001/11/28 16:07:47 tkormann Exp $
  + * @version $Id: JSVGViewerFrame.java,v 1.66 2001/11/29 09:17:41 tkormann Exp $
    */
   public class JSVGViewerFrame
       extends    JFrame
  @@ -1696,7 +1696,7 @@
               if (debug) {
                   ex.printStackTrace();
               }
  -            JOptionPane pane =
  +            JErrorPane pane =
                   new JErrorPane(ex, JOptionPane.ERROR_MESSAGE);
               JDialog dialog = pane.createDialog(JSVGViewerFrame.this, "ERROR");
               dialog.setModal(false);
  
  
  
  1.31      +2 -2      xml-batik/sources/org/apache/batik/swing/JSVGCanvas.java
  
  Index: JSVGCanvas.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/JSVGCanvas.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- JSVGCanvas.java   2001/11/28 16:07:47     1.30
  +++ JSVGCanvas.java   2001/11/29 09:17:41     1.31
  @@ -69,7 +69,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stephane Hillion</a>
  - * @version $Id: JSVGCanvas.java,v 1.30 2001/11/28 16:07:47 tkormann Exp $
  + * @version $Id: JSVGCanvas.java,v 1.31 2001/11/29 09:17:41 tkormann Exp $
    */
   public class JSVGCanvas extends JSVGComponent {
   
  @@ -908,7 +908,7 @@
               if (svgUserAgent != null) {
                   super.displayError(ex);
               } else {
  -                JOptionPane pane =
  +                JErrorPane pane =
                       new JErrorPane(ex, JOptionPane.ERROR_MESSAGE);
                   JDialog dialog = pane.createDialog(JSVGCanvas.this, "ERROR");
                   dialog.setModal(false);
  
  
  
  1.3       +134 -110  xml-batik/sources/org/apache/batik/util/gui/JErrorPane.java
  
  Index: JErrorPane.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/gui/JErrorPane.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JErrorPane.java   2001/11/29 08:14:16     1.2
  +++ JErrorPane.java   2001/11/29 09:17:41     1.3
  @@ -13,6 +13,7 @@
   import java.awt.Component;
   import java.awt.GridBagConstraints;
   import java.awt.GridBagLayout;
  +import java.awt.FlowLayout;
   import java.awt.Insets;
   
   import java.awt.event.ActionEvent;
  @@ -24,15 +25,18 @@
   import java.util.Locale;
   import java.util.Map;
   import java.util.ResourceBundle;
  +import java.util.StringTokenizer;
   
   import javax.swing.AbstractAction;
   import javax.swing.Action;
  +import javax.swing.BorderFactory;
   import javax.swing.JButton;
   import javax.swing.JComponent;
   import javax.swing.JDialog;
   import javax.swing.JLabel;
   import javax.swing.JOptionPane;
   import javax.swing.JPanel;
  +import javax.swing.JSeparator;
   import javax.swing.JScrollPane;
   import javax.swing.JTextArea;
   
  @@ -45,9 +49,9 @@
    * This class represents a dialog to display an error (message + Exception).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: JErrorPane.java,v 1.2 2001/11/29 08:14:16 tkormann Exp $
  + * @version $Id: JErrorPane.java,v 1.3 2001/11/29 09:17:41 tkormann Exp $
    */
  -public class JErrorPane extends JOptionPane {
  +public class JErrorPane extends JPanel implements ActionMap {
   
       /**
        * The resource file name
  @@ -81,12 +85,43 @@
       protected String stacktrace;
   
       /**
  +     * The button factory.
  +     */
  +    protected ButtonFactory bf = new ButtonFactory(bundle, this);
  +
  +    /**
  +     * The text area used to show the stack trace.
  +     */
  +    protected JComponent detailsArea;
  +
  +    /**
  +     * The button used to show or not the details.
  +     */
  +    protected JButton showDetailButton;
  +
  +    /**
  +     * This flag bit indicates whether or not the stack trace is shown.
  +     */
  +    protected boolean isDetailShown = false;
  +
  +    /**
  +     * The sub panel that contains the stack trace text area.
  +     */
  +    protected JPanel subpanel;
  +
  +    /**
        * Constructs a new JErrorPane.
        *
        * @param th the throwable object that describes the errror
        * @param type the dialog type
        */
       public JErrorPane(Throwable th, int type) {
  +        super(new GridBagLayout());
  +
  +        setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  +
  +        listeners.put("ShowDetailButtonAction", new ShowDetailButtonAction());
  +        listeners.put("OKButtonAction", new OKButtonAction());
           this.msg = th.getMessage();
   
           StringWriter writer = new StringWriter();
  @@ -94,123 +129,112 @@
           writer.flush();
           this.stacktrace = writer.toString();
   
  -        setMessage(new MessagePanel());
  -        setMessageType(type);
  +        ExtendedGridBagConstraints constraints =
  +            new ExtendedGridBagConstraints();
  +
  +        JTextArea msgArea = new JTextArea();
  +        msgArea.setText(msg);
  +        msgArea.setColumns(50);
  +        msgArea.setFont(new JLabel().getFont());
  +        msgArea.setForeground(new JLabel().getForeground());
  +        msgArea.setOpaque(false);
  +        msgArea.setEditable(false);
  +        msgArea.setLineWrap(true);
  +
  +        constraints.setWeight(0, 0);
  +        constraints.anchor = GridBagConstraints.WEST;
  +        constraints.fill = GridBagConstraints.NONE;
  +        constraints.setGridBounds(0, 0, 1, 1);
  +        add(msgArea, constraints);
  +
  +        constraints.setWeight(1, 0);
  +        constraints.anchor = GridBagConstraints.CENTER;
  +        constraints.fill = GridBagConstraints.HORIZONTAL;
  +        constraints.setGridBounds(0, 1, 1, 1);
  +        add(createButtonsPanel(), constraints);
  +
  +        JTextArea details = new JTextArea();
  +        msgArea.setColumns(50);
  +        details.setText(stacktrace);
  +        details.setEditable(false);
  +
  +        detailsArea = new JPanel(new BorderLayout(0, 10));
  +        detailsArea.add(new JSeparator(), BorderLayout.NORTH);
  +        detailsArea.add(new JScrollPane(details), BorderLayout.CENTER);
  +
  +        subpanel = new JPanel(new BorderLayout());
  +
  +        constraints.insets = new Insets(10, 4, 4, 4);
  +        constraints.setWeight(1, 1);
  +        constraints.anchor = GridBagConstraints.CENTER;
  +        constraints.fill = GridBagConstraints.BOTH;
  +        constraints.setGridBounds(0, 2, 1, 1);
  +        add(subpanel, constraints);
       }
   
  +    public JDialog createDialog(Component owner, String title) {
  +        JDialog dialog  =
  +            new JDialog(JOptionPane.getFrameForComponent(owner), title);
  +        dialog.getContentPane().add(this, BorderLayout.CENTER);
  +        dialog.pack();
  +        return dialog;
  +    }
  +
  +    protected JPanel createButtonsPanel() {
  +        JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  +
  +        showDetailButton = bf.createJButton("ShowDetailButton");
  +        panel.add(showDetailButton);
  +
  +        JButton okButton = bf.createJButton("OKButton");
  +        panel.add(okButton);
  +
  +        return panel;
  +    }
  +
       /**
  -     * The message panel.
  +     * The map that contains the listeners
        */
  -    protected class MessagePanel extends JPanel implements ActionMap {
  +    protected Map listeners = new HashMap();
   
  -        /**
  -         * The button factory.
  -         */
  -        protected ButtonFactory bf = new ButtonFactory(bundle, this);
  -
  -        /**
  -         * The text area used to show the stack trace.
  -         */
  -        protected JComponent detailsArea;
  -
  -        /**
  -         * The button used to show or not the details.
  -         */
  -        protected JButton showDetailButton;
  -
  -        /**
  -         * This flag bit indicates whether or not the stack trace is shown.
  -         */
  -        protected boolean isDetailShown = false;
  -
  -        /**
  -         * The sub panel that contains the stack trace text area.
  -         */
  -        protected JPanel subpanel;
  -
  -        /**
  -         * Constructs a new <tt>MessagePanel</tt>.
  -         */
  -        public MessagePanel() {
  -            super(new GridBagLayout());
  -
  -            listeners.put("ShowDetailButtonAction",
  -                          new ShowDetailButtonAction());
  -
  -            ExtendedGridBagConstraints constraints =
  -                new ExtendedGridBagConstraints();
  -
  -            JTextArea msgArea = new JTextArea();
  -            msgArea.setColumns(50);
  -            msgArea.setFont(new JLabel().getFont());
  -            msgArea.setForeground(new JLabel().getForeground());
  -            msgArea.setOpaque(false);
  -            msgArea.setEditable(false);
  -            msgArea.setText(msg);
  -            msgArea.setLineWrap(true);
  -
  -            constraints.insets = new Insets(5, 5, 5, 5);
  -            constraints.setWeight(0, 0);
  -            constraints.anchor = GridBagConstraints.WEST;
  -            constraints.fill = GridBagConstraints.NONE;
  -            constraints.setGridBounds(0, 0, 1, 1);
  -            add(msgArea, constraints);
  -
  -            constraints.insets = new Insets(0, 5, 5, 5);
  -            showDetailButton = bf.createJButton("ShowDetailButton");
  -            constraints.setWeight(0, 0);
  -            constraints.anchor = GridBagConstraints.NORTHWEST;
  -            constraints.fill = GridBagConstraints.NONE;
  -            constraints.setGridBounds(0, 1, 1, 1);
  -            add(showDetailButton, constraints);
  -
  -            JTextArea details = new JTextArea();
  -            details.setText(stacktrace);
  -            details.setEditable(false);
  -            detailsArea = new JScrollPane(details);
  -
  -            subpanel = new JPanel(new BorderLayout());
  -            constraints.setWeight(1d, 1d);
  -            constraints.anchor = GridBagConstraints.CENTER;
  -            constraints.fill = GridBagConstraints.BOTH;
  -            constraints.setGridBounds(0, 2, 1, 1);
  -            add(subpanel, constraints);
  -        }
  +    /**
  +     * Returns the action associated with the given string or null on error
  +     *
  +     * @param key the key mapped with the action to get
  +     * @throws MissingListenerException if the action is not found
  +     */
  +    public Action getAction(String key) throws MissingListenerException {
  +        return (Action)listeners.get(key);
  +    }
  +
  +    /**
  +     * The action associated with the 'OK' button.
  +     */
  +    protected class OKButtonAction extends AbstractAction {
   
  -        /**
  -         * The map that contains the listeners
  -         */
  -        protected Map listeners = new HashMap();
  -
  -        /**
  -         * Returns the action associated with the given string or null on error
  -         *
  -         * @param key the key mapped with the action to get
  -         * @throws MissingListenerException if the action is not found
  -         */
  -        public Action getAction(String key) throws MissingListenerException {
  -            return (Action)listeners.get(key);
  +        public void actionPerformed(ActionEvent evt) {
  +            ((JDialog)getTopLevelAncestor()).dispose();
           }
  +    }
  +
  +    /**
  +     * The action associated with the 'Show Detail' button.
  +     */
  +    protected class ShowDetailButtonAction extends AbstractAction {
   
  -        /**
  -         * The action associated with the 'Show Detail' button.
  -         */
  -        protected class ShowDetailButtonAction extends AbstractAction {
  -
  -            public void actionPerformed(ActionEvent evt) {
  -                if (isDetailShown) {
  -                    subpanel.remove(detailsArea);
  -                    isDetailShown = false;
  -                    showDetailButton.setText
  -                        (resources.getString("ShowDetailButton.text"));
  -                } else {
  -                    subpanel.add(detailsArea, BorderLayout.CENTER);
  -                    showDetailButton.setText
  -                        (resources.getString("ShowDetailButton.text2"));
  -                    isDetailShown = true;
  -                }
  -                ((JDialog)getTopLevelAncestor()).pack();
  +        public void actionPerformed(ActionEvent evt) {
  +            if (isDetailShown) {
  +                subpanel.remove(detailsArea);
  +                isDetailShown = false;
  +                showDetailButton.setText
  +                    (resources.getString("ShowDetailButton.text"));
  +            } else {
  +                subpanel.add(detailsArea, BorderLayout.CENTER);
  +                showDetailButton.setText
  +                    (resources.getString("ShowDetailButton.text2"));
  +                isDetailShown = true;
               }
  +            ((JDialog)getTopLevelAncestor()).pack();
           }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to