public void setDate(Date date) {
   dateField.setValue(date);
 }
    CreateFormIntervalliOre() {

      setLabelWidth(30);
      setFrame(true);
      setButtonAlign(HorizontalAlignment.CENTER);
      setHeading("Dettaglio Ore.");
      setHeaderVisible(false);
      setWidth(700);
      setHeight(95);
      setStyleAttribute("padding-left", "10px");
      setStyleAttribute("padding-top", "10px");
      setBorders(false);

      Date retVal = null;
      try {
        retVal = DateTimeFormat.getFormat("dd-MM-yyyy").parse(01 + "-" + 03 + "-" + 2013);
      } catch (Exception e) {
        retVal = null;
      }

      giornoRiferimento.setValue(new Date());
      giornoRiferimento.setMinValue(retVal);
      giornoRiferimento.setItemId("data");
      dtfldGiorno.setValue(giornoRiferimento.getValue());

      ListStore<PersonaleModel> store = new ListStore<PersonaleModel>();
      cmbxDipendente.setStore(store);
      cmbxDipendente.setFieldLabel("Dipendente");
      cmbxDipendente.setEnabled(true);
      cmbxDipendente.setEmptyText("Selezionare il dipendente..");
      cmbxDipendente.setEditable(false);
      cmbxDipendente.setVisible(true);
      cmbxDipendente.setTriggerAction(TriggerAction.ALL);
      cmbxDipendente.setAllowBlank(false);
      cmbxDipendente.setDisplayField("nomeCompleto");
      cmbxDipendente.addListener(
          Events.OnClick,
          new Listener<BaseEvent>() {
            @Override
            public void handleEvent(BaseEvent be) {
              getAllDipendenti();
            }
          });

      ButtonBar buttonBarTop = new ButtonBar();
      buttonBarTop.setAlignment(HorizontalAlignment.CENTER);
      buttonBarTop.setStyleAttribute("padding-bottom", "5px");
      buttonBarTop.setBorders(false);
      buttonBarTop.setWidth(570);
      buttonBarTop.setItemId("buttonBar");

      // buttonBarTop.add(btnPrev);
      buttonBarTop.add(giornoRiferimento);
      buttonBarTop.add(cmbxDipendente);
      buttonBarTop.add(btnSend);
      // buttonBarTop.add(btnNext);

      btnInviaCommenti.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.escl1()));
      btnInviaCommenti.setToolTip("Segnala eventuali problemi o anomalie.");
      btnInviaCommenti.setSize(26, 26);
      btnInviaCommenti.setIconAlign(IconAlign.TOP);
      btnInviaCommenti.addSelectionListener(
          new SelectionListener<ButtonEvent>() {
            @Override
            public void componentSelected(ButtonEvent ce) {
              Dialog d = new DialogInvioCommenti(txtfldUsername.getValue().toString(), new Date());
              d.show();
            }
          });

      btnRiepilogoCommesse.setEnabled(true);
      btnRiepilogoCommesse.setSize(26, 26);
      btnRiepilogoCommesse.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.riep_comm()));
      btnRiepilogoCommesse.setToolTip("Riepilogo Commesse");
      btnRiepilogoCommesse.addSelectionListener(
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
              /*Dialog d= new Dialog();
              d.setHeaderVisible(true);
              d.setHeading("Riepilogo dettagliato (Commesse).");
              d.setSize(550, 605);
              d.add(new PanelRiepilogoGiornalieroCommesse(txtfldUsername.getValue().toString(), giornoRiferimento.getValue()));
              d.setButtons("");
              d.show();*/
              Date data = dtfldGiorno.getValue();
              Dialog d = new Dialog();
              d.setHeaderVisible(true);
              d.setConstrain(false);
              d.setHeading("Riepilogo dettagliato (Commesse).");
              d.setSize(1500, 650);
              d.add(
                  new PanelRiepilogoMeseGiornalieroCommesseHorizontal(
                      0,
                      txtfldUsername.getValue().toString(),
                      data,
                      "0.00",
                      "0.00",
                      "0.00",
                      "0.00"));
              d.setButtons("");
              d.show();
            }
          });

      frm.setHeaderVisible(false);
      frm.setBorders(false);
      frm.setItemId("formPanel");
      frm.setWidth(1060);
      frm.setHeight(890);
      frm.setStyleAttribute("padding-left", "0px");
      frm.setStyleAttribute("padding-top", "0px");
      frm.setScrollMode(Scroll.AUTO);

      main.setLayout(new ColumnLayout());
      main.setBorders(false);
      main.setStyleAttribute("margin-top", "-10px");
      main.setItemId("main");

      left.setStyleAttribute("padding-left", "10px");
      FormLayout layout = new FormLayout();
      left.setLayout(layout);
      left.setItemId("left");

      right.setStyleAttribute("padding-left", "30px");
      layout = new FormLayout();
      right.setLayout(layout);
      right.setItemId("right");

      ButtonBar btnBarOperazioni = new ButtonBar();
      btnBarOperazioni.setHeight(28);
      btnBarOperazioni.setAlignment(HorizontalAlignment.LEFT);
      btnBarOperazioni.setBorders(false);
      btnBarOperazioni.add(btnRiepilogoCommesse);
      btnBarOperazioni.add(btnInviaCommenti);
      btnBarOperazioni.add(btnConferma);

      left.add(btnBarOperazioni);
      left.add(buttonBarTop);

      main.add(left);
      frm.add(main);
      frm.layout(true);
      add(frm);

      btnSend.setSize(26, 26);
      btnSend.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.reload()));
      btnSend.setToolTip("Carica Dati");
      btnSend.addSelectionListener(
          new SelectionListener<ButtonEvent>() {
            @Override
            public void componentSelected(ButtonEvent ce) {
              txtfldUsername.setValue(
                  cmbxDipendente
                      .getValue()
                      .get("username")
                      .toString()); // setto il valore globale dell'username per il caricamento dei
                                    // vari fieldset
              dtfldGiorno.setValue(
                  giornoRiferimento
                      .getValue()); // setto il valore globale della data con la data selezionata
              reloadFoglioOre();
            }
          });

      // btnConferma.setSize(46, 46);
      btnConferma.setIcon(AbstractImagePrototype.create(MyImages.INSTANCE.saveLittle()));
      btnConferma.setIconAlign(IconAlign.TOP);
      btnConferma.setToolTip("Conferma");
      btnConferma.setSize(26, 26);
      btnConferma.addSelectionListener(
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {

              if (frm.isValid()) {
                String username = new String();
                Date giorno = new Date();
                DateField dtfld = new DateField();

                username = cmbxDipendente.getValue().get("username");
                List<IntervalliCommesseModel> intervalliC =
                    new ArrayList<IntervalliCommesseModel>();

                FldsetIntervalliCommesse fldSetIntervalliC;
                LayoutContainer lc = new LayoutContainer();
                LayoutContainer lcR = new LayoutContainer();
                ButtonBar bttnBar = new ButtonBar();

                lc = (LayoutContainer) frm.getItemByItemId("main");
                // Intervalli IU
                lc = (LayoutContainer) lc.getItemByItemId("left");

                // Data
                bttnBar = (ButtonBar) lc.getItemByItemId("buttonBar");
                dtfld = (DateField) bttnBar.getItemByItemId("data");
                giorno = dtfld.getValue();

                // Intervalli Comm
                fldSetIntervalliC =
                    (FldsetIntervalliCommesse) lc.getItemByItemId("fldSetIntervalliC");
                if (fldSetIntervalliC.getItemCount() > 1)
                  intervalliC = elaboraIntervalliC(fldSetIntervalliC);

                // Giustificativi
                lcR = (LayoutContainer) frm.getItemByItemId("main");
                lcR = (LayoutContainer) lcR.getItemByItemId("right");

                // txtfldOreTotali=fldSetGiustificativi.txtfldOreTotEffettive;

                AdministrationService.Util.getInstance()
                    .insertFoglioOreGiorno(
                        username,
                        giorno,
                        intervalliC,
                        new AsyncCallback<Boolean>() {

                          @Override
                          public void onFailure(Throwable caught) {
                            Window.alert("Errore di connessione on insertFoglioOreGiorno()!");
                          }

                          @Override
                          public void onSuccess(Boolean result) {
                            if (result) {
                              Window.alert("Caricamento avvenuto con successo.");
                              reloadFoglioOre();
                            } else {
                              Window.alert("error: Impossibile salvare i dati!");
                            }
                          }
                        });
              }
            }
          });
    }
