Example usage for com.vaadin.ui GridLayout GridLayout

List of usage examples for com.vaadin.ui GridLayout GridLayout

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout GridLayout.

Prototype

public GridLayout(int columns, int rows) 

Source Link

Document

Constructor for a grid of given size (number of columns and rows).

Usage

From source file:dhbw.ka.mwi.businesshorizon2.ui.process.parameter.ParameterViewImpl.java

License:Open Source License

private void generateUi() {

    setMargin(true);//from w w w  .j a  v a  2s  . c o  m
    //setSizeFull();
    setLocked(true);
    setStyleName("small");

    // TODO: Zeilenanzahl anpassen
    gridLayout = new GridLayout(3, 30);
    gridLayout.setMargin(true);
    gridLayout.setSpacing(true);
    //gridLayout.setSizeFull();

    VerticalLayout infoBox = new VerticalLayout();
    infoBox.setMargin(true);
    Label infoText1 = new Label("<h3>Deterministische Parameter:</h3>");
    infoText1.setContentMode(Label.CONTENT_XHTML);
    Label infoText2 = new Label(
            "Hier geben Sie das Basisjahr an, auf welches die knftigen Cashflows abgezinst werden. "
                    + "Zustzlich mssen Sie auch die Anzahl der einzubeziehenden zuknftigen Perioden ange-ben. "
                    + "Beachten Sie hierbei, dass Sie nur so viele Perioden angeben, "
                    + "wie Sie Daten ber die Cashflows des Unternehmens haben.");
    Label infoText3 = new Label("<h3>Stochastische Parameter:</h3>");
    infoText3.setContentMode(Label.CONTENT_XHTML);
    Label infoText4 = new Label(
            "Hier geben Sie das Basisjahr an, auf welches die knftigen Cashflows abgezinst werden. "
                    + "Zustzlich mssen Sie auch die Anzahl der zu prognostizierenden Perioden angeben. "
                    + "Die Prognose erfolgt auf Basis vergangener Werte, daher mssen Sie auch die Anzahl der ver-gangenen Perioden angeben. "
                    + "Beachten Sie hierbei, dass Sie nur so viele Perioden angeben, wie Sie Daten ber die Cashflows des Unternehmens haben. "
                    + "Des Weiteren haben Sie die Mglichkeit die Anzahl der Wiederholungen anzugeben. "
                    + "Info: Je mehr Iterationen Sie durchfhren lassen, desto genauer werden die Prognosewerte, aber desto lnger dauert die Berechnung.");

    infoBox.addComponent(infoText1);
    infoBox.addComponent(infoText2);
    infoBox.addComponent(infoText3);
    infoBox.addComponent(infoText4);

    setFirstComponent(gridLayout);
    setSecondComponent(infoBox);

    // Heading 1
    labelHeadingCommon = new Label("Allgemein");
    //gridLayout.addComponent(labelHeadingCommon, 0, 0);

    labelBasisYear = new Label("Basisjahr");
    gridLayout.addComponent(labelBasisYear, 0, 1);

    textfieldBasisYear = new TextField();
    textfieldBasisYear.setImmediate(true);
    textfieldBasisYear.setDescription(toolTipBasisYear);
    textfieldBasisYear.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.basisYearChosen((String) textfieldBasisYear.getValue());
        }
    });
    gridLayout.addComponent(textfieldBasisYear, 1, 1);

    // Heading 2
    labelHeadingMethDet = new Label("Stochastische Parameter:");
    gridLayout.addComponent(labelHeadingMethDet, 0, 3);

    labelNumPeriods = new Label("Anzahl zu prognostizierender Perioden");
    gridLayout.addComponent(labelNumPeriods, 0, 4);

    textfieldNumPeriodsToForecast = new TextField();
    textfieldNumPeriodsToForecast.setImmediate(true);
    textfieldNumPeriodsToForecast.setDescription(toolTipNumPeriodsToForecast);
    textfieldNumPeriodsToForecast.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.numberPeriodsToForecastChosen((String) textfieldNumPeriodsToForecast.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPeriodsToForecast, 1, 4);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 4);

    labelIterations = new Label("Durchlufe / Iterationen");
    gridLayout.addComponent(labelIterations, 0, 5);

    textfieldIterations = new TextField();
    textfieldIterations.setImmediate(true);
    // textfieldIterations.setValue(10000);
    textfieldIterations.setDescription(toolTipIterations);
    textfieldIterations.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            logger.debug(textfieldIterations.getValue());
            presenter.iterationChosen((String) textfieldIterations.getValue());
        }
    });
    gridLayout.addComponent(textfieldIterations, 1, 5);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 5);

    labelNumSpecifiedPastPeriods = new Label("Anzahl anzugebender, vergangener Perioden");
    gridLayout.addComponent(labelNumSpecifiedPastPeriods, 0, 6);

    textfieldNumSpecifiedPastPeriods = new TextField();
    textfieldNumSpecifiedPastPeriods.setImmediate(true);
    // textfieldIterations.setValue(10000);
    textfieldNumSpecifiedPastPeriods.setDescription(toolTipNumSpecifiedPastPeriods);
    textfieldNumSpecifiedPastPeriods.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            logger.debug(textfieldNumSpecifiedPastPeriods.getValue());
            presenter.specifiedPastPeriodsChosen((String) textfieldNumSpecifiedPastPeriods.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumSpecifiedPastPeriods, 1, 6);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 6);

    /**
     * Auskommentiert, da nicht fr Zeitreihenanalyse bentigt
     * 
    labelStepsPerPeriod = new Label("Schritte pro Periode");
    gridLayout.addComponent(labelStepsPerPeriod, 0, 6);
            
            
    textfieldStepsPerPeriod = new TextField();
    textfieldStepsPerPeriod.setImmediate(true);
    textfieldStepsPerPeriod.setDescription(toolTipStepsPerPeriod);
    textfieldStepsPerPeriod.addListener(new Property.ValueChangeListener() {
       private static final long serialVersionUID = 1L;
            
       public void valueChange(ValueChangeEvent event) {
    presenter.stepsPerPeriodChosen((String) textfieldStepsPerPeriod
          .getValue());
       }
    });
    gridLayout.addComponent(textfieldStepsPerPeriod, 1, 6);
            
    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 6);
     */
    // Heading 3

    labelHeadingTimeSeries = new Label("Stochastisch: Zeitreihenanalyse");
    //gridLayout.addComponent(labelHeadingTimeSeries, 0, 8);

    labelNumPastPeriods = new Label("Anzahl einbezogener, vergangener Perioden");
    gridLayout.addComponent(labelNumPastPeriods, 0, 9);

    textfieldNumPastPeriods = new TextField();
    textfieldNumPastPeriods.setImmediate(true);
    // textfieldNumPastPeriods: Wert darf hier nicht gesetzt werden
    // -> ber Event, sodass der Wert ins Projekt bernommen wird und nicht
    // nur einfach angezeigt wird ohne ausgewertet werden zu knnen
    // textfieldNumPastPeriods.setValue(5);
    textfieldNumPastPeriods.setDescription(toolTipNumPastPeriods
            + " Bitte beachten Sie, dass in dem Reiter Perioden immer eine Periode mehr angegeben werden muss. Diese zustzliche Periode wird bei einem Berechnungsverfahren der Zeitreihenanalyse bentigt.");
    textfieldNumPastPeriods.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.relevantPastPeriodsChosen((String) textfieldNumPastPeriods.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPastPeriods, 1, 9);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 9);

    checkboxIndustryRepresentative = new CheckBox();
    checkboxIndustryRepresentative.setCaption("Branchenstellvertreter einbeziehen");
    checkboxIndustryRepresentative.setDescription(toolTipIndustryRepresentatives);
    checkboxIndustryRepresentative.addListener(new ClickListener() {
        /**
         * Derzeit unbenutzt, da die Funkionalitaet in der Berechnung noch
         * nicht hinterlegt ist.
         * 
         * @see init()-Methode dieser Klasse
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.industryRepresentativeCheckBoxSelected(checkboxIndustryRepresentative.booleanValue());
        }
    });
    gridLayout.addComponent(checkboxIndustryRepresentative, 0, 10);

    comboBoxRepresentatives = new ComboBox();
    comboBoxRepresentatives.setImmediate(true);
    comboBoxRepresentatives.setInputPrompt("Branche ausw\u00e4hlen");
    comboBoxRepresentatives.setNullSelectionAllowed(false);
    comboBoxRepresentatives.addListener(new Property.ValueChangeListener() {
        /**
         * Derzeit unbenutzt, da die Funkionalitaet in der Berechnung auf
         * Basis von Branchenverreter in dieser Softareversion noch nicht
         * hinterlegt ist.
         * 
         * @see init()-Methode dieser Klasse
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            presenter.industryRepresentativeListItemChosen((String) event.getProperty().getValue());
            logger.debug("Branche " + event + " gewaehlt");
        }
    });

    gridLayout.addComponent(comboBoxRepresentatives, 1, 10);

    // Heading 4

    // Heading 6
    labelHeadingMethDet = new Label("Deterministische Parameter:");
    gridLayout.addComponent(labelHeadingMethDet, 0, 26);
    labelNumPeriods_deterministic = new Label("Anzahl anzugebender Perioden");
    gridLayout.addComponent(labelNumPeriods_deterministic, 0, 27);

    textfieldNumPeriodsToForecast_deterministic = new TextField();
    textfieldNumPeriodsToForecast_deterministic.setImmediate(true);
    textfieldNumPeriodsToForecast_deterministic.setDescription(toolTipNumPeriodsToForecast_deterministic);
    textfieldNumPeriodsToForecast_deterministic.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        public void valueChange(ValueChangeEvent event) {
            presenter.numberPeriodsToForecastChosen_deterministic(
                    (String) textfieldNumPeriodsToForecast_deterministic.getValue());
        }
    });
    gridLayout.addComponent(textfieldNumPeriodsToForecast_deterministic, 1, 27);

    labelUnitQuantity = new Label("Anzahl");
    gridLayout.addComponent(labelUnitQuantity, 2, 27);

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.resultscreen.morescenarios.MoreScenarioResultViewImpl.java

License:Open Source License

/**
 * Erstelle das GUI zum Prozessschritt "Ausgabe"
 * //from w  w w.  ja  va 2 s .co  m
 * @author Tobias Lindner
 */
private void generateUi() {
    setSizeFull();

    planningLayout = new GridLayout(4, 3);

    planningTable = new Table();

    planningTable.setWidth(100, UNITS_PERCENTAGE);
    planningTable.setPageLength(4);

    planningTable.addContainerProperty("first", String.class, null);
    planningTable.setColumnHeader("first", "");

    planningTable.addContainerProperty("scenario1", GridLayout.class, null);
    planningTable.setColumnHeader("scenario1", "Szenario 1");

    planningTable.addContainerProperty("scenario2", GridLayout.class, null);
    planningTable.setColumnHeader("scenario2", "Szenario 2");

    itemId1 = planningTable.addItem();
    row1 = planningTable.getItem(itemId1);
    row1.getItemProperty("first").setValue("Planungsprmissen");
    itemId2 = planningTable.addItem();
    row2 = planningTable.getItem(itemId2);
    row2.getItemProperty("first").setValue("Unternehmenswert");
    itemId3 = planningTable.addItem();
    row3 = planningTable.getItem(itemId3);
    row3.getItemProperty("first").setValue("Kapitalstruktur");

    planningGridScenario1 = new GridLayout(2, 5);
    planningGridScenario2 = new GridLayout(2, 5);
    planningGridScenario3 = new GridLayout(2, 5);

    companyValueLayoutScenario1 = new GridLayout();
    companyValueLayoutScenario2 = new GridLayout();
    companyValueLayoutScenario3 = new GridLayout();

    capitalStructureChartScenario1 = new GridLayout(1, 1);
    //      capitalStructureChartScenario1.setSizeFull();
    capitalStructureChartScenario2 = new GridLayout();
    capitalStructureChartScenario3 = new GridLayout();

    row1.getItemProperty("scenario1").setValue(planningGridScenario1);
    row1.getItemProperty("scenario2").setValue(planningGridScenario2);

    row2.getItemProperty("scenario1").setValue(companyValueLayoutScenario1);
    row2.getItemProperty("scenario2").setValue(companyValueLayoutScenario2);

    row3.getItemProperty("scenario1").setValue(capitalStructureChartScenario1);
    row3.getItemProperty("scenario2").setValue(capitalStructureChartScenario2);

    createScenario1Layout();
    createScenario2Layout();
    createScenario3Layout();

    addComponent(planningTable);

    planningTable.setCellStyleGenerator(new Table.CellStyleGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public String getStyle(Object itemId, Object propertyId) {
            if (propertyId == null) {
                if (itemId == itemId2) {
                    return "yello-row";
                }

                if (itemId == itemId1) {
                    return "table-line";
                }

                if (itemId == itemId3) {
                    return "table-capital";
                }
                return null;
            }

            else {
                return null;
            }
        }
    });

    planningTable.addStyleName("scenarioTable");

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.resultscreen.morescenarios.MoreScenarioResultViewImpl.java

License:Open Source License

public void createLayout() {
    logger.debug("createLayout");

    grid = new GridLayout(2, 4);
    planningLabel = new Label("Planungsprmissen:");
    companyValueLabel = new Label("Unternehmenswert:");
    planningLayout = new GridLayout();
    companyValue = new Label("30.000.000");

    grid.setSizeFull();//ww w.  j  a v  a  2  s  . c o m
    grid.setColumnExpandRatio(1, 5);

    grid.addComponent(planningLabel, 0, 0);
    grid.addComponent(planningLayout, 1, 0);
    grid.addComponent(companyValueLabel, 0, 1);
    grid.addComponent(companyValue, 1, 1);

    addComponent(grid);

}

From source file:dhbw.ka.mwi.businesshorizon2.ui.resultscreen.onescenario.OneScenarioResultViewImpl.java

License:Open Source License

/**
 * Erstelle das GUI zum Prozessschritt "Ausgabe"
 * /* www .j  ava 2s  . c om*/
 * @author Florian Stier
 */
private void generateUi() {

    setSizeFull();
    planningLayout = new HorizontalLayout();
    planningLabel = new Label("Planungsprmissen:");
    scenarioLayout = new GridLayout(2, 5);
    renditeEKLabel = new Label("Renditeforderung EK:");
    renditeFKLabel = new Label("Renditeforderung FK:");
    gewerbeStLabel = new Label("Gewerbesteuer:");
    koerperStLabel = new Label("Krperschaftssteuer inkl. Solidarittszuschlag:");
    personalTaxRateLabel = new Label("Persnlicher Steuersatz");
    renditeEK = new Label();
    renditeFK = new Label();
    gewerbeSt = new Label();
    koerperSt = new Label();
    personalTaxRate = new Label();
    companyValueLayout = new HorizontalLayout();
    companyValueLabel = new Label("Unternehmenswert:");
    companyValue = new Label();
    gap = new Label();
    gap2 = new Label();
    gap3 = new Label();
    gap4 = new Label();
    expandingGap = new Label();
    expandingGap2 = new Label();
    expandingGap3 = new Label();
    capitalChartLayout = new VerticalLayout();
    cashflowChartLayout = new VerticalLayout();
    chartArea = new HorizontalLayout();

    gap.setWidth("20px");
    gap2.setWidth("20px");
    gap3.setHeight("20px");
    gap4.setHeight("20px");
    expandingGap.setSizeFull();

    planningLayout.setWidth(100, UNITS_PERCENTAGE);
    companyValueLayout.setHeight(100, UNITS_PIXELS);
    companyValueLayout.setWidth(100, UNITS_PERCENTAGE);
    scenarioLayout.setWidth(100, UNITS_PERCENTAGE);
    planningLabel.setWidth(SIZE_UNDEFINED, 0);
    companyValue.setWidth(SIZE_UNDEFINED, 0);
    companyValueLabel.setWidth(SIZE_UNDEFINED, 0);
    capitalChartLayout.setWidth(250, UNITS_PIXELS);
    capitalChartLayout.setHeight(250, UNITS_PIXELS);
    cashflowChartLayout.setWidth(350, UNITS_PIXELS);
    cashflowChartLayout.setHeight(250, UNITS_PIXELS);
    chartArea.setWidth(100, UNITS_PERCENTAGE);
    chartArea.setHeight(SIZE_UNDEFINED, 0);

    planningLabel.setStyleName("font12bold");
    renditeEKLabel.setStyleName("font12bold");
    renditeFKLabel.setStyleName("font12bold");
    gewerbeStLabel.setStyleName("font12bold");
    koerperStLabel.setStyleName("font12bold");
    personalTaxRateLabel.setStyleName("font12bold");
    renditeEK.setStyleName("font12bold");
    renditeFK.setStyleName("font12bold");
    gewerbeSt.setStyleName("font12bold");
    koerperSt.setStyleName("font12bold");
    personalTaxRate.setStyleName("font12bold");
    companyValueLabel.setStyleName("font14bold");
    companyValue.setStyleName("font14bold");

    scenarioLayout.setStyleName("resultScenarioLayout");
    companyValueLayout.setStyleName("companyValueLayout");

    planningLayout.addComponent(planningLabel);
    planningLayout.addComponent(gap2);
    planningLayout.addComponent(scenarioLayout);
    scenarioLayout.addComponent(renditeEKLabel, 0, 0);
    scenarioLayout.addComponent(renditeEK, 1, 0);
    scenarioLayout.addComponent(renditeFKLabel, 0, 1);
    scenarioLayout.addComponent(renditeFK, 1, 1);
    scenarioLayout.addComponent(gewerbeStLabel, 0, 2);
    scenarioLayout.addComponent(gewerbeSt, 1, 2);
    scenarioLayout.addComponent(koerperStLabel, 0, 3);
    scenarioLayout.addComponent(koerperSt, 1, 3);
    scenarioLayout.addComponent(personalTaxRateLabel, 0, 4);
    scenarioLayout.addComponent(personalTaxRate, 1, 4);
    companyValueLayout.addComponent(expandingGap2);
    companyValueLayout.addComponent(companyValueLabel);
    companyValueLayout.addComponent(gap);
    companyValueLayout.addComponent(companyValue);
    companyValueLayout.addComponent(expandingGap3);

    planningLayout.setComponentAlignment(planningLabel, Alignment.MIDDLE_LEFT);
    planningLayout.setExpandRatio(scenarioLayout, 1.0f);
    companyValueLayout.setComponentAlignment(companyValueLabel, Alignment.MIDDLE_CENTER);
    companyValueLayout.setComponentAlignment(companyValue, Alignment.MIDDLE_CENTER);
    companyValueLayout.setExpandRatio(expandingGap2, 1.0f);
    companyValueLayout.setExpandRatio(expandingGap3, 1.0f);
    //      scenarioLayout.setColumnExpandRatio(1, 1.0f);
    //      scenarioLayout.setComponentAlignment(renditeEK, Alignment.MIDDLE_RIGHT);
    //      scenarioLayout.setComponentAlignment(renditeFK, Alignment.MIDDLE_RIGHT);
    //      scenarioLayout.setComponentAlignment(gewerbeSt, Alignment.MIDDLE_RIGHT);
    scenarioLayout.setComponentAlignment(koerperSt, Alignment.BOTTOM_CENTER);

    chartArea.addComponent(capitalChartLayout);
    chartArea.addComponent(cashflowChartLayout);

    addComponent(planningLayout);
    addComponent(gap3);
    addComponent(companyValueLayout);
    addComponent(gap4);
    addComponent(chartArea);
    addComponent(expandingGap);

    setExpandRatio(expandingGap, 1.0f);
}

From source file:dhbw.ka.mwi.businesshorizon2.ui.scenarioscreen.ScenarioScreenViewImpl.java

License:Open Source License

/**
 * Die Methode fuegt der View ein Szenario hinzu. Sie baut hierzu saemtliche
 * notwendigen GUI-Elemente und entsprechenden Listener hinzu.
 * //from w  ww.j  a  v  a2  s  . c o  m
 * Auf ein GridLayout umgestellt.
 * 
 * @author Julius Hacker, Tobias Lindner
 * @param rateReturnEquity Standardwert fuer die Renditeforderung Eigenkapital
 * @param rateReturnCapitalStock Standardwert fuer die Renditeforderung Fremdkapital
 * @param businessTax Standardwert fuer die Gewerbesteuer
 * @param corporateAndSolitaryTax Standardwert fuer die Koerperschaftssteuer mit Solidaritaetszuschlag.
 */

@Override
public void addScenario(String rateReturnEquity, String rateReturnCapitalStock, String corporateAndSolitaryTax,
        String businessTax, String personalTaxRate, boolean isIncludeInCalculation, final int number) {
    HashMap<String, AbstractComponent> scenarioComponents = new HashMap<String, AbstractComponent>();

    Property.ValueChangeListener changeListener = new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            presenter.updateScenario(number);
            logger.debug("TextChange ausgeloest");
            logger.debug("ChangeListener " + System.identityHashCode(this));
            presenter.isValid();
        }
    };

    final GridLayout gl = new GridLayout(3, 7);
    gl.addStyleName("gridLayoutScenarios");
    gl.setSizeFull();
    gl.setColumnExpandRatio(0, 2);
    gl.setColumnExpandRatio(1, 1);
    gl.setColumnExpandRatio(2, 1);

    final Label scenarioName = new Label("<strong>Szenario " + number + "</strong>");
    scenarioName.setContentMode(Label.CONTENT_XHTML);
    scenarioComponents.put("label", scenarioName);

    logger.debug("SzenarioName: " + scenarioName);
    gl.addComponent(scenarioName, 0, 0);

    //EK Rendite
    final Label textEigenkapital = new Label("Renditeforderung Eigenkapital: ");
    textEigenkapital.setSizeFull();

    final TextField tfEigenkapital = new TextField();

    if (!"0.0".equals(rateReturnEquity)) {
        tfEigenkapital.setValue(rateReturnEquity);
    }

    tfEigenkapital.setImmediate(true);
    tfEigenkapital.addStyleName("scenario");
    tfEigenkapital.addListener(changeListener);

    gl.addComponent(textEigenkapital, 0, 1);
    gl.addComponent(tfEigenkapital, 1, 1);

    scenarioComponents.put("rateReturnEquity", tfEigenkapital);

    // Fremdkapital      
    final Label textFremdkapitel = new Label("Renditeforderung FK: ");

    final TextField tfFremdkapital = new TextField();

    if (!"0.0".equals(rateReturnCapitalStock)) {
        tfFremdkapital.setValue(rateReturnCapitalStock);
    }

    tfFremdkapital.setImmediate(true);
    tfFremdkapital.addStyleName("scenario");
    tfFremdkapital.addListener(changeListener);

    gl.addComponent(textFremdkapitel, 0, 2);
    gl.addComponent(tfFremdkapital, 1, 2);

    scenarioComponents.put("rateReturnCapitalStock", tfFremdkapital);

    //Gewerbesteuer
    final Label textGewerbesteuer = new Label("Gewerbesteuer:");
    final TextField tfGewerbesteuer = new TextField();

    if (!"0.0".equals(businessTax)) {
        tfGewerbesteuer.setValue(businessTax);
    }

    tfGewerbesteuer.setImmediate(true);
    tfGewerbesteuer.addStyleName("scenario");
    tfGewerbesteuer.addListener(changeListener);

    gl.addComponent(textGewerbesteuer, 0, 3);
    gl.addComponent(tfGewerbesteuer, 1, 3);

    scenarioComponents.put("businessTax", tfGewerbesteuer);

    //Krperschaftssteuer
    final Label textKoerperschaftssteuer = new Label("Krperschaftssteuer mit Solidarittszuschlag: ");

    final TextField tfKoerperschaftssteuer = new TextField();

    if (!"0.0".equals(corporateAndSolitaryTax)) {
        tfKoerperschaftssteuer.setValue(corporateAndSolitaryTax);
    }

    tfKoerperschaftssteuer.setImmediate(true);
    tfKoerperschaftssteuer.addStyleName("scenario");
    tfKoerperschaftssteuer.addListener(changeListener);

    gl.addComponent(textKoerperschaftssteuer, 0, 4);
    gl.addComponent(tfKoerperschaftssteuer, 1, 4);

    scenarioComponents.put("corporateAndSolitaryTax", tfKoerperschaftssteuer);

    // Persnlicher Steuersatz
    final Label textPersonalTaxRate = new Label("pers\u00F6nlicher Steuersatz: ");
    final TextField tfPersonalTaxRate = new TextField();
    if (!"0.0".equals(personalTaxRate)) {
        tfPersonalTaxRate.setValue(personalTaxRate);
    }
    tfPersonalTaxRate.setImmediate(true);
    tfPersonalTaxRate.addStyleName("scenario");
    tfPersonalTaxRate.addListener(changeListener);

    gl.addComponent(textPersonalTaxRate, 0, 5);
    gl.addComponent(tfPersonalTaxRate, 1, 5);

    scenarioComponents.put("personalTaxRate", tfPersonalTaxRate);

    deleteIcon = new Embedded(null,
            new ThemeResource("./images/icons/newIcons/1418766003_editor_trash_delete_recycle_bin_-128.png"));
    deleteIcon.setHeight(60, UNITS_PIXELS);
    deleteIcon.addStyleName("deleteScenario");

    deleteIcon.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void click(ClickEvent event) {
            presenter.removeScenario(number);
        }

    });

    gl.addComponent(deleteIcon, 2, 0, 2, 6);
    gl.setComponentAlignment(deleteIcon, Alignment.MIDDLE_CENTER);

    final Label gap = new Label();
    gap.setHeight(20, UNITS_PIXELS);

    gl.addComponent(gap, 0, 6);

    scenarioComponents.put("scenario", gl);

    this.scenarios.add(scenarioComponents);
    this.vlScenarios.addComponent(gl);

    //Button bei 3 Scenarios deaktivieren
    if (number == 3) {
        deactivateAddScenario();
    }
}

