001
002 /*****************************************************************************
003
004 jBudget.
005 Copyright (C) 2006 Dmitri Petrov
006
007 This program is free software: you can redistribute it and/or modify
008 it under the terms of the GNU General Public License as published by
009 the Free Software Foundation, either version 3 of the License, or
010 (at your option) any later version.
011
012 This program is distributed in the hope that it will be useful,
013 but WITHOUT ANY WARRANTY; without even the implied warranty of
014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015 GNU General Public License for more details.
016
017 You should have received a copy of the GNU General Public License
018 along with this program. If not, see <http://www.gnu.org/licenses/>.
019
020 /*****************************************************************************
021
022 /*
023 * CategoryRemoveDialog.java
024 *
025 * Created on April 6, 2006, 3:06 PM
026 */
027
028 package org.jbudget.gui.budget;
029
030 import java.awt.BorderLayout;
031 import org.jbudget.gui.BasicDialog;
032
033 /**
034 * Creates a dialog that confirms the removal of a Budget Category and,
035 * if necessary, asks how the subcategories and allocations should be
036 * treated.
037 *
038 * @author petrov
039 */
040 public class CategoryRemoveDialog extends BasicDialog
041 {
042 /** True if the subdirectories should be removed. */
043 boolean recursive = true;
044 /** If true the allocations will be removed */
045 boolean removeAllocations = true;
046 /** If true the allocations will be transfered to the parent of the
047 * current subcategory */
048 boolean inheritAllocations = false;
049
050 private CategoryRemovePanel panel = new CategoryRemovePanel();
051
052 /** Creates a new instance of CategoryRemoveDialog
053 * @param parent the parent window of this dialog.
054 * @param name name of the category that will be displayed in the title
055 * string of the dialog.
056 */
057 public CategoryRemoveDialog(java.awt.Frame parent, String name)
058 {
059 super(parent, false);
060 setTitle("Remove Budget Category");
061
062 inputPanel.add(panel,BorderLayout.CENTER);
063 panel.titleLabel.setText("Remove Budget Category '" + name + "'");
064
065 pack();
066
067 if (parent != null)
068 {
069 setLocation(parent.getX() + parent.getWidth()/2 - getWidth()/2,
070 parent.getY() + parent.getHeight()/2 - getHeight()/2);
071 }
072
073 setVisible(true);
074 }
075
076 /** Executed when the OK button is pressed */
077 protected boolean okAction()
078 {
079 recursive = panel.removeSubRB.isSelected();
080 removeAllocations = panel.removeAllocRB.isSelected();
081 inheritAllocations = panel.promoteAllocRB.isSelected();
082 return true;
083 }
084
085 }