Author: echatellier Date: 2012-05-16 17:50:57 +0200 (Wed, 16 May 2012) New Revision: 3430 Url: http://chorem.org/repositories/revision/lima/3430 Log: Remove another "helper" class. Removed: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2012-05-16 14:25:36 UTC (rev 3429) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2012-05-16 15:50:57 UTC (rev 3430) @@ -27,7 +27,10 @@ import static org.nuiton.i18n.I18n._; +import java.awt.Component; + import javax.swing.JOptionPane; +import javax.swing.JTextArea; import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; @@ -41,8 +44,9 @@ import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.importexport.ImportExport; -import org.chorem.lima.util.DialogHelper; +import org.chorem.lima.util.ReportDialogView; import org.jdesktop.swingx.JXTreeTable; +import org.nuiton.util.Resource; /** * Handler associated with account view. @@ -244,8 +248,26 @@ public void financialStatementChartCheck() { String result = financialStatementService.checkFinancialStatementChart(); - DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view); + showReportDialog(result, _("lima.financialstatement.check"), view); } + + /** + * Permet d'afficher une boite de dialogue avec rapport + * + * @param message + * @param parent + * @param title + */ + public void showReportDialog(String message, String title, Component parent) { + ReportDialogView reportDialogView = new ReportDialogView(); + reportDialogView.setIconImage(Resource.getIcon("icons/lima.png").getImage()); + JTextArea textArea = reportDialogView.getTextArea(); + textArea.setText(message); + reportDialogView.setSize(600, 400); + reportDialogView.setTitle(title); + reportDialogView.setLocationRelativeTo(parent); + reportDialogView.setVisible(true); + } @Override public void notifyMethod(String serviceName, String methodName) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-05-16 14:25:36 UTC (rev 3429) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-05-16 15:50:57 UTC (rev 3430) @@ -45,7 +45,6 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.util.DialogHelper; /** * Handler associated with financial transaction view. @@ -206,19 +205,12 @@ if (response == JOptionPane.YES_OPTION) { - try { - tableModel.removeObject(selectedValue, indexSelectedRow); - //select the upper line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow - 1, indexSelectedRow - 1); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't remove transaction or entry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + tableModel.removeObject(selectedValue, indexSelectedRow); + //select the upper line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow - 1, indexSelectedRow - 1); } } else { if (log.isWarnEnabled()) { @@ -238,24 +230,17 @@ int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - try { - //copy + paste the description - String description = (String) tableModel.getValueAt(indexSelectedRow, 4); - int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow + 1, indexSelectedRow + 1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add emptyentry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + //copy + paste the description + String description = (String) tableModel.getValueAt(indexSelectedRow, 4); + int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); + //select the new line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); } else { if (log.isWarnEnabled()) { log.warn("Call addentry selected transaction without selection"); @@ -282,22 +267,15 @@ if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); if (clipBoard instanceof Entry) { - try { - int index = tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow + 1, indexSelectedRow + 1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't past entry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + int index = tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); + //select the new line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); } } @@ -310,22 +288,15 @@ table = view.getFinancialTransactionSearchTable(); tableModel = view.getFinancialTransactionSearchTableModel(); - try { - int index = tableModel.addFinancialTransaction(); - //select the new line - int numberRow = table.getRowCount(); - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); - //focus on first column - table.changeSelection(index, 0, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add financialtransaction", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + int index = tableModel.addFinancialTransaction(); + //select the new line + int numberRow = table.getRowCount(); + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); + //focus on first column + table.changeSelection(index, 0, false, false); + table.requestFocusInWindow(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-05-16 14:25:36 UTC (rev 3429) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-05-16 15:50:57 UTC (rev 3430) @@ -48,7 +48,6 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.DialogHelper; import org.jdesktop.swingx.JXTable; import org.nuiton.util.DateUtil; Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2012-05-16 14:25:36 UTC (rev 3429) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2012-05-16 15:50:57 UTC (rev 3430) @@ -1,97 +0,0 @@ -/* - * #%L - * Lima Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * 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 3 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, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -package org.chorem.lima.util; - -import org.nuiton.util.Resource; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JTextArea; -import java.awt.Component; - -import static org.nuiton.i18n.I18n._; - -/** - * @author ore - * @author Rémi Chapelet - * @deprecated with no replacement, use JOptionPane directly - */ -@Deprecated -public class DialogHelper { - - /** - * Use instead: JOptionPane.showMessageDialog (String message,String titre,int type) - * <p/> - * for e.g: - * JOptionPane.showMessageDialog( - * view, - * _("lima.importexport.export.terminated"), - * _("lima.importexport.export"), - * JOptionPane.INFORMATION_MESSAGE); - * - * @param message - * @deprecated since 0.5, prefer use the method {@link #showErrorMessageDialog(Component, Throwable)} - */ - @Deprecated - public static void showMessageDialog(String message) { - JFrame f = new JFrame(); - f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JOptionPane.showMessageDialog( - f, - message, - _("lima.common.error"), - JOptionPane.ERROR_MESSAGE); - f.dispose(); - } - - public static void showErrorMessageDialog(Component view, Throwable e) { - JOptionPane.showMessageDialog( - view, - e.getMessage(), - _("lima.common.error"), - JOptionPane.ERROR_MESSAGE); - } - - /** - * Permet d'afficher une boite de dialogue avec rapport - * - * @param message - * @param parent - * @param title - */ - public static void showReportDialog(String message, String title, Component parent) { - ReportDialogView reportDialogView = new ReportDialogView(); - reportDialogView.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JTextArea textArea = reportDialogView.getTextArea(); - textArea.setText(message); - reportDialogView.setSize(600, 400); - reportDialogView.setTitle(title); - reportDialogView.setLocationRelativeTo(parent); - reportDialogView.setVisible(true); - } - - -}