Exemplo n.º 1
0
  // This is called if the upload is finishe
  public void uploadSucceeded(Upload.SucceededEvent event) {

    boolean validData = false;
    try {
      ExperimentBean newExp = this.validateForm();
      if (newExp != null) {
        validData = true;
      }
      if (validData) {
        // send the file to the reader to extract the information

        boolean test =
            eh.handelExperimentFile(
                file,
                event.getMIMEType(),
                newExp); // Getting data from the uploaded file..here we assume that the experiment
                         // id is 1

        if (!test) {
          getWindow()
              .showNotification(
                  "Failed !  Please Check Your Uploaded File !"); // file didn't store in db
        } else {
          // Display the uploaded file in the file panel.
          getWindow().showNotification("Successful !");
          updateComponents(user);
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 2
0
  public OutputStream receiveUpload(String filename, String MIMEType) {
    mainTabs.setReadOnly(true);
    subTabs.setReadOnly(true);
    FileOutputStream fos = null; // Output stream to write to
    file = new File(filename);

    try {
      System.out.println(MIMEType);
      if (MIMEType.equalsIgnoreCase("text/plain")
          || MIMEType.equalsIgnoreCase(
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
          || MIMEType.equalsIgnoreCase("application/octet-stream")) {
        fos = new FileOutputStream(file);
      } else {
      }

    } catch (final java.io.FileNotFoundException e) {
      Label l = new Label("<h4 style='color:red'>" + e.getMessage() + "</h4>");
      l.setContentMode(Label.CONTENT_XHTML);
      expDetails.addComponent(l);
      e.printStackTrace();
      return null;
    } catch (final Exception e) {
      // Error while opening the file. Not reported here.
      e.printStackTrace();
      return null;
    }

    return fos; // Return the output stream to write to
  }
Exemplo n.º 3
0
  private void buildMainLayout() {
    // setMainWindow(new Window("Address Book Demo application"));

    MyApplication.debug(3, "buildMainLayout");
    // getWindow().setName("FirstPage!");
    layout = new VerticalLayout();
    layout.setSizeFull();

    layout.addComponent(createToolbar());
    layout.addComponent(horizontalSplit);

    /* Allocate all available extra space to the horizontal split panel */

    layout.setExpandRatio(horizontalSplit, 1);
    /* Set the initial split position so we can have a 200 pixel menu to the left */

    horizontalSplit.setSplitPosition(200, SplitPanel.UNITS_PIXELS);
    MyApplication.debug(3, "buildMainLayout 2");
    try {
      if (layout != null) {
        getWindow().setLayout(layout);
        MyApplication.debug(3, "buildMainLayout end");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }