From a772737e953ac9c79194e67478761cd9c2e0e43d Mon Sep 17 00:00:00 2001 From: Valentin Martinet Date: Mon, 21 Dec 2009 21:06:08 +0000 Subject: [PATCH] Implements SipCommFileFilter in the Whiteboard plugin. The Mac OS X save file dialog is now used. Deleted warnings and corrected lines > 80 characters. --- .../gui/main/chat/toolBars/MainToolBar.java | 1 + .../contactlist/ContactRightButtonMenu.java | 1 + .../accountinfo/AccountDetailsPanel.java | 9 +- .../NotificationConfigurationPanel.java | 11 +- .../plugin/pluginmanager/NewBundleDialog.java | 8 +- .../plugin/sshaccregwizz/FirstWizardPage.java | 10 +- .../whiteboard/gui/WhiteboardFileFilter.java | 5 +- .../whiteboard/gui/WhiteboardFrame.java | 111 ++++++++++++------ .../util/swing/GenericFileDialog.java | 30 ++++- .../util/swing/SipCommFileChooser.java | 7 ++ .../util/swing/SipCommFileChooserImpl.java | 10 ++ .../util/swing/SipCommFileDialogImpl.java | 22 ++-- 12 files changed, 155 insertions(+), 70 deletions(-) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index df7fa0357..18683e08b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -215,6 +215,7 @@ else if (buttonText.equals("sendFile")) { SipCommFileChooser scfc = GenericFileDialog.create( null, "Send file...", + SipCommFileChooser.LOAD_FILE_OPERATION, ConfigurationManager.getSendFileLastDir()); File selectedFile = scfc.getFileFromDialog(); if(selectedFile != null) diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java index bee11576f..4e3d56f46 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactRightButtonMenu.java @@ -525,6 +525,7 @@ public void run() SipCommFileChooser scfc = GenericFileDialog.create( null, "Send file...", + SipCommFileChooser.LOAD_FILE_OPERATION, ConfigurationManager.getSendFileLastDir()); File selectedFile = scfc.getFileFromDialog(); if(selectedFile != null) diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountDetailsPanel.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountDetailsPanel.java index 1b2118b1d..d09d556e2 100644 --- a/src/net/java/sip/communicator/plugin/accountinfo/AccountDetailsPanel.java +++ b/src/net/java/sip/communicator/plugin/accountinfo/AccountDetailsPanel.java @@ -14,7 +14,6 @@ import javax.imageio.*; import javax.swing.*; import javax.swing.event.*; -import javax.swing.filechooser.FileFilter; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.ServerStoredDetails.*; @@ -31,7 +30,9 @@ public class AccountDetailsPanel extends TransparentPanel { - private Logger logger = Logger.getLogger(AccountDetailsPanel.class); + private static final long serialVersionUID = 5524135388175045624L; + + private Logger logger = Logger.getLogger(AccountDetailsPanel.class); /** * The operation set giving access to the server stored account details. @@ -661,7 +662,9 @@ private class ChangeAvatarActionListener implements ActionListener public void actionPerformed(ActionEvent e) { SipCommFileChooser chooser = GenericFileDialog.create( - null, "Change avatar...", lastAvatarDir.getAbsolutePath()); + null, "Change avatar...", + SipCommFileChooser.LOAD_FILE_OPERATION, + lastAvatarDir.getAbsolutePath()); chooser.addFilter(new ImageFilter()); File file = chooser.getFileFromDialog(); diff --git a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java index 96e4eb672..fa7e7c1e2 100644 --- a/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java +++ b/src/net/java/sip/communicator/plugin/notificationconfiguration/NotificationConfigurationPanel.java @@ -36,7 +36,9 @@ public class NotificationConfigurationPanel DocumentListener, NotificationChangeListener { - private final Logger logger + private static final long serialVersionUID = 5784331951722787598L; + + private final Logger logger = Logger.getLogger(NotificationConfigurationPanel.class); // Declaration of variables on the table notifications @@ -321,9 +323,10 @@ public NotificationConfigurationPanel() this.setLayout(gridLayoutGlobal); - fileChooserSound = GenericFileDialog.create(null, "Choose a sound..."); - fileChooserProgram = GenericFileDialog.create( - null, "Choose a program..."); + fileChooserSound = GenericFileDialog.create(null, "Choose a sound...", + SipCommFileChooser.LOAD_FILE_OPERATION); + fileChooserProgram = GenericFileDialog.create(null, + "Choose a program...", SipCommFileChooser.LOAD_FILE_OPERATION); //fileChooserSound.setMultiSelectionEnabled(false); //fileChooserProgram.setMultiSelectionEnabled(false); fileChooserSound.addFilter(new SoundFilter()); diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/NewBundleDialog.java b/src/net/java/sip/communicator/plugin/pluginmanager/NewBundleDialog.java index 05a25640d..68a052457 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/NewBundleDialog.java +++ b/src/net/java/sip/communicator/plugin/pluginmanager/NewBundleDialog.java @@ -21,8 +21,9 @@ public class NewBundleDialog extends SIPCommDialog implements ActionListener -{ - private JButton installButton +{private static final long serialVersionUID = 7638976584338100969L; + + private JButton installButton = new JButton(Resources.getString("plugin.pluginmanager.INSTALL")); private JButton cancelButton @@ -102,7 +103,8 @@ public void actionPerformed (ActionEvent e) else if (sourceButton.equals(fileChooserButton)) { SipCommFileChooser chooser = GenericFileDialog.create( - null, "New bundle..."); + null, "New bundle...", + SipCommFileChooser.LOAD_FILE_OPERATION); File newBundleFile = chooser.getFileFromDialog(); diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java index 67cf4d034..4c41f8185 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java @@ -34,7 +34,9 @@ public class FirstWizardPage extends TransparentPanel implements WizardPage, DocumentListener { - public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; + private static final long serialVersionUID = 8576006544813706541L; + + public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; private JPanel accountPanel = new TransparentPanel(new BorderLayout(10, 10)); @@ -213,7 +215,8 @@ private void init() public void actionPerformed(ActionEvent event) { identityFileChooser = GenericFileDialog.create( - null, "Select Identify File"); + null, "Select Identify File", + SipCommFileChooser.LOAD_FILE_OPERATION); File f = identityFileChooser.getFileFromDialog(); if(f != null) @@ -227,7 +230,8 @@ public void actionPerformed(ActionEvent event) public void actionPerformed(ActionEvent event) { knownHostsFileChooser = GenericFileDialog.create( - null, "Select SSH Known Hosts File"); + null, "Select SSH Known Hosts File", + SipCommFileChooser.LOAD_FILE_OPERATION); File f = knownHostsFileChooser.getFileFromDialog(); if(f != null) diff --git a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java index ed0d305cc..739838791 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFileFilter.java @@ -8,14 +8,15 @@ package net.java.sip.communicator.plugin.whiteboard.gui; import java.io.File; -import javax.swing.filechooser.FileFilter; + +import net.java.sip.communicator.util.swing.*; /** * A simple file filter manager * * @author Julien Waechter */ -public class WhiteboardFileFilter extends FileFilter { +public class WhiteboardFileFilter extends SipCommFileFilter { /** * file extension diff --git a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFrame.java b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFrame.java index fd341488e..d95bf0fb4 100644 --- a/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFrame.java +++ b/src/net/java/sip/communicator/plugin/whiteboard/gui/WhiteboardFrame.java @@ -29,11 +29,14 @@ * The frame for the Whiteboard * * @author Julien Waechter + * @author Valentin Martinet */ public class WhiteboardFrame extends SIPCommFrame { - private static final Logger logger = + private static final long serialVersionUID = 5441329948483907247L; + + private static final Logger logger = Logger.getLogger(WhiteboardFrame.class); /** @@ -215,7 +218,8 @@ public class WhiteboardFrame /** * List of WhiteboardShape */ - private List displayList = new CopyOnWriteArrayList(); + private List displayList = + new CopyOnWriteArrayList(); /** * Aarray of WhiteboardPoint @@ -694,8 +698,8 @@ else if (shape.getSelectionPoint(s2w.transform(e if (currentTool == MODIF) { - setCursor(Cursor - .getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + setCursor(Cursor.getPredefinedCursor( + Cursor.CROSSHAIR_CURSOR)); if (preselected == null) { @@ -854,7 +858,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) jToolBar1.add(jButtonSave); - jButtonOpen.setToolTipText(Resources.getString("plugin.whiteboard.OPEN")); + jButtonOpen.setToolTipText( + Resources.getString("plugin.whiteboard.OPEN")); jButtonOpen.setEnabled(false); jToolBar1.add(jButtonOpen); @@ -875,7 +880,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 8)); buttonGroup.add(selectionButton); - selectionButton.setToolTipText(Resources.getString("plugin.whiteboard.SELECT")); + selectionButton.setToolTipText( + Resources.getString("plugin.whiteboard.SELECT")); selectionButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -887,7 +893,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(selectionButton); buttonGroup.add(modifButton); - modifButton.setToolTipText(Resources.getString("plugin.whiteboard.MODIFICATION")); + modifButton.setToolTipText( + Resources.getString("plugin.whiteboard.MODIFICATION")); modifButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -923,7 +930,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(textButton); buttonGroup.add(lineButton); - lineButton.setToolTipText(Resources.getString("plugin.whiteboard.LINE")); + lineButton.setToolTipText( + Resources.getString("plugin.whiteboard.LINE")); lineButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -935,7 +943,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(lineButton); buttonGroup.add(polylineButton); - polylineButton.setToolTipText(Resources.getString("plugin.whiteboard.POLYLINE")); + polylineButton.setToolTipText( + Resources.getString("plugin.whiteboard.POLYLINE")); polylineButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -959,7 +968,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(rectangleButton); buttonGroup.add(fillRectangleButton); - fillRectangleButton.setToolTipText(Resources.getString("plugin.whiteboard.FILLED_RECTANGLE")); + fillRectangleButton.setToolTipText( + Resources.getString("plugin.whiteboard.FILLED_RECTANGLE")); fillRectangleButton .addActionListener(new java.awt.event.ActionListener() { @@ -972,7 +982,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(fillRectangleButton); buttonGroup.add(imageButton); - imageButton.setToolTipText(Resources.getString("plugin.whiteboard.IMAGE")); + imageButton.setToolTipText( + Resources.getString("plugin.whiteboard.IMAGE")); imageButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -984,7 +995,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(imageButton); buttonGroup.add(polygonButton); - polygonButton.setToolTipText(Resources.getString("plugin.whiteboard.POLYGON")); + polygonButton.setToolTipText( + Resources.getString("plugin.whiteboard.POLYGON")); polygonButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -996,7 +1008,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(polygonButton); buttonGroup.add(fillPolygonButton); - fillPolygonButton.setToolTipText(Resources.getString("plugin.whiteboard.FILLEDPOLYGON")); + fillPolygonButton.setToolTipText( + Resources.getString("plugin.whiteboard.FILLEDPOLYGON")); fillPolygonButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -1008,7 +1021,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(fillPolygonButton); buttonGroup.add(circleButton); - circleButton.setToolTipText(Resources.getString("plugin.whiteboard.CIRCLE")); + circleButton.setToolTipText( + Resources.getString("plugin.whiteboard.CIRCLE")); circleButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -1020,7 +1034,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(circleButton); buttonGroup.add(fillCircleButton); - fillCircleButton.setToolTipText(Resources.getString("plugin.whiteboard.FILLED_CIRCLE")); + fillCircleButton.setToolTipText( + Resources.getString("plugin.whiteboard.FILLED_CIRCLE")); fillCircleButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -1031,7 +1046,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) toolBar.add(fillCircleButton); - colorChooserButton.setToolTipText(Resources.getString("plugin.whiteboard.COLOR")); + colorChooserButton.setToolTipText( + Resources.getString("plugin.whiteboard.COLOR")); colorChooserButton .addActionListener(new java.awt.event.ActionListener() { @@ -1052,7 +1068,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) jPanel2.setLayout(new GridBagLayout()); - jLabelThickness.setText(Resources.getString("plugin.whiteboard.THICKNESS")); + jLabelThickness.setText( + Resources.getString("plugin.whiteboard.THICKNESS")); jPanel2.add(jLabelThickness); @@ -1131,7 +1148,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) editMenu.add(gridMenuItem); - deselectMenuItem.setText(Resources.getString("plugin.whiteboard.DESELECT")); + deselectMenuItem.setText( + Resources.getString("plugin.whiteboard.DESELECT")); deselectMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) @@ -1163,7 +1181,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) editMenu.add(deleteMenuItem); - propertiesMenuItem.setText(Resources.getString("plugin.whiteboard.PROPERTIES")); + propertiesMenuItem.setText( + Resources.getString("plugin.whiteboard.PROPERTIES")); propertiesMenuItem.setEnabled(false); editMenu.add(propertiesMenuItem); @@ -1203,22 +1222,28 @@ private void modifButtonActionPerformed(java.awt.event.ActionEvent evt) private void jButtonSaveActionPerformed(java.awt.event.ActionEvent evt) { - JFileChooser chooser = new JFileChooser(lastDir); - chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter()); + SipCommFileChooser chooser = GenericFileDialog.create( + WhiteboardFrame.this, + "Save file...", + SipCommFileChooser.SAVE_FILE_OPERATION); + + //chooser.removeChoosableFileFilter(chooser.getAcceptAllFileFilter()); WhiteboardFileFilter filterJpg = new WhiteboardFileFilter("jpg", "JPEG Files (*.jpg)"); WhiteboardFileFilter filterPng = new WhiteboardFileFilter("png", "PNG Files (*.png)"); - chooser.setFileFilter(filterJpg); - chooser.addChoosableFileFilter(filterPng); - int returnVal = chooser.showSaveDialog(WhiteboardFrame.this); - if (returnVal == JFileChooser.APPROVE_OPTION) + + chooser.addFilter(filterJpg); + chooser.addFilter(filterPng); + + File file = chooser.getFileFromDialog(); + + if (file != null) { try { - File file = chooser.getSelectedFile(); WhiteboardFileFilter ff = - (WhiteboardFileFilter) chooser.getFileFilter(); + (WhiteboardFileFilter) chooser.getUsedFilter(); if (!ff.getExtension().equals(ff.getExtension(file))) { file = @@ -1267,7 +1292,8 @@ private void deselectMenuItemActionPerformed(java.awt.event.ActionEvent evt) * * @param evt */ - private void jSpinnerThicknessStateChanged(javax.swing.event.ChangeEvent evt) + private void jSpinnerThicknessStateChanged( + javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_jSpinnerThicknessStateChanged if (selectedShape != null) { @@ -1282,7 +1308,8 @@ private void jSpinnerThicknessStateChanged(javax.swing.event.ChangeEvent evt) * * @param evt */ - private void fillCircleButtonActionPerformed(java.awt.event.ActionEvent evt) + private void fillCircleButtonActionPerformed( + java.awt.event.ActionEvent evt) {// GEN-FIRST:event_fillCircleButtonActionPerformed if (fillCircleButton.isSelected()) currentTool = FILL_CIRCLE; @@ -1315,7 +1342,8 @@ private void polylineButtonActionPerformed(java.awt.event.ActionEvent evt) * * @param evt */ - private void fillPolygonButtonActionPerformed(java.awt.event.ActionEvent evt) + private void fillPolygonButtonActionPerformed( + java.awt.event.ActionEvent evt) {// GEN-FIRST:event_fillPolygonButtonActionPerformed if (fillPolygonButton.isSelected()) currentTool = FILL_POLYGON; @@ -1627,8 +1655,9 @@ private void rectangleOperation(MouseEvent e) * * @param e */ - /* not sure why this is here but it's never used. i am not deleting it though - * in case we decide to revive the whiteboard one day. and this appears necessary + /* not sure why this is here but it's never used. i am not deleting it + * though in case we decide to revive the whiteboard one day. and this + * appears necessary private void ellipseOperation(MouseEvent e) { Graphics g = drawCanvas.getGraphics(); @@ -2019,16 +2048,21 @@ private void releasedImage() { doneDrawing = true; - JFileChooser chooser = new JFileChooser(lastDir); + SipCommFileChooser chooser = GenericFileDialog.create( + WhiteboardFrame.this, + "Choose image...", + SipCommFileChooser.LOAD_FILE_OPERATION); + + File file = chooser.getFileFromDialog(); WhiteboardFileFilter filter = new WhiteboardFileFilter("jpg", "JPEG Files (*.jpg)"); - chooser.setFileFilter(filter); - int returnVal = chooser.showOpenDialog(WhiteboardFrame.this); - if (returnVal == JFileChooser.APPROVE_OPTION) + + chooser.addFilter(filter); + + if (file != null) { try { - File file = chooser.getSelectedFile(); lastDir = file.getParentFile(); FileInputStream in = new FileInputStream(file); byte buffer[] = new byte[in.available()]; @@ -2122,7 +2156,8 @@ private void releasedText(int x, int y) String t = (String) JOptionPane.showInputDialog(this, - "Please enter your text", "plugin.whiteboard.TEXT", JOptionPane.QUESTION_MESSAGE, + "Please enter your text", "plugin.whiteboard.TEXT", + JOptionPane.QUESTION_MESSAGE, null, null, "plugin.whiteboard.TEXT"); if (t != null && t.length() > 0) diff --git a/src/net/java/sip/communicator/util/swing/GenericFileDialog.java b/src/net/java/sip/communicator/util/swing/GenericFileDialog.java index 36b7a34de..87647e86d 100644 --- a/src/net/java/sip/communicator/util/swing/GenericFileDialog.java +++ b/src/net/java/sip/communicator/util/swing/GenericFileDialog.java @@ -29,11 +29,28 @@ public class GenericFileDialog * @param title dialog's title * @return SipCommFileChooser an implementation of SipCommFileChooser */ - public static SipCommFileChooser create(Frame parent, String title) + public static SipCommFileChooser create( + Frame parent, String title, int fileOperation) { + if(OSUtils.IS_MAC) { - return new SipCommFileDialogImpl(parent, title); + int operation = -1; + if(fileOperation == SipCommFileChooser.LOAD_FILE_OPERATION) + operation = FileDialog.LOAD; + else if(fileOperation == SipCommFileChooser.SAVE_FILE_OPERATION) + operation = FileDialog.SAVE; + else + try + { + throw new Exception("UnknownFileOperation"); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return new SipCommFileDialogImpl(parent, title, operation); } else { @@ -51,10 +68,13 @@ public static SipCommFileChooser create(Frame parent, String title) * @return SipCommFileChooser an implementation of SipCommFileChooser */ public static SipCommFileChooser create( - Frame parent, String title, String path) + Frame parent, String title, int fileOperation, String path) { - SipCommFileChooser scfc = GenericFileDialog.create(parent, title); - scfc.setStartPath(path); + SipCommFileChooser scfc = + GenericFileDialog.create(parent, title, fileOperation); + + if(path != null) + scfc.setStartPath(path); return scfc; } diff --git a/src/net/java/sip/communicator/util/swing/SipCommFileChooser.java b/src/net/java/sip/communicator/util/swing/SipCommFileChooser.java index 9f21ae615..b71f70701 100644 --- a/src/net/java/sip/communicator/util/swing/SipCommFileChooser.java +++ b/src/net/java/sip/communicator/util/swing/SipCommFileChooser.java @@ -62,4 +62,11 @@ public interface SipCommFileChooser * @param filter the filter to add */ public void addFilter(SipCommFileFilter filter); + + /** + * Returns the filter the user has chosen for saving a file. + * + * @return SipCommFileFilter the used filter when saving a file + */ + public SipCommFileFilter getUsedFilter(); } diff --git a/src/net/java/sip/communicator/util/swing/SipCommFileChooserImpl.java b/src/net/java/sip/communicator/util/swing/SipCommFileChooserImpl.java index e0fe25538..fe676379f 100644 --- a/src/net/java/sip/communicator/util/swing/SipCommFileChooserImpl.java +++ b/src/net/java/sip/communicator/util/swing/SipCommFileChooserImpl.java @@ -152,4 +152,14 @@ public void addFilter(SipCommFileFilter filter) { this.addChoosableFileFilter(filter); } + + /** + * Returns the filter the user has chosen for saving a file. + * + * @return SipCommFileFilter the used filter when saving a file + */ + public SipCommFileFilter getUsedFilter() + { + return (SipCommFileFilter)this.getFileFilter(); + } } diff --git a/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java b/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java index fa5caae27..a9de6b35a 100644 --- a/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java +++ b/src/net/java/sip/communicator/util/swing/SipCommFileDialogImpl.java @@ -42,18 +42,6 @@ public SipCommFileDialogImpl(Frame parent, String title) public SipCommFileDialogImpl(Frame parent, String title, int fileOperation) { super(parent, title, fileOperation); - if(fileOperation != SipCommFileChooser.LOAD_FILE_OPERATION - || fileOperation != SipCommFileChooser.SAVE_FILE_OPERATION) - { - try - { - throw new Exception("UnknownFileOperation"); - } - catch (Exception e) - { - e.printStackTrace(); - } - } } /** @@ -104,4 +92,14 @@ public void addFilter(SipCommFileFilter filter) { this.setFilenameFilter(filter); } + + /** + * Returns the filter the user has chosen for saving a file. + * + * @return SipCommFileFilter the used filter when saving a file + */ + public SipCommFileFilter getUsedFilter() + { + return (SipCommFileFilter)this.getFilenameFilter(); + } }