From source file:edu.kit.dama.ui.admin.administration.user.UserDataAdministrationTab.java

License:Apache License

private GridLayout getFilterWindowLayout() {
    if (filterWindowLayout == null) {
        String id = "viewLayout";
        LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

        filterWindowLayout = new GridLayout(2, 3);
        filterWindowLayout.setId(DEBUG_ID_PREFIX + id);
        filterWindowLayout.setSpacing(true);
        filterWindowLayout.setMargin(true);
        filterWindowLayout.addStyleName(CSSTokenContainer.GREY_CAPTION);

        filterWindowLayout.addComponent(getFilterColumnBox(), 0, 0);
        filterWindowLayout.addComponent(getFilterOptions(), 1, 0, 1, 1);
        filterWindowLayout.addComponent(getFilterSearchField(), 0, 1);
        filterWindowLayout.addComponent(getFilterButton(), 1, 2);
        filterWindowLayout.setComponentAlignment(getFilterButton(), Alignment.BOTTOM_RIGHT);

        filterWindowLayout.setColumnExpandRatio(0, 0.7f);
        filterWindowLayout.setColumnExpandRatio(1, 0.3f);
    }/*from  ww w .  jav a2s.c  om*/
    return filterWindowLayout;
}

From source file:edu.kit.dama.ui.admin.administration.usergroup.UserGroupAdministrationTab.java

License:Apache License

private GridLayout getFilterWindowLayout() {
    if (filterWindowLayout == null) {
        String id = "viewLayout";
        LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

        filterWindowLayout = new GridLayout(2, 3);
        filterWindowLayout.setId(DEBUG_ID_PREFIX + id);
        filterWindowLayout.setSpacing(true);
        filterWindowLayout.setMargin(true);
        filterWindowLayout.addStyleName(CSSTokenContainer.GREY_CAPTION);

        filterWindowLayout.addComponent(getColumnBox(), 0, 0);
        filterWindowLayout.addComponent(getFilterOptions(), 1, 0, 1, 1);
        filterWindowLayout.addComponent(getFilterSearchField(), 0, 1);
        filterWindowLayout.addComponent(getFilterButton(), 1, 2);
        filterWindowLayout.setComponentAlignment(getFilterButton(), Alignment.BOTTOM_RIGHT);

        filterWindowLayout.setColumnExpandRatio(0, 0.7f);
        filterWindowLayout.setColumnExpandRatio(1, 0.3f);
    }//  ww  w  .j  a v a2  s . c  om
    return filterWindowLayout;
}

From source file:edu.kit.dama.ui.admin.ServiceAccessTokenDialog.java

License:Apache License

private void buildMainLayout() {
    authenticatorSelection = new ComboBox("Credential Type");
    authenticatorSelection.setWidth("100%");
    authenticatorSelection.setNullSelectionAllowed(false);
    authenticatorSelection.addStyleName("myboldcaption");

    //load all authenticators
    authenticators.add(new MainLoginAuthenticator());
    authenticatorSelection.addItem(authenticators.get(0).getAuthenticatorId());

    //fill authenticator list and selection box
    AuthenticatorFactory.getInstance().getAuthenticators().forEach((auth) -> {
        authenticators.add(auth);/*from   w w w.j  a  va  2 s  .  c om*/
        authenticatorSelection.addItem(auth.getAuthenticatorId());
    });

    //selection handler
    authenticatorSelection.addValueChangeListener((event) -> {
        String value = (String) authenticatorSelection.getValue();
        authenticators.forEach((auth) -> {
            if (auth.getAuthenticatorId().equals(value)) {
                updateAuthenticatorAttributeLayout(auth);
            }
        });
    });

    //generate secret handling
    generateButton.addClickListener((event) -> {
        String newSecret = RandomStringUtils.randomAlphanumeric(16);
        if (secretField != null) {
            //check this just to get sure
            secretField.setValue(newSecret);
            nosecretField.setValue(newSecret);
            UIComponentTools.showInformation("New random secret has been generated.");
        }
    });

    //show secret handling
    showSecret.addValueChangeListener((event2) -> {
        if (secretField != null) {
            //check this just to get sure
            if (showSecret.getValue()) {
                nosecretField.setValue(secretField.getValue());
                authenticatorConfigurationLayout.replaceComponent(secretField, nosecretField);
            } else {
                secretField.setValue(nosecretField.getValue());
                authenticatorConfigurationLayout.replaceComponent(nosecretField, secretField);
            }
        }
    });

    ClickListener listener = (Button.ClickEvent event) -> {
        boolean update = false;
        boolean created = false;

        if (okButton.equals(event.getSource()) && selectedId > 0) {
            //update of existing credential
            update = true;
            IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
            mdm.setAuthorizationContext(UIHelper.getSessionContext());
            try {
                ServiceAccessToken existingToken = mdm.find(ServiceAccessToken.class, selectedId);
                //transfer information from existing token to new one and persist
                ServiceAccessToken newToken = getToken(existingToken.getUserId());
                newToken.setId(selectedId);
                newToken.setServiceId(existingToken.getServiceId());
                mdm.save(newToken);
            } catch (UnauthorizedAccessAttemptException | SecretEncryptionException ex) {
                UIComponentTools.showWarning("Unable to store credential.");
                return;
            } finally {
                mdm.close();
            }
        } else if (okButton.equals(event.getSource()) && selectedId <= 0) {
            //creation of new token
            String typeSelection = (String) authenticatorSelection.getValue();
            IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
            mdm.setAuthorizationContext(UIHelper.getSessionContext());
            String userId = UIHelper.getSessionUser().getDistinguishedName();
            try {
                try {
                    List<ServiceAccessToken> token = mdm.findResultList(
                            "SELECT t FROM ServiceAccessToken t WHERE t.serviceId=?1 AND t.userId=?2",
                            new Object[] { typeSelection, userId }, ServiceAccessToken.class);
                    if (!token.isEmpty()) {
                        UIComponentTools.showWarning("There exists already a credential of type '"
                                + typeSelection + "' for your userId.");
                        return;
                    }
                } catch (UnauthorizedAccessAttemptException ex) {
                    UIComponentTools.showWarning("Unable to check for existing credential.");
                    return;
                }

                ServiceAccessToken newToken = getToken(userId);

                String uid = newToken.getUserId();
                newToken.setUserId(null);
                if (!mdm.find(newToken, newToken).isEmpty()) {
                    throw new UnauthorizedAccessAttemptException("Duplicate credential detected.");
                }

                newToken.setUserId(uid);
                mdm.save(newToken);
                created = true;
            } catch (UnauthorizedAccessAttemptException | SecretEncryptionException ex) {
                UIComponentTools
                        .showWarning("Failed to create new credential. (Message: " + ex.getMessage() + ")");
                return;
            } finally {
                mdm.close();
            }

        }
        //close window
        if (currentWin != null) {
            UI.getCurrent().removeWindow(currentWin);
            if (update) {
                UIComponentTools.showInformation("Credential successfully updated.");
            } else if (created) {
                UIComponentTools.showInformation("Credential successfully created.");
            }
        }
    };
    okButton.addClickListener(listener);
    cancelButton.addClickListener(listener);

    //fill dummy config layout
    authenticatorConfigurationLayout = new GridLayout(1, 1);
    authenticatorConfigurationLayout.addComponent(new Label("Please select an authenticator."));
    authenticatorConfigurationLayout.setSpacing(true);
    authenticatorConfigurationLayout.setWidth("400px");

    HorizontalLayout buttonLayout = new HorizontalLayout(cancelButton, okButton);
    buttonLayout.setSpacing(true);

    mainLayout = new VerticalLayout(authenticatorSelection, authenticatorConfigurationLayout, buttonLayout);
    mainLayout.setSpacing(true);
    mainLayout.setMargin(true);
    mainLayout.setExpandRatio(authenticatorConfigurationLayout, 1.0f);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_RIGHT);
}