Exemplo n.º 3
0
  public PanelGridContrato() {

    setCollapsible(true);
    setResizable(false);
    setMinimizable(true);
    setHeadingHtml("Contratos");
    setSize(700, 459);
    setLayout(new FitLayout());

    mainPanel = new ContentPanel();
    mainPanel.setFrame(true);
    mainPanel.setHeaderVisible(false);
    mainPanel.setLayout(new RowLayout(Orientation.VERTICAL));

    panelTool = new ContentPanel();
    panelTool.setHeaderVisible(false);
    panelTool.setFrame(true);
    panelTool.setCollapsible(true);
    panelTool.setLayout(new AbsoluteLayout());

    btnRelatrio = new Button("Relatório");
    btnRelatrio.setSize("44px", "44px");
    btnRelatrio.setIconAlign(IconAlign.TOP);
    btnRelatrio.setIcon(AbstractImagePrototype.create(ImagensResources.INSTANCE.report24()));
    //		btnRelatrio.setEnabled(false);
    btnRelatrio.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            ParametrosReport parametros = new ParametrosReport();
            parametros.setNomeRelatorio(JasperName.CONTRATO);
            parametros.setContratoId(getSelecaoGrid().getId());

            InstanceService.RELATORIO_SERVICE.relatorio(parametros, new RelatorioCallback());
          }
        });

    panelTool.add(btnRelatrio, new AbsoluteData(606, 6));

    btnEditar = new Button("Editar");
    btnEditar.setSize("44px", "44px");
    btnEditar.setIconAlign(IconAlign.TOP);
    btnEditar.setIcon(AbstractImagePrototype.create(ImagensResources.INSTANCE.iconEditar24()));
    btnEditar.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {

            DTOContrato contrato = getSelecaoGrid();

            if (contrato != null) {
              FormContrato formContrato = ProviderFacadeManager.formContrato.createInstance();
              formContrato.setModal(true);
              formContrato.loadDTOContrato(contrato);
              formContrato.show();
            } else {
              WebMessageBox.alert("Selecione o contrato para editar!");
            }
          }
        });
    panelTool.add(btnEditar, new AbsoluteData(556, 6));

    btnNovo = new Button("Novo");
    btnNovo.setSize("44px", "44px");
    btnNovo.setIconAlign(IconAlign.TOP);
    btnNovo.setIcon(AbstractImagePrototype.create(ImagensResources.INSTANCE.iconAdicionar24()));
    btnNovo.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            FormContrato formContrato = ProviderFacadeManager.formContrato.createInstance();
            formContrato.setModal(true);
            formContrato.show();
          }
        });
    panelTool.add(btnNovo, new AbsoluteData(506, 6));

    panelTool.add(new LabelField("Cliente:"), new AbsoluteData(6, 6));

    RpcProxy<PagingLoadResult<DTOCliente>> proxyCliente =
        new RpcProxy<PagingLoadResult<DTOCliente>>() {
          @Override
          public void load(
              Object loadConfig, AsyncCallback<PagingLoadResult<DTOCliente>> callback) {
            InstanceService.CLIENTE_SERVICE.loadPagingList((PagingLoadConfig) loadConfig, callback);
          }
        };

    PagingLoader<PagingLoadResult<ModelData>> loaderCliente =
        new BasePagingLoader<PagingLoadResult<ModelData>>(proxyCliente);

    storeCliente = new ListStore<DTOCliente>(loaderCliente);

    comboCliente = new ComboBox<DTOCliente>();
    comboCliente.setStore(storeCliente);
    comboCliente.setSize("286px", "22px");
    comboCliente.setTemplate(getTemplateNome());
    comboCliente.setValueField("id");
    comboCliente.setDisplayField("nome");
    comboCliente.setItemSelector("div.search-item");
    comboCliente.setHideTrigger(true);
    comboCliente.setLoadingText("Carregando...");
    comboCliente.setPageSize(10);
    comboCliente.addListener(
        Events.OnBlur,
        new Listener<ComponentEvent>() {
          public void handleEvent(ComponentEvent evt) {
            if (comboCliente.getValue() == null) {
              comboCliente.clear();
            }
          };
        });

    panelTool.add(comboCliente, new AbsoluteData(6, 28));

    tfData = new DateField();
    tfData.setSize("119px", "22px");
    tfData.setEditable(false);
    tfData.setValue(new Date());
    tfData
        .getDatePicker()
        .addListener(
            Events.Select,
            new Listener<DatePickerEvent>() {
              @Override
              public void handleEvent(DatePickerEvent be) {
                loadContratos();
              }
            });
    tfData.getPropertyEditor().setFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
    panelTool.add(tfData, new AbsoluteData(298, 28));

    btnPesquisa = new Button();
    btnPesquisa.setSize("44px", "44px");
    btnPesquisa.setIcon(AbstractImagePrototype.create(ImagensResources.INSTANCE.iconPesquisa24()));
    btnPesquisa.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            pesquisa();
          }
        });
    panelTool.add(btnPesquisa, new AbsoluteData(423, 6));

    panelTool.add(new LabelField("Data:"), new AbsoluteData(300, 6));
    mainPanel.add(panelTool, new RowData(Style.DEFAULT, 75.0, new Margins(3)));

    storeContratos = new ListStore<DTOContrato>();

    gridContratos = new Grid<DTOContrato>(storeContratos, getColumnModel());
    gridContratos.setBorders(true);
    gridContratos.setAutoExpandColumn("nomeCliente");

    mainPanel.add(gridContratos, new RowData(Style.DEFAULT, 340.0, new Margins(3)));

    add(mainPanel);

    loadContratos();
  }