@Override
  protected void init(VaadinRequest request) {
    final PortletPreferences portletPrefs =
        ((PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST))
            .getPreferences();

    VerticalLayout editLayout = new VerticalLayout();
    editLayout.setMargin(true);
    editLayout.setSpacing(true);

    OptionGroup langSelect = new OptionGroup("Choose application language");
    langSelect.setMultiSelect(false);
    langSelect.addItem(LanguageConst.getLocaleStrFromLocale(LanguageConst.LOCALE_FI));
    langSelect.addItem(LanguageConst.getLocaleStrFromLocale(LanguageConst.LOCALE_EN));
    editLayout.addComponent(langSelect);

    String localeStr = portletPrefs.getValue(TupaConst.PORTLET_PREFERENCE_KEY_LANGUAGE, null);
    if (localeStr != null) {
      langSelect.setValue(localeStr);
    }

    Button storeBtn = VaadinTools.createButton("Save", FontAwesome.SAVE, null, null);
    storeBtn.addClickListener(
        e -> {
          if (langSelect.getValue() == null) {
            VaadinTools.showWarning("Please select language", null);
          } else {
            try {
              portletPrefs.setValue(
                  TupaConst.PORTLET_PREFERENCE_KEY_LANGUAGE, langSelect.getValue().toString());
              portletPrefs.store();
              VaadinTools.showNotification("Language selection saved!", null);
            } catch (Exception e1) {
              VaadinTools.showError(
                  "Something went wrong when saving the language preference", null);
              e1.printStackTrace();
            }
          }
        });
    editLayout.addComponent(storeBtn);
    setContent(editLayout);
  }
  @Override
  public void init() {
    buttonCancel = new Button("Batalkan");
    buttonCancel.addClickListener(this);

    buttonShow = new Button("Tampilkan Laporan");
    buttonShow.addClickListener(this);

    buttonPrint = new Button("Cetak");
    buttonPrint.addClickListener(this);
    buttonPrint.setIcon(new ThemeResource("icons/image/icon-print.png"));

    opener = new BrowserWindowOpener(ReportPrint.class);
    opener.setFeatures("height=200,width=400,resizable");
    // A button to open the printer-friendly page.
    opener.extend(buttonPrint);

    DateTime now = DateTime.now();
    Date beginYear =
        now.withDayOfYear(now.dayOfYear().getMinimumValue())
            .withHourOfDay(now.hourOfDay().getMinimumValue())
            .toDate();
    Date endYear =
        now.withDayOfYear(now.dayOfYear().getMaximumValue())
            .withHourOfDay(now.hourOfDay().getMaximumValue())
            .toDate();

    selectStartDate = new DateField("Dari Tanggal");
    selectStartDate.setImmediate(true);
    selectStartDate.setWidth(function.FORM_WIDTH);
    selectStartDate.setValue(beginYear);

    selectEndDate = new DateField("Hingga Tanggal");
    selectEndDate.setImmediate(true);
    selectEndDate.setWidth(function.FORM_WIDTH);
    selectEndDate.setValue(endYear);
    selectAcceptance = new OptionGroup("Persetujuan");
    Item itemType1 = selectAcceptance.addItem("diterima");
    Item itemType2 = selectAcceptance.addItem("belumditerima");
    selectAcceptance.setImmediate(true);
    selectAcceptance.setValue("diterima");

    selectAcceptance.setItemCaption("diterima", "Barang Kadaluarsa Disetujui");

    selectAcceptance.setItemCaption("belumditerima", "Barang Kadaluarsa Belum Disetujui");
    selectContent = new ComboBox("Pilih Tampilan");
    selectContent.setImmediate(true);
    selectContent.addItem(ReportContent.CHART);
    selectContent.addItem(ReportContent.TABLE);
    selectContent.addItem(ReportContent.TABLE_CHART);
    selectContent.setItemCaption(ReportContent.CHART, "Tampilkan Chart");
    selectContent.setItemCaption(ReportContent.TABLE, "Tampilkan Tabel");
    selectContent.setItemCaption(ReportContent.TABLE_CHART, "Tampilkan Tabel dan Chart");
    selectContent.setItemCaption(4, "Minggu Ke-4");
    selectContent.setValue(ReportContent.TABLE);

    selectAcceptance.addValueChangeListener(this);
    selectStartDate.addValueChangeListener(this);
    selectEndDate.addValueChangeListener(this);
    selectContent.addValueChangeListener(this);
    updateWindowOpener();

    construct();
  }