Ejemplo n.º 1
0
 public SaveHandler(
     EditSoftwarePackageDialog dialogPointer, GwtSoftwarePackage newSoftwarePackage) {
   super();
   this.dialog = dialogPointer;
   this.localSoftwarePackage = new GwtSoftwarePackage();
   this.localSoftwarePackage.setId(newSoftwarePackage.getId());
   this.localSoftwarePackage.setName(newSoftwarePackage.getName());
   currentSoftwarePackage = newSoftwarePackage.getName();
   this.localSoftwarePackage.setDescription(newSoftwarePackage.getDescription());
 }
Ejemplo n.º 2
0
    public void onClick(ClickEvent event) {
      List<GwtSoftwarePackage> list = listOfSoftwarePackages;
      this.dialog.hide();

      localSoftwarePackage.setName(
          SquareUtil.firstCharacterToUpperCase(SoftwarePackageTextBox.getText().trim()));
      localSoftwarePackage.setDescription(
          SquareUtil.firstCharacterToUpperCase(SoftwarePackageDefinitionTextBox.getText().trim()));

      if (!currentSoftwarePackage.trim().equalsIgnoreCase(localSoftwarePackage.getName())) {
        for (int i = 0; i < list.size(); i++) {
          if (SoftwarePackageTextBox.getText().equalsIgnoreCase(list.get(i).getName())) {

            Window.alert(messages.createSoftwarePackageDialogBoxAlreadyExist());
            return;
          }
        }
      }
      updateSoftwarePackageCommand.updateCommand(this.localSoftwarePackage);
    }
Ejemplo n.º 3
0
  /**
   * Sets up the controls in the dialog
   *
   * @param SoftwarePackage The category to be updated in this dialog.
   */
  private void initializeDialog(GwtSoftwarePackage SoftwarePackage) {

    VerticalPanel baseLayout = new VerticalPanel();
    VerticalPanel nameLayout = new VerticalPanel();
    VerticalPanel descriptionLayout = new VerticalPanel();
    HorizontalPanel buttonsLayout = new HorizontalPanel();
    this.setText(messages.editSoftwarePackageDialogBoxTitle());
    nameLayout.add(new Label(messages.createSoftwarePackageDialogBoxName()));
    nameLayout.add(this.SoftwarePackageTextBox);
    nameLayout.add(new Label(messages.createSoftwarePackageDialogBoxDefinition()));
    nameLayout.add(this.SoftwarePackageDefinitionTextBox);

    this.SoftwarePackageTextBox.setWidth("500px");
    this.SoftwarePackageTextBox.setText(SoftwarePackage.getName());
    this.SoftwarePackageDefinitionTextBox.setWidth("500px");
    this.SoftwarePackageDefinitionTextBox.setSize("500px", "80px");
    this.SoftwarePackageDefinitionTextBox.setText(SoftwarePackage.getDescription());

    // Set up the buttons
    saveButton =
        new Button(
            messages.createSoftwarePackageDialogBoxSave(), new SaveHandler(this, SoftwarePackage));
    Button cancelButton =
        new Button(messages.createSoftwarePackageDialogBoxCancel(), new CancelHandler(this));
    Button deleteButton =
        new Button(messages.createSoftwarePackageDialogBoxDelete(), new DeleteHandler(this));
    this.SoftwarePackageTextBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            configureButton();
          }
        });

    this.SoftwarePackageTextBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            configureButton();
          }
        });

    this.SoftwarePackageTextBox.addKeyDownHandler(
        new KeyDownHandler() {
          public void onKeyDown(KeyDownEvent event) {
            configureButton();
          }
        });

    this.SoftwarePackageDefinitionTextBox.addKeyUpHandler(
        new KeyUpHandler() {
          public void onKeyUp(KeyUpEvent event) {
            configureButton();
          }
        });

    this.SoftwarePackageDefinitionTextBox.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            configureButton();
          }
        });

    this.SoftwarePackageDefinitionTextBox.addKeyDownHandler(
        new KeyDownHandler() {
          public void onKeyDown(KeyDownEvent event) {
            configureButton();
          }
        });

    saveButton.setWidth("100px");
    cancelButton.setWidth("100px");
    deleteButton.setWidth("100px");

    buttonsLayout.setSpacing(10);
    buttonsLayout.add(saveButton);
    buttonsLayout.add(cancelButton);
    buttonsLayout.add(deleteButton);

    // set the base layout
    baseLayout.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    baseLayout.add(nameLayout);
    baseLayout.add(descriptionLayout);
    baseLayout.add(buttonsLayout);
    baseLayout.setSpacing(5);

    this.setWidget(baseLayout);
  }