[Jsxe-cvs] SF.net SVN: jsxe: [910] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-06-07 05:46:07
|
Revision: 910 Author: ian_lewis Date: 2006-06-06 22:45:54 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=910&view=rev Log Message: ----------- Updated the document options to use abstract classes to lay out the dialog. OptionsPanel is now deprecated in favor of using the OptionPane and AbstractOptionPane classes. Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages.en trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java Added Paths: ----------- trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/Changelog 2006-06-07 05:45:54 UTC (rev 910) @@ -1,3 +1,9 @@ +06/07/2006 Ian Lewis <Ian...@me...> + + * Updated the document options to use abstract classes to lay out the + dialog. OptionsPanel is now deprecated in favor of using the OptionPane + and AbstractOptionPane classes. + 06/06/2006 Ian Lewis <Ian...@me...> * Added a new Document Options Dialog which handles settings on a per Modified: trunk/jsxe/messages/messages.en =================================================================== --- trunk/jsxe/messages/messages.en 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/messages/messages.en 2006-06-07 05:45:54 UTC (rev 910) @@ -72,6 +72,7 @@ Document.Options.Title=XML Document Options Document.Options.Message=This dialog changes settings for the current\n document only. To change settings on an\n editor-wide basis, see the\n Tools->Global Options dialog box. Document.Options.Line.Separator=Line Separator: +Document.Options.Line.Separator.ToolTip=The line separator. Usually you'll pick the line separator used by your operating system. Document.Options.Encoding=Encoding: Document.Options.Encoding.ToolTip=The encoding that jsXe uses to write the file. Document.Options.Indent.Width=Indent width: Modified: trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/CatalogManager.java 2006-06-07 05:45:54 UTC (rev 910) @@ -4,8 +4,8 @@ :folding=explicit:collapseFolds=1: * Copyright (C) 2001, 2003 Slava Pestov - * Portions copyright (C) 2002 Chris Stevenson - * Portions copyright (C) 2005 Ian Lewis (Ian...@me...) + * Portions Copyright (C) 2002 Chris Stevenson + * Portions Copyright (C) 2005 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Modified: trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-06-07 05:45:54 UTC (rev 910) @@ -35,6 +35,7 @@ import net.sourceforge.jsxe.dom.XMLDocument; import net.sourceforge.jsxe.dom.XMLDocumentListener; import net.sourceforge.jsxe.dom.AdapterNode; +import net.sourceforge.jsxe.options.AbstractOptionPane; import net.sourceforge.jsxe.options.OptionPane; import net.sourceforge.jsxe.gui.*; import net.sourceforge.jsxe.util.Log; @@ -479,14 +480,14 @@ return equalsOnDisk(buffer.getFile()); }//}}} - //{{{ getOptionsPanel() + //{{{ getOptionPane() /** * Gets the pane for editing options for this DocumentBuffer. * @return the option pane specific to this DocumentBuffer */ - public OptionsPanel getOptionsPanel() { - return new DocumentBufferOptionsPanel(); + public OptionPane getOptionPane() { + return new DocumentBufferOptionPane(); }//}}} //{{{ fireStructureChanged() @@ -533,31 +534,27 @@ return "Untitled-" + Integer.toString(untitledNo+1); }//}}} - //{{{ DocumentBufferOptionsPane class + //{{{ DocumentBufferOptionPane class - private class DocumentBufferOptionsPanel extends OptionsPanel { + private class DocumentBufferOptionPane extends AbstractOptionPane { //{{{ DocumentBufferOptionsPanel() + public DocumentBufferOptionPane() { + super("documentbuffer"); + }//}}} - public DocumentBufferOptionsPanel() { + //{{{ _init() + protected void _init() { - GridBagLayout layout = new GridBagLayout(); - GridBagConstraints constraints = new GridBagConstraints(); - - //the grid y coordinate. - int gridY = 0; - - setLayout(layout); - - //Set up line separator combo-box + //{{{ line separator m_m_lineSeparators.put("Unix (\\n)", "\n"); m_m_lineSeparators.put("DOS/Windows (\\r\\n)", "\r\n"); m_m_lineSeparators.put("MacOS (\\r)", "\r"); - JLabel lineSeparatorLabel = new JLabel(Messages.getMessage("Document.Options.Line.Separator")); - lineSeparatorLabel.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); + // JLabel lineSeparatorLabel = new JLabel(Messages.getMessage("Document.Options.Line.Separator")); + // lineSeparatorLabel.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); m_m_lineSeparatorComboBox = new JComboBox(new Vector(m_m_lineSeparators.keySet())); m_m_lineSeparatorComboBox.setName("LineSeparatorComboBox"); - m_m_lineSeparatorComboBox.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); + // m_m_lineSeparatorComboBox.setToolTipText(Messages.getMessage("Document.Options.Line.Separator.ToolTip")); String lineSep = getProperty(LINE_SEPARATOR); if (lineSep.equals("\r\n")) { @@ -567,15 +564,21 @@ } else { m_m_lineSeparatorComboBox.setSelectedItem("Unix (\\n)"); } + + addComponent(Messages.getMessage("Document.Options.Line.Separator"), + m_m_lineSeparatorComboBox, + Messages.getMessage("Document.Options.Line.Separator.ToolTip")); - //set up the encoding combo-box. + //}}} + + //{{{ encoding String[] encodings = MiscUtilities.getSupportedEncodings(); - JLabel encodingLabel = new JLabel(Messages.getMessage("Document.Options.Encoding")); - encodingLabel.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); + // JLabel encodingLabel = new JLabel(Messages.getMessage("Document.Options.Encoding")); + // encodingLabel.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); encodingComboBox = new JComboBox(encodings); encodingComboBox.setName("EncodingComboBox"); encodingComboBox.setEditable(false); - encodingComboBox.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); + // encodingComboBox.setToolTipText(Messages.getMessage("Document.Options.Encoding.ToolTip")); for (int i=0; i<encodings.length; i++) { if (getProperty(ENCODING).equals(encodings[i])) { @@ -583,8 +586,15 @@ } } - JLabel indentLabel = new JLabel(Messages.getMessage("Document.Options.Indent.Width")); - indentLabel.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); + addComponent(Messages.getMessage("Document.Options.Encoding"), + encodingComboBox, + Messages.getMessage("Document.Options.Encoding.ToolTip")); + + //}}} + + //{{{ indent width + // JLabel indentLabel = new JLabel(Messages.getMessage("Document.Options.Indent.Width")); + // indentLabel.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); Vector sizes = new Vector(3); sizes.add("2"); sizes.add("4"); @@ -593,169 +603,76 @@ indentComboBox.setName("IndentComboBox"); indentComboBox.setEditable(true); indentComboBox.setSelectedItem(getProperty(INDENT)); - indentComboBox.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); + // indentComboBox.setToolTipText(Messages.getMessage("Document.Options.Indent.Width.ToolTip")); + addComponent(Messages.getMessage("Document.Options.Indent.Width"), + indentComboBox, + Messages.getMessage("Document.Options.Indent.Width.ToolTip")); - // boolean whitespace = Boolean.valueOf(m_document.getProperty(XMLDocument.WS_IN_ELEMENT_CONTENT, "true")).booleanValue(); + //}}} + + //{{{ format output boolean formatOutput = Boolean.valueOf(getProperty(XMLDocument.FORMAT_XML, "false")).booleanValue(); + formatCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Format.XML"), formatOutput); - // whitespaceCheckBox = new JCheckBox("Whitespace in element content", whitespace); - formatCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Format.XML"), formatOutput); + addComponent(formatCheckBox, Messages.getMessage("Document.Options.Format.XML.ToolTip")); + //}}} - // whitespaceCheckBox.addChangeListener(new WhiteSpaceChangeListener()); - + //{{{ validate boolean validating = Boolean.valueOf(getProperty(XMLDocument.IS_VALIDATING, "false")).booleanValue(); m_m_validatingCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Validate"), validating); - // formatCheckBox.setEnabled(!whitespace); + addComponent(m_m_validatingCheckBox, Messages.getMessage("Document.Options.Validate.ToolTip")); + //}}} - constraints.gridy = gridY; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(lineSeparatorLabel, constraints); - add(lineSeparatorLabel); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_m_lineSeparatorComboBox, constraints); - add(m_m_lineSeparatorComboBox); - - constraints.gridy = gridY; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(encodingLabel, constraints); - add(encodingLabel); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(encodingComboBox, constraints); - add(encodingComboBox); - - constraints.gridy = gridY; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(indentLabel, constraints); - add(indentLabel); - - constraints.gridy = gridY++; - constraints.gridx = 1; - constraints.gridheight = 1; - constraints.gridwidth = 1; - constraints.weightx = 1.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(indentComboBox, constraints); - add(indentComboBox); - - // constraints.gridy = gridY++; - // constraints.gridx = 0; - // constraints.gridheight = 1; - // constraints.gridwidth = GridBagConstraints.REMAINDER; - // constraints.weightx = 0.0f; - // constraints.fill = GridBagConstraints.BOTH; - // constraints.insets = new Insets(1,0,1,0); - - // layout.setConstraints(whitespaceCheckBox, constraints); - // add(whitespaceCheckBox); - - constraints.gridy = gridY++; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(formatCheckBox, constraints); - add(formatCheckBox); - formatCheckBox.setToolTipText(Messages.getMessage("Document.Options.Format.XML.ToolTip")); - - constraints.gridy = gridY++; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); - - layout.setConstraints(m_m_validatingCheckBox, constraints); - add(m_m_validatingCheckBox); - m_m_validatingCheckBox.setToolTipText(Messages.getMessage("Document.Options.Validate.ToolTip")); - + //{{{ soft tabs boolean softTabs = Boolean.valueOf(getProperty(XMLDocument.IS_USING_SOFT_TABS, "false")).booleanValue(); - m_m_softTabsCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Soft.Tabs"), softTabs); - constraints.gridy = gridY++; - constraints.gridx = 0; - constraints.gridheight = 1; - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 0.0f; - constraints.fill = GridBagConstraints.BOTH; - constraints.insets = new Insets(1,0,1,0); + addComponent(m_m_softTabsCheckBox, Messages.getMessage("Document.Options.Soft.Tabs.ToolTip")); + ////}}} - layout.setConstraints(m_m_softTabsCheckBox, constraints); - add(m_m_softTabsCheckBox); - m_m_softTabsCheckBox.setToolTipText(Messages.getMessage("Document.Options.Soft.Tabs.ToolTip")); - }//}}} - //{{{ save() - - public void save() { + //{{{ _save() + protected void _save() { + //{{{ line separator if (!(m_m_lineSeparators.get(m_m_lineSeparatorComboBox.getSelectedItem()).toString().equals(getProperty(LINE_SEPARATOR)))) { setDirty(true); setProperty(LINE_SEPARATOR, m_m_lineSeparators.get(m_m_lineSeparatorComboBox.getSelectedItem()).toString()); - } + }//}}} + //{{{ formatting if (!String.valueOf(formatCheckBox.isSelected()).equals(getProperty(XMLDocument.FORMAT_XML))) { setDirty(true); setProperty(XMLDocument.FORMAT_XML, String.valueOf(formatCheckBox.isSelected())); } + //}}} + + //{{{ soft tabs if (!String.valueOf(m_m_softTabsCheckBox.isSelected()).equals(getProperty(XMLDocument.IS_USING_SOFT_TABS))) { setDirty(true); setProperty(XMLDocument.IS_USING_SOFT_TABS, String.valueOf(m_m_softTabsCheckBox.isSelected())); } + //}}} + + //{{{ validating + if (!String.valueOf(m_m_validatingCheckBox.isSelected()).equals(getProperty(XMLDocument.IS_VALIDATING))) { setProperty(XMLDocument.IS_VALIDATING, String.valueOf(m_m_validatingCheckBox.isSelected())); } - // if (!String.valueOf(whitespaceCheckBox.isSelected()).equals(m_document.getProperty(XMLDocument.WS_IN_ELEMENT_CONTENT))) { - // setDirty(true); - // m_document.setProperty(XMLDocument.WS_IN_ELEMENT_CONTENT, String.valueOf(whitespaceCheckBox.isSelected())); - // } + //}}} + + //{{{ encoding + if (!encodingComboBox.getSelectedItem().toString().equals(getProperty(XMLDocument.ENCODING))) { setDirty(true); setProperty(XMLDocument.ENCODING, encodingComboBox.getSelectedItem().toString()); } + //}}} + //{{{ indent width + if (!getProperty(XMLDocument.INDENT).equals(indentComboBox.getSelectedItem().toString())) { try { //don't need to set dirty, no change to text @@ -771,38 +688,20 @@ //Bad input, don't save. } } + //}}} };//}}} //{{{ getName() - public String getName() { return "documentbuffer"; }//}}} //{{{ getTitle() - public String getTitle() { return Messages.getMessage("Document.Options.Title"); - };//}}} + }//}}} - // //{{{ WhiteSpaceChangeListener class - - // private class WhiteSpaceChangeListener implements ChangeListener { - - // //{{{ stateChanged() - - // public void stateChanged(ChangeEvent e) { - // boolean whitespace = whitespaceCheckBox.isSelected(); - // if (whitespace) { - // formatCheckBox.setSelected(false); - // } - // formatCheckBox.setEnabled(!whitespace); - // }//}}} - - // }//}}} - //{{{ Private members - private DocumentBuffer m_buffer; private JCheckBox m_m_softTabsCheckBox; private JComboBox encodingComboBox; Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/DocumentOptionsDialog.java 2006-06-07 05:45:54 UTC (rev 910) @@ -3,7 +3,7 @@ :tabSize=4:indentSize=4:noTabs=true: :folding=explicit:collapseFolds=1: -Copyright (C) 2005 Trish Harnett (tri...@me...) +Copyright (C) 2005 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -28,6 +28,7 @@ //{{{ jsXe imports import net.sourceforge.jsxe.DocumentBuffer; +import net.sourceforge.jsxe.options.OptionPane; import net.sourceforge.jsxe.util.Log; //}}} @@ -60,17 +61,19 @@ super(parent, Messages.getMessage("Document.Options.Title"), true); m_view = parent; DocumentBuffer buffer = m_view.getDocumentBuffer(); - m_optionsPanel = buffer.getOptionsPanel(); + m_optionPane = buffer.getOptionPane(); + m_optionPane.init(); + JPanel content = new JPanel(new BorderLayout(12,12)); content.setBorder(new EmptyBorder(12,12,12,12)); setContentPane(content); - JPanel panel = new JPanel(new BorderLayout()); + GridPanel panel = new GridPanel(); - panel.add(createMultilineLabel(Messages.getMessage("Document.Options.Message")), BorderLayout.NORTH); - panel.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.CENTER); - panel.add(m_optionsPanel, BorderLayout.SOUTH); + panel.addComponent(createMultilineLabel(Messages.getMessage("Document.Options.Message"))); + panel.addSeparator(); + panel.addComponent(m_optionPane.getComponent()); getContentPane().add(panel, BorderLayout.CENTER); @@ -104,7 +107,7 @@ //{{{ ok() public void ok() { - m_optionsPanel.save(); + m_optionPane.save(); cancel(); }//}}} @@ -154,6 +157,6 @@ /** * The document options panel for the current document */ - private OptionsPanel m_optionsPanel; + private OptionPane m_optionPane; //}}} } Added: trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java (rev 0) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/GridPanel.java 2006-06-07 05:45:54 UTC (rev 910) @@ -0,0 +1,195 @@ +/* +AbstractOptionPane.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 1998, 1999, 2000, 2001, 2002 Slava Pestov +Portions Copyright (C) 2005 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt + */ + +package net.sourceforge.jsxe.gui; + +//{{{ Imports +import javax.swing.border.EmptyBorder; +import javax.swing.*; +import java.awt.*; +//}}} + +/** + * A convenient class for laying out components in a form or dialog. + * + * It is derived from Java's <code>JPanel</code> class and uses a + * <code>GridBagLayout</code> object for component management. Since + * <code>GridBagLayout</code> can be a bit cumbersome to use, this class + * contains shortcut methods to simplify layout: + * + * <ul> + * <li>{@link #addComponent(Component)}</li> + * <li>{@link #addComponent(Component,int)}</li> + * <li>{@link #addSeparator()}</li> + * <li>{@link #addSeparator(String)}</li> + * </ul> + * + * @ + * @author Slava Pestov + * @author John Gellene (API documentation) + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @since jsXe 0.5 pre1 + */ +public class GridPanel extends JPanel { + + //{{{ GridPanel constructor + /** + * Creates a new panel. + */ + public GridPanel() { + setLayout(gridBag = new GridBagLayout()); + } //}}} + + //{{{ getComponent() method + /** + * Returns the component that should be displayed for this option pane. + * Because this class extends Component, it simply returns "this". + */ + public Component getComponent() { + return this; + } //}}} + + //{{{ addComponent() method + /** + * Adds a component to the option pane. Components are + * added in a vertical fashion, one per row. + * @param comp The component + */ + public void addComponent(Component comp) { + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = GridBagConstraints.NONE; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(comp,cons); + add(comp); + } //}}} + + //{{{ addComponent() method + /** + * Adds a component to the option pane. Components are + * added in a vertical fashion, one per row. + * @param comp The component + * @param fill Fill parameter to GridBagConstraints + */ + public void addComponent(Component comp, int fill) { + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = fill; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(comp,cons); + add(comp); + } //}}} + + //{{{ addSeparator() method + /** + * Adds a separator component. + */ + public void addSeparator() { + addComponent(Box.createVerticalStrut(6)); + + JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); + + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = GridBagConstraints.BOTH; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + //cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(sep,cons); + add(sep); + + addComponent(Box.createVerticalStrut(6)); + } //}}} + + //{{{ addSeparator() method + /** + * Adds a separator component. + * @param label The separator label property + */ + public void addSeparator(String label) { + if (y != 0) { + addComponent(Box.createVerticalStrut(6)); + } + + Box box = new Box(BoxLayout.X_AXIS); + Box box2 = new Box(BoxLayout.Y_AXIS); + box2.add(Box.createGlue()); + box2.add(new JSeparator(JSeparator.HORIZONTAL)); + box2.add(Box.createGlue()); + box.add(box2); + JLabel l = new JLabel(label); + l.setMaximumSize(l.getPreferredSize()); + box.add(l); + Box box3 = new Box(BoxLayout.Y_AXIS); + box3.add(Box.createGlue()); + box3.add(new JSeparator(JSeparator.HORIZONTAL)); + box3.add(Box.createGlue()); + box.add(box3); + + GridBagConstraints cons = new GridBagConstraints(); + cons.gridy = y++; + cons.gridheight = 1; + cons.gridwidth = cons.REMAINDER; + cons.fill = GridBagConstraints.BOTH; + cons.anchor = GridBagConstraints.WEST; + cons.weightx = 1.0f; + cons.insets = new Insets(1,0,1,0); + + gridBag.setConstraints(box,cons); + add(box); + } //}}} + + //{{{ Protected members + /** + * Has the option pane been initialized? + */ + protected boolean initialized; + + /** + * The layout manager. + */ + protected GridBagLayout gridBag; + + /** + * The number of components already added to the layout manager. + */ + protected int y; + //}}} + +} Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/OptionsPanel.java 2006-06-07 05:45:54 UTC (rev 910) @@ -47,6 +47,7 @@ * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> * @version $Id$ * @see OptionsDialog + * @deprecated implement OptionPane directly or use AbstractOptionPane */ public abstract class OptionsPanel extends JPanel implements OptionPane { Modified: trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java 2006-06-07 03:42:19 UTC (rev 909) +++ trunk/jsxe/src/net/sourceforge/jsxe/options/OptionPane.java 2006-06-07 05:45:54 UTC (rev 910) @@ -34,8 +34,9 @@ * method. The label displayed in the option pane's tab is obtained from the * <code>getTitle()</code> method. * - * Note that you should extend the {@link net.sourceforge.jsxe.gui.OptionPanel} - * if creating an OptionPane for use with jsXe. + * Note that you may want to extend the + * {@link net.sourceforge.jsxe.options.AbstractOptionPane} if creating an + * OptionPane for use with jsXe. * * @see OptionGroup * @see net.sourceforge.jsxe.gui.OptionsDialog#addOptionPane(OptionPane) @@ -55,6 +56,9 @@ //}}} //{{{ getTitle() + /** + * Get the human readable title of the option pane + */ public String getTitle(); //}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |