Package org.apache.wicket.markup.html

Examples of org.apache.wicket.markup.html.WebResource


        {
          throw new WicketRuntimeException(e);
        }
        final byte[] imageData = baos.toByteArray();

        item.add(new Image("image", new WebResource()
        {

          @Override
          public IResourceStream getResourceStream()
          {
View Full Code Here


        {
          throw new WicketRuntimeException(e);
        }
        final byte[] imageData = baos.toByteArray();

        item.add(new Image("image", new WebResource()
        {
          private static final long serialVersionUID = 1L;

          @Override
          public IResourceStream getResourceStream()
View Full Code Here

  public ReportDownloadPage(final IExcelReport reportInfo)
  {
    super();

    final WebResource export = new WebResource()
    {
      private static final long serialVersionUID = 7267314593474884211L;

      @Override
      public IResourceStream getResourceStream()
      {
        try
        {
          File file = File.createTempFile("excel", null);
          FileOutputStream fileOut = new FileOutputStream(file);
          reportInfo.generate().write(fileOut);
          fileOut.close();
          return new FileResourceStream(file);
        }
        catch (IOException e)
        {
          throw new SystemeException(e);
        }
      }

      @Override
      protected void setHeaders(WebResponse response)
      {
        super.setHeaders(response);
        response.setAttachmentHeader(reportInfo.getFileName() + ".xls");
      }
    };

    export.setCacheable(false);
    this.add(new ResourceLink("download", export));
  }
View Full Code Here

        Integer.class));
    add(new TextField("delimiterChar").setRequired(true));
    add(new TextArea("commentaires"));
    add(new Label("importFile.name"));

    this.add(viewFileLink = new ResourceLink("viewFile", new WebResource()
    {
      private static final long serialVersionUID = 1L;

      @Override
      public IResourceStream getResourceStream()
View Full Code Here

    add(new Label("date"));
    add(new Label("compte.personne.nomPrenom"));
    add(new TextArea("commentaires"));
    add(new Label("importFile.name"));

    this.add(viewFileLink = new ResourceLink("viewFile", new WebResource()
    {
      private static final long serialVersionUID = 1L;

      @Override
      public IResourceStream getResourceStream()
View Full Code Here

    final List<CategorieParticipante> categoriesParticipantes = saisonReload
        .getCategoriesParticipantes();
    //Call pour initializer la liste.
    categoriesParticipantes.iterator();

    final WebResource export = new WebResource()
    {
      private static final long serialVersionUID = -479972350710704177L;

      @Override
      public IResourceStream getResourceStream()
      {
        final SelectionStrategy selectStr = new PlaqueFixeSelectionStrategy(
            saisonReload, categorieParticipanteService);
        final OrderingStrategy orderStr = new ComparatorOrderingStrategy(
            PlaqueAttribueeLine.COMP_NOM_PRENOM);

        final HSSFWorkbook wb = new HSSFWorkbook();
        int sheetIndex = -1;

        final HSSFFont font = wb.createFont();
        font.setFontHeightInPoints((short) 12);
        font.setFontName("Arial");

        final HSSFCellStyle style = wb.createCellStyle();
        style.setFont(font);

        for (CategorieParticipante catPart : categoriesParticipantes)
        {
          int categorySheetIndex = -1;

          Collection<PlaqueAttribueeLine> plaquesCategorie = selectStr
              .getResult(catPart.getCategorie(), plaques);
          plaquesCategorie = orderStr.getResult(plaquesCategorie);

          final Iterator<PlaqueAttribueeLine> itLine = plaquesCategorie
              .iterator();

          while (itLine.hasNext())
          {
            final HSSFSheet sheet = newSheet(wb, catPart
                .getCategorie(), ++categorySheetIndex);
            sheetIndex++;
            sheet.getPrintSetup().setLandscape(true);
            boolean emptySheet = true;

            for (short j = 0; j < ListePlaquePage.COLONNES_PAR_PAGE; j++)
            {
              for (short k = 0; k < ListePlaquePage.LIGNES_PAR_PAGE; k++)
              {
                if (itLine.hasNext())
                {
                  final PlaqueAttribueeLine line = itLine
                      .next();

                  //Seules les feuilles où il y a au moins un nom
                  //sont incluses dans le classeur.
                  if (line.getNomPrenom() != null
                      && !line.getNomPrenom().equals(""))
                  {
                    emptySheet = false;
                  }

                  final HSSFRow row = sheet
                      .createRow(getIndexLigne(k));

                  HSSFCell cell = row
                      .createCell(getIndexColonne(
                          j,
                          ListePlaquePage.INDEX_PLAQUE));
                  cell.setCellValue(new HSSFRichTextString(
                      line.getPlaque()));
                  cell.setCellStyle(style);

                  cell = row.createCell(getIndexColonne(j,
                      ListePlaquePage.INDEX_NOM));
                  cell.setCellValue(new HSSFRichTextString(
                      line.getNomPrenom()));
                  cell.setCellStyle(style);

                  cell = row.createCell(getIndexColonne(j,
                      ListePlaquePage.INDEX_COMMENTAIRE));
                  cell.setCellValue(new HSSFRichTextString(
                      line.getCommentaire()));
                  cell.setCellStyle(style);
                }
                else
                {
                  //Aucune ligne à écrire... Terminer la boucle.
                  break;
                }
              }
            }

            //Enlever la feuille si elle est vide.
            if (emptySheet)
            {
              wb.removeSheetAt(sheetIndex--);
            }
          }
        }

        try
        {
          File file = File.createTempFile("excel", null);
          FileOutputStream fileOut = new FileOutputStream(file);
          wb.write(fileOut);
          fileOut.close();

          return new FileResourceStream(file);
        }
        catch (FileNotFoundException e)
        {
          throw new SystemeException(e);
        }
        catch (IOException e)
        {
          throw new SystemeException(e);
        }
      }

      @Override
      protected void setHeaders(WebResponse response)
      {
        super.setHeaders(response);
        response.setAttachmentHeader("Plaques - "
            + saisonReload.getAnnee().toString() + ".xls");
      }

      private HSSFSheet newSheet(final HSSFWorkbook wb,
          final Categorie categorie, final int page)
      {
        final HSSFSheet sheet = wb.createSheet(categorie
            .getCodeCategorie()
            + " " + categorie.getSexe() + "(" + page + ")");

        sheet.setColumnWidth((short) 0, (short) 2500);
        sheet.setColumnWidth((short) 1, (short) 8500);
        sheet.setColumnWidth((short) 2, (short) 3500);
        sheet.setColumnWidth((short) 3, (short) 1000);
        sheet.setColumnWidth((short) 4, (short) 2500);
        sheet.setColumnWidth((short) 5, (short) 8500);
        sheet.setColumnWidth((short) 6, (short) 3500);

        // --------- En-tête -----------
        HSSFFont font = wb.createFont();
        font.setFontHeightInPoints((short) 36);
        font.setFontName("Arial");
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        HSSFCellStyle style = wb.createCellStyle();
        style.setFont(font);

        HSSFRow row = sheet.createRow((short) 0);
        HSSFCell cell = row.createCell((short) 0);
        cell.setCellValue(new HSSFRichTextString(categorie
            .getDiscipline().getNom()));

        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 1));

        cell = row.createCell((short) 2);
        cell.setCellValue(new HSSFRichTextString(categorie.getNom()));

        sheet.addMergedRegion(new Region(0, (short) 2, 0, (short) 5));

        cell = row.createCell((short) 6);
        cell.setCellValue(new HSSFRichTextString(categorie.getSexe()));

        HSSFUtils.applyStyle(row, style);

        // ------- Séparateur -----------
        row = sheet.createRow((short) 1);
        row.setHeightInPoints(new Float(7.5));

        row = sheet.createRow((short) 2);

        for (short i = 0; i < ListePlaquePage.COLONNES_PAR_PAGE; i++)
        {
          cell = row.createCell(getIndexColonne(i,
              ListePlaquePage.INDEX_PLAQUE));
          cell.setCellValue(new HSSFRichTextString("PLAQUE"));

          cell = row.createCell(getIndexColonne(i,
              ListePlaquePage.INDEX_NOM));
          cell.setCellValue(new HSSFRichTextString("NOM, PRÉNOM"));

          cell = row.createCell(getIndexColonne(i,
              ListePlaquePage.INDEX_COMMENTAIRE));
          cell.setCellValue(new HSSFRichTextString(""));
        }

        font = wb.createFont();
        font.setFontHeightInPoints((short) 10);
        font.setFontName("Arial");
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        style = wb.createCellStyle();
        style.setFont(font);

        HSSFUtils.applyStyle(row, style);

        return sheet;
      }

      private short getIndexColonne(final short colonne, final short champ)
      {
        return (short) (champ + colonne * ListePlaquePage.NB_CHAMPS);
      }

      private short getIndexLigne(final short ligne)
      {
        return (short) (ligne + ListePlaquePage.PREMIERE_LIGNE);
      }

    };
    export.setCacheable(false);
    this.add(new ResourceLink("download", export));
  }
View Full Code Here

                item.add(tweetView);
            }
        };

        add(userView);
        WebResource export = new WebResource() {

            @Override
            public IResourceStream getResourceStream() {
                return new StringResourceStream(getTweetsAsString(), "text/plain");
            }

            @Override
            protected void setHeaders(WebResponse response) {
                super.setHeaders(response);
                response.setAttachmentHeader("tweets.txt");
            }
        };

        export.setCacheable(false);
        add(new ResourceLink("exportTsvLink", export));
        add(new Link("exportHtmlLink") {

            @Override
            public void onClick() {
View Full Code Here

        {
          throw new WicketRuntimeException(e);
        }
        final byte[] imageData = baos.toByteArray();

        item.add(new Image("image", new WebResource()
        {
          private static final long serialVersionUID = 1L;

          @Override
          public IResourceStream getResourceStream()
View Full Code Here

        {
          throw new WicketRuntimeException(e);
        }
        final byte[] imageData = baos.toByteArray();

        item.add(new Image<Void>("image", new WebResource()
        {
          private static final long serialVersionUID = 1L;

          @Override
          public IResourceStream getResourceStream()
View Full Code Here

        LOG.warn("Your Picnik API key must be in Java System property picnik.apikey");
      }
     
      LOG.debug("new PicnikExamplePage in Session " + getSession().getId() + " from "  + ((WebRequest)getRequest()).getHttpServletRequest().getRemoteAddr());
     
      final NonCachingImage nonCachingImage1 = new NonCachingImage("picnikImage1", new WebResource() {
      @Override
      public IResourceStream getResourceStream() {
        return new FileResourceStream(imageFile1);
      }
      });
      nonCachingImage1.setOutputMarkupId(true);
    add(nonCachingImage1);

      PullPanel pullPanel = new PullPanel("pullPanel") {
      @Override
      protected Form createForm(String id, IModel model) {
        return new Form(id, model) {
          @Override
          protected void onSubmit() {
            PicnikFileUpload upload = (PicnikFileUpload) getModelObject();
           
              LOG.debug("File received in Session " + getSession().getId() + " from "  + ((WebRequest)getRequest()).getHttpServletRequest().getRemoteAddr());
             
            FileUpload fileUpload = upload.getFileUpload();
            if (fileUpload != null) {
              LOG.debug("Size: " + fileUpload.getSize());
              LOG.debug("Name: " + fileUpload.getClientFileName());
              LOG.debug("Type: " + fileUpload.getContentType());
              try {
                fileUpload.writeTo(imageFile1);
              } catch (IOException e) {
                throw new WicketRuntimeException(e);
              }
              // following line is actually only required when doing the modal way
              setResponsePage(CloseModalPage.class);             
            }           
          }
        };
      }
      };
      add(pullPanel);

      PicnikCall call1 = new PicnikCall();
      call1.getGeneralSettings().setApiKey(picnikApi);

      ExportSettings exportSettings1 = pullPanel.getExportSettings();
      exportSettings1.setTitle("Wicket!");
    call1.setExportSettings(exportSettings1);
   
    NavigationSettings navSettings = new NavigationSettings();
    navSettings.setPage("/in/upload");
    call1.setNavigationSettings(navSettings);
   
      PicnikLinkModel picnikLinkModel1 = new PicnikLinkModel(call1);
    ExternalLink picnikLink1 = new ExternalLink("importLink1", picnikLinkModel1);
    add(picnikLink1);
     
    final Image logoImage = new Image("logoImage", new ResourceReference(PullPanel.class, "picnik_logo_small.jpg"));
    picnikLink1.add(logoImage);

      // ========================================================================
    // same thing, but in modal window
      PicnikCall call3 = new PicnikCall();
      call3.getGeneralSettings().setApiKey(picnikApi);
      call3.getImportSettings().setImportSource("http://www.indyphone.de/static/media/89e9e0a2-0d17-49db-97fb-e46a2e8c68ea.png");
     
      NavigationSettings navSettings3 = new NavigationSettings();
      navSettings3.setPage("/edit");
     
      ExportSettings exportSettings3 = pullPanel.getExportSettings();
      exportSettings3.setTitle("Wicket!");
    call3.setExportSettings(exportSettings3);
   
    BoxSettings boxSettings3 = new BoxSettings();
    boxSettings3.setExpandButton(false);
    boxSettings3.setCloseTarget("http://rue.dnsdojo.net:42000/wicketstuff-picnik/");
     
      PicnikLinkModel picnikLinkModel3 = new PicnikLinkModel(call3);
     
    ModalPicnikLink modalPicnikLink = new ModalPicnikLink("modalPicnikLink", picnikLinkModel3)
    {
      @Override
      protected void onPicnikFinished(AjaxRequestTarget target) {
              target.addComponent(nonCachingImage1);
      }
     
    };
    add(modalPicnikLink);
   
      // ========================================================================

      final NonCachingImage picnikImage2 = new NonCachingImage("picnikImage2", new WebResource() {
      @Override
      public IResourceStream getResourceStream() {
        return new FileResourceStream(imageFile2);
      }
      });
View Full Code Here

TOP

Related Classes of org.apache.wicket.markup.html.WebResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.