Exemplo n.º 1
0
  /**
   * Assigns this as the context menu of given table. Allows context menu to appear only on certain
   * parts of the table.
   *
   * @param table
   * @param onRow show context menu when row is clicked
   * @param onHeader show context menu when header is clicked
   * @param onFooter show context menu when footer is clicked
   */
  public void setAsTableContextMenu(
      final Table table, final boolean onRow, final boolean onHeader, final boolean onFooter) {
    extend(table);

    setOpenAutomatically(false);

    if (onRow) {
      table.addItemClickListener(
          new ItemClickEvent.ItemClickListener() {
            private static final long serialVersionUID = -348059189217149508L;

            @Override
            public void itemClick(ItemClickEvent event) {
              if (event.getButton() == MouseButton.RIGHT) {
                events.preContextMenuOpen();
                fireEvent(
                    new ContextMenuOpenedOnTableRowEvent(
                        TableContextMenu.this, table, event.getItemId(), event.getPropertyId()));
                open(event.getClientX(), event.getClientY());
              }
            }
          });
    }

    if (onHeader) {
      table.addHeaderClickListener(
          new HeaderClickListener() {
            private static final long serialVersionUID = -5880755689414670581L;

            @Override
            public void headerClick(HeaderClickEvent event) {
              if (event.getButton() == MouseButton.RIGHT) {
                events.preContextMenuOpen();
                fireEvent(
                    new ContextMenuOpenedOnTableHeaderEvent(
                        TableContextMenu.this, table, event.getPropertyId()));
                open(event.getClientX(), event.getClientY());
              }
            }
          });
    }

    if (onFooter) {
      table.addFooterClickListener(
          new FooterClickListener() {
            private static final long serialVersionUID = 2884227013964132482L;

            @Override
            public void footerClick(FooterClickEvent event) {
              if (event.getButton() == MouseButton.RIGHT) {
                events.preContextMenuOpen();
                fireEvent(
                    new ContextMenuOpenedOnTableHeaderEvent(
                        TableContextMenu.this, table, event.getPropertyId()));
                open(event.getClientX(), event.getClientY());
              }
            }
          });
    }
  }
Exemplo n.º 2
0
  public Caracteristicas() {
    buildMainLayout();
    setCompositionRoot(mainLayout);

    // TODO add user code here
    // Variables
    datos = new Datos();
    listaAvance = new LinkedList<LinkedList<Object>>();
    // Textfields
    txtNoAvance.setEnabled(false);
    // Comboboxes
    cmbEtapa.setNullSelectionAllowed(false);
    llenarLista(datos.getEtapaFenologica(), cmbEtapa);
    // Timefields
    tmfAvance.set24HourClock(false);
    tmfRecesion.set24HourClock(false);
    // Tables
    tblAvance.addContainerProperty("Núm.", Object.class, null);
    tblAvance.addContainerProperty("Distancia (m)", Object.class, null);
    tblAvance.addContainerProperty("Avance (tiempo)", Object.class, null);
    tblAvance.addContainerProperty("Recesión (tiempo)", Object.class, null);
    tblAvance.setSelectable(true);
    tblAvance.setSortEnabled(true);
    tblAvance.addItemClickListener(cargarAvanceListener);
    // Buttons
    btnAdd.addClickListener(addAvanceListener);
    btnCancel.addClickListener(cancelarListener);

    limpiarAvance();
    setValidaciones();
  }
Exemplo n.º 3
0
  /** 初始化表格 * */
  private void initRightTable(Table table, Container container) {
    table.setSizeFull();
    table.setHeight(100, Unit.PERCENTAGE);
    table.setContainerDataSource(container);
    table.setVisibleColumns(Constants.COMPLAIN_TYPE_COL);
    table.setColumnHeaders(Constants.COMPLAIN_TYPE_COL_HEADERS_CHINESE);

    table.setColumnCollapsingAllowed(true);
    table.setColumnReorderingAllowed(true);
    table.addItemClickListener(
        new ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            // MouseButton.LEFT 左键单击
            if (event.getButtonName().equals(MouseButton.LEFT.getName())) {
              createWindow(event.getItem());
            }
          }
        });
  }
Exemplo n.º 4
0
  @SuppressWarnings("unchecked")
  @Override
  public void setup(VaadinRequest request) {

    final Table items = new Table("Items - double-click to edit");
    items.setSelectable(true);
    items.addContainerProperty("name", String.class, "");
    items.addContainerProperty("birthday", Date.class, "");

    final TableFieldFactory fieldFactory = new ItemFieldFactory();
    items.setTableFieldFactory(fieldFactory);

    Calendar cal = Calendar.getInstance();
    cal.set(2010, 7, 12, 12, 7, 54);

    for (String name : names) {
      items.addItem(name);
      items.getItem(name).getItemProperty("name").setValue(name);
      items
          .getItem(name)
          .getItemProperty("birthday")
          .setValue(new FormattedDate(cal.getTime().getTime()));
    }

    items.addItemClickListener(
        new ItemClickEvent.ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            if (event.isDoubleClick()) {
              selectionEvent = event;
              items.setEditable(true);
            } else if (items.isEditable()) {
              items.setEditable(false);
            }
          }
        });

    addComponent(items);
  }
Exemplo n.º 5
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;
  }
Exemplo n.º 6
0
  private Panel allLinksDetails() {
    // positioning indices
    // final int leftStart=10,topStart=10, space=100;
    // create the panel that will hold all components
    Panel linksDetails = new Panel("Links Details");
    // set panel's properties
    linksDetails.setWidth("100%");
    linksDetails.setHeight("100%");

    // Create absolute layout specifying its properties
    final AbsoluteLayout layout = new AbsoluteLayout();
    // set layout's properties
    layout.setSizeFull();

    // Create components Objects and specify their properties
    Button btnLoad = new Button("Load task");
    // final Table tblSourceDestination = new Table("Source and Destination URIs");
    tblSourceDestination.setSelectable(true);
    tblSourceDestination.setWidth("90%");
    // fill the Source and Destination URIs table
    SQLContainer container = connectToDB("root", "mofo", userName);
    Notification.show("Welcome " + userName + " you loaded task Nr.: " + task);
    Compare.Equal suburbFilter = new Compare.Equal("taskId", Integer.valueOf(task));
    container.addContainerFilter(suburbFilter);
    // Fill the main (tblSourceDestination) table with resources
    tblSourceDestination.setContainerDataSource(container);
    tblSourceDestinationparam = tblSourceDestination;

    // add component to the layout specifying its position on the layout
    int tableWidth = (int) tblSourceDestination.getWidth();
    layout.addComponent(btnLoad, "left:1500px; top: 10px;");
    layout.addComponent(tblSourceDestination, "left: 10px; top: 20px;");

    linksDetails.setContent(layout);
    // Add EventHandlers for some of the components

    btnLoad.addClickListener(
        new Button.ClickListener() {
          @Override
          public void buttonClick(ClickEvent event) {
            // lStartTime= System.currentTimeMillis();

            try {
              Object rowId = tblSourceDestination.getValue();
              Property sourceProperty =
                  tblSourceDestination.getContainerProperty(rowId, "sourceURI");
              Property destinationProperty =
                  tblSourceDestination.getContainerProperty(rowId, "destinationURI");

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

              Notification loadURI = new Notification("");
              loadURI.show("Links' URIs are successfully loaded ");
            } catch (Exception e) {
              Notification error = new Notification("Error");
              error.show("You did not select an item in the links table");
            }
          }
        });

    tblSourceDestination.addItemClickListener(
        new ItemClickEvent.ItemClickListener() {

          @Override
          public void itemClick(ItemClickEvent event) {
            /*lStartTime= System.currentTimeMillis();

            try
            {
            	Object rowId =tblSourceDestination.getValue();
                Property sourceProperty=tblSourceDestination.getContainerProperty(rowId,"sourceURI");
                Property destinationProperty=tblSourceDestination.getContainerProperty(rowId,"destinationURI");

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


                Notification loadURI= new Notification("");
                loadURI.show("Links' URIs are successfully loaded ");
            }
            catch(Exception e)
            {
            	Notification error= new Notification("Error");
            	error.show("You did not select an item in the links table");
            }*/
          }
        });

    return linksDetails;
  }
