OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Blame | Last modification | View Log | RSS feed

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
 * 
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing the software, include this License Header Notice in each file.
 */
 
 package org.openconcerto.erp.core.supplychain.order.ui;

import org.openconcerto.utils.i18n.TranslationManager;

import java.awt.Color;
import java.util.HashMap;
import java.util.Map;

public enum EtatCommandeFournisseur {

    BROUILLON(1, "supplychain.order.state.waiting", Color.RED), EN_ATTENTE(2, "supplychain.order.state.running", Color.WHITE), EN_RECEPTION(3, "supplychain.order.state.toReceipt",
            Color.BLUE), RECEPTION_PARTIEL(4, "supplychain.supplychain.state.receipt.partial", Color.ORANGE), RECEPTIONNEE(5, "supplychain.order.state.receipt",
                    Color.GREEN), LITIGE(6, "supplychain.order.state.block", Color.RED), ANNULEE(7, "supplychain.order.state.cancelled", Color.GRAY);

    private final int id;
    private final String translationID;
    private final Color color;

    private EtatCommandeFournisseur(int id, String translationID, Color color) {
        this.id = id;
        this.translationID = translationID;
        this.color = color;
    }

    public int getId() {
        return id;
    }

    public String getTranslationID() {
        return translationID;
    }

    public String getTranslation() {
        final String translationForItem = TranslationManager.getInstance().getTranslationForItem(translationID);

        return (translationForItem == null || translationForItem.trim().length() == 0) ? translationID : translationForItem;
    }

    private static final Map<Integer, EtatCommandeFournisseur> idToEnum = new HashMap<Integer, EtatCommandeFournisseur>();
    static {
        for (EtatCommandeFournisseur e : values())
            idToEnum.put(e.getId(), e);
    }

    public static EtatCommandeFournisseur fromID(int id) {
        return idToEnum.get(id);
    }

    @Override
    public String toString() {
        return getTranslation();
    }

    public Color getColor() {
        return color;
    }
}