PageRenderTime 42ms CodeModel.GetById 20ms app.highlight 5ms RepoModel.GetById 15ms app.codeStats 0ms

/src/mpv5/db/objects/ProductList.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 105 lines | 59 code | 14 blank | 32 comment | 3 complexity | aa93433809762cf1c24adfb2fd9b43fa MD5 | raw file
  1/*
  2 *  This file is part of YaBS.
  3 *
  4 *      YaBS is free software: you can redistribute it and/or modify
  5 *      it under the terms of the GNU General Public License as published by
  6 *      the Free Software Foundation, either version 3 of the License, or
  7 *      (at your option) any later version.
  8 *
  9 *      YaBS is distributed in the hope that it will be useful,
 10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 *      GNU General Public License for more details.
 13 *
 14 *      You should have received a copy of the GNU General Public License
 15 *      along with YaBS.  If not, see <http://www.gnu.org/licenses/>.
 16 */
 17package mpv5.db.objects;
 18
 19import java.math.BigDecimal;
 20import java.util.ArrayList;
 21import java.util.logging.Level;
 22import java.util.logging.Logger;
 23import javax.swing.JComponent;
 24
 25import mpv5.db.common.Context;
 26import mpv5.db.common.DatabaseObject;
 27import mpv5.db.common.QueryCriteria;
 28import mpv5.db.common.QueryHandler;
 29import mpv5.logging.Log;
 30import mpv5.ui.panels.ProductListsPanel;
 31import mpv5.utils.images.MPIcon;
 32
 33/**
 34 *
 35 * 
 36 */
 37public class ProductList extends DatabaseObject {
 38
 39    private String description;
 40    private boolean asproduct = false;
 41
 42    public ProductList() {
 43        setContext(Context.getProductlist());
 44    }
 45
 46    @Override
 47    public JComponent getView() {
 48        return new ProductListsPanel();
 49    }
 50
 51    @Override
 52    public mpv5.utils.images.MPIcon getIcon() {
 53        return new MPIcon("/mpv5/resources/images/22/playlist.png");
 54    }
 55
 56    /**
 57     * @return the description
 58     */
 59    public String __getDescription() {
 60        return description;
 61    }
 62
 63    /**
 64     * @param description the description to set
 65     */
 66    public void setDescription(String description) {
 67        this.description = description;
 68    }
 69
 70    /**
 71     * @return the asproduct
 72     */
 73    public boolean __isAsproduct() {
 74        return asproduct;
 75    }
 76
 77    /**
 78     * @param asproduct the asproduct to set
 79     */
 80    public void setAsproduct(boolean asproduct) {
 81        this.asproduct = asproduct;
 82    }
 83
 84    @Override
 85    public boolean delete() {
 86        QueryCriteria c = new QueryCriteria("productlistsids", __getIDS());
 87        if (asproduct) {
 88            try {
 89                QueryHandler.instanceOf().clone(Context.getProduct()).delete(c);
 90            } catch (Exception ex) {
 91                Log.Debug(ex);
 92            }
 93        }
 94        return super.delete();
 95    }
 96
 97    @Override
 98    public boolean save(boolean b) {
 99        if (getCname().length() == 0) {
100            setCname("<unnamed>");
101        }
102        return super.save(b);
103    }
104
105}