Ejemplo 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();
    }
  }
Ejemplo 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
  }
Ejemplo 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();
    }
  }
Ejemplo n.º 4
0
  public WindowManagerTeacher() {

    setCaption("quan ly bo mon "); // Constants.USER_CAPTION) ;

    mainLayout = new HorizontalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth(Constants.WIDTH_MAX, Sizeable.UNITS_PIXELS);
    mainLayout.setMargin(false);
    mainLayout.setSpacing(true);

    mainLayout.addComponent(new leftSide());

    rContentList = new VerticalLayout();
    rContentList.setWidth("100%");
    mainLayout.addComponent(rContentList);
    mainLayout.setExpandRatio(rContentList, 1.0f);

    rContentModify = new rightContentAddNewTeacher(1);
    rContentModify.setWidth("100%");

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setStyleName("bl-mainContent");
    v.addComponent(mainLayout);
    v.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER);

    addComponent(new topLogin());
    addComponent(new topPanel());
    addComponent(new mainMenu());
    addComponent(v);
    addComponent(new bottom());

    // --------------------bl
    Label title = new Label("<center><h1>Danh sách giang vien<h1></center>", Label.CONTENT_XHTML);

    table = new Table();
    table.setWidth("100%");
    table.setPageLength(20);

    rContentList.addComponent(title);
    rContentList.addComponent(table);

    Connection conn = null;
    Statement stmt = null;

    try {
      JDBCConnectionPool pool =
          new SimpleJDBCConnectionPool(
              JDBC_DRIVER,
              DB_URL + QlgiangvienApplication.DB_DBNAME,
              QlgiangvienApplication.DB_USER,
              QlgiangvienApplication.DB_PASS);

      String mysql = "SELECT * from GiangVien";

      TableQuery query = new TableQuery("GiangVien", pool);
      query.setVersionColumn("OPTLOCK");

      SQLContainer container = new SQLContainer(query);
      container.setAutoCommit(true);
      //          container.re
      table.setContainerDataSource(container);

      //           FreeformQuery query = new FreeformQuery(mysql, pool, "MaGV") ;

      //           container = new SQLContainer(query);

      //           table.setContainerDataSource(container) ;

      table.addGeneratedColumn(
          "Chinh Sua",
          new Table.ColumnGenerator() {
            public Component generateCell(Table source, Object itemId, Object columnId) {
              final Item item = table.getItem(itemId);

              Button btnModify =
                  new Button(
                      "Chinh Sua",
                      new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {

                          //              				rContentList.setVisible(false);
                          //              				rContentModify.setVisible(true);
                          System.out.println(item.toString());
                          rContentModify.setUpdateData(
                              item.getItemProperty("MaGV").getValue().toString());
                          mainLayout.removeComponent(rContentList);
                          mainLayout.addComponent(rContentModify);
                          mainLayout.setExpandRatio(rContentModify, 1.0f);
                        }
                      });

              return btnModify;
            }
          });
      confirmDelete();
      table.addGeneratedColumn(
          "Xoa",
          new Table.ColumnGenerator() {
            public Component generateCell(Table source, Object itemId, Object columnId) {

              //            	   Item item = table.getItem(itemId);

              Button btnModify =
                  new Button(
                      "Xoa",
                      new Button.ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent event) {

                          if (subwindow.getParent() == null) {

                            getWindow().addWindow(subwindow);
                          }
                        }
                      });

              return btnModify;
            }
          });

    } catch (Exception e) {
      System.out.println("in right COntent: " + e.toString());
    }
  } // end of container