From: <wu...@us...> - 2008-04-06 13:54:41
|
Revision: 106 http://davinspector.svn.sourceforge.net/davinspector/?rev=106&view=rev Author: wuest Date: 2008-04-06 06:54:38 -0700 (Sun, 06 Apr 2008) Log Message: ----------- Added export dialog to the main window. You can now export the client or server message history to a file. Added an IOException dialog to Util. Modified Paths: -------------- trunk/DAVInspector/resource/TextBundle.properties trunk/DAVInspector/resource/TextBundle_de_DE.properties trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java Added Paths: ----------- trunk/DAVInspector/resource/fileexport.png trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java Modified: trunk/DAVInspector/resource/TextBundle.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle.properties 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/resource/TextBundle.properties 2008-04-06 13:54:38 UTC (rev 106) @@ -7,7 +7,7 @@ ac_send_to_client_description=Send Server data to the Client ac_configure=Configure ac_configure_description=Configure the application -ac_configure_plugins=Configure +ac_configure_plugins=Configure Plugins ac_configure_plugins_description=Configure the loaded plugins ac_about=About ac_about_description=Display information about the application @@ -25,6 +25,9 @@ ac_enable_auto_mode_description=Data is automatically transfered ac_disable_auto_mode=Disable Auto Mode ac_disable_auto_mode_description=No automatic data transfer +ac_export=Export ... +ac_export_description=Export client or server messages to a file + #ac popup menu ac_paste=Paste ac_paste_description=Paste @@ -48,7 +51,6 @@ menu_file=File menu_view=View menu_help=Help -menu_plugins=Plugins #AboutDialog dlg_about_title=About DAVInspector @@ -70,6 +72,13 @@ dlg_plugin_configuration_type_edit=Edit dlg_plugin_configuration_type_view=View +#ExportDialog +dlg_export_title=Export +dlg_export_label_file=File +dlg_export_radio_client=Export Client Messages +dlg_export_radio_server=Export Server Messages +dlg_export_save_dialog_title=Save Export to ... + #PluginConfigurationTableModel #Column names col_plugin_configuration_client=Client Modified: trunk/DAVInspector/resource/TextBundle_de_DE.properties =================================================================== --- trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/resource/TextBundle_de_DE.properties 2008-04-06 13:54:38 UTC (rev 106) @@ -7,7 +7,7 @@ ac_send_to_client_description=Server-Daten zum Client \xFCbertragen ac_configure=Einstellungen ac_configure_description=Die Einstellungen des Programms \xE4ndern -ac_configure_plugins=Konfiguration +ac_configure_plugins=Konfiguration Plugins ac_configure_plugins_description=Die geladenen Plugins konfigurieren ac_about=\xDCber... ac_about_description=Information zum Programm anzeigen @@ -25,6 +25,9 @@ ac_enable_auto_mode_description=Die Daten werden automatisch \xFCbertragen ac_disable_auto_mode=Automatik deaktivieren ac_disable_auto_mode_description=Die Daten m\xFCssen manuell \xFCbertragen werden +ac_export=Export ... +ac_export_description=Client- oder Servernachrichten in einer Datei speichern + #ac popup menu ac_paste=Einf\xFCgen ac_paste_description=Text aus Zwischenablage einf\xFCgen @@ -48,7 +51,6 @@ menu_file=Datei menu_view=Ansicht menu_help=Hilfe -menu_plugins=Plugins #AboutDialog dlg_about_title=\xDCber DAVInspector @@ -79,6 +81,13 @@ col_plugin_configuration_author=Autor col_plugin_configuration_description=Beschreibung +#ExportDialog +dlg_export_title=Export +dlg_export_label_file=Datei +dlg_export_radio_client=Exportiere Client-Nachrichten +dlg_export_radio_server=Exportiere Server-Nachrichten +dlg_export_save_dialog_title=Speichere Export unter ... + #HistoryTableModel col_history_type=Richtung col_history_id=ID Added: trunk/DAVInspector/resource/fileexport.png =================================================================== (Binary files differ) Property changes on: trunk/DAVInspector/resource/fileexport.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Constant.java 2008-04-06 13:54:38 UTC (rev 106) @@ -60,6 +60,12 @@ /** About dialog height. */ public static final int UI_ABOUT_DIALOG_HEIGTH = 275; + /** Export dialog width. */ + public static final int UI_EXPORT_DIALOG_WIDTH = 500; + + /** Export dialog height. */ + public static final int UI_EXPORT_DIALOG_HEIGTH = 175; + /** Background color of replies. */ public static final Color UI_REPLY_COLOR = new Color(255, 232, 140); Modified: trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/common/Util.java 2008-04-06 13:54:38 UTC (rev 106) @@ -28,8 +28,10 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; +import java.io.IOException; import java.text.DecimalFormat; +import javax.swing.JOptionPane; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; @@ -106,4 +108,17 @@ DecimalFormat decimalFormat = new DecimalFormat("###,##0.#"); return decimalFormat.format(result) + ' ' + units[unitIndex]; } + + /** + * This method opens a dialog window displaying the IOError. + * + * @param ioe {@link IOException} + */ + public static void showIOExceptionMessageDialog(IOException ioe) { + JOptionPane.showMessageDialog(null, + Internationalization.getTranslation("dlg_ioerror_text") + "\n" + + ioe.getLocalizedMessage(), + Internationalization.getTranslation("dlg_ioerror_title"), + JOptionPane.ERROR_MESSAGE); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/history/MessageHistory.java 2008-04-06 13:54:38 UTC (rev 106) @@ -25,14 +25,20 @@ package de.dlr.davinspector.history; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Vector; import javax.swing.event.EventListenerList; +import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.common.Util; + /** * This class saves and provides access to the processed messages. * @@ -71,6 +77,33 @@ } /** + * Save the message history of the client or server in a file. + * + * @param direction Direction + * @param filename String + */ + public void exportToFile(Direction direction, String filename) { + String buffer = ""; + File file = new File(filename); + try { + FileOutputStream out = new FileOutputStream(file); + for (Iterator<AMessage> iterator = myMessages.iterator(); iterator.hasNext();) { + AMessage message = (AMessage) iterator.next(); + if (message.getDirection() == direction) { + // INFO: maybe let the user choose to export full data, only headers or body ... + // TODO: write delimiter for export + buffer = message.getRawData(); + out.write(buffer.getBytes()); + } + } + out.flush(); + out.close(); + } catch (IOException ioe) { + Util.showIOExceptionMessageDialog(ioe); + } + } + + /** * Deletes all stored messages. */ public void deleteAllMessages() { Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/IRelayModel.java 2008-04-06 13:54:38 UTC (rev 106) @@ -67,6 +67,14 @@ * @param id Integer */ void loadMessageById(Integer id); + + /** + * Export the message history of one side (client or server) to a file. + * + * @param direction Direction + * @param filename String + */ + void exportHistory(Direction direction, String filename); /** * This method notifies the listeners for server or client depending on the <code>direction</code> Modified: trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/relay/RelayModel.java 2008-04-06 13:54:38 UTC (rev 106) @@ -44,8 +44,6 @@ /** * Implementation of the relay interface. Provides the server socket * and manages the channel threads. - * TODO: edit-plugin - * TODO: breakpoint-plugin * * @version $LastChangedRevision$ * @author Jochen Wuest @@ -136,6 +134,15 @@ /** * {@inheritDoc} * + * @see de.dlr.davinspector.relay.IRelayModel#exportHistory(de.dlr.davinspector.common.Constant.Direction, java.lang.String) + */ + public void exportHistory(Direction direction, String filename) { + myMessageHistory.exportToFile(direction, filename); + } + + /** + * {@inheritDoc} + * * @see de.dlr.davinspector.relay.IRelayModel#isAutomodeActive() */ public Boolean isAutomodeActive() { Added: trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java (rev 0) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/ExportDialog.java 2008-04-06 13:54:38 UTC (rev 106) @@ -0,0 +1,353 @@ +/* + * ExportDialog.java + * + * This dialog lets the user choose if he wants to export the client or server + * messages to a choosen file. + * + * Created: 05.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.ui; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Window; +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.GroupLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; +import javax.swing.LayoutStyle; + +import de.dlr.davinspector.common.Constant; +import de.dlr.davinspector.common.Constant.Direction; +import de.dlr.davinspector.common.Internationalization; +import de.dlr.davinspector.common.Util; + + +/** + * This dialog lets the user choose if he wants to export the client or server + * messages to a choosen file. + * + * @version $LastChangedRevision$ + * @author Jochen Wuest + */ +public class ExportDialog extends JDialog { + + /** Serial Version UID, not valid. */ + private static final long serialVersionUID = 1L; + + /** */ + private JPanel jContentPane = null; + + /** */ + private JButton jButtonOk = null; + + /** */ + private JButton jButtonCancel = null; + + /** */ + private ButtonGroup buttonGroup = new ButtonGroup(); + + /** */ + private JTextField jTextField = new JTextField(); + + /** */ + private JLabel jLabel = new JLabel(); + + /** */ + private JButton jButton = new JButton(); + + /** */ + private JRadioButton jRadioButtonClient = new JRadioButton(); + + /** */ + private JRadioButton jRadioButtonServer = new JRadioButton(); + + /** */ + private JPanel jPanelButtonBar = null; + + /** */ + private JPanel jPanelExport = null; + + /** The Controller. */ + private IMainController myController; + + /** The parent frame. */ + private Frame myParent; + + /** + * Constructor of AboutDialog. + * + * @param owner Parent Frame + * @param controller IMainController + */ + public ExportDialog(Frame owner, IMainController controller) { + super(owner); + myParent = owner; + myController = controller; + initialize(); + } + + /** + * This method initializes this. + */ + private void initialize() { + setSize(Constant.UI_EXPORT_DIALOG_WIDTH, Constant.UI_EXPORT_DIALOG_HEIGTH); + setTitle(Constant.APP_TITLE + " " + Internationalization.getTranslation("dlg_export_title")); + setContentPane(this.getJContentPane()); + setModal(true); + setResizable(false); + Util.centerWindow((Window) this); + } + + /** + * This method initializes jContentPane. + * + * @return javax.swing.JPanel + */ + private JPanel getJContentPane() { + if (jContentPane == null) { + jContentPane = new JPanel(); + jContentPane.setLayout(new BorderLayout()); + jContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + jContentPane.add(getExportPanel(), BorderLayout.CENTER); + jContentPane.add(getJPanelButtonBar(), BorderLayout.SOUTH); + } + return jContentPane; + } + + /** + * This method initializes jButtonCancel. + * + * @return javax.swing.JButton + */ + private JButton getJButtonCancel() { + if (jButtonCancel == null) { + jButtonCancel = new JButton(); + jButtonCancel.setText(Internationalization.getTranslation("dlg_configuration_cancel")); + jButtonCancel.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + closeWindow(); + } + + }); + } + return jButtonCancel; + } + + /** + * This method closes the window. + */ + public void closeWindow() { + setVisible(false); + dispose(); + } + + /** + * This method returns the default filename. + * + * @return String + */ + private String getDefaultFileName() { + String path = ""; + // if a filename is already set, + // get the path and add the new filename + if (!jTextField.getText().isEmpty()) { + String oldFilename = jTextField.getText(); + path = new File(oldFilename).getParent(); + // if getParent() returns null there is no parent + if (path == null) { + path = ""; + } else { + path += File.separatorChar; + } + } + + Date now = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm"); + + String side = "_server_"; + if (jRadioButtonClient.isSelected()) { + side = "_client_"; + } + return path + "export" + side + dateFormat.format(now) + ".rec"; + } + + /** + * This method initializes jButtonOk. + * + * @return javax.swing.JButton + */ + private JButton getJButtonOk() { + if (jButtonOk == null) { + jButtonOk = new JButton(); + jButtonOk.setText(Internationalization.getTranslation("dlg_configuration_ok")); + jButtonOk.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent e) { + myController.exportHistory(getDirection(), getFilename()); + closeWindow(); + } + }); + } + return jButtonOk; + } + + /** + * This Method returns the chosen filename from the text field. + * + * @return String + */ + private String getFilename() { + return jTextField.getText(); + } + + /** + * This method returns the selected direction from the radio group. + * + * @return Direction + */ + private Direction getDirection() { + if (jRadioButtonClient.isSelected()) { + return Direction.ClientToServer; + } else { + return Direction.ServerToClient; + } + } + + /** + * This method initializes jPanelButtonBar. + * + * @return javax.swing.JPanel + */ + private JPanel getJPanelButtonBar() { + if (jPanelButtonBar == null) { + jPanelButtonBar = new JPanel(); + jPanelButtonBar.setLayout(new BoxLayout(jPanelButtonBar, BoxLayout.LINE_AXIS)); + jPanelButtonBar.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); + jPanelButtonBar.setAlignmentX(Component.RIGHT_ALIGNMENT); + jPanelButtonBar.add(Box.createHorizontalGlue()); + jPanelButtonBar.add(getJButtonOk()); + jPanelButtonBar.add(Box.createRigidArea(new Dimension(10, 0))); + jPanelButtonBar.add(getJButtonCancel()); + } + return jPanelButtonBar; + } + + /** + * This method opens a file chooser dialog and evaluates the result. + * If a valid file is chosen, the local variable <code>myFilename</code> is updated and + * the method <code>setRecordingFile()</code> of the RecordingPlugin is called. + * + * @param event Event + */ + private void jButtonOpenFileChooserActionPerformed(java.awt.event.ActionEvent event) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); + fileChooser.setDialogTitle(Internationalization.getTranslation("dlg_export_save_dialog_title")); + fileChooser.setSelectedFile(new File(getDefaultFileName())); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + + if (fileChooser.showSaveDialog(myParent) == JFileChooser.APPROVE_OPTION) { + File file = fileChooser.getSelectedFile(); + jTextField.setText(file.getAbsolutePath()); + } + } + + /** + * This method initializes jPanelExport. + * + * @return javax.swing.JPanel + */ + private JPanel getExportPanel() { + if (jPanelExport == null) { + jPanelExport = new JPanel(); + + buttonGroup.add(jRadioButtonClient); + jRadioButtonClient.setSelected(true); + jRadioButtonClient.setText(Internationalization.getTranslation("dlg_export_radio_client")); + jRadioButtonClient.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField.setText(getDefaultFileName()); + } + }); + + buttonGroup.add(jRadioButtonServer); + jRadioButtonServer.setText(Internationalization.getTranslation("dlg_export_radio_server")); + jRadioButtonServer.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jTextField.setText(getDefaultFileName()); + } + }); + + jLabel.setText(Internationalization.getTranslation("dlg_export_label_file") + ':'); + jTextField.setText(getDefaultFileName()); + jButton.setText("..."); + jButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButtonOpenFileChooserActionPerformed(evt); + } + }); + + GroupLayout layout = new GroupLayout(jPanelExport); + jPanelExport.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel) + .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) + .addComponent(jRadioButtonClient) + .addComponent(jRadioButtonServer) + .addGroup(layout.createSequentialGroup() + .addComponent(jTextField, GroupLayout.DEFAULT_SIZE, Byte.MAX_VALUE * 3, Short.MAX_VALUE) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jButton))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup() + .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE) + .addComponent(jLabel) + .addComponent(jButton) + .addComponent(jTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jRadioButtonClient) + .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jRadioButtonServer)) + ); + } + return jPanelExport; + } +} Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/IMainController.java 2008-04-06 13:54:38 UTC (rev 106) @@ -25,7 +25,9 @@ package de.dlr.davinspector.ui; +import de.dlr.davinspector.common.Constant.Direction; + /** * This is the interface of the controller. * @@ -77,4 +79,12 @@ * @param id Integer */ void loadMessage(Integer id); + + /** + * Export the message history of one side (client or server) to a file. + * + * @param direction Direction + * @param filename String + */ + void exportHistory(Direction direction, String filename); } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainController.java 2008-04-06 13:54:38 UTC (rev 106) @@ -25,6 +25,7 @@ package de.dlr.davinspector.ui; +import de.dlr.davinspector.common.Constant.Direction; import de.dlr.davinspector.configuration.Configuration; import de.dlr.davinspector.relay.IRelayModel; @@ -53,6 +54,7 @@ myView = new MainView(this, myRelay); // Init view myView.disableSendToActions(); + myView.disableExportAction(); } /** @@ -63,6 +65,7 @@ public void enableRelay() { Configuration config = new Configuration(); myRelay.startRelay(config); + myView.enableExportAction(); // enable sendTo-Actions only if automode is not active if (myRelay.isAutomodeActive()) { myView.disableSendToActions(); @@ -145,4 +148,13 @@ public void loadMessage(Integer id) { myRelay.loadMessageById(id); } + + /** + * {@inheritDoc} + * + * @see de.dlr.davinspector.ui.IMainController#exportHistory(de.dlr.davinspector.common.Constant.Direction, java.lang.String) + */ + public void exportHistory(Direction direction, String filename) { + myRelay.exportHistory(direction, filename); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/MainView.java 2008-04-06 13:54:38 UTC (rev 106) @@ -45,6 +45,7 @@ import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JSeparator; import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.JTable; @@ -162,15 +163,18 @@ /** Menu item "about". */ private JMenuItem jMenuItemAbout = null; - /** Plugin menu. */ - private JMenu jMenuPlugins = null; - /** Menu item "configure plugins". */ private JMenuItem jMenuItemConfigurePlugins = null; + /** Menu item export. */ + private JMenuItem jMenuItemExport = null; + /** Configuration dialog. */ private ConfigurationDialog myConfigDialog = null; + /** Export dialog. */ + private ExportDialog myExportDialog = null; + /** Plugin configuration dialog. */ private PluginConfigurationDialog myPluginConfigurationDialog = null; @@ -434,6 +438,25 @@ } }; + /** + * Action: Export history. + */ + private Action exportAction = new AbstractAction() { + static final long serialVersionUID = 1L; + { + putValue(Action.NAME, Internationalization.getTranslation("ac_export")); + putValue(Action.SHORT_DESCRIPTION, Internationalization.getTranslation("ac_export_description")); + putValue(Action.SMALL_ICON, UIResource.getIcon(UIResource.ICON_EXPORT)); + } + + public void actionPerformed(ActionEvent e) { + if (myExportDialog == null) { + myExportDialog = new ExportDialog(jFrame, myController); + } + myExportDialog.setVisible(true); + } + }; + /** * Constructor of MainView. Initializes the GUI elements, * loads the plugins and registers listeners. @@ -692,7 +715,6 @@ jJMenuBar = new JMenuBar(); jJMenuBar.add(getJMenuFile()); jJMenuBar.add(getJMenuView()); - jJMenuBar.add(getJMenuPlugins()); jJMenuBar.add(getJMenuHelp()); } return jJMenuBar; @@ -708,6 +730,10 @@ jMenuFile = new JMenu(); jMenuFile.setText(Internationalization.getTranslation("menu_file")); jMenuFile.add(getJMenuItemConfigure()); + jMenuFile.add(getJMenuItemConfigurePlugins()); + jMenuFile.add(new JSeparator()); + jMenuFile.add(getJMenuItemExport()); + jMenuFile.add(new JSeparator()); jMenuFile.add(getJMenuItemExit()); } return jMenuFile; @@ -817,20 +843,6 @@ } /** - * This method initializes jMenuPlugins. - * - * @return javax.swing.JMenu - */ - private JMenu getJMenuPlugins() { - if (jMenuPlugins == null) { - jMenuPlugins = new JMenu(); - jMenuPlugins.setText(Internationalization.getTranslation("menu_plugins")); - jMenuPlugins.add(getJMenuItemConfigurePlugins()); - } - return jMenuPlugins; - } - - /** * This method initializes jMenuItemConfigurePlugins. * * @return javax.swing.JMenuItem. @@ -841,6 +853,18 @@ } return jMenuItemConfigurePlugins; } + + /** + * This method initializes jMenuItemExport. + * + * @return javax.swing.JMenuItem. + */ + private JMenuItem getJMenuItemExport() { + if (jMenuItemExport == null) { + jMenuItemExport = new JMenuItem(exportAction); + } + return jMenuItemExport; + } /** * This method initializes jSplitPaneHorizontal. @@ -1058,4 +1082,18 @@ sendToClientAction.setEnabled(false); sendToServerAction.setEnabled(false); } + + /** + * Enable the export menu item. + */ + public void enableExportAction() { + exportAction.setEnabled(true); + } + + /** + * Disable the export menu item. + */ + public void disableExportAction() { + exportAction.setEnabled(false); + } } Modified: trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java =================================================================== --- trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-04-05 15:46:01 UTC (rev 105) +++ trunk/DAVInspector/src/de/dlr/davinspector/ui/UIResource.java 2008-04-06 13:54:38 UTC (rev 106) @@ -97,6 +97,9 @@ /** */ public static final String ICON_SAVEAS = "filesaveas.png"; + /** */ + public static final String ICON_EXPORT = "fileexport.png"; + /** This hash map is used to cache the ImageIcons. */ private static final Map<String, ImageIcon> RESOURCE_MAP = new HashMap<String, ImageIcon>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |