List of usage examples for com.vaadin.ui TextField setValue
@Override public void setValue(String value)
From source file:dhbw.ka.mwi.businesshorizon2.ui.periodscreen.direkteeingabe.DirektViewImpl.java
License:Open Source License
private int createTextFields(int pastPeriods, int currYear, Item row1, Item row2) { for (int i = 0; i < pastPeriods; i++) { final int year = currYear; TextField field1 = new TextField(); field1.setWidth(50, UNITS_PIXELS); field1.setImmediate(true);// w w w.j a va 2s.c o m field1.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue; try { dValue = Double.parseDouble(value); presenter.setValid(); } catch (Exception e) { dValue = 0.0; getWindow().showNotification((String) "", "Ihre Eingabe des Cashlflows/der Ausschttung fr das Jahr" + year + "ist keine valide Kommazahl. Bitte berprfen Sie ihre Eingabe.", Notification.TYPE_WARNING_MESSAGE); presenter.setInvalid(); } presenter.setCashFlowValue(dValue, year); // presenter.checkValid(); } }); field1.setValue(presenter.getCashFlow(year)); TextField field2 = new TextField(); field2.setWidth(50, UNITS_PIXELS); field2.setImmediate(true); field2.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue; try { dValue = Double.parseDouble(value); presenter.setValid(); } catch (Exception e) { dValue = 0.0; getWindow().showNotification((String) "", "Ihre Eingabe des Bilanzwertes fr das Jahr" + year + "ist keine valide Kommazahl. Bitte berprfen Sie ihre Eingabe.", Notification.TYPE_WARNING_MESSAGE); presenter.setInvalid(); } presenter.setCapitalStockValue(dValue, year); // presenter.checkValid(); } }); field2.setValue(presenter.getCapitalStock(year)); row1.getItemProperty(currYear).setValue(field1); row2.getItemProperty(currYear).setValue(field2); currYear++; } return currYear; }
From source file:dhbw.ka.mwi.businesshorizon2.ui.periodscreen.gesamtkostenverfahren.GesamtkostenVerfahrenViewImpl.java
License:Open Source License
private int createTextFields(int pastPeriods, int currYear, Item capitalRow, Item row1, Item row2, Item row3, Item row4, Item row5, Item row6, Item row7, Item row8, Item row9, Item row10, Item row11, Item row12, Item row13, Item row14, Item row15) { for (int i = 0; i < pastPeriods; i++) { final int year = currYear; TextField field0 = new TextField(); field0.setWidth(50, UNITS_PIXELS); field0.setImmediate(true);/*from ww w. ja va2s. co m*/ field0.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setFremdkapital(dValue, year); } }); field0.setValue(presenter.getFremdkapital(year)); capitalRow.getItemProperty(currYear).setValue(field0); TextField field1 = new TextField(); field1.setWidth(50, UNITS_PIXELS); field1.setImmediate(true); field1.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setUmsatzerloese(dValue, year); } }); field1.setValue(presenter.getUmsatzerloese(year)); TextField field2 = new TextField(); field2.setWidth(50, UNITS_PIXELS); field2.setImmediate(true); field2.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setBestanderhoehung(dValue, year); } }); field2.setValue(presenter.getBestanderhoehung(year)); TextField field3 = new TextField(); field3.setWidth(50, UNITS_PIXELS); field3.setImmediate(true); field3.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setBestandverminderung(dValue, year); } }); field3.setValue(presenter.getBestandminderung(year)); TextField field4 = new TextField(); field4.setWidth(50, UNITS_PIXELS); field4.setImmediate(true); field4.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setMaterialaufwand(dValue, year); } }); field4.setValue(presenter.getMaterialaufwand(year)); TextField field5 = new TextField(); field5.setWidth(50, UNITS_PIXELS); field5.setImmediate(true); field5.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setLoehne(dValue, year); } }); field5.setValue(presenter.getLoehne(year)); TextField field6 = new TextField(); field6.setWidth(50, UNITS_PIXELS); field6.setImmediate(true); field6.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setEinstellungskosten(dValue, year); } }); field6.setValue(presenter.getEinstellungskosten(year)); TextField field7 = new TextField(); field7.setWidth(50, UNITS_PIXELS); field7.setImmediate(true); field7.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setPensionrueckstellungen(dValue, year); } }); field7.setValue(presenter.getPensionsrueckstellungen(year)); TextField field8 = new TextField(); field8.setWidth(50, UNITS_PIXELS); field8.setImmediate(true); field8.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setSonstigPersonal(dValue, year); } }); field8.setValue(presenter.getSonstigPersonalkosten(year)); TextField field9 = new TextField(); field9.setWidth(50, UNITS_PIXELS); field9.setImmediate(true); field9.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setAbschreibungen(dValue, year); } }); field9.setValue(presenter.getAbschreibungen(year)); TextField field10 = new TextField(); field10.setWidth(50, UNITS_PIXELS); field10.setImmediate(true); field10.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setSonstigAufwand(dValue, year); } }); field10.setValue(presenter.getSonstigAufwand(year)); TextField field11 = new TextField(); field11.setWidth(50, UNITS_PIXELS); field11.setImmediate(true); field11.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setSonstigErtrag(dValue, year); } }); field11.setValue(presenter.getSonstigErtrag(year)); TextField field12 = new TextField(); field12.setWidth(50, UNITS_PIXELS); field12.setImmediate(true); field12.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setWertpapierErtrag(dValue, year); } }); field12.setValue(presenter.getWertpapierErtrag(year)); TextField field13 = new TextField(); field13.setWidth(50, UNITS_PIXELS); field13.setImmediate(true); field13.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setZinsaufwand(dValue, year); } }); field13.setValue(presenter.getZinsaufwand(year)); TextField field14 = new TextField(); field14.setWidth(50, UNITS_PIXELS); field14.setImmediate(true); field14.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setAusserordentlichErtrag(dValue, year); } }); field14.setValue(presenter.getAusserordentlichErtrag(year)); TextField field15 = new TextField(); field15.setWidth(50, UNITS_PIXELS); field15.setImmediate(true); field15.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setAusserordentlichAufwand(dValue, year); } }); field15.setValue(presenter.getAusserordentlichAufwand(year)); row1.getItemProperty(currYear).setValue(field1); row2.getItemProperty(currYear).setValue(field2); row3.getItemProperty(currYear).setValue(field3); row4.getItemProperty(currYear).setValue(field4); row5.getItemProperty(currYear).setValue(field5); row6.getItemProperty(currYear).setValue(field6); row7.getItemProperty(currYear).setValue(field7); row8.getItemProperty(currYear).setValue(field8); row9.getItemProperty(currYear).setValue(field9); row10.getItemProperty(currYear).setValue(field10); row11.getItemProperty(currYear).setValue(field11); row12.getItemProperty(currYear).setValue(field12); row13.getItemProperty(currYear).setValue(field13); row14.getItemProperty(currYear).setValue(field14); row15.getItemProperty(currYear).setValue(field15); currYear++; } return currYear; }
From source file:dhbw.ka.mwi.businesshorizon2.ui.periodscreen.umsatzkostenverfahren.UmsatzkostenVerfahrenViewImpl.java
License:Open Source License
private int createTextFields(int pastPeriods, int currYear, Item capitalRow, Item row1, Item row2, Item row3, Item row4, Item row5, Item row7, Item row9, Item row10, Item row11, Item row12, Item row13, Item row14, Item row15) {/*from www .j ava 2s .c o m*/ for (int i = 0; i < pastPeriods; i++) { final int year = currYear; TextField field0 = new TextField(); field0.setWidth(50, UNITS_PIXELS); field0.setImmediate(true); field0.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setFremdkapital(dValue, year); } }); field0.setValue(presenter.getFremdkapital(year)); capitalRow.getItemProperty(currYear).setValue(field0); TextField field1 = new TextField(); field1.setWidth(50, UNITS_PIXELS); field1.setImmediate(true); field1.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setUmsatzerloese(dValue, year); } }); field1.setValue(presenter.getUmsatzerloese(year)); TextField field2 = new TextField(); field2.setWidth(50, UNITS_PIXELS); field2.setImmediate(true); field2.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setHerstellkosten(dValue, year); } }); field2.setValue(presenter.getHerstellkosten(year)); TextField field3 = new TextField(); field3.setWidth(50, UNITS_PIXELS); field3.setImmediate(true); field3.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setVertriebskosten(dValue, year); } }); field3.setValue(presenter.getVertriebskosten(year)); TextField field4 = new TextField(); field4.setWidth(50, UNITS_PIXELS); field4.setImmediate(true); field4.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setForschungskosten(dValue, year); } }); field4.setValue(presenter.getForschungskosten(year)); TextField field5 = new TextField(); field5.setWidth(50, UNITS_PIXELS); field5.setImmediate(true); field5.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setVerwaltungskosten(dValue, year); } }); field5.setValue(presenter.getVerwaltungskosten(year)); TextField field7 = new TextField(); field7.setWidth(50, UNITS_PIXELS); field7.setImmediate(true); field7.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setPensionrueckstellungen(dValue, year); } }); field7.setValue(presenter.getPensionsrueckstellungen(year)); TextField field9 = new TextField(); field9.setWidth(50, UNITS_PIXELS); field9.setImmediate(true); field9.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setAbschreibungen(dValue, year); } }); field9.setValue(presenter.getAbschreibungen(year)); TextField field10 = new TextField(); field10.setWidth(50, UNITS_PIXELS); field10.setImmediate(true); field10.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setSonstigAufwand(dValue, year); } }); field10.setValue(presenter.getSonstigAufwand(year)); TextField field11 = new TextField(); field11.setWidth(50, UNITS_PIXELS); field11.setImmediate(true); field11.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setSonstigErtrag(dValue, year); } }); field11.setValue(presenter.getSonstigErtrag(year)); TextField field12 = new TextField(); field12.setWidth(50, UNITS_PIXELS); field12.setImmediate(true); field12.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setWertpapierErtrag(dValue, year); } }); field12.setValue(presenter.getWertpapierErtrag(year)); TextField field13 = new TextField(); field13.setWidth(50, UNITS_PIXELS); field13.setImmediate(true); field13.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setZinsaufwand(dValue, year); } }); field13.setValue(presenter.getZinsaufwand(year)); TextField field14 = new TextField(); field14.setWidth(50, UNITS_PIXELS); field14.setImmediate(true); field14.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setAusserordentlichErtrag(dValue, year); } }); field14.setValue(presenter.getAusserordentlichErtrag(year)); TextField field15 = new TextField(); field15.setWidth(50, UNITS_PIXELS); field15.setImmediate(true); field15.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); double dValue = Double.parseDouble(value); presenter.setAusserordentlichAufwand(dValue, year); } }); field15.setValue(presenter.getAusserordentlichAufwand(year)); row1.getItemProperty(currYear).setValue(field1); row2.getItemProperty(currYear).setValue(field2); row3.getItemProperty(currYear).setValue(field3); row4.getItemProperty(currYear).setValue(field4); row5.getItemProperty(currYear).setValue(field5); row7.getItemProperty(currYear).setValue(field7); row9.getItemProperty(currYear).setValue(field9); row10.getItemProperty(currYear).setValue(field10); row11.getItemProperty(currYear).setValue(field11); row12.getItemProperty(currYear).setValue(field12); row13.getItemProperty(currYear).setValue(field13); row14.getItemProperty(currYear).setValue(field14); row15.getItemProperty(currYear).setValue(field15); currYear++; } return currYear; }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.period.input.AbstractInputView.java
License:Open Source License
public void addInputField(String pd) { TextField tf = new TextField(pd); tf.setImmediate(true);// w ww . j av a 2 s . co m tf.setWidth("200px"); tf.addListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { // TODO Auto-generated method stub TextField tf = (TextField) event.getProperty(); presenter.validateChange((String) tf.getValue(), panel.getComponentArea(tf).getColumn1(), panel.getComponentArea(tf).getRow1(), tf.getCaption()); try { tf.setValue(df.format(df.parse((String) tf.getValue()).doubleValue())); } catch (ReadOnlyException | ConversionException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); panel.addComponent(tf); tf.setTextChangeEventMode(TextChangeEventMode.EAGER); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.period.input.AbstractInputView.java
License:Open Source License
/** * Erstelle das GUI zum zur Eingabe/* w ww . jav a2 s . c o m*/ * * @author Daniel Dengler */ public void addInputField(String pd, double initialContent) { TextField tf = new TextField(pd, df.format(initialContent)); df.format(initialContent); tf.setImmediate(true); tf.setWidth("200px"); tf.addListener(new Property.ValueChangeListener() { /** * */ private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { // TODO Auto-generated method stub TextField tf = (TextField) event.getProperty(); presenter.validateChange((String) tf.getValue(), panel.getComponentArea(tf).getColumn1(), panel.getComponentArea(tf).getRow1(), tf.getCaption()); try { tf.setValue(df.format(df.parse((String) tf.getValue()).doubleValue())); } catch (ReadOnlyException | ConversionException | ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); panel.addComponent(tf); tf.setTextChangeEventMode(TextChangeEventMode.EAGER); }
From source file:dhbw.ka.mwi.businesshorizon2.ui.process.scenario.ScenarioViewImpl.java
License:Open Source License
/** * Die Methode fuegt der View ein Szenario hinzu. Sie baut hierzu saemtliche * notwendigen GUI-Elemente und entsprecheenden Listener hinzu. * // w w w . j a v a2s. c o m * @author Julius Hacker * @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, 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)); } }; HorizontalLayout hlScenario = new HorizontalLayout(); hlScenario.setSizeFull(); FormLayout formLeft = new FormLayout(); FormLayout formRight = new FormLayout(); hlScenario.addComponent(formLeft); //hlScenario.addComponent(formRight); final Label scenarioName = new Label("<strong>Szenario " + number + "</strong>"); scenarioName.setContentMode(Label.CONTENT_XHTML); scenarioComponents.put("label", scenarioName); formLeft.addComponent(scenarioName); scenarioName.setWidth(Sizeable.SIZE_UNDEFINED, 0); final CheckBox cbBerechnungEinbezug = new CheckBox("In Berechnung einbeziehen"); cbBerechnungEinbezug.setValue(isIncludeInCalculation); cbBerechnungEinbezug.setImmediate(true); cbBerechnungEinbezug.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { presenter.updateScenario(number); logger.debug("ChangeListener " + System.identityHashCode(this)); } }); scenarioComponents.put("isIncludeInCalculation", cbBerechnungEinbezug); formLeft.addComponent(cbBerechnungEinbezug); final TextField tfEigenkapital = new TextField("Renditeforderung Eigenkapital: "); if (!"0.0".equals(rateReturnEquity)) { tfEigenkapital.setValue(rateReturnEquity); } tfEigenkapital.setImmediate(true); tfEigenkapital.addListener(changeListener); scenarioComponents.put("rateReturnEquity", tfEigenkapital); formLeft.addComponent(tfEigenkapital); final TextField tfFremdkapital = new TextField("Renditeforderung Fremdkapital: "); if (!"0.0".equals(rateReturnCapitalStock)) { tfFremdkapital.setValue(rateReturnCapitalStock); } tfFremdkapital.setImmediate(true); tfFremdkapital.addListener(changeListener); scenarioComponents.put("rateReturnCapitalStock", tfFremdkapital); formLeft.addComponent(tfFremdkapital); final TextField tfGewerbesteuer = new TextField("Gewerbesteuer: "); if (!"0.0".equals(businessTax)) { tfGewerbesteuer.setValue(businessTax); } tfGewerbesteuer.setImmediate(true); tfGewerbesteuer.addListener(changeListener); scenarioComponents.put("businessTax", tfGewerbesteuer); formLeft.addComponent(tfGewerbesteuer); final TextField tfKoerperschaftssteuer = new TextField( "K\u00F6rperschaftssteuer mit Solidarit\u00E4tszuschlag: "); if (!"0.0".equals(corporateAndSolitaryTax)) { tfKoerperschaftssteuer.setValue(corporateAndSolitaryTax); } tfKoerperschaftssteuer.setImmediate(true); tfKoerperschaftssteuer.addListener(changeListener); scenarioComponents.put("corporateAndSolitaryTax", tfKoerperschaftssteuer); formLeft.addComponent(tfKoerperschaftssteuer); final Button removeScenario = new Button("Szenario entfernen"); removeScenario.addListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { presenter.removeScenario(number); } }); formLeft.addComponent(removeScenario); formLeft.setWidth(Sizeable.SIZE_UNDEFINED, 0); formLeft.setWidth(Sizeable.SIZE_UNDEFINED, 0); scenarioComponents.put("scenario", hlScenario); this.scenarios.add(scenarioComponents); this.vlScenarios.addComponent(hlScenario); }
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. * // w w w . j a v a 2s . 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.GenericSpecificPropertiesLayout.java
License:Apache License
/** * Fill the layout depending on the provided configurable and properties. * * @param pConfigurable The configurable used to obtain all supported * property keys and their descriptions. * @param pProperties A set of key-value pairs for the provided * configurable./*from w ww. j a v a 2s . c om*/ * * @throws UIComponentUpdateException If pConfigurable is null. */ public void updateComponents(IConfigurable pConfigurable, Properties pProperties) throws UIComponentUpdateException { if (pConfigurable == null) { reset(); throw new UIComponentUpdateException("Invalid IConfigurable argument 'null'."); } //obtain all properties String[] keys = pConfigurable.getInternalPropertyKeys(); if (keys == null || keys.length == 0) { reset(); LOGGER.warn("Provided configurable has no specific properties."); return; } removeAllComponents(); for (String key : keys) { TextField propertyField = UIUtils7.factoryTextField(key, ""); if (pProperties != null) { //obtain and set the value String defaultValue = (String) pProperties.get(key); propertyField.setValue(defaultValue); propertyField.setId(key); } String description = pConfigurable.getInternalPropertyDescription(key); Label propertyDescription; if (description != null && description.length() > 1) { propertyDescription = new Label( "Description: " + pConfigurable.getInternalPropertyDescription(key)); } else { propertyDescription = new Label("No description available"); } propertyDescription.setEnabled(false); propertyField.addStyleName(CSSTokenContainer.BOLD_CAPTION); addComponent(propertyField); addComponent(propertyDescription); propertiesFields.add(propertyField); } }
From source file:edu.kit.dama.ui.admin.LandingPageComponent.java
License:Apache License
public final void update(DigitalObject object, boolean privileged) { if (object == null) { UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(1, 1); builder.fill(new Label("Access to digital object not permitted."), 0, 0); mainLayout = builder.getLayout(); mainLayout.setMargin(true);//from w w w .ja v a 2s.c om mainLayout.setSpacing(true); mainLayout.setStyleName("landing"); HorizontalLayout hLayout = new HorizontalLayout(mainLayout); hLayout.setSizeFull(); hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(hLayout); } else { final TextField oidField = new TextField(); Button searchButton = new Button("Search"); Button metsButton = new Button("METS"); final Button dcButton = new Button("DublinCore"); Button dataButton = new Button("Download"); VerticalLayout metadataDownloadButtons = new VerticalLayout(dcButton, metsButton); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(3, 6); StreamResource metsResource = new StreamResource(() -> { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); MetsBuilder.init(object).createMinimalMetsDocument(UserData.WORLD_USER).write(bout); return new ByteArrayInputStream(bout.toByteArray()); } catch (Exception ex) { LOGGER.error("Failed to provide METS document.", ex); UIComponentTools.showError( "Failed to initialize METS document for download. Cause: " + ex.getMessage()); return null; } }, object.getDigitalObjectIdentifier() + ".mets.xml"); StreamResource dcResource = new StreamResource(() -> { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DublinCoreHelper.writeDublinCoreDocument(object, UserData.WORLD_USER, bout); return new ByteArrayInputStream(bout.toByteArray()); } catch (ParserConfigurationException ex) { LOGGER.error("Failed to provide DC document.", ex); UIComponentTools .showError("Failed to initialize DC document for download. Cause: " + ex.getMessage()); return null; } }, object.getDigitalObjectIdentifier() + ".dc.xml"); StreamResource dataResource = new StreamResource(() -> { IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { IAuthorizationContext ctx = new AuthorizationContext(new UserId(Constants.WORLD_USER_ID), new GroupId(Constants.WORLD_USER_ID), Role.GUEST); if (accessGranted(object, ctx) || accessGranted(object, UIHelper.getSessionContext())) { Response response = new PublicDownloadHandler().prepareStream(object); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return (InputStream) response.getEntity(); } else { LOGGER.error("Preparation of the public download for object " + object.getDigitalObjectIdentifier() + " returned status " + response.getStatus() + ". Aborting."); } } throw new IOException("Public access not available."); } catch (IOException ex) { LOGGER.error( "Failed to provide data stream for object " + object.getDigitalObjectIdentifier() + ".", ex); UIComponentTools.showError( "Failed to initialize data stream for public download. Probably, the digital object is not publicly available."); return null; } }, object.getDigitalObjectIdentifier() + ".zip"); Map<String, String> dcElementMap = new HashMap<>(); try { dcElementMap = DublinCoreHelper.createDublinCoreElementMap(object, UserData.WORLD_USER); } catch (ParserConfigurationException ex) { LOGGER.error( "Failed to create DC metadata for object with id " + object.getDigitalObjectIdentifier(), ex); } oidField.setValue(object.getDigitalObjectIdentifier()); FileDownloader metsDownloader = new FileDownloader(metsResource); metsDownloader.extend(metsButton); FileDownloader dcDownloader = new FileDownloader(dcResource); dcDownloader.extend(dcButton); FileDownloader dataDownloader = new FileDownloader(dataResource); dataDownloader.extend(dataButton); oidField.setSizeFull(); searchButton.setWidth("128px"); searchButton.addClickListener((Button.ClickEvent event) -> { String oid = oidField.getValue(); Page.getCurrent().setLocation( URI.create(UIHelper.getWebAppUrl().toString() + "?landing&oid=" + oid).toString()); }); dcButton.setWidth("128px"); metsButton.setWidth("128px"); dataButton.setWidth("128px"); metadataDownloadButtons.setComponentAlignment(dcButton, Alignment.TOP_LEFT); metadataDownloadButtons.setComponentAlignment(metsButton, Alignment.TOP_LEFT); //build layout Label oidLabel = new Label("<u>Object Id</u>", ContentMode.HTML); builder.fillRow(oidLabel, 0, 0, 1); oidLabel.addStyleName("myboldcaption"); builder.addComponent(oidField, 0, 1, 2, 1).addComponent(searchButton, 2, 1); Label dcMetadataLabel = new Label("<u>DC Metadata</u>", ContentMode.HTML); builder.fillRow(dcMetadataLabel, 0, 2, 1); dcMetadataLabel.addStyleName("myboldcaption"); Set<Map.Entry<String, String>> entries = dcElementMap.entrySet(); Table dcTable = new Table(); dcTable.setPageLength(entries.size() + 1); dcTable.addContainerProperty("dc:key", String.class, "-"); dcTable.addContainerProperty("dc:value", String.class, "-"); entries.forEach((entry) -> { Object newItemId = dcTable.addItem(); Item row1 = dcTable.getItem(newItemId); row1.getItemProperty("dc:key").setValue(entry.getKey()); row1.getItemProperty("dc:value").setValue(entry.getValue()); }); dcTable.setWidth("640px"); dcTable.addStyleName("myboldcaption"); builder.addComponent(dcTable, 0, 3, 2, 1); builder.addComponent(metadataDownloadButtons, 2, 3, 1, 1); builder.fillRow(new Label("<u>Data Access</u>", ContentMode.HTML), 0, 4, 1); long bytes = DataOrganizationUtils.getAssociatedDataSize(object.getDigitalObjectId()); String formatted = AbstractFile.formatSize(bytes); Label oidDownloadLabel = new Label( object.getDigitalObjectIdentifier() + ".zip (approx. " + formatted + ")"); oidDownloadLabel.addStyleName("myboldcaption"); builder.addComponent(oidDownloadLabel, 0, 5, 2, 1); builder.addComponent(dataButton, 2, 5, 1, 1); mainLayout = builder.getLayout(); mainLayout.setRowExpandRatio(0, .1f); mainLayout.setRowExpandRatio(1, .1f); mainLayout.setRowExpandRatio(2, .6f); mainLayout.setRowExpandRatio(3, .1f); mainLayout.setRowExpandRatio(4, .1f); mainLayout.setColumnExpandRatio(0, .1f); mainLayout.setColumnExpandRatio(1, .8f); mainLayout.setColumnExpandRatio(2, .1f); } mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setStyleName("landing"); HorizontalLayout hLayout = new HorizontalLayout(mainLayout); hLayout.setSizeFull(); hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(hLayout); }
From source file:edu.kit.dama.ui.admin.schedule.trigger.ExpressionTriggerConfigurationPanel.java
License:Apache License
/** * Factory a standard text field that with the default look and behavior. * * @param pLabel The field label.//from ww w. j av a 2 s . c o m * @param pDescription The field description that may contain information * about allowed values. * @param pDefaultValue The default value. * @param pRequired Set the field to be required. * @param pNullAllowed TRUE = Null is a valid value. * * @return The text field. */ private TextField factoryTextField(String pLabel, String pDescription, String pDefaultValue, boolean pRequired, boolean pNullAllowed) { TextField result = new TextField(pLabel); result.setDescription(pDescription); result.setWidth("40px"); result.setImmediate(true); result.setRequired(pRequired); result.setValue(pDefaultValue); result.setNullSettingAllowed(pNullAllowed); if (pNullAllowed) { result.setNullRepresentation(""); } result.addStyleName(CSSTokenContainer.BOLD_CAPTION); return result; }