Example usage for com.google.gwt.user.client.ui Label Label

List of usage examples for com.google.gwt.user.client.ui Label Label

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Label Label.

Prototype

protected Label(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void updateSummary() {
    summaryLogConsole.clear();//  w  w  w . j  a v  a 2  s  .c  om

    //
    // Refresh account selection table
    //
    summaryLog("Re-scanning accounts... " + summaryAccountTable.size() + " to " + accountTable.size());
    {
        HashMap<String, SummaryAccount> newSummaryAccountTable = new HashMap<String, SummaryAccount>();
        for (Account a : accountTable.values()) {
            SummaryAccount sa = (SummaryAccount) summaryAccountTable.get(a.acctName);
            if (sa == null) {
                sa = new SummaryAccount(a.acctName);
            }
            newSummaryAccountTable.put(a.acctName, sa);
        }
        summaryAccountTable = newSummaryAccountTable;
    }
    summaryLog("Re-scanning accounts...done " + summaryAccountTable.size() + " to " + accountTable.size());

    //
    // Refresh asset selection table
    //
    summaryLog("Re-scanning assets... " + summaryAssetTable.size() + " to " + assetTable.size());

    issueAssetTable(summaryEndDate.getValue(), null, null);
    assetTableDropSoldPositions();

    {
        HashMap<String, SummaryAsset> newSummaryAssetTable = new HashMap<String, SummaryAsset>();
        for (Asset a : assetTable.values()) {
            SummaryAsset sa = (SummaryAsset) summaryAssetTable.get(a.assetName);
            if (sa == null) {
                sa = new SummaryAsset(a.assetName);
            }
            newSummaryAssetTable.put(a.assetName, sa);
        }
        summaryAssetTable = newSummaryAssetTable;
    }
    summaryLog("Re-scanning assets...done " + summaryAssetTable.size() + " to " + assetTable.size());

    long sumDeposit = 0;
    long sumWithdraw = 0;
    long sumBalance = 0;

    //
    // Display account selections
    //
    summaryAccountGrid.clear();
    int rows = summaryAccountTable.size() + 2;
    summaryAccountGrid.resize(rows, 4);
    summaryAccountGrid.setWidget(0, 0, new Label("Conta"));
    summaryAccountGrid.setWidget(0, 1, new Label("Dep."));
    summaryAccountGrid.setWidget(0, 2, new Label("Saq."));
    summaryAccountGrid.setWidget(0, 3, new Label("Saldo"));
    int row = 1;
    for (SummaryAccount sa : summaryAccountTable.values()) {
        Account a = accountTable.get(sa.accountName);
        String accDepositsStr = "?";
        String accWithdrawalsStr = "?";
        String accBalanceStr = "?";
        if (a != null) {
            long balanceCents = a.getBalanceCents();

            accDepositsStr = CurrencyUtil.format(a.depositsCents);
            accWithdrawalsStr = CurrencyUtil.format(a.withdrawalsCents);
            accBalanceStr = CurrencyUtil.format(balanceCents);

            if (sa.checkBox.getValue()) {
                sumDeposit += a.depositsCents;
                sumWithdraw += a.withdrawalsCents;
                sumBalance += balanceCents;
            }
        }

        summaryAccountGrid.setWidget(row, 0, sa.checkBox);
        summaryAccountGrid.setWidget(row, 1, new Label(accDepositsStr));
        summaryAccountGrid.setWidget(row, 2, new Label(accWithdrawalsStr));
        summaryAccountGrid.setWidget(row, 3, new Label(accBalanceStr));

        ++row;
    }
    int lastRow = rows - 1;
    summaryAccountGrid.setWidget(lastRow, 1, new Label(CurrencyUtil.format(sumDeposit)));
    summaryAccountGrid.setWidget(lastRow, 2, new Label(CurrencyUtil.format(sumWithdraw)));
    summaryAccountGrid.setWidget(lastRow, 3, new Label(CurrencyUtil.format(sumBalance)));

    long sumRealizable = 0;

    //
    // Display asset selections
    //
    summaryAssetGrid.clear();
    rows = summaryAssetTable.size() + 2;
    summaryAssetGrid.resize(rows, 2);
    summaryAssetGrid.setWidget(0, 0, new Label("Ativo"));
    summaryAssetGrid.setWidget(0, 1, new Label("Realizavel"));
    row = 1;
    for (SummaryAsset sa : summaryAssetTable.values()) {
        String realizableStr = "?";
        Asset a = assetTable.get(sa.assetName);
        if (a != null) {
            Quote assetQuote = findQuote(a.assetName, summaryEndDate.getValue());
            if (assetQuote != null) {
                long realizableCents = a.getRealizableCents(assetQuote);
                realizableStr = CurrencyUtil.format(realizableCents);
                if (sa.checkBox.getValue()) {
                    sumRealizable += realizableCents;
                }
            }
        }

        summaryAssetGrid.setWidget(row, 0, sa.checkBox);
        summaryAssetGrid.setWidget(row, 1, new Label(realizableStr));

        ++row;
    }
    lastRow = rows - 1;
    summaryAssetGrid.setWidget(lastRow, 1, new Label(CurrencyUtil.format(sumRealizable)));

    long equityCents = sumBalance + sumRealizable;
    long equityPlusWithdrawalsCents = equityCents + sumWithdraw;
    long totalEarningsCents = equityPlusWithdrawalsCents - sumDeposit;
    double totalResult = ((double) totalEarningsCents) / ((double) sumDeposit);

    long equityEarningsCents = equityCents - sumDeposit;
    double equityGrowth = ((double) equityEarningsCents) / ((double) sumDeposit);

    summaryGrid.clear();
    summaryGrid.resize(10, 3);

    summaryGrid.setWidget(0, 0, new Label("A"));
    summaryGrid.setWidget(1, 0, new Label("B"));
    summaryGrid.setWidget(2, 0, new Label("C"));
    summaryGrid.setWidget(3, 0, new Label("D"));
    summaryGrid.setWidget(4, 0, new Label("E"));
    summaryGrid.setWidget(5, 0, new Label("F"));
    summaryGrid.setWidget(6, 0, new Label("G"));
    summaryGrid.setWidget(7, 0, new Label("H"));
    summaryGrid.setWidget(8, 0, new Label("I"));
    summaryGrid.setWidget(9, 0, new Label("J"));

    summaryGrid.setWidget(0, 1, new Label("Depositos:"));
    summaryGrid.setWidget(1, 1, new Label("Saques+Saldo+Realizavel:"));
    summaryGrid.setWidget(2, 1, new Label("Ganho interno total (B-A):"));
    summaryGrid.setWidget(3, 1, new Label("Retorno interno total do investimento (C/A):"));
    summaryGrid.setWidget(4, 1, new Label("Patrimonio (Saldo+Realizavel):"));
    summaryGrid.setWidget(5, 1, new Label("Ganho patrimonial (E-A):"));
    summaryGrid.setWidget(6, 1, new Label("Crescimento patrimonial (F/A):"));
    summaryGrid.setWidget(7, 1, new Label("Taxa composta diaria:"));
    summaryGrid.setWidget(8, 1, new Label("Taxa composta mensal:"));
    summaryGrid.setWidget(9, 1, new Label("Taxa composta anual:"));

    summaryGrid.setWidget(0, 2, new Label(CurrencyUtil.format(sumDeposit)));
    summaryGrid.setWidget(1, 2, new Label(CurrencyUtil.format(equityPlusWithdrawalsCents)));
    summaryGrid.setWidget(2, 2, new Label(CurrencyUtil.format(totalEarningsCents)));
    summaryGrid.setWidget(3, 2, new Label(Percent.format2(totalResult)));
    summaryGrid.setWidget(4, 2, new Label(CurrencyUtil.format(equityCents)));
    summaryGrid.setWidget(5, 2, new Label(CurrencyUtil.format(equityEarningsCents)));
    summaryGrid.setWidget(6, 2, new Label(Percent.format2(equityGrowth)));

    //
    // Scan deposits and withdrawals
    //
    summaryLog("Building polynomial...");
    Date endDate = summaryEndDate.getValue();
    //int endMon = DateUtil.linearMonth(endDate);
    ArrayList<Term> poly = new ArrayList<Term>();
    for (Operation op : operationList) {
        Date opDate = op.getDate();

        // Skip newer than endDate operations
        if (opDate.compareTo(endDate) > 0)
            break;

        // Pick only these
        if (!(op instanceof Deposit) && !(op instanceof Withdraw)) {
            continue;
        }

        // Skip non-selected accounts
        String accountName = op.getAccount();
        if (accountName == null)
            continue;
        SummaryAccount sa = summaryAccountTable.get(accountName);
        if (sa == null)
            continue;
        if (!sa.checkBox.getValue())
            continue;

        long valueCents = 0;
        if (op instanceof Deposit) {
            Deposit d = (Deposit) op;
            valueCents = d.depValueCents + d.depExpenseCents;
        } else {
            Withdraw w = (Withdraw) op;
            valueCents = -w.wdrawValueCents;
        }

        // Find month
        //int currMon = DateUtil.linearMonth(opDate);
        //int months = endMon - currMon;

        long days = DateUtil.daysBetween(opDate, endDate);

        summaryLog(Preference.dateFormat.format(opDate) + " days=" + days + " value="
                + CurrencyUtil.format(valueCents));

        poly.add(new Term(valueCents, days));
    }

    // add constant to polynomial
    summaryLog(Preference.dateFormat.format(endDate) + " days=" + 0 + " value="
            + CurrencyUtil.format(equityCents));
    poly.add(new Term(-equityCents, 0));

    summaryLog("Building polynomial...done " + poly.size() + " terms");

    summaryFlowGrid.clear();
    summaryFlowGrid.resize(1 + poly.size(), 3);
    summaryFlowGrid.setWidget(0, 0, new Label("Dias"));
    summaryFlowGrid.setWidget(0, 1, new Label("Fluxo"));
    summaryFlowGrid.setWidget(0, 2, new Label("Data"));
    int polyRow = 0;
    for (Term t : poly) {
        ++polyRow;

        long days = (long) t.exponent;
        Date pastDate = DateUtil.addDays(endDate, -days);

        summaryFlowGrid.setWidget(polyRow, 0, new Label(String.valueOf(days)));
        summaryFlowGrid.setWidget(polyRow, 1, new Label(CurrencyUtil.localeFormat(-(long) t.coeficient)));
        summaryFlowGrid.setWidget(polyRow, 2, new Label(Preference.dateFormat.format(pastDate)));
    }

    int maxLoop = 20;
    double maxError = .00001;
    double x0 = 1.0003; // 0,03% ao dia
    summaryLog("Solving... maxLoop=" + maxLoop + " maxError=" + maxError + " x0=" + (100 * (x0 - 1)) + "%");
    double x = x0;
    double err = 1;
    for (int i = 0; i < maxLoop; ++i) {
        double y = Polynomial.eval(poly, x);
        err = Math.abs(y);
        summaryLog("i=" + i + " x=" + x + " y=" + y + " err=" + err);
        if (err < maxError)
            break;
        double dy = Polynomial.evalDerivative(poly, x);
        double newX = x - y / dy;
        summaryLog("i=" + i + " x=" + x + " y=" + y + " err=" + err + " dy=" + dy + " newX=" + newX);
        x = newX;
    }

    if (err < maxError) {
        summaryLog("Solving...success");
        summaryGrid.setWidget(7, 2, new Label(Percent.format6(x - 1)));
        summaryGrid.setWidget(8, 2, new Label(Percent.format4(Math.pow(x, 30) - 1)));
        summaryGrid.setWidget(9, 2, new Label(Percent.format2(Math.pow(x, 365) - 1)));
    } else {
        summaryLog("Solving...failure to converge");
        summaryGrid.setWidget(7, 2, new Label("failure to converge"));
        summaryGrid.setWidget(8, 2, new Label("failure to converge"));
        summaryGrid.setWidget(9, 2, new Label("failure to converge"));
    }
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void displayEvolutionMonth(final int COLS, int row, int month, long deposits, long totalDeposits,
        long withdrawals, long totalWithdrawals) {

    int rows = 1 + row;
    if (rows > evolutionGrid.getRowCount()) {
        // Grow grid
        evolutionGrid.resize(rows, COLS);
    }//  w w w .j ava  2s . c  om

    String monStr = DateUtil.monthStr(month);
    long investmentBalance = totalDeposits - totalWithdrawals;

    evolutionGrid.setWidget(row, 0, new Label(monStr));
    evolutionGrid.setWidget(row, 1, new Label(CurrencyUtil.format(deposits)));
    evolutionGrid.setWidget(row, 2, new Label(CurrencyUtil.format(totalDeposits)));
    evolutionGrid.setWidget(row, 3, new Label(CurrencyUtil.format(withdrawals)));
    evolutionGrid.setWidget(row, 4, new Label(CurrencyUtil.format(totalWithdrawals)));
    evolutionGrid.setWidget(row, 5, new Label(CurrencyUtil.format(investmentBalance)));
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void updateEvolution() {
    final int COLS = 9;
    int rows = 0;

    evolutionGrid.clear();// www .  j  a v  a 2  s.c o m
    evolutionGrid.resize(rows + 1, COLS); // header
    evolutionGrid.getRowFormatter().addStyleName(0, "tableHeader");

    //
    // Header
    //
    evolutionGrid.setWidget(0, 0, new Label(Constant.MONTH));
    evolutionGrid.setWidget(0, 1, new Label(Constant.DEPOSITS));
    evolutionGrid.setWidget(0, 2, new Label("Total de " + Constant.DEPOSITS));
    evolutionGrid.setWidget(0, 3, new Label("Saques"));
    evolutionGrid.setWidget(0, 4, new Label("Total de Saques"));
    evolutionGrid.setWidget(0, 5, new Label("Saldo Investido"));

    evolutionGrid.setWidget(0, 6, new Label("Caixa"));
    evolutionGrid.setWidget(0, 7, new Label("Realizavel"));
    evolutionGrid.setWidget(0, 8, new Label("Patrimonio"));

    long deposits = 0;
    long totalDeposits = 0;
    long withdrawals = 0;
    long totalWithdrawals = 0;
    int firstMon = -1;
    int prevMon = -1;
    int currMon = 0;
    Date endDate = evolutionEndDate.getValue();
    for (Operation op : operationList) {
        Date opDate = op.getDate();

        // Skip newer than endDate operations
        if (opDate.compareTo(endDate) > 0)
            break;

        // Pick only these
        if (!(op instanceof Deposit) && !(op instanceof Withdraw)) {
            continue;
        }

        // Find month
        currMon = DateUtil.linearMonth(opDate);
        if (firstMon < 0) {
            firstMon = currMon;
            prevMon = currMon;
        }
        if (currMon != prevMon) {
            int row = 1 + prevMon - firstMon;

            displayEvolutionMonth(COLS, row, prevMon, deposits, totalDeposits, withdrawals, totalWithdrawals);

            deposits = 0;
            withdrawals = 0;

            prevMon = currMon;
        }

        if (op instanceof Deposit) {
            Deposit d = (Deposit) op;
            deposits += d.depValueCents;
            totalDeposits += d.depValueCents;
        } else {
            Withdraw w = (Withdraw) op;
            withdrawals += w.wdrawValueCents;
            totalWithdrawals += w.wdrawValueCents;
        }

    }

    if (deposits + withdrawals > 0) {

        // Last month
        int row = 1 + prevMon - firstMon;
        displayEvolutionMonth(COLS, row, currMon, deposits, totalDeposits, withdrawals, totalWithdrawals);

        // Averages

        long investmentBalance = totalDeposits - totalWithdrawals;

        // Grow grid
        int avgRow = evolutionGrid.getRowCount();
        long months = avgRow - 1;

        evolutionGrid.resize(1 + avgRow, COLS);

        evolutionGrid.setWidget(avgRow, 0, new Label("Media"));
        evolutionGrid.setWidget(avgRow, 2, new Label(CurrencyUtil.format(totalDeposits / months)));
        evolutionGrid.setWidget(avgRow, 4, new Label(CurrencyUtil.format(totalWithdrawals / months)));
        evolutionGrid.setWidget(avgRow, 5, new Label(CurrencyUtil.format(investmentBalance / months)));
    }
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void buildTaxPanel() {
    HorizontalPanel headPanel = new HorizontalPanel();
    VerticalPanel prefPanel = new VerticalPanel();
    VerticalPanel startLossPanel = new VerticalPanel();
    HorizontalPanel lossPanel = new HorizontalPanel();
    HorizontalPanel dayTradeLossPanel = new HorizontalPanel();

    taxPanel.clear();/*from  w w w.j  a  v  a2 s .  co  m*/
    taxEndDatePanel.add(new Label("Data:"));
    taxEndDatePanel.add(taxEndDate);
    taxPanel.add(taxEndDatePanel);

    StockTaxPrefResetButtonHandler stockTaxPrefButtonHandler = new StockTaxPrefResetButtonHandler();
    Button stockTaxPrefButton = new Button("Restaurar Recomendacoes", stockTaxPrefButtonHandler);

    prefPanel.add(stockTaxPrefButton);
    prefPanel.add(Preference.stockDayTradeAffectExemptionLimit);
    prefPanel.add(Preference.stockExemptGainsReduceCarriedLoss);
    prefPanel.add(Preference.stockTaxRatioOverPretaxEarnings);
    prefPanel.addStyleName("boxedTable");

    lossPanel.add(new Label("Perda acumulada inicial:"));
    lossPanel.add(Preference.startTaxCarryLoss);
    dayTradeLossPanel.add(new Label("Perda acumulada inicial em Day-trade:"));
    dayTradeLossPanel.add(Preference.startTaxDayTradeCarryLoss);

    startLossPanel.add(lossPanel);
    startLossPanel.add(dayTradeLossPanel);

    headPanel.add(prefPanel);
    headPanel.add(startLossPanel);
    taxPanel.add(headPanel);

    taxPanel.add(new Label("Apuracao Mensal:"));
    taxPanel.add(taxGrid);
    taxPanel.add(new Label("Legenda:"));
    taxPanel.add(new Label("IR.Devido: Codigo Receita DARF: Pessoa Fisica = 6015, Pessoa Juridica = 3317"));
    taxPanel.add(new Label("DT.IR.Devido: Codigo Receita DARF: Pessoa Fisica = 6015, Pessoa Juridica = 3317"));
    taxPanel.add(new Label("Resumo Anual:"));
    taxPanel.add(taxYearlySummaryGrid);
    taxPanel.add(new Label("Legenda:"));
    taxPanel.add(new Label("Repasse BTC: Rendimentos Tributaveis"));
    taxPanel.add(new Label("Lucro Liquido na Venda de Titulos: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Cupons de Titulos: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Aluguel de Acoes: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Juros Sobre Capital Proprio: Rendimentos Sujeitos a Tributacao Exclusiva"));
    taxPanel.add(new Label("Dividendos: Rendimentos Isentos e nao Tributaveis"));
    taxPanel.add(new Label("Ganho Liquido Isento: Rendimentos Isentos e nao Tributaveis"));
    taxPanel.add(debugPanel);
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void updateTaxGrid() {

    debugPanel.clear();//from  w ww  . j a v  a2s .  co  m

    //
    // Scan operations
    //

    Date endDate = taxEndDate.getValue();
    ArrayList<Sales> monthlyTaxTable = new ArrayList<Sales>();
    ArrayList<YearSummary> yearTable = new ArrayList<YearSummary>();
    int firstSaleMonth = -1;
    int firstYear = -1;
    int rows = 0;

    for (int i = 0; i < operationList.size(); ++i) {
        Operation op = operationList.get(i);
        Date opDate = op.getDate();

        // Skip newer than endDate operations
        if (opDate.compareTo(endDate) > 0)
            break;

        // Compute yearly yields
        if (op instanceof Yield) {
            Yield y = (Yield) op;
            if ((y.yieldType != Yield.YIELD_JSCP) && (y.yieldType != Yield.YIELD_DIVIDEND)
                    && (y.yieldType != Yield.YIELD_RENTAL) && (y.yieldType != Yield.YIELD_RENTAL2)
                    && (y.yieldType != Yield.YIELD_COUPON))
                continue;

            int year = DateUtil.year(opDate);
            if (firstYear < 0) {
                firstYear = year;
            }
            int yearIndex = year - firstYear;

            YearSummary ySum = lookupYear(yearTable, yearIndex);

            if (y.yieldType == Yield.YIELD_JSCP) {
                ySum.ySumJscpCents += y.yieldNetCents;
            }
            if (y.yieldType == Yield.YIELD_DIVIDEND) {
                ySum.ySumDividendsCents += y.yieldNetCents;
            }
            if (y.yieldType == Yield.YIELD_RENTAL) {
                ySum.ySumRentalCents += y.yieldNetCents;
            }
            if (y.yieldType == Yield.YIELD_RENTAL2) {
                ySum.ySumRental2Cents += y.yieldNetCents;
            }
            if (y.yieldType == Yield.YIELD_COUPON) {
                ySum.ySumCouponCents += y.yieldNetCents;
            }

            continue;
        }

        // Pick only sales and daytrades
        if (!(op instanceof Sell) && !(op instanceof DayTrade)) {
            continue;
        }

        // For sales, consider only stocks
        Sell s = null;
        if (op instanceof Sell) {
            s = (Sell) op;
            if (s.getAssetType() != Asset.ASSET_ACAO) {
                continue;
            }
        }

        // Find month
        int currMon = DateUtil.linearMonth(opDate);
        if (firstSaleMonth < 0) {
            firstSaleMonth = currMon;
        }
        int monIndex = currMon - firstSaleMonth;

        // Grow monthly table with null slots, if needed
        for (int j = monthlyTaxTable.size(); j <= monIndex; ++j) {
            monthlyTaxTable.add(j, null);
        }

        // Lookup month table
        Sales monthSales = monthlyTaxTable.get(monIndex);
        if (monthSales == null) {
            monthSales = new Sales();
            monthlyTaxTable.add(monIndex, monthSales);
            ++rows;
        }

        if (op instanceof DayTrade) {
            DayTrade dt = (DayTrade) op;
            monthSales.dayTradeMonthlySalesGrossCents += dt.dtSellGrossValueCents;
            monthSales.dayTradeRetainedTaxCents += dt.dtRetainedTaxCents;
            continue;
        }

        monthSales.salesGrossValueCents += s.sellGrossValueCents;
        monthSales.retainedTaxCents += s.sellRetainedTaxCents;
    }

    //
    // Accumulate sales
    //

    AccumulateSales accumulateSalesCallback = new AccumulateSales(monthlyTaxTable, firstSaleMonth, debugPanel);

    // Re-scan operations list accumulating sales
    issueAssetTable(endDate, accumulateSalesCallback, accumulateSalesCallback);

    //
    // Show tax grid result
    //

    final int COLS = 17;
    taxGrid.clear();
    taxGrid.resize(rows + 1, COLS); // header

    taxGrid.getRowFormatter().addStyleName(0, "taxGridHeader");

    //
    // Header
    //
    taxGrid.setWidget(0, 0, new Label(Constant.MONTH));

    // Normal
    taxGrid.setWidget(0, 1, new Label("V.Brut."));
    taxGrid.setWidget(0, 2, new Label("Ganho/Perda"));
    taxGrid.setWidget(0, 3, new Label("Perda.Acum."));
    taxGrid.setWidget(0, 4, new Label("G/P.Liq."));
    taxGrid.setWidget(0, 5, new Label("LAIF"));
    taxGrid.setWidget(0, 6, new Label("IR.Total"));
    taxGrid.setWidget(0, 7, new Label("IRRF"));
    taxGrid.setWidget(0, 8, new Label("IR.Devido"));

    // Daytrade
    taxGrid.setWidget(0, 9, new Label("DT.V.Brut."));
    taxGrid.setWidget(0, 10, new Label("DT.Ganho/Perda"));
    taxGrid.setWidget(0, 11, new Label("DT.Perda.Acum."));
    taxGrid.setWidget(0, 12, new Label("DT.G/P.Liq."));
    taxGrid.setWidget(0, 13, new Label("DT.LAIF"));
    taxGrid.setWidget(0, 14, new Label("DT.IR.Total"));
    taxGrid.setWidget(0, 15, new Label("DT.IRRF"));
    taxGrid.setWidget(0, 16, new Label("DT.IR.Devido"));

    //
    // Scan months
    //

    int row = 0;
    long carryLossCents = CurrencyUtil.parseToCents(Preference.startTaxCarryLoss.getText());
    long dayTradeCarryLossCents = CurrencyUtil.parseToCents(Preference.startTaxDayTradeCarryLoss.getText());
    for (int i = 0; i < monthlyTaxTable.size(); ++i) {
        Sales monthSales = (Sales) monthlyTaxTable.get(i);
        if (monthSales == null)
            continue;

        ++row;

        int mon = i + firstSaleMonth;
        String monStr = DateUtil.monthStr(mon);

        int year = DateUtil.monthToYear(mon);
        if (firstYear < 0) {
            firstYear = year;
        }
        int yearIndex = year - firstYear;
        YearSummary ySum = lookupYear(yearTable, yearIndex);

        //
        // First: Normal operations
        //

        long taxMonthGrossSalesCents = monthSales.salesGrossValueCents; // normal sales
        if (Preference.stockDayTradeAffectExemptionLimit.getValue()) {
            // add day-trade sales (only for tax exemption evaluation)
            taxMonthGrossSalesCents += monthSales.dayTradeMonthlySalesGrossCents;
        }

        long netProfitCents = monthSales.monthSalesNetProfitsCents;

        if (monthSales.monthSalesNetProfitsCents <= 0) {
            // There is loss

            // Just accumulate loss
            carryLossCents += monthSales.monthSalesNetProfitsCents;
        } else {
            // There is profit

            if (!Stock.stockSaleIsTaxExempt(taxMonthGrossSalesCents)
                    || Preference.stockExemptGainsReduceCarriedLoss.getValue()) {

                // There is NO tax exemption
                //  or
                // Exempt gains reduce accumulated loss

                // Subtract accumulated loss from profit
                netProfitCents += carryLossCents;
                // Compensate accumulated loss with current gains
                carryLossCents += monthSales.monthSalesNetProfitsCents;
                if (carryLossCents > 0)
                    carryLossCents = 0;
            }

            if (Stock.stockSaleIsTaxExempt(taxMonthGrossSalesCents)) {
                // There IS tax exemption

                // Accumulate yearly tax-exempt gains
                ySum.ySumExemptProfitCents += monthSales.monthSalesNetProfitsCents;
            }

        }

        //
        // From last month of the year, accumulate yearly loss
        //
        ySum.ySumCarryLossCents = carryLossCents;

        //
        // Monthly due tax
        //
        double taxRate = Stock.stockTaxRate(taxMonthGrossSalesCents);
        long pretaxProfitCents = netProfitCents + monthSales.retainedTaxCents;
        long taxValueCents = -1;
        if (Preference.stockTaxRatioOverPretaxEarnings.getValue()) {
            // consider pretax earnings
            taxValueCents = Stock.getTaxValueCents(pretaxProfitCents, taxRate);
        } else {
            // consider after tax earnings
            taxValueCents = Stock.getTaxValueCents(netProfitCents, taxRate);
        }
        long dueTaxCents = taxValueCents - monthSales.retainedTaxCents;
        if (dueTaxCents < 0)
            dueTaxCents = 0;

        //
        // Second: Day-trade operations
        //

        long dtMonthlyNetResultCents = monthSales.dayTradeMonthlyNetResultCents;

        if (monthSales.dayTradeMonthlyNetResultCents <= 0) {
            // There is loss

            // Just accumulate loss
            dayTradeCarryLossCents += monthSales.dayTradeMonthlyNetResultCents;
        } else {
            // There is profit

            // Subtract accumulated loss from profit
            dtMonthlyNetResultCents += dayTradeCarryLossCents;

            // Compensate accumulated loss with current gains
            dayTradeCarryLossCents += monthSales.dayTradeMonthlyNetResultCents;
            if (dayTradeCarryLossCents > 0)
                dayTradeCarryLossCents = 0;
        }

        //
        // From last month of the year, accumulate yearly loss
        //
        ySum.ySumDayTradeCarryLossCents = dayTradeCarryLossCents;

        //
        // Monthly due tax
        //
        long dtPretaxResultCents = dtMonthlyNetResultCents + monthSales.dayTradeRetainedTaxCents;
        long dtTaxValueCents = -1;
        if (Preference.stockTaxRatioOverPretaxEarnings.getValue()) {
            // consider pretax earnings
            dtTaxValueCents = Math.round(Preference.stockDayTradeTaxFee * (double) dtPretaxResultCents);
        } else {
            // consider after tax earnings
            dtTaxValueCents = Math.round(Preference.stockDayTradeTaxFee * (double) dtMonthlyNetResultCents);
        }
        if (dtTaxValueCents < 0)
            dtTaxValueCents = 0;
        long dtDueTaxCents = dtTaxValueCents - monthSales.dayTradeRetainedTaxCents;
        if (dtDueTaxCents < 0)
            dtDueTaxCents = 0;

        //
        // Show
        //

        taxGrid.setWidget(row, 0, new Label(monStr));

        // Normal
        taxGrid.setWidget(row, 1, new Label(CurrencyUtil.format(monthSales.salesGrossValueCents)));
        taxGrid.setWidget(row, 2, new Label(CurrencyUtil.format(monthSales.monthSalesNetProfitsCents)));
        taxGrid.setWidget(row, 3, new Label(CurrencyUtil.format(carryLossCents)));
        taxGrid.setWidget(row, 4, new Label(CurrencyUtil.format(netProfitCents)));
        taxGrid.setWidget(row, 5, new Label(CurrencyUtil.format(pretaxProfitCents)));
        taxGrid.setWidget(row, 6, new Label(CurrencyUtil.format(taxValueCents)));
        taxGrid.setWidget(row, 7, new Label(CurrencyUtil.format(monthSales.retainedTaxCents)));
        taxGrid.setWidget(row, 8, new Label(CurrencyUtil.format(dueTaxCents)));

        // Day-trade
        taxGrid.setWidget(row, 9, new Label(CurrencyUtil.format(monthSales.dayTradeMonthlySalesGrossCents)));
        taxGrid.setWidget(row, 10, new Label(CurrencyUtil.format(monthSales.dayTradeMonthlyNetResultCents)));
        taxGrid.setWidget(row, 11, new Label(CurrencyUtil.format(dayTradeCarryLossCents)));
        taxGrid.setWidget(row, 12, new Label(CurrencyUtil.format(dtMonthlyNetResultCents)));
        taxGrid.setWidget(row, 13, new Label(CurrencyUtil.format(dtPretaxResultCents)));
        taxGrid.setWidget(row, 14, new Label(CurrencyUtil.format(dtTaxValueCents)));
        taxGrid.setWidget(row, 15, new Label(CurrencyUtil.format(monthSales.dayTradeRetainedTaxCents)));
        taxGrid.setWidget(row, 16, new Label(CurrencyUtil.format(dtDueTaxCents)));
    }

    //
    // Show yearly summary
    //

    final int YCOLS = 10;
    taxYearlySummaryGrid.clear();
    taxYearlySummaryGrid.resize(yearTable.size() + 1, YCOLS); // header

    taxYearlySummaryGrid.getRowFormatter().addStyleName(0, "taxGridHeader");

    // Header
    taxYearlySummaryGrid.setWidget(0, 0, new Label("Ano"));
    taxYearlySummaryGrid.setWidget(0, 1, new Label("Repasse.BTC"));
    taxYearlySummaryGrid.setWidget(0, 2, new Label("LLV.Titulos"));
    taxYearlySummaryGrid.setWidget(0, 3, new Label("Cupons"));
    taxYearlySummaryGrid.setWidget(0, 4, new Label("Aluguel"));
    taxYearlySummaryGrid.setWidget(0, 5, new Label("JSCP"));
    taxYearlySummaryGrid.setWidget(0, 6, new Label("Dividendos"));
    taxYearlySummaryGrid.setWidget(0, 7, new Label("Ganho.Liq.Isento"));
    taxYearlySummaryGrid.setWidget(0, 8, new Label("Perda.Acum."));
    taxYearlySummaryGrid.setWidget(0, 9, new Label("DT.Perda.Acum."));

    int yearRow = 0;
    for (int i = 0; i < yearTable.size(); ++i) {

        ++yearRow;
        int year = i + firstYear;
        taxYearlySummaryGrid.setWidget(yearRow, 0, new Label(String.valueOf(year)));

        YearSummary yearSum = yearTable.get(i);
        if (yearSum == null)
            continue;

        taxYearlySummaryGrid.setWidget(yearRow, 1, new Label(CurrencyUtil.format(yearSum.ySumRental2Cents)));
        taxYearlySummaryGrid.setWidget(yearRow, 2,
                new Label(CurrencyUtil.format(yearSum.ySumBondSaleNetEarningsCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 3, new Label(CurrencyUtil.format(yearSum.ySumCouponCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 4, new Label(CurrencyUtil.format(yearSum.ySumRentalCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 5, new Label(CurrencyUtil.format(yearSum.ySumJscpCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 6, new Label(CurrencyUtil.format(yearSum.ySumDividendsCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 7,
                new Label(CurrencyUtil.format(yearSum.ySumExemptProfitCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 8, new Label(CurrencyUtil.format(yearSum.ySumCarryLossCents)));
        taxYearlySummaryGrid.setWidget(yearRow, 9,
                new Label(CurrencyUtil.format(yearSum.ySumDayTradeCarryLossCents)));
    }

    //debugPanel.add(new Label("yearTable.size(): " + yearTable.size()));
    //debugPanel.add(new Label("yearRow: " + yearRow));
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void buildPortfolioPanel() {
    portfolioEndDatePanel.add(new Label("Data:"));
    portfolioEndDatePanel.add(portfolioEndDate);

    HorizontalPanel controlPanel = new HorizontalPanel();
    FetchQuotesButtonHandler fetchQuotesButtonHandler = new FetchQuotesButtonHandler();
    Button fetchQuotesButton = new Button("Buscar Cotacoes", fetchQuotesButtonHandler);
    controlPanel.add(portfolioHideSoldPositionsCheckBox);
    controlPanel.add(fetchQuotesButton);

    portfolioPanel.clear();/*  ww w.ja va  2  s  . c om*/
    portfolioPanel.add(portfolioEndDatePanel);
    portfolioPanel.add(controlPanel);
    portfolioPanel.add(portfolioTab);
    portfolioPanel.add(accountBalanceTab);
    portfolioPanel.add(portfolioDebugPanel);

    portfolioDebugPanel.clear();
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void portfolioDebug(String msg) {
    portfolioDebugPanel.add(new Label(msg));
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void updatePortfolioTable() {

    issueAssetTable(portfolioEndDate.getValue(), null, null); // Re-scan operations list

    if (portfolioHideSoldPositionsCheckBox.getValue()) {
        assetTableDropSoldPositions();/*from  w w  w .ja  v a  2s .co m*/
    }

    // update portfolioTab

    final int COL_BUY = 5;
    final int COL_EXPENSE = 6;
    final int COL_SALE = 9;
    final int COL_YIELD = 10;
    final int COL_REALIZABLE = 13;
    final int COL_RATIO = 14;
    final int COLS = 17;

    final int LAST_ROW = assetTable.size() + 1;
    final int portfolioTabRows = assetTable.size() + 2;
    portfolioTab.resize(portfolioTabRows, COLS);
    portfolioTab.getRowFormatter().addStyleName(0, "tableHeader");

    // Header
    portfolioTab.setWidget(0, 0, new Label("Ativo"));
    portfolioTab.setWidget(0, 1, new Label("Compras"));
    portfolioTab.setWidget(0, 2, new Label("Bonus"));
    portfolioTab.setWidget(0, 3, new Label("Vendas"));
    portfolioTab.setWidget(0, 4, new Label("Posicao"));
    portfolioTab.setWidget(0, COL_BUY, new Label("Custos"));
    portfolioTab.setWidget(0, COL_EXPENSE, new Label("Remessas"));
    portfolioTab.setWidget(0, 7, new Label("C." + Constant.AVERAGE_O + " IR"));
    portfolioTab.setWidget(0, 8, new Label("C." + Constant.AVERAGE_O + " Real"));
    portfolioTab.setWidget(0, COL_SALE, new Label(Constant.REALIZATIONS));
    portfolioTab.setWidget(0, COL_YIELD, new Label("Proventos"));
    portfolioTab.setWidget(0, 11, new Label("Day-Trade"));
    portfolioTab.setWidget(0, 12, new Label(Constant.QUOTE));
    portfolioTab.setWidget(0, COL_REALIZABLE, new Label(Constant.REALIZABLE));
    portfolioTab.setWidget(0, COL_RATIO, new Label(Constant.RATIO));
    portfolioTab.setWidget(0, 15, new Label("Resultado"));
    portfolioTab.setWidget(0, 16, new Label("Retorno"));

    long sumBuyCents = 0;
    long sumExpenseCents = 0;
    long sumSaleCents = 0;
    long sumYieldCents = 0;
    long sumRealizableCents = 0;

    int row = 1;
    for (Iterator<Asset> i = assetTable.values().iterator(); i.hasNext(); ++row) {
        Asset a = i.next();

        sumBuyCents += a.purchaseGrossCostCents;
        sumExpenseCents += a.purchaseExpenseCents;
        sumSaleCents += a.salesNetRevenueCents;
        sumYieldCents += a.yieldAfterTaxCents;

        double currentAmount = a.getCurrentAmount();
        //double acquiredAmount = a.getAcquiredAmount();
        long taxAverageBuyCost = Math.round(a.getTaxAverageAcquisitionCostCents());
        long realAverageBuyCost = Math.round(a.getRealAverageAcquisitionCost());

        String unitValue = "?";
        String realizable = "?";
        String result = "?";
        String roeStr = "?";
        String style = "negative";

        Quote assetQuote = findQuote(a.assetName, portfolioEndDate.getValue());
        if ((assetQuote != null) || (Preference.amountIsZero(currentAmount))) {

            // When amountIsZero, getRealizableCents yields 0
            // regardless of assetQuote

            long realizableCents = a.getRealizableCents(assetQuote);
            if (Preference.amountIsNonZero(currentAmount)) {
                sumRealizableCents += realizableCents;
            }

            // When amountIsZero, getResultCents ignores assetQuote

            long resultCents = a.getResultCents(assetQuote);
            if (resultCents > 0)
                style = "positive";
            long costCents = a.purchaseGrossCostCents + a.purchaseExpenseCents;
            if (costCents != 0) {
                double roe = (double) resultCents / (double) costCents;
                roeStr = Percent.format2(roe);
            }

            if (assetQuote != null) {
                unitValue = Preference.unitaryQuoteFormat.format(assetQuote.getUnitValue());
            }
            realizable = CurrencyUtil.format(realizableCents);
            result = CurrencyUtil.format(resultCents);
        }

        AssetTextBox unitQuoteBox = new AssetTextBox(a.assetName);
        unitQuoteBox.setText(unitValue);
        unitQuoteBox.addChangeHandler(unitQuoteHandler);

        Label resultLabel = new Label(result);
        Label roeLabel = new Label(roeStr);
        resultLabel.setStyleName(style);
        roeLabel.setStyleName(style);

        portfolioTab.setWidget(row, 0, new Label(a.assetName));
        portfolioTab.setWidget(row, 1, new Label(Preference.amountFormat.format(a.amountBought)));
        portfolioTab.setWidget(row, 2, new Label(Preference.amountFormat.format(a.amountBonus)));
        portfolioTab.setWidget(row, 3, new Label(Preference.amountFormat.format(a.amountSold)));
        portfolioTab.setWidget(row, 4, new Label(Preference.amountFormat.format(currentAmount)));
        portfolioTab.setWidget(row, COL_BUY, new Label(CurrencyUtil.format(a.purchaseGrossCostCents)));
        portfolioTab.setWidget(row, COL_EXPENSE, new Label(CurrencyUtil.format(a.purchaseExpenseCents)));
        portfolioTab.setWidget(row, 7, new Label(CurrencyUtil.format(taxAverageBuyCost)));
        portfolioTab.setWidget(row, 8, new Label(CurrencyUtil.format(realAverageBuyCost)));
        portfolioTab.setWidget(row, COL_SALE, new Label(CurrencyUtil.format(a.salesNetRevenueCents)));
        portfolioTab.setWidget(row, COL_YIELD, new Label(CurrencyUtil.format(a.yieldAfterTaxCents)));
        portfolioTab.setWidget(row, 11, new Label(CurrencyUtil.format(a.dayTradeNetResultCents)));
        portfolioTab.setWidget(row, 12, unitQuoteBox);
        portfolioTab.setWidget(row, COL_REALIZABLE, new Label(realizable));
        // room COL_RATIO=14 is assigned below with asset %
        portfolioTab.setWidget(row, 15, resultLabel);
        portfolioTab.setWidget(row, 16, roeLabel);

        for (int c = 1; c < COLS; ++c) {
            portfolioTab.getCellFormatter().addStyleName(row, c, "portfolioNumericColumn");
        }
    }

    //
    // Fill in last row
    //

    for (int c = 0; c < COLS; ++c) {
        portfolioTab.clearCell(LAST_ROW, c);
        portfolioTab.getCellFormatter().addStyleName(LAST_ROW, c, "portfolioNumericColumn");
    }
    portfolioTab.setWidget(LAST_ROW, COL_BUY, new Label(CurrencyUtil.format(sumBuyCents)));
    portfolioTab.setWidget(LAST_ROW, COL_EXPENSE, new Label(CurrencyUtil.format(sumExpenseCents)));
    portfolioTab.setWidget(LAST_ROW, COL_SALE, new Label(CurrencyUtil.format(sumSaleCents)));
    portfolioTab.setWidget(LAST_ROW, COL_YIELD, new Label(CurrencyUtil.format(sumYieldCents)));
    portfolioTab.setWidget(LAST_ROW, COL_REALIZABLE, new Label(CurrencyUtil.format(sumRealizableCents)));

    //
    // Fill in ratio column
    //

    row = 1;
    for (Iterator<Asset> i = assetTable.values().iterator(); i.hasNext(); ++row) {
        Asset a = i.next();

        double currentAmount = a.getCurrentAmount();
        if (Preference.amountIsZero(currentAmount)) {
            portfolioTab.clearCell(row, COL_RATIO);
            continue;
        }

        Quote assetQuote = findQuote(a.assetName, portfolioEndDate.getValue());
        if (assetQuote == null) {
            portfolioTab.clearCell(row, COL_RATIO);
            continue;
        }

        long realizableCents = a.getRealizableCents(assetQuote);

        double assetFraction = ((double) realizableCents) / sumRealizableCents;

        portfolioTab.setWidget(row, COL_RATIO, new Label(Percent.format2(assetFraction)));
    }

    //
    // Build account balance summary
    //

    final int COLUMNS = 11;
    accountBalanceTab.resize(accountTable.size() + 1, COLUMNS);
    accountBalanceTab.getRowFormatter().addStyleName(0, "tableHeader");

    // Header
    accountBalanceTab.setWidget(0, 0, new Label("Conta"));
    accountBalanceTab.setWidget(0, 1, new Label(Constant.DEPOSITS));
    accountBalanceTab.setWidget(0, 2, new Label("Proventos"));
    accountBalanceTab.setWidget(0, 3, new Label("Vendas"));
    accountBalanceTab.setWidget(0, 4, new Label("Saques"));
    accountBalanceTab.setWidget(0, 5, new Label("T.Origem"));
    accountBalanceTab.setWidget(0, 6, new Label("T.Destino"));
    accountBalanceTab.setWidget(0, 7, new Label("Taxas"));
    accountBalanceTab.setWidget(0, 8, new Label("Compras"));
    accountBalanceTab.setWidget(0, 9, new Label("Day-Trade"));
    accountBalanceTab.setWidget(0, 10, new Label("Saldo"));

    row = 1;
    for (Account a : accountTable.values()) {

        for (int c = 1; c < COLUMNS; ++c) {
            accountBalanceTab.getCellFormatter().addStyleName(row, c, "portfolioNumericColumn");
        }

        accountBalanceTab.setWidget(row, 0, new Label(a.acctName));
        accountBalanceTab.setWidget(row, 1, new Label(CurrencyUtil.format(a.depositsCents)));
        accountBalanceTab.setWidget(row, 2, new Label(CurrencyUtil.format(a.yieldsCents)));
        accountBalanceTab.setWidget(row, 3, new Label(CurrencyUtil.format(a.salesCents)));
        accountBalanceTab.setWidget(row, 4, new Label(CurrencyUtil.format(a.withdrawalsCents)));
        accountBalanceTab.setWidget(row, 5, new Label(CurrencyUtil.format(a.transferFromCents)));
        accountBalanceTab.setWidget(row, 6, new Label(CurrencyUtil.format(a.transferToCents)));
        accountBalanceTab.setWidget(row, 7, new Label(CurrencyUtil.format(a.brokerTaxesCents)));
        accountBalanceTab.setWidget(row, 8, new Label(CurrencyUtil.format(a.buysCents)));
        accountBalanceTab.setWidget(row, 9, new Label(CurrencyUtil.format(a.dayTradeCents)));
        accountBalanceTab.setWidget(row, 10, new Label(CurrencyUtil.format(a.getBalanceCents())));

        ++row;
    }
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void buildOpTab() {
    int cols = 12;
    int tradeCount = countTradeListDisplaySize();
    opTab.resize(tradeCount + 1, cols + 1);
    opTab.getRowFormatter().addStyleName(0, "tableHeader");

    final int COL_SELL_GROSS = 6;
    final int COL_RETAINED_TAX = 9;

    // Header//  www . j a  v a2s  .c o m
    opTab.setWidget(0, 0, new Label("Id"));
    opTab.setWidget(0, 1, new Label("Data"));
    opTab.setWidget(0, 2, new Label("Op."));
    opTab.setWidget(0, 3, new Label("Tipo"));
    opTab.setWidget(0, 4, new Label("Ativo"));
    opTab.setWidget(0, 5, new Label("Quant."));
    opTab.setWidget(0, COL_SELL_GROSS, new Label("G.Bruto"));
    opTab.setWidget(0, 7, new Label("C.Bruto/G.Liq."));
    opTab.setWidget(0, 8, new Label("Remessa"));
    opTab.setWidget(0, COL_RETAINED_TAX, new Label("IRRF"));
    opTab.setWidget(0, 10, new Label("Conta"));
    opTab.setWidget(0, 11, new Label(Constant.AVERAGE_O));
    opTab.setWidget(0, 12, new Label("Excluir"));

    String year = tradeFilterYear.getText();
    String asset = tradeFilterAssetSuggest.getText();
    String account = tradeFilterAccountSuggest.getText();

    for (int i = 0, row = tradeCount + 1; i < operationList.size(); ++i) {
        Operation op = operationList.get(i);

        if (tradeFilterMiss(op, year, asset, account))
            continue;

        // Build a text box for sellGrossValue ?
        SellGrossValueBox grossBox = null;
        SellRetainedTaxBox retainedTaxBox = null;
        if (op instanceof Sell) {
            Sell s = (Sell) op;
            if (s.getAssetType() == Asset.ASSET_ACAO) {
                // Build a text box for sellGrossValue 
                grossBox = new SellGrossValueBox(s);
                grossBox.setText(CurrencyUtil.format(s.sellGrossValueCents));
                grossBox.addChangeHandler(sellGrossValueHandler);

                // Build a text box for sellRetainedTax 
                retainedTaxBox = new SellRetainedTaxBox(s);
                retainedTaxBox.setText(CurrencyUtil.format(s.sellRetainedTaxCents));
                retainedTaxBox.addChangeHandler(sellRetainedTaxHandler);
            }
        }

        --row;
        for (int j = 0; j < cols; ++j) {
            if ((grossBox != null) && (j == COL_SELL_GROSS)) {
                opTab.setWidget(row, j, grossBox);
                continue;
            }
            if ((retainedTaxBox != null) && (j == COL_RETAINED_TAX)) {
                opTab.setWidget(row, j, retainedTaxBox);
                continue;
            }

            // default: get from operation
            opTab.setWidget(row, j, op.getCol(j));
        }
        ClickHandler del = new DelOpButtonHandler();
        CarrierButton delButton = new CarrierButton("X", del, op);
        opTab.setWidget(row, cols, delButton);
    }
}

From source file:carteirainveste.client.DateUtil.java

License:Creative Commons License

void buildAddAccountPanel() {

    addAccountPanel.clear();// ww  w  .  j ava  2s . c o m

    addAccountPanel.add(accountActionDropBox);

    // Create a DateBox
    addAccountDate.setFormat(new DateBox.DefaultFormat(Preference.dateFormat));
    addAccountDate.setValue(new Date());
    addAccountPanel.add(addAccountDate);

    int accountAction = accountActionDropBox.getSelectedIndex();
    switch (accountAction) {
    case Operation.ACC_TRANSFER:
        VerticalPanel nameFromPanel = new VerticalPanel();
        nameFromPanel.add(new Label("Conta Origem"));
        nameFromPanel.add(addAccountFromName);
        addAccountPanel.add(nameFromPanel);

        VerticalPanel nameToPanel = new VerticalPanel();
        nameToPanel.add(new Label("Conta Destino"));
        nameToPanel.add(addAccountToName);
        addAccountPanel.add(nameToPanel);
        break;
    default:
        VerticalPanel namePanel = new VerticalPanel();
        namePanel.add(new Label("Conta"));
        namePanel.add(addAccountName);
        addAccountPanel.add(namePanel);
    }

    VerticalPanel valuePanel = new VerticalPanel();
    valuePanel.add(new Label("Valor"));
    valuePanel.add(addAccountValue);
    addAccountPanel.add(valuePanel);

    switch (accountAction) {
    case Operation.ACC_DEPOSIT:
        VerticalPanel expensePanel = new VerticalPanel();
        expensePanel.add(new Label("Remessa"));
        expensePanel.add(addAccountExpense);
        addAccountPanel.add(expensePanel);
        break;
    default:
    }

    addAccountPanel.add(addAccountButton);
}