Exemplo n.º 7
0
  private void buildView() {
    logger.info(
        "Company ID : "
            + companyid
            + " | User Name : "
            + username
            + " > "
            + "Painting PurchaseEnquiry UI");
    // Initialization for Purchase Enquire Details user input components
    tfEnqNo = new TextField("Enquiry No");
    tfEnqNo.setMaxLength(40);
    tfEnqQty = new TextField();
    tfEnqQty.setValue("0");
    tfEnqQty.setWidth("90");
    dfDueDate = new GERPPopupDateField("Due Date");
    dfDueDate.setInputPrompt("Select Date");
    dfEnqDate = new GERPPopupDateField("Enquiry Date");
    dfEnqDate.setInputPrompt("Select Date");
    taEnqDtlRem = new TextArea("Remarks");
    taEnqDtlRem.setMaxLength(40);
    taEnqDtlRem.setWidth("150");
    taEnqDtlRem.setHeight("50");
    taEnqRem = new TextArea("Remarks");
    taEnqRem.setHeight("50");
    taEnqDtlRem.setMaxLength(100);
    cbBranch = new GERPComboBox("Branch Name");
    cbBranch.setItemCaptionPropertyId("branchName");
    loadBranchList();
    try {
      ApprovalSchemaDM obj =
          serviceSmsPurEnqHdr.getReviewerId(companyid, appScreenId, branchId, roleId).get(0);
      if (obj.getApprLevel().equals("Approver")) {
        cbEnqStatus =
            new GERPComboBox("Status", BASEConstants.T_SMS_P_ENQUIRY_HDR, BASEConstants.RP_STATUS);
      } else {
        cbEnqStatus =
            new GERPComboBox(
                "Status", BASEConstants.T_SMS_P_ENQUIRY_HDR, BASEConstants.PE_STATUS_RV);
      }
    } catch (Exception e) {
      logger.info(e.getMessage());
    }
    cbEnqStatus.setWidth("120");
    cbEnqDtlStatus =
        new GERPComboBox("Status", BASEConstants.M_GENERIC_TABLE, BASEConstants.M_GENERIC_COLUMN);
    lsProduct = new ListSelect("Product Name");
    lsProduct.setItemCaptionPropertyId("prodname");
    lsProduct.setMultiSelect(true);
    loadProduct();
    lsProduct.setImmediate(true);
    lsProduct.addValueChangeListener(
        new ValueChangeListener() {
          /** */
          private static final long serialVersionUID = 1L;

          @Override
          public void valueChange(ValueChangeEvent event) {
            String[] split =
                lsProduct
                    .getValue()
                    .toString()
                    .replaceAll("\\[", "")
                    .replaceAll("\\]", "")
                    .split(",");
            for (String obj : split) {
              if (obj.trim().length() > 0) {
                cbUom.setReadOnly(false);
                cbUom.setValue(
                    serviceProduct
                        .getProductList(
                            companyid, Long.valueOf(obj.trim()), null, null, null, null, null, "F")
                        .get(0)
                        .getUom());
                cbUom.setReadOnly(true);
              }
            }
          }
        });
    cbUom = new TextField();
    cbUom.setWidth("77");
    cbUom.setHeight("23");
    lsVendorName = new ListSelect("Vendor Name ");
    lsVendorName.setMultiSelect(true);
    lsVendorName.setItemCaptionPropertyId("vendorName");
    loadVendorList();
    lsVendorName.setWidth("150");
    lsVendorName.setHeight("75");
    hlSearchLayout = new GERPAddEditHLayout();
    assembleSearchLayout();
    hlSrchContainer.addComponent(GERPPanelGenerator.createPanel(hlSearchLayout));
    resetFields();
    loadSrchRslt();
    loadPurDtl();
    btnaddSpec.setStyleName("add");
    btnaddSpec.addClickListener(
        new ClickListener() {
          // Click Listener for Add and Update
          private static final long serialVersionUID = 6551953728534136363L;

          @Override
          public void buttonClick(ClickEvent event) {
            if (dtlValidation()) {
              saveEnqDtl();
            }
          }
        });
    btndelete.setEnabled(false);
    // ClickListener for Enquire Detail Tale
    tblSmsEnqDtl.addItemClickListener(
        new ItemClickListener() {
          private static final long serialVersionUID = 1L;

          @Override
          public void itemClick(ItemClickEvent event) {
            if (tblSmsEnqDtl.isSelected(event.getItemId())) {
              tblSmsEnqDtl.setImmediate(true);
              btnaddSpec.setCaption("Add");
              btnaddSpec.setStyleName("savebt");
              btndelete.setEnabled(false);
              enqDtlresetFields();
            } else {
              ((AbstractSelect) event.getSource()).select(event.getItemId());
              btnaddSpec.setCaption("Update");
              btnaddSpec.setStyleName("savebt");
              btndelete.setEnabled(true);
              editSmsPurDetail();
            }
          }
        });
    btndelete.addClickListener(
        new ClickListener() {
          // Click Listener for Add and Update
          private static final long serialVersionUID = 6551953728534136363L;

          @Override
          public void buttonClick(ClickEvent event) {
            if (btndelete == event.getButton()) {
              deleteDetails();
            }
          }
        });
  }