From: <wu...@us...> - 2008-04-03 16:36:34
|
Revision: 102 http://davinspector.svn.sourceforge.net/davinspector/?rev=102&view=rev Author: wuest Date: 2008-04-03 09:36:25 -0700 (Thu, 03 Apr 2008) Log Message: ----------- Added new visual component to display header information in different categories. Modified Paths: -------------- trunk/DAVInspector/build-user.xml trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java Added Paths: ----------- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/minus.png trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/plus.png Modified: trunk/DAVInspector/build-user.xml =================================================================== --- trunk/DAVInspector/build-user.xml 2008-04-03 16:33:49 UTC (rev 101) +++ trunk/DAVInspector/build-user.xml 2008-04-03 16:36:25 UTC (rev 102) @@ -53,6 +53,10 @@ basedir="bin" includes="de/dlr/davinspector/plugins/recordingplugin/**"> </jar> + <jar jarfile="${dist}/plugins/RawEditPlugin.jar" + basedir="bin" + includes="de/dlr/davinspector/plugins/raweditplugin/**"> + </jar> <!-- Copy DAVInspector resource files --> <copy todir="bin/de/dlr/davinspector/resource"> @@ -67,7 +71,7 @@ <manifest> <attribute name="Main-Class" value="de/dlr/davinspector.DAVInspector"/> <attribute name="Built-By" value="${user.name}"/> - <attribute name="Class-Path" value=". log4j.properties lib/log4j.jar"/> + <attribute name="Class-Path" value=". /plugins/RecordingPlugin.jar log4j.properties lib/log4j.jar"/> <section name="DAVInspector"> <attribute name="Specification-Title" value="${project.name}"/> Modified: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-04-03 16:33:49 UTC (rev 101) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/HeaderPlugin.java 2008-04-03 16:36:25 UTC (rev 102) @@ -25,9 +25,9 @@ package de.dlr.davinspector.plugins.headerplugin; +import javax.swing.BoxLayout; import javax.swing.JComponent; -import javax.swing.JScrollPane; -import javax.swing.JTextPane; +import javax.swing.JPanel; import de.dlr.davinspector.common.Util; import de.dlr.davinspector.history.AMessage; @@ -49,19 +49,28 @@ /** State of the plugin. */ private Boolean isActive = true; - /** The text pane. */ - private JTextPane myJTextPane = null; + /** The panel. */ + private JPanel myJPanel = null; - /** The scroll pane. */ - private JScrollPane myJScrollPane = null; + /** */ + private JCategoryTable myResponseHeaders; + /** */ + private JCategoryTable myRequestHeaders; + + /** */ + private JCategoryTable myMiscHeaders; + + /** */ + private JCategoryTable myCommonHeaders; + /** * {@inheritDoc} * * @see de.dlr.DAVInspector.Plugin.IViewPlugin#getUI() */ public JComponent getUI() { - return myJScrollPane; + return myJPanel; } /** @@ -106,7 +115,7 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#getVersion() */ public int getVersion() { - return 1; + return 2; } /** @@ -116,13 +125,27 @@ */ public void init(PluginManager pluginManager, PluginDirection direction) { myPlugInDirection = direction; - if (myJScrollPane == null) { - myJScrollPane = new JScrollPane(); - myJTextPane = new JTextPane(); - myJTextPane.setEditable(false); - myJScrollPane.setViewportView(myJTextPane); + if (myJPanel == null) { + + myJPanel = new JPanel(); + myJPanel.setLayout(new BoxLayout(myJPanel, BoxLayout.PAGE_AXIS)); + + myCommonHeaders = new JCategoryTable(myJPanel, "Common"); + myResponseHeaders = new JCategoryTable(myJPanel, "Response"); + myRequestHeaders = new JCategoryTable(myJPanel, "Request"); + myMiscHeaders = new JCategoryTable(myJPanel, "Misc"); + + myJPanel.add(myCommonHeaders); + myJPanel.add(myResponseHeaders); + myJPanel.add(myRequestHeaders); + myJPanel.add(myMiscHeaders); + + // test data + myCommonHeaders.addRow(new Object[]{"ert", "zui"}); + myResponseHeaders.addRow(new Object[]{"test", "test2"}); + myRequestHeaders.addRow(new Object[]{"test3", "test4"}); + myMiscHeaders.addRow(new Object[]{"ghj", "l\xF6\xE4"}); } - myJTextPane.setText(""); Util.setUIDesign(); } @@ -168,8 +191,12 @@ * @see de.dlr.DAVInspector.Plugin.IPlugin#update(java.lang.String) */ public void update(AMessage msg) { - if (isActive && myJTextPane != null) { - myJTextPane.setText(msg.getHeader()); + if (isActive && myJPanel != null) { + // TODO: Update tables; +// myCommonHeaders.clearTable(); +// myResponseHeaders.clearTable(); +// myRequestHeaders.clearTable(); +// myMiscHeaders.clearTable(); } } @@ -179,17 +206,11 @@ * @see de.dlr.davinspector.plugin.IPlugin#clear() */ public void clear() { - if (myJTextPane != null) { - myJTextPane.setText(""); + if (myJPanel != null) { + myCommonHeaders.clearTable(); + myResponseHeaders.clearTable(); + myRequestHeaders.clearTable(); + myMiscHeaders.clearTable(); } } - -// /** -// * {@inheritDoc} -// * -// * @see de.dlr.davinspector.plugin.IEditPlugin#getOutput() -// */ -// public AMessage getOutput() { -// return new Message(); -// } } Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/JCategoryTable.java 2008-04-03 16:36:25 UTC (rev 102) @@ -0,0 +1,169 @@ +/* + * JCategoryTable.java + * + * TODO: wues_ha Enter comment! + * + * Created: 03.04.2008 Jochen Wuest <joc...@dl...> + * Changed: + * + * $Id$ + * + * Copyright 2007 Deutsches Zentrum fuer Luft- und Raumfahrt e.V. (DLR) + * + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package de.dlr.davinspector.plugins.headerplugin; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.SystemColor; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JToggleButton; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableModel; + + +/** + * TODO: wues_ha: Enter comment! + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class JCategoryTable extends JPanel { + + /** Serial Version UID, not valid. */ + private static final long serialVersionUID = 1L; + + /** */ + private final ImageIcon iconPlus = + new ImageIcon(JCategoryTable.class.getResource("/de/dlr/davinspector/plugins/headerplugin/plus.png")); + + /** */ + private final ImageIcon iconMinus = + new ImageIcon(JCategoryTable.class.getResource("/de/dlr/davinspector/plugins/headerplugin/minus.png")); + + /** */ + private JToggleButton jToggleButton; + + /** */ + private JScrollPane jScrollPane; + + /** */ + private JTable jTable; + + /** */ + private Dimension sizePanel; + + /** */ + private DefaultTableModel myCategoryTableModel; + + /** */ + private JComponent myComponent; + + /** + * Constructor for JCategoryTable. + * + * @param component {@link JComponent} The parent JComponent object. + * @param tableTitle {@link String} The title of the Table. + */ + public JCategoryTable(JComponent component, String tableTitle) { + myComponent = component; + init(tableTitle); + } + + /** + * This method initializes all visual elements. + * + * @param tableTitle The title of the Table. + */ + private void init(String tableTitle) { + + jToggleButton = new JToggleButton(); + jScrollPane = new JScrollPane(); + jTable = new JTable(); + + jToggleButton.setIcon(iconPlus); + jToggleButton.setSelectedIcon(iconMinus); + jToggleButton.setSelected(true); + jToggleButton.setText(tableTitle); + jToggleButton.setBorder(null); + jToggleButton.setBorderPainted(false); + jToggleButton.setFocusPainted(false); + jToggleButton.setBackground(SystemColor.LIGHT_GRAY); + jToggleButton.setHorizontalAlignment(SwingConstants.LEFT); + + jToggleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jToggleButtonActionPerformed(evt); + } + }); + + myCategoryTableModel = new DefaultTableModel(); + myCategoryTableModel.addColumn("Key"); + myCategoryTableModel.addColumn("Value"); + + // TODO: do not allow editing of table data + jTable.setModel(myCategoryTableModel); + jTable.setTableHeader(null); + + jScrollPane.setViewportView(jTable); + + setLayout(new BorderLayout()); + add(jToggleButton, BorderLayout.NORTH); + add(jScrollPane, BorderLayout.CENTER); + } + + /** + * This method handles the toggle button event. On action "hide" the current size of + * the panel is stored in <code>sizePanel</code>, the table is set invisible and the + * parent component is forced to refresh the layout. On action "show" the stored panel + * size is restored and the parent component is forced to refresh it's layout. + * + * @param evt Event + */ + private void jToggleButtonActionPerformed(java.awt.event.ActionEvent evt) { + if (jScrollPane.isVisible()) { + jScrollPane.setVisible(false); + sizePanel = getSize(); + setSize(jToggleButton.getSize()); + myComponent.validate(); + } else { + jScrollPane.setVisible(true); + setSize(sizePanel); + myComponent.validate(); + } + } + + /** + * This method adds a row to the table. + * A row consists of two columns: key and value. + * + * @param rowData Object[] + */ + public void addRow(Object[] rowData) { + myCategoryTableModel.addRow(rowData); + } + + /** + * This method deletes all rows. + */ + public void clearTable() { + myCategoryTableModel.setRowCount(0); + } +} Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/minus.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/minus.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/plus.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/src/de/dlr/davinspector/plugins/headerplugin/plus.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |