private void populatePaymentCategories() {
    try {
      List<CategoryType> svcCategories = accSvc.getCategoriesForSheet(balSheet);

      categories = new LinkedHashMap<>(svcCategories.size());

      paymentCategories.removeAllItems();
      if (typeFrm != null) ((Select) typeFrm.getField(ADD_TYPE_FLD_CAT)).removeAllItems();

      for (CategoryType cat : svcCategories) {
        categories.put(cat.getName(), cat);
        paymentCategories.addItem(cat.getName());
        if (typeFrm != null) ((Select) typeFrm.getField(ADD_TYPE_FLD_CAT)).addItem(cat.getName());
      }

      Set<String> keys = categories.keySet();
      if (keys.size() > 0) paymentCategories.select(keys.iterator().next());

    } catch (AccountsSheetException e) {
      close();
      Messenger.genericMessage(
          MessageSeverity.ERROR,
          STRINGS.getString(AccountsMessages.MSGR_UNRECOVERABLE_ERROR),
          "Failed trying to query Payment Categories for Balance Sheet",
          e);
    }
  }
Example #2
0
  @Override
  protected void setup(VaadinRequest request) {
    final VerticalLayout uiLayout = new VerticalLayout();
    uiLayout.setMargin(true);
    setContent(uiLayout);

    final VerticalLayout windowLayout = new VerticalLayout();

    final Window testWindow = new Window("WebKitFail", windowLayout);
    testWindow.setWidth(300, Unit.PIXELS);

    GridLayout gl = new GridLayout();
    gl.setHeight(null);
    gl.setWidth(100, Unit.PERCENTAGE);
    windowLayout.addComponent(gl);

    ListSelect listSelect = new ListSelect();
    listSelect.setWidth(100, Unit.PERCENTAGE);
    gl.addComponent(listSelect);
    gl.setMargin(true);

    final Button testButton =
        new Button(
            "Open Window",
            new Button.ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                UI.getCurrent().addWindow(testWindow);
              }
            });
    uiLayout.addComponent(testButton);
  }
Example #3
0
 @Override
 protected void resetFields() {
   logger.info(
       "Company ID : "
           + companyid
           + " | User Name : "
           + username
           + " > "
           + "Resetting the UI controls");
   tfEnqNo.setReadOnly(false);
   tfEnqNo.setValue("");
   cbEnqStatus.setValue(null);
   listEnqDtls = new ArrayList<SmsPurEnqDtlDM>();
   tblSmsEnqDtl.removeAllItems();
   cbBranch.setValue(branchId);
   cbBranch.setComponentError(null);
   lsVendorName.setValue(null);
   lsVendorName.setComponentError(null);
   dfDueDate.setValue(null);
   dfEnqDate.setValue(null);
   taEnqRem.setValue("");
   taEnqDtlRem.setValue("");
   dfEnqDate.setValue(new Date());
   cbEnqStatus.setValue(cbEnqStatus.getItemIds().iterator().next());
   cbUom.setReadOnly(true);
   dfDueDate.setValue(addDays(new Date(), 7));
 }
Example #4
0
  public void loadStudents(List<Enrollment> enrs) {
    lstStudents.removeAllItems();

    for (Enrollment enr : enrs) {
      lstStudents.addItem(enr);
      StringBuffer caption = new StringBuffer();

      PhysicalPerson person = enr.getAdmissionAct().getStudent().getPhysicalPerson();

      if (person.getIdentificationNumber() != null) {
        caption.append(person.getIdentificationNumber() + "-");
      } else {
        caption.append("-- ");
      }

      if (person.getLastName() != null) {
        caption.append(person.getLastName() + ", ");
      } else {
        caption.append("--");
      }

      if (person.getName() != null) {
        caption.append(person.getName());
      } else {
        caption.append("--");
      }

      lstStudents.setItemCaption(enr, caption.toString());
    }
  }
Example #5
0
 private boolean dtlValidation() {
   boolean isValid = true;
   if (cbUom.getValue() == null) {
     cbUom.setComponentError(new UserError(GERPErrorCodes.NULL_MATERIAL_UOM));
     isValid = false;
   } else {
     cbUom.setComponentError(null);
   }
   if ((tfEnqQty.getValue() == "0")) {
     tfEnqQty.setComponentError(new UserError(GERPErrorCodes.NULL_ENQUIRY_QTY));
     isValid = false;
   } else {
     tfEnqQty.setComponentError(null);
     isValid = true;
   }
   Long achievedQty;
   try {
     achievedQty = Long.valueOf(tfEnqQty.getValue());
     if (achievedQty < 0) {
       tfEnqQty.setComponentError(new UserError(GERPErrorCodes.LESS_THEN_ZERO));
       isValid = false;
     }
   } catch (Exception e) {
     tfEnqQty.setComponentError(new UserError(GERPErrorCodes.QUNATITY_CHAR_VALIDATION));
     isValid = false;
   }
   if (lsProduct.getValue() == null) {
     lsProduct.setComponentError(new UserError(GERPErrorCodes.NULL_PRODUCT_NAME));
     isValid = false;
   } else {
     lsProduct.setComponentError(null);
   }
   return isValid;
 }
Example #6
0
  public void moveRightLeft() {
    Collection<Enrollment> studentRSelects =
        (Collection<Enrollment>) lstStudentSelecteds.getValue();

    List<Enrollment> lstLeftSelecteds = new ArrayList<Enrollment>();

    for (Enrollment enr : studentRSelects) {
      lstLeftSelecteds.add(enr);

      for (Enrollment itemRem : (Collection<Enrollment>) lstStudentSelecteds.getItemIds()) {
        if (enr.getId().equals(itemRem.getId())) {
          lstStudentSelecteds.removeItem(itemRem);
          break;
        }
      }
    }

    for (Enrollment enr : (Collection<Enrollment>) lstStudents.getItemIds()) {
      boolean flagExist = false;
      for (Enrollment itemAdd : lstLeftSelecteds) {
        if (enr.getId().equalsIgnoreCase(itemAdd.getId())) {
          flagExist = true;
        }
      }

      if (flagExist == false) {
        lstLeftSelecteds.add(enr);
      }
    }

    loadStudents(lstLeftSelecteds);
  }
Example #7
0
  public void initializePanelRigth() {
    lstStudentSelecteds = new ListSelect("Alumnos Asignados");
    lstStudentSelecteds.setSizeFull();
    lstStudentSelecteds.setMultiSelect(true);

    mainPanel.addComponent(lstStudentSelecteds);
    mainPanel.setExpandRatio(lstStudentSelecteds, new Float(0.45));
  }
Example #8
0
 @Override
 protected void addDetails() {
   logger.info(
       "Company ID : "
           + companyid
           + " | User Name : "
           + username
           + " > "
           + "Adding new record...");
   // remove the components in the search layout and input controls in the same container
   hlUserInputLayout.removeAllComponents();
   hlUserIPContainer.addComponent(GERPPanelGenerator.createPanel(hlUserInputLayout));
   assembleInputUserLayout();
   // reset the input controls to default value
   tblMstScrSrchRslt.setVisible(false);
   hlCmdBtnLayout.setVisible(false);
   btnaddSpec.setCaption("Add");
   tblSmsEnqDtl.setVisible(true);
   cbBranch.setRequired(true);
   lsVendorName.setRequired(true);
   tfEnqNo.setReadOnly(true);
   lsProduct.setRequired(true);
   lsProduct.setComponentError(null);
   dfEnqDate.setComponentError(null);
   cbUom.setRequired(true);
   loadPurDtl();
   resetFields();
   tfEnqNo.setReadOnly(true);
   try {
     tfEnqNo.setReadOnly(false);
     SlnoGenDM slnoObj =
         serviceSlnogen.getSequenceNumber(companyid, branchId, moduleId, "SM_ENQRYNO ").get(0);
     if (slnoObj.getAutoGenYN().equals("Y")) {
       tfEnqNo.setValue(slnoObj.getKeyDesc());
       tfEnqNo.setReadOnly(true);
     } else {
       tfEnqNo.setReadOnly(false);
     }
   } catch (Exception e) {
     logger.info(e.getMessage());
   }
   comments =
       new SmsComments(
           vlTableForm,
           null,
           companyid,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null,
           null);
 }
Example #9
0
  public void loadStudentsSelecteds(List<Enrollment> enrsSel) {
    lstStudentSelecteds.removeAllItems();

    for (Enrollment enr : enrsSel) {
      lstStudentSelecteds.addItem(enr);
    }

    removeItemLeftIfExistRight();
  }
Example #10
0
 public void removeItemLeftIfExistRight() {
   for (Enrollment enrRight : (Collection<Enrollment>) lstStudentSelecteds.getItemIds()) {
     for (Enrollment enrLeft : (Collection<Enrollment>) lstStudents.getItemIds()) {
       if (enrRight.getId().equals(enrLeft.getId())) {
         lstStudents.removeItem(enrLeft);
         break;
       }
     }
   }
 }
  @Override
  public void buttonClick(final ClickEvent event) {
    final Object o = orgUnitList.getValue();

    if (o instanceof Set) {
      final Set set = (Set) o;
      for (final Object ob : set) {
        orgUnitList.removeItem(ob);
      }
    } else if (o != null) {
      orgUnitList.removeItem(o);
    }
  }
  /**
   * Build content 'evaluation process' of tab 3.
   *
   * @return content of third tab
   */
  private Layout buildTab3Content() {
    VerticalLayout tab3Content = new VerticalLayout();
    tab3Content.setSpacing(true);
    tab3Content.setMargin(true);
    tab3Content.setSizeFull();

    Label instructions =
        new Label(
            "<b>Instructions:</b> <i>Please select and click a sentence below in order to process the evaluation.</i>",
            Label.CONTENT_XHTML);
    tab3Content.addComponent(instructions);

    this.tableEvaluation = new Table("Evaluation process:");
    tableEvaluation.setHeight("150px");
    tableEvaluation.setWidth("100%");
    tableEvaluation.setImmediate(true);
    tableEvaluation.setSelectable(true);
    tableEvaluation.setMultiSelect(false);
    tableEvaluation.setSortDisabled(false);
    tableEvaluation.addContainerProperty("ID", Integer.class, null);
    tableEvaluation.addContainerProperty("Sentence", String.class, null);
    tableEvaluation.addContainerProperty("Precision", Double.class, null);
    tableEvaluation.addContainerProperty("Recall", Double.class, null);
    tableEvaluation.addContainerProperty("F-Score", Double.class, null);
    tab3Content.addComponent(tableEvaluation);

    this.buttonNext2 = new Button("Next");
    buttonNext2.setImmediate(true);
    buttonNext2.setDescription("Get the next sentence in table");
    tab3Content.addComponent(buttonNext2);

    this.textAreaEvalSentence = new TextArea("Sentence:");
    textAreaEvalSentence.setImmediate(false);
    textAreaEvalSentence.setReadOnly(true);
    textAreaEvalSentence.setRows(3);
    textAreaEvalSentence.setWidth("100%");
    tab3Content.addComponent(textAreaEvalSentence);

    HorizontalLayout hlay1 = new HorizontalLayout();
    this.listSelectGoldstandard = new ListSelect("Goldstandard:");
    listSelectGoldstandard.setImmediate(true);
    listSelectGoldstandard.setHeight("120px");
    listSelectGoldstandard.setWidth("100%");
    listSelectGoldstandard.setNullSelectionAllowed(false);
    this.listSelectFramework = new ListSelect("Framework:");
    listSelectFramework.setImmediate(true);
    listSelectFramework.setHeight("120px");
    listSelectFramework.setWidth("100%");
    listSelectFramework.setNullSelectionAllowed(false);
    hlay1.setSpacing(true);
    hlay1.setMargin(false);
    hlay1.setWidth("100%");
    hlay1.addComponent(listSelectGoldstandard);
    hlay1.addComponent(listSelectFramework);
    tab3Content.addComponent(hlay1);

    return tab3Content;
  }
Example #13
0
 @Override
 protected void cancelDetails() {
   logger.info(
       "Company ID : " + companyid + " | User Name : " + username + " > " + "Canceling action ");
   hlUserIPContainer.removeAllComponents();
   assembleSearchLayout();
   hlCmdBtnLayout.setVisible(true);
   tblSmsEnqDtl.removeAllItems();
   tblMstScrSrchRslt.setVisible(true);
   tfEnqNo.setReadOnly(false);
   cbBranch.setRequired(false);
   lsVendorName.setRequired(false);
   lsVendorName.setComponentError(null);
   enqDtlresetFields();
   resetFields();
   loadSrchRslt();
 }
  /**
   * Build content 'annotation process' of tab 2.
   *
   * @return content of second tab
   */
  private Layout buildTab2Content() {
    VerticalLayout tab2Content = new VerticalLayout();
    tab2Content.setSpacing(true);
    tab2Content.setMargin(true);
    tab2Content.setSizeFull();

    this.textAreaSentence = new TextArea("Sentence:");
    textAreaSentence.setImmediate(true);
    textAreaSentence.setRows(7);
    textAreaSentence.setWidth("100%");
    tab2Content.addComponent(textAreaSentence);

    HorizontalLayout hlay1 = new HorizontalLayout();
    this.buttonNew = new Button("New");
    buttonNew.setImmediate(true);
    buttonNew.setDescription("Type in new sentences");
    this.buttonAnnotate = new Button("Annotate");
    buttonAnnotate.setImmediate(true);
    buttonAnnotate.setDescription("Annotate the sentences above");
    hlay1.setSpacing(true);
    hlay1.setMargin(false);
    hlay1.addComponent(buttonNew);
    hlay1.addComponent(buttonAnnotate);
    tab2Content.addComponent(hlay1);

    this.listSelectAnnotation = new ListSelect("Annotations:");
    listSelectAnnotation.setImmediate(true);
    listSelectAnnotation.setHeight("150px");
    listSelectAnnotation.setWidth("100%");
    listSelectAnnotation.setNullSelectionAllowed(false);
    tab2Content.addComponent(listSelectAnnotation);

    this.textAreaAnnotation = new TextArea("Further annotations with other surface forms:");
    textAreaAnnotation.setImmediate(false);
    textAreaAnnotation.setRows(4);
    textAreaAnnotation.setReadOnly(true);
    textAreaAnnotation.setWidth("100%");
    tab2Content.addComponent(textAreaAnnotation);

    // this.buttonNext = new Button("Next");
    // buttonNext.setImmediate(true);
    // buttonNext.setDescription("Get next annotation");
    // tab2Content.addComponent(buttonNext);

    return tab2Content;
  }
Example #15
0
 @Override
 protected void validateDetails() throws ValidationException {
   logger.info(
       "Company ID : " + companyid + " | User Name : " + username + " > " + "Validating Data ");
   Boolean errorFlag = false;
   if (cbBranch.getValue() == null) {
     cbBranch.setComponentError(new UserError(GERPErrorCodes.NULL_BRACH_NAME));
     errorFlag = true;
   } else {
     cbBranch.setComponentError(null);
     errorFlag = false;
   }
   if (lsVendorName.getValue() == null || lsVendorName.getValue().toString() == "[]") {
     lsVendorName.setComponentError(new UserError(GERPErrorCodes.NULL_VENDOR_NAME));
     errorFlag = true;
   } else {
     lsVendorName.setComponentError(null);
     errorFlag = false;
   }
   if (tblSmsEnqDtl.size() == 0) {
     cbUom.setComponentError(new UserError(GERPErrorCodes.NULL_MATERIAL_UOM));
     tfEnqQty.setComponentError(new UserError(GERPErrorCodes.NULL_ENQUIRY_QTY));
     lsProduct.setComponentError(new UserError(GERPErrorCodes.NULL_PRODUCT_NAME));
     errorFlag = true;
   }
   if ((dfEnqDate.getValue() != null) || (dfDueDate.getValue() != null)) {
     if (dfEnqDate.getValue().after(dfDueDate.getValue())) {
       dfDueDate.setComponentError(new UserError(GERPErrorCodes.MMS_DATE_OUTOFRANGE));
       logger.warn(
           "Company ID : "
               + companyid
               + " | User Name : "
               + username
               + " > "
               + "Throwing ValidationException. User data is > "
               + dfEnqDate.getValue());
       errorFlag = true;
     }
   }
   if (errorFlag) {
     throw new ERPException.ValidationException();
   }
 }
Example #16
0
 @Override
 protected void editDetails() {
   hlUserInputLayout.removeAllComponents();
   hlUserIPContainer.addComponent(GERPPanelGenerator.createPanel(hlUserInputLayout));
   assembleInputUserLayout();
   tblMstScrSrchRslt.setVisible(false);
   hlCmdBtnLayout.setVisible(false);
   tblSmsEnqDtl.setVisible(true);
   if (tfEnqNo.getValue() == null || tfEnqNo.getValue().trim().length() == 0) {
     tfEnqNo.setReadOnly(false);
   }
   cbBranch.setRequired(true);
   lsVendorName.setRequired(true);
   resetFields();
   editPurHdr();
   editSmsPurDetail();
   lsProduct.setRequired(true);
   cbUom.setRequired(true);
 }
Example #17
0
  public void initializePanelLeft() {
    txtSearch = new TextField();
    txtSearch.setWidth("100%");
    txtSearch.setHeight("100%");

    txtSearch.addListener(
        new TextChangeListener() {
          private static final long serialVersionUID = 1L;

          public void textChange(TextChangeEvent event) {
            String filter = event.getText();
            search(filter);
          }
        });

    btnSearch.setStyleName("searchButton");
    btnSearch.setDescription("Buscar");

    HorizontalLayout pnlSearch = new HorizontalLayout();
    pnlSearch.setWidth("100%");
    pnlSearch.setHeight("100%");
    pnlSearch.setMargin(false);
    pnlSearch.addComponent(txtSearch);
    pnlSearch.addComponent(btnSearch);

    lstStudents = new ListSelect("Alumnos Disponibles");
    lstStudents.setSizeFull();
    lstStudents.setMultiSelect(true);

    // panel left
    VerticalLayout pnlLeft = new VerticalLayout();
    pnlLeft.setHeight("100%");
    pnlLeft.setWidth("100%");
    pnlLeft.addComponent(pnlSearch);
    pnlLeft.addComponent(lstStudents);
    pnlLeft.setMargin(false);
    pnlLeft.setExpandRatio(pnlSearch, new Float(0.08));
    pnlLeft.setExpandRatio(lstStudents, new Float(0.92));

    mainPanel.addComponent(pnlLeft);
    mainPanel.setExpandRatio(pnlLeft, new Float(0.45));
  }
Example #18
0
  private void populatePaymentTypes(CategoryType selectedCategory) {
    try {
      List<PaymentType> svcTypes = accSvc.getTypesForCategory(selectedCategory);

      types = new LinkedHashMap<>();

      paymentTypes.removeAllItems();
      for (PaymentType type : svcTypes) {
        types.put(type.getName(), type);
        paymentTypes.addItem(type.getName());
      }
    } catch (AccountsSheetException e) {
      close();
      Messenger.genericMessage(
          MessageSeverity.ERROR,
          STRINGS.getString(AccountsMessages.MSGR_UNRECOVERABLE_ERROR),
          "Failed trying to query Payment Types for Balance Sheet",
          e);
    }
  }
Example #19
0
 // Load Vendor List
 private void loadVendorList() {
   try {
     BeanContainer<Long, VendorDM> beanVendor = new BeanContainer<Long, VendorDM>(VendorDM.class);
     beanVendor.setBeanIdProperty("vendorId");
     beanVendor.addAll(
         serviceVendor.getVendorList(
             branchId, null, companyid, null, null, null, null, null, "Active", null, "P"));
     lsVendorName.setContainerDataSource(beanVendor);
   } catch (Exception e) {
     logger.info(e.getMessage());
   }
 }
Example #20
0
 private void loadProduct() {
   try {
     BeanContainer<Long, ProductDM> beanVendor =
         new BeanContainer<Long, ProductDM>(ProductDM.class);
     beanVendor.setBeanIdProperty("prodid");
     beanVendor.addAll(
         serviceProduct.getProductList(companyid, null, null, null, "Active", null, null, "P"));
     lsProduct.setContainerDataSource(beanVendor);
   } catch (Exception e) {
     logger.info(e.getMessage());
   }
 }
Example #21
0
 private void editSmsPurDetail() {
   logger.info(
       "Company ID : "
           + companyid
           + " | User Name : "
           + username
           + " > "
           + "Editing the selected record");
   hlUserInputLayout.setVisible(true);
   if (tblSmsEnqDtl.getValue() != null) {
     SmsPurEnqDtlDM purEnqDtlDM = beanPurEnqDtlDM.getItem(tblSmsEnqDtl.getValue()).getBean();
     lsProduct.setValue(null);
     Long prodid = purEnqDtlDM.getProductId();
     Collection<?> prodids = lsProduct.getItemIds();
     for (Iterator<?> iterator = prodids.iterator(); iterator.hasNext(); ) {
       Object itemId = (Object) iterator.next();
       BeanItem<?> item = (BeanItem<?>) lsProduct.getItem(itemId);
       // Get the actual bean and use the data
       ProductDM st = (ProductDM) item.getBean();
       if (prodid != null && prodid.equals(st.getProdid())) {
         lsProduct.select(itemId);
       }
     }
     if (cbUom.getValue() != null) {
       cbUom.setReadOnly(false);
       cbUom.setValue(purEnqDtlDM.getProductUom());
       cbUom.setReadOnly(true);
     }
     if (tfEnqQty.getValue() != null) {
       tfEnqQty.setValue(purEnqDtlDM.getEnquiryQty().toString());
     }
     if (purEnqDtlDM.getRemarks() != null) {
       taEnqDtlRem.setValue(purEnqDtlDM.getRemarks().toString());
     }
     if (purEnqDtlDM.getEnqDtlStaus() != null) {
       cbEnqDtlStatus.setValue(purEnqDtlDM.getEnqDtlStaus());
     }
   }
 }
Example #22
0
  @Override
  public void buttonClick(ClickEvent event) {
    switch ((Integer) event.getButton().getData()) {
      case ADD_NEW_CATEGORY:
        try {
          catFrm.commit();
          if (catFrm.isValid()) {
            accSvc.addNewPaymentCategory(
                (String) catFrm.getField(ADD_CATG_FLD_NAME).getValue(),
                ((CheckBox) catFrm.getField(ADD_CATG_CREDIT_BOOL)).booleanValue(),
                balSheet);
          }
        } catch (InvalidValueException e) {
          // Ignoring InvalidValueException as
          // an appropriate msg is displayed in UI
        } catch (AccountsSheetException e) {
          close();
          Messenger.genericMessage(
              MessageSeverity.ERROR,
              STRINGS.getString(AccountsMessages.MSGR_UNRECOVERABLE_ERROR),
              "Failed trying to add Payment Categories for Balance Sheet",
              e);
        }
        break;
      case ADD_NEW_TYPE:
        try {
          typeFrm.commit();
          if (typeFrm.isValid()) {
            accSvc.addNewPaymentType(
                (String) typeFrm.getField(ADD_TYPE_FLD_NAME).getValue(),
                categories.get(typeFrm.getField(ADD_TYPE_FLD_CAT).getValue()));
          }
        } catch (InvalidValueException e) {
          // Ignoring InvalidValueException as
          // an appropriate msg is displayed in UI
        } catch (AccountsSheetException e) {
          close();
          Messenger.genericMessage(
              MessageSeverity.ERROR,
              STRINGS.getString(AccountsMessages.MSGR_UNRECOVERABLE_ERROR),
              "Failed trying to add Payment Types for Balance Sheet",
              e);
        }
        break;
    }

    populatePaymentCategories();
    populatePaymentTypes(categories.get(paymentCategories.getValue()));

    accordion.setSelectedTab(current);
  }
Example #23
0
 public void buttonClick(ClickEvent event) {
   Button btn = event.getButton();
   if (btn.equals(buttonSave)) {
     Collection<Enrollment> stC = (Collection<Enrollment>) lstStudentSelecteds.getItemIds();
     widget.setStudentsSelecteds(new ArrayList(stC));
     widget.removeSelectableStudent();
     widget.sortTable();
   } else if (btn.equals(buttonCancel)) {
     widget.removeSelectableStudent();
   } else if (btn.equals(btnAddAll)) {
     moveLeftRight();
   } else if (btn.equals(btnRemoveAll)) {
     moveRightLeft();
   } else if (btn.equals(btnSearch)) {
     search((String) txtSearch.getValue());
   }
 }
Example #24
0
 private void enqDtlresetFields() {
   logger.info(
       "Company ID : "
           + companyid
           + " | User Name : "
           + username
           + " > "
           + "Resetting the UI controls");
   lsProduct.setValue(null);
   tfEnqQty.setValue("0");
   taEnqDtlRem.setValue("");
   cbUom.setReadOnly(false);
   cbUom.setValue("");
   cbUom.setReadOnly(true);
   cbEnqDtlStatus.setValue(cbEnqDtlStatus.getItemIds().iterator().next());
   cbUom.setComponentError(null);
   btnaddSpec.setCaption("Add");
   tfEnqQty.setComponentError(null);
 }
Example #25
0
  private Panel designMainPanel() {
    // positioning indices
    final int leftStart = 450, topStart = 10, space = 100;
    // create the panel that will hold all components

    Panel pnlURIsProperties = new Panel("URI Display");

    pnlURIsProperties.setWidth("100%");
    pnlURIsProperties.setHeight("100%");

    // Create absolute layout specifying its properties
    final AbsoluteLayout layout = new AbsoluteLayout();
    layout.setWidth("100%");
    layout.setHeight("100%");
    layout.setSizeFull();

    // Create components Objects and specify their properties

    Button btnCorrect = new Button("Correct");
    Button btnIncorrect = new Button("Incorrect");
    Button btnUnsure = new Button("Unsure");
    Button btnGetProperties = new Button("Get properties");

    final NativeSelect cmbSourceEndpoint = new NativeSelect("Source Endpoint");
    final NativeSelect cmbDestinationEndpoint = new NativeSelect("Destination Endpoint");
    final ListSelect lstSuggestedProperties = new ListSelect("Lookup Properties");
    // to load properties of loaded resources automatically
    final CheckBox chkAutomaticPropertiesLoad =
        new CheckBox("Automatic Properties loading (next time)");
    chkAutomaticPropertiesLoad.setValue(false);

    cmbSourceEndpoint.setNullSelectionAllowed(false);
    cmbDestinationEndpoint.setNullSelectionAllowed(false);

    lstSuggestedProperties.setRows(4);
    lstSuggestedProperties.setNullSelectionAllowed(false);

    source = new Label("Source URI");
    destination = new Label("Destination URI");

    final Table tblSourcePropertiesMapping = new Table("Source Properties");
    final Table tblDestinationPropertiesMapping = new Table("Destination Properties");
    tblSourcePropertiesParam = tblSourcePropertiesMapping;
    tblDestinationPropertiesParam = tblDestinationPropertiesMapping;

    tblSourcePropertiesMapping.setWidth("50%");
    tblDestinationPropertiesMapping.setWidth("100%");
    tblSourcePropertiesMapping.setSelectable(true);
    tblDestinationPropertiesMapping.setSelectable(true);
    /* Define the names and data types of columns.
     * The "default value" parameter is meaningless here. */
    tblSourcePropertiesMapping.addContainerProperty("Property", String.class, null);
    tblSourcePropertiesMapping.addContainerProperty("Value", String.class, null);

    tblDestinationPropertiesMapping.addContainerProperty("Property", String.class, null);
    tblDestinationPropertiesMapping.addContainerProperty("Value", String.class, null);
    tblDestinationPropertiesMapping.setMultiSelect(true);
    /// get data for comboboxes
    SQLContainer cmbContainer = connectToDB("root", "mofo", "Endpoints");
    // fill endpoints
    cmbSourceEndpoint.setContainerDataSource(cmbContainer);
    cmbDestinationEndpoint.setContainerDataSource(cmbContainer);

    cmbSourceEndpoint.setValue(cmbSourceEndpoint.getItemIds().iterator().next());
    cmbDestinationEndpoint.setValue(cmbDestinationEndpoint.getItemIds().iterator().next());

    SQLContainer lstContainer = getSuggestedProperties("root", "mofo");
    int lstSize = lstContainer.size();
    int i = 0;
    for (Object cityItemId : lstContainer.getItemIds()) {
      lstSuggestedProperties.addItem(i);
      String g = lstContainer.getItem(cityItemId).getItemProperty("property").getValue().toString();
      lstSuggestedProperties.setItemCaption(i, g);
      i++;
    }
    lstSuggestedProperties.setValue(lstSuggestedProperties.getItemIds().iterator().next());

    btnCorrect.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            try {
              Object rowId = tblSourceDestinationparam.getValue();
              Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue());
              lEndTime = System.currentTimeMillis();
              long lEllapsedTime = lEndTime - lStartTime;
              tblSourceDestinationparam.setEditable(true);
              tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Correct");
              tblSourceDestinationparam
                  .getContainerProperty(rowId, "time")
                  .setValue(String.valueOf(lEllapsedTime));

              tblSourceDestinationparam.setEditable(false);
              SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource();
              try {
                c.commit();
              } catch (UnsupportedOperationException | SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              int maxindex = tblSourceDestination.size();
              SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource();
              // Item x=s.getItem(tblSourceDestination.getValue());
              if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) {
                int index = s.indexOfId(tblSourceDestination.getValue());
                index++;
                tblSourceDestination.setValue(s.getIdByIndex(index));
                try {
                  Object rowId2 = tblSourceDestination.getValue();
                  Property sourceProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "sourceURI");
                  Property destinationProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "destinationURI");

                  source.setValue(sourceProperty.toString());
                  destination.setValue(destinationProperty.toString());
                  tblSourcePropertiesParam.removeAllItems();
                  tblDestinationPropertiesParam.removeAllItems();

                  Notification loadURI = new Notification("");
                  loadURI.show("Links' URIs are successfully loaded ");
                  if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked
                  {
                    // load the properties automatically
                    String sourceEndpoint = "", destinationEndpoint = "";
                    sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
                    destinationEndpoint =
                        cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
                    try {
                      String sparqlQuery = source.getValue();
                      getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
                      sparqlQuery = destination.getValue();
                      getURIProperties(
                          sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
                    } catch (Exception e) {
                      Notification.show("ERROR");
                    }
                    lStartTime = System.currentTimeMillis();
                    // start time for next one
                  }
                } catch (Exception e) {
                  Notification error = new Notification("Error");
                  error.show("You did not select an item in the links table");
                }
              }
            } catch (Exception e) {
              Notification.show(e.getMessage());
            }

            ///////////////////////////////////

          }
        });
    btnIncorrect.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            try {
              Object rowId = tblSourceDestinationparam.getValue();
              Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue());
              lEndTime = System.currentTimeMillis();
              long lEllapsedTime = lEndTime - lStartTime;
              tblSourceDestinationparam.setEditable(true);
              tblSourceDestinationparam
                  .getContainerProperty(rowId, "decision")
                  .setValue("Incorrect");
              tblSourceDestinationparam
                  .getContainerProperty(rowId, "time")
                  .setValue(String.valueOf(lEllapsedTime));
              tblSourceDestinationparam.setEditable(false);
              SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource();
              try {
                c.commit();
              } catch (UnsupportedOperationException | SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              int maxindex = tblSourceDestination.size();
              SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource();
              // Item x=s.getItem(tblSourceDestination.getValue());
              if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) {
                int index = s.indexOfId(tblSourceDestination.getValue());
                index++;
                tblSourceDestination.setValue(s.getIdByIndex(index));
                try {
                  Object rowId2 = tblSourceDestination.getValue();
                  Property sourceProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "sourceURI");
                  Property destinationProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "destinationURI");

                  source.setValue(sourceProperty.toString());
                  destination.setValue(destinationProperty.toString());
                  tblSourcePropertiesParam.removeAllItems();
                  tblDestinationPropertiesParam.removeAllItems();

                  Notification loadURI = new Notification("");
                  loadURI.show("Links' URIs are successfully loaded ");

                  if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked
                  {
                    // load the properties automatically
                    String sourceEndpoint = "", destinationEndpoint = "";
                    sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
                    destinationEndpoint =
                        cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
                    try {
                      String sparqlQuery = source.getValue();
                      getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
                      sparqlQuery = destination.getValue();
                      getURIProperties(
                          sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
                    } catch (Exception e) {
                      Notification.show("ERROR Not Properties queried");
                    }
                    lStartTime = System.currentTimeMillis();
                    // start time for next one
                  }
                } catch (Exception e) {
                  Notification error = new Notification("Error");
                  error.show("You did not select an item in the links table");
                }
              }
            } catch (Exception e) {
              Notification.show(e.getMessage());
            }
            ///////////////////////////////////

          }
        });
    btnUnsure.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            try {
              Object rowId = tblSourceDestinationparam.getValue();
              Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue());
              lEndTime = System.currentTimeMillis();
              float lEllapsedTime = lEndTime - lStartTime;
              String elapsedTime = String.valueOf(lEllapsedTime);
              tblSourceDestinationparam.setEditable(true);
              tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Unsure");
              tblSourceDestinationparam.getContainerProperty(rowId, "time").setValue(elapsedTime);
              tblSourceDestinationparam.setEditable(false);
              SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource();
              try {
                c.commit();
              } catch (UnsupportedOperationException | SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }

              // int selectedId=Integer.parseInt(tblSourceDestination.getValue().toString());
              int maxindex = tblSourceDestination.size();
              SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource();
              // Item x=s.getItem(tblSourceDestination.getValue());
              if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) {
                int index = s.indexOfId(tblSourceDestination.getValue());
                index++;
                tblSourceDestination.setValue(s.getIdByIndex(index));
                try {
                  Object rowId2 = tblSourceDestination.getValue();
                  Property sourceProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "sourceURI");
                  Property destinationProperty =
                      tblSourceDestination.getContainerProperty(rowId2, "destinationURI");

                  source.setValue(sourceProperty.toString());
                  destination.setValue(destinationProperty.toString());
                  tblSourcePropertiesParam.removeAllItems();
                  tblDestinationPropertiesParam.removeAllItems();

                  Notification loadURI = new Notification("");
                  loadURI.show("Links' URIs are successfully loaded ");
                  if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked
                  {
                    // load the properties automatically
                    String sourceEndpoint = "", destinationEndpoint = "";
                    sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
                    destinationEndpoint =
                        cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
                    try {
                      String sparqlQuery = source.getValue();
                      getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
                      sparqlQuery = destination.getValue();
                      getURIProperties(
                          sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
                    } catch (Exception e) {
                      Notification.show("ERROR Not Properties queried");
                    }
                    lStartTime = System.currentTimeMillis();
                    // start time for next one
                  }
                } catch (Exception e) {
                  Notification error = new Notification("Error");
                  error.show("You did not select an item in the links table");
                }
              }
            } catch (Exception e) {
              Notification.show(e.getMessage());
            }
          }
        });
    btnGetProperties.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            String sourceEndpoint = "", destinationEndpoint = "";
            sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue());
            destinationEndpoint =
                cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue());
            lStartTime = System.currentTimeMillis();

            try {
              String sparqlQuery = source.getValue();
              getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping);
              sparqlQuery = destination.getValue();
              getURIProperties(sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping);
            } catch (Exception e) {
              Notification.show(
                  "ERROR while sparqling the endpoint for resources' properties (Are they selected/loaded ?)");
            }
            // cachingForTriples(tblSourceDestination, sourceEndpoint);
          }
        });

    lstSuggestedProperties.addValueChangeListener(
        new ValueChangeListener() {
          @Override
          public void valueChange(final ValueChangeEvent event) {
            final String valueString = String.valueOf(event.getProperty().getValue());
            // Notification.show(valueString);
            List<Object> Ids = new ArrayList<Object>();
            Object first = null;
            for (Iterator i = tblSourcePropertiesMapping.getItemIds().iterator(); i.hasNext(); ) {
              // Get the current item identifier, which is an integer.
              first = i.next();
              int iid = (Integer) first;
              String other =
                  tblSourcePropertiesMapping.getItem(iid).getItemProperty("Property").toString();
              // Notification.show(other);
              if (other.equals(valueString)) // if(other.equals(property))
              {
                Ids.add(iid);
                break;
              }
            }
            tblSourcePropertiesMapping.setImmediate(true);
            tblSourcePropertiesMapping.setValue(Ids);
            tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first);
          }
        });

    tblSourcePropertiesMapping.addItemClickListener(
        new ItemClickEvent.ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            String property =
                tblSourcePropertiesMapping
                    .getContainerProperty(event.getItemId(), event.getPropertyId())
                    .toString();
            List<String> res = getRelatedProperties(property);

            if (res == null) {
              Notification.show("No related Properties");
              return;
            }
            boolean Found = false;
            List<Object> Ids = new ArrayList<Object>();
            Object first = null;
            int x = 0;
            for (String relatedProperty : res) {
              for (Iterator i = tblDestinationPropertiesMapping.getItemIds().iterator();
                  i.hasNext(); ) {
                // Get the current item identifier, which is an integer.
                Object theId = i.next();
                int iid = (Integer) theId;
                String other =
                    tblDestinationPropertiesMapping
                        .getItem(iid)
                        .getItemProperty(event.getPropertyId())
                        .toString();

                if (other.equals(relatedProperty)) // if(other.equals(property))
                {
                  Ids.add(iid);
                  if (x == 0) {
                    first = theId;
                    x = 1;
                  }
                  Found = true;
                }
              }
            }
            if (!Found)
              Notification.show(
                  "Related property is not Found in destination table try manual search");
            else {
              Notification.show("Found in destination table");
              tblDestinationPropertiesMapping.setValue(Ids);
              tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first);
            }
          }
        });
    // add component to the layout specifying its position on the layout

    layout.addComponent(btnCorrect, "left: " + leftStart + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        btnIncorrect, "left: " + (leftStart + space) + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        btnUnsure, "left: " + (leftStart + 2 * space) + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        btnGetProperties,
        "left: " + (leftStart + 3 * space + 50) + "px; top: " + (topStart + 450) + "px;");
    layout.addComponent(
        chkAutomaticPropertiesLoad,
        "left: " + (leftStart + 3 * space + 250) + "px; top: " + (topStart + 450) + "px;");

    /*layout.addComponent(sourceURI,"left: "+(leftStart-space/2)+"px; top: "+(topStart+space/2)+"px;");
    layout.addComponent(destinationURI,"left: "+(leftStart+2*space)+"px; top: "+(topStart+space/2)+"px;");*/

    layout.addComponent(source, "left: 30px; top: " + (topStart + space / 2) + "px;");
    layout.addComponent(
        destination,
        "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space / 2) + "px;");

    layout.addComponent(cmbSourceEndpoint, "left: 50px; top: " + (topStart + 20) + "px;");
    layout.addComponent(
        cmbDestinationEndpoint,
        "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + 20) + "px;");
    layout.addComponent(
        lstSuggestedProperties,
        "left: " + (leftStart + 100) + "px; top: " + (topStart + 20) + "px;");

    layout.addComponent(
        tblSourcePropertiesMapping, "left: 10px; top: " + (topStart + space) + "px;");
    layout.addComponent(
        tblDestinationPropertiesMapping,
        "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space) + "px;");

    pnlURIsProperties.setContent(layout);

    return pnlURIsProperties;
  }
Example #26
0
 @Override
 protected void saveDetails() throws SaveException, FileNotFoundException, IOException {
   logger.info(
       "Company ID : " + companyid + " | User Name : " + username + " > " + "Saving Data... ");
   try {
     SmsPurEnqHdrDM purEnqobj = new SmsPurEnqHdrDM();
     if (tblMstScrSrchRslt.getValue() != null) {
       purEnqobj = beanPurEnqHdrDM.getItem(tblMstScrSrchRslt.getValue()).getBean();
       purEnqobj.setEnquiryNo(tfEnqNo.getValue());
     }
     purEnqobj.setEnquiryNo(tfEnqNo.getValue());
     purEnqobj.setCompanyId(companyid);
     purEnqobj.setEnqRemark(taEnqRem.getValue().toString());
     purEnqobj.setBranchId((Long) cbBranch.getValue());
     purEnqobj.setDueDate((Date) dfDueDate.getValue());
     purEnqobj.setEnquiryDate((Date) dfEnqDate.getValue());
     purEnqobj.setEnquiryStatus(((String) cbEnqStatus.getValue()));
     purEnqobj.setPreparedBy(employeeId);
     purEnqobj.setReviewedBy(null);
     purEnqobj.setActionedBy(null);
     purEnqobj.setLastUpdateddt(DateUtils.getcurrentdate());
     purEnqobj.setLastUpdatedby(username);
     serviceSmsPurEnqHdr.saveorUpdateSmsPurEnqHdrDetails(purEnqobj);
     enquiryId = purEnqobj.getEnquiryId();
     String[] split =
         lsVendorName.getValue().toString().replaceAll("\\[", "").replaceAll("\\]", "").split(",");
     for (String obj : split) {
       if (obj.trim().length() > 0) {
         EnquiryVendorDtlDM enqvendtl = new EnquiryVendorDtlDM();
         enqvendtl.setEnqid(purEnqobj.getEnquiryId());
         System.out.println("vendid" + Long.valueOf(obj.trim()));
         enqvendtl.setVendorid(Long.valueOf(obj.trim()));
         serviceEnquiryVendorDtl.save(enqvendtl);
       }
     }
     @SuppressWarnings("unchecked")
     Collection<SmsPurEnqDtlDM> itemIds =
         (Collection<SmsPurEnqDtlDM>) tblSmsEnqDtl.getVisibleItemIds();
     for (SmsPurEnqDtlDM save : (Collection<SmsPurEnqDtlDM>) itemIds) {
       save.setEnquiryId(Long.valueOf(purEnqobj.getEnquiryId().toString()));
       serviceSmsPurEnqDtl.saveorUpdateSmsPurEnqDtlDetails(save);
     }
     comments.resetfields();
     if (tblMstScrSrchRslt.getValue() == null) {
       try {
         SlnoGenDM slnoObj =
             serviceSlnogen.getSequenceNumber(companyid, branchId, moduleId, "SM_ENQRYNO").get(0);
         if (slnoObj.getAutoGenYN().equals("Y")) {
           serviceSlnogen.updateNextSequenceNumber(companyid, branchId, moduleId, "SM_ENQRYNO");
         }
       } catch (Exception e) {
       }
     }
     tfEnqNo.setReadOnly(false);
     tfEnqNo.setValue(purEnqobj.getEnquiryNo());
     tfEnqNo.setReadOnly(true);
     comments.saveEnquiry(purEnqobj.getEnquiryId(), purEnqobj.getEnquiryStatus());
     loadSrchRslt();
     enqDtlresetFields();
   } catch (Exception e) {
     logger.info(e.getMessage());
   }
 }
Example #27
0
 private void saveEnqDtl() {
   logger.info(
       "Company ID : " + companyid + " | User Name : " + username + " > " + "Saving Data... ");
   try {
     int count = 0;
     String[] split =
         lsProduct.getValue().toString().replaceAll("\\[", "").replaceAll("\\]", "").split(",");
     for (String obj : split) {
       if (obj.trim().length() > 0) {
         for (SmsPurEnqDtlDM smsPurEnqDtlDM : listEnqDtls) {
           if (smsPurEnqDtlDM.getProductId().equals(Long.valueOf(obj.trim()))) {
             count++;
             break;
           }
         }
         if (tblSmsEnqDtl.getValue() != null) {
           count = 0;
         }
         if (count == 0) {
           SmsPurEnqDtlDM enqDtlObj = new SmsPurEnqDtlDM();
           if (tblSmsEnqDtl.getValue() != null) {
             enqDtlObj = beanPurEnqDtlDM.getItem(tblSmsEnqDtl.getValue()).getBean();
             listEnqDtls.remove(enqDtlObj);
           }
           if (lsProduct.getValue() != null) {
             enqDtlObj.setProductId(Long.valueOf(obj.trim()));
             enqDtlObj.setPordName(
                 serviceProduct
                     .getProductList(
                         null, Long.valueOf(obj.trim()), null, null, null, null, null, "P")
                     .get(0)
                     .getProdname());
           }
           if (cbUom.getValue() != null) {
             cbUom.setReadOnly(false);
             enqDtlObj.setProductUom(cbUom.getValue().toString());
             cbUom.setReadOnly(true);
           }
           enqDtlObj.setRemarks(taEnqDtlRem.getValue().toString());
           if (tfEnqQty.getValue() != null && tfEnqQty.getValue().trim().length() > 0) {
             enqDtlObj.setEnquiryQty(Long.valueOf(tfEnqQty.getValue()));
           }
           if (cbEnqDtlStatus.getValue() != null) {
             enqDtlObj.setEnqDtlStaus((cbEnqDtlStatus.getValue().toString()));
           }
           enqDtlObj.setLastUpdateddt(DateUtils.getcurrentdate());
           enqDtlObj.setLastUpdatedby(username);
           listEnqDtls.add(enqDtlObj);
           loadPurDtl();
           btnaddSpec.setCaption("Add");
           count = 0;
         } else {
           lsProduct.setComponentError(new UserError("Product Already Exist.."));
         }
       }
     }
     enqDtlresetFields();
   } catch (Exception e) {
     logger.info(e.getMessage());
   }
 }
Example #28
0
  private DataBinder<MarathonData> showOverviewData(final FormLayout layout) {
    layout.setMargin(true);
    final BeanFieldGroup<MarathonData> binder =
        new BeanFieldGroup<MarathonData>(MarathonData.class);
    layout.addComponent(binder.buildAndBind("Veranstaltung", "marathonName"));
    final BeanItemContainer<String> categoryListContainer =
        new BeanItemContainer<String>(String.class);

    final ListSelect categoryListSelect = new ListSelect("Kategorieen", categoryListContainer);
    categoryListSelect.setNewItemsAllowed(true);
    categoryListSelect.setNullSelectionAllowed(false);
    categoryListSelect.setMultiSelect(false);
    layout.addComponent(categoryListSelect);
    final Button removeItemButton = new Button("Kategorie löschen");
    layout.addComponent(removeItemButton);
    removeItemButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(final ClickEvent event) {
            categoryListContainer.removeItem(categoryListSelect.getValue());
          }
        });
    // final ListSelect categoryList = new ListSelect("Kategorieen");
    // layout.addComponent(categoryList);

    final BeanItemContainer<DriverData> driverContainer =
        new BeanItemContainer<DriverData>(DriverData.class);

    final Table table = new Table("Fahrer");
    table.setContainerDataSource(driverContainer);
    table.removeContainerProperty("smallSheets");
    table.removeContainerProperty("startTimes");
    table.removeContainerProperty("category");
    table.addGeneratedColumn(
        "Kategorie",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final ComboBox comboBox = new ComboBox();
            comboBox.setContainerDataSource(categoryListContainer);
            final DriverData driverData = (DriverData) itemId;
            final String category =
                driverData.getCategory() == null ? "" : driverData.getCategory();

            final ObjectProperty<String> property = new ObjectProperty<String>(category);
            comboBox.setPropertyDataSource(property);
            property.addValueChangeListener(
                new ValueChangeListener() {

                  @Override
                  public void valueChange(final ValueChangeEvent event) {
                    driverData.setCategory(property.getValue());
                  }
                });
            return comboBox;
          }
        });
    table.addGeneratedColumn(
        "Generieren",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final DriverData driverData = (DriverData) itemId;
            final Button button = new Button("PDF");
            button.addClickListener(
                new ClickListener() {
                  @Override
                  public void buttonClick(final ClickEvent event) {
                    // showPdfHandler.showPdf(driverData.getName());
                  }
                });
            return button;
          }
        });
    table.addGeneratedColumn("Phase A Zettel", createPhaseCheckbox(Phase.A));
    table.addGeneratedColumn("Phase D Zettel", createPhaseCheckbox(Phase.D));
    table.addGeneratedColumn("Phase E Zettel", createPhaseCheckbox(Phase.E));
    final DurationFieldFactory fieldFactory = new DurationFieldFactory();
    table.addGeneratedColumn("Phase A Start", createPhaseStartInput(fieldFactory, Phase.A));
    table.addGeneratedColumn("Phase D Start", createPhaseStartInput(fieldFactory, Phase.D));
    table.addGeneratedColumn("Phase E Start", createPhaseStartInput(fieldFactory, Phase.E));
    table.addGeneratedColumn(
        "Fahrer Löschen",
        new ColumnGenerator() {

          @Override
          public Object generateCell(
              final Table source, final Object itemId, final Object columnId) {
            final Button button = new Button("-");
            button.addClickListener(
                new ClickListener() {

                  @Override
                  public void buttonClick(final ClickEvent event) {
                    driverContainer.removeItem(itemId);
                  }
                });
            return button;
          }
        });

    table.setEditable(true);
    table.setSortEnabled(false);
    // table.setNullSelectionAllowed(true);
    layout.addComponent(table);
    final Button addDriverButton = new Button("Neuer Fahrer");
    addDriverButton.addClickListener(
        new ClickListener() {

          @Override
          public void buttonClick(final ClickEvent event) {
            final DriverData driver = new DriverData();
            driver.setName("Fahrer - " + driverContainer.size());
            driverContainer.addBean(driver);
          }
        });
    layout.addComponent(addDriverButton);

    return new DataBinder<MarathonData>() {

      private MarathonData data;

      @Override
      public void bindData(final MarathonData data) {
        this.data = data;
        binder.setItemDataSource(data);
        categoryListContainer.removeAllItems();
        for (final String category : data.getCategories()) {
          categoryListContainer.addBean(category);
        }
        driverContainer.removeAllItems();
        for (final DriverData driver : data.getDrivers().values()) {
          driverContainer.addBean(driver);
        }
      }

      @Override
      public void commitHandler() {
        try {
          binder.commit();
          final List<String> categories = data.getCategories();
          categories.clear();
          categories.addAll(categoryListContainer.getItemIds());
          final Map<String, DriverData> drivers = data.getDrivers();
          drivers.clear();
          for (final DriverData driver : driverContainer.getItemIds()) {
            drivers.put(driver.getName(), driver);
          }
        } catch (final CommitException e) {
          throw new RuntimeException("Cannot commit", e);
        }
      }

      @Override
      public MarathonData getCurrentData() {
        return data;
      }
    };
  }
Example #29
0
  public PaymentTypeMgmt(BalanceSheet sheet) {
    super(AccountsMessages.BAL_SHEET_NEW_PAY_TYPE);

    this.balSheet = sheet;

    setWidth("320px");
    setIcon(IconManager.getIcon(IconManager.CATG_MGMT_SM));

    accordion = new Accordion();
    accordion.setSizeFull();

    HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);

    VerticalLayout vl1 = new VerticalLayout();
    vl1.setSpacing(true);

    paymentCategories =
        new ListSelect(STRINGS.getString(AccountsMessages.BAL_SHEET_PAYMENT_CATEGORY));
    populatePaymentCategories();
    paymentCategories.setNullSelectionAllowed(false);
    paymentCategories.setImmediate(true);
    paymentCategories.setRows(NUM_ROWS);
    paymentCategories.addListener(this);

    Set<String> keys = categories.keySet();
    if (keys.size() > 0) paymentCategories.select(keys.iterator().next());

    vl1.addComponent(paymentCategories);

    hl.addComponent(vl1);

    VerticalLayout vl2 = new VerticalLayout();
    vl2.setSpacing(true);

    paymentTypes = new ListSelect(STRINGS.getString(AccountsMessages.BAL_SHEET_PAYMENT_TYPE));
    populatePaymentTypes(categories.get(paymentCategories.getValue()));
    paymentTypes.setNullSelectionAllowed(false);
    paymentTypes.setImmediate(true);
    paymentTypes.setRows(NUM_ROWS);

    vl2.addComponent(paymentTypes);

    hl.addComponent(vl2);

    current = accordion.addTab(hl);
    current.setCaption(STRINGS.getString(AccountsMessages.CURRENT));

    addNewCategory = accordion.addTab(generateCreateNewCategoryForm());
    addNewCategory.setCaption(
        STRINGS.getString(AccountsMessages.ADD_NEW)
            + " "
            + STRINGS.getString(AccountsMessages.BAL_SHEET_PAYMENT_CATEGORY));

    addNewType = accordion.addTab(generateCreateNewTypeForm());
    addNewType.setCaption(
        STRINGS.getString(AccountsMessages.ADD_NEW)
            + " "
            + STRINGS.getString(AccountsMessages.BAL_SHEET_PAYMENT_TYPE));

    addComponent(accordion);
  }
Example #30
0
 @Override
 public void valueChange(ValueChangeEvent event) {
   populatePaymentTypes(categories.get(paymentCategories.getValue()));
 }