From source file:edu.kit.dama.ui.admin.utils.PathSelector.java

License:Apache License

/**
 *
 *///from w w w . ja v  a 2 s.c  o m
private void buildMainLayout() {
    String id = "mainLayout";
    LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ...");

    mainLayout = new GridLayout(3, 3);
    mainLayout.setImmediate(true);
    mainLayout.setSizeFull();
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    mainLayout.addComponent(getRootBox(), 0, 0);
    mainLayout.addComponent(getTreeTable(), 0, 1, 2, 1);
    mainLayout.addComponent(getPathField(), 0, 2, 1, 2);
    mainLayout.addComponent(getSelectButton(), 2, 2);

    mainLayout.setComponentAlignment(getPathField(), Alignment.BOTTOM_LEFT);
    mainLayout.setComponentAlignment(getSelectButton(), Alignment.BOTTOM_RIGHT);

    mainLayout.setColumnExpandRatio(0, 0.4f);
    mainLayout.setColumnExpandRatio(1, 0.39f);
    mainLayout.setColumnExpandRatio(2, 0.01f);

    mainLayout.setRowExpandRatio(0, 0.01f);
    mainLayout.setRowExpandRatio(1, 0.9f);
    mainLayout.setRowExpandRatio(2, 0.01f);
}

From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java

License:Open Source License

void handleShowActiveUsersPerServer(MenuBar mbar) {
    Object[][] oa = Mmowgli2UI.getGlobals().getSessionCountByServer();

    Window svrCountWin = new Window("Display Active Users Per Server");
    svrCountWin.setModal(true);/*  w  ww. j a  v a  2  s  . com*/
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setWidth("99%");
    svrCountWin.setContent(layout);

    GridLayout gl = new GridLayout(2, Math.max(1, oa.length));
    gl.setSpacing(true);
    gl.addStyleName("m-greyborder");
    for (Object[] row : oa) {
        Label lab = new Label();
        lab.setSizeUndefined();
        lab.setValue(row[0].toString());
        gl.addComponent(lab);
        gl.setComponentAlignment(lab, Alignment.MIDDLE_RIGHT);

        gl.addComponent(new Label(row[1].toString()));
    }
    layout.addComponent(gl);
    layout.setComponentAlignment(gl, Alignment.MIDDLE_CENTER);

    svrCountWin.setWidth("250px");
    UI.getCurrent().addWindow(svrCountWin);
    svrCountWin.center();
}