示例#1
0
 WebCheckBox getPropertyCheckbox(Property prop) {
   WebCheckBox option = new WebCheckBox();
   option.setAction(new ButtonAction(ButtonAction.Type.CHANGE_SETTINGS, prop));
   option.setText(prop.getName());
   option.setSelected(prop.getValue());
   return option;
 }
    AddUserDialog() {
      this.setTitle(Tr.tr("Add New Contact"));
      // this.setSize(400, 280);
      this.setResizable(false);
      this.setModal(true);

      GroupPanel groupPanel = new GroupPanel(10, false);
      groupPanel.setMargin(5);

      // editable fields
      WebPanel namePanel = new WebPanel();
      namePanel.setLayout(new BorderLayout(10, 5));
      namePanel.add(new WebLabel(Tr.tr("Display Name:")), BorderLayout.WEST);
      mNameField = new WebTextField();
      namePanel.add(mNameField, BorderLayout.CENTER);
      groupPanel.add(namePanel);
      groupPanel.add(new WebSeparator(true, true));

      mEncryptionBox = new WebCheckBox(Tr.tr("Encryption"));
      mEncryptionBox.setAnimated(false);
      mEncryptionBox.setSelected(true);
      groupPanel.add(mEncryptionBox);
      groupPanel.add(new WebSeparator(true, true));

      groupPanel.add(new WebLabel("JID:"));
      mJIDField = new WebTextField(38);
      groupPanel.add(mJIDField);
      groupPanel.add(new WebSeparator(true, true));

      this.add(groupPanel, BorderLayout.CENTER);

      // buttons
      WebButton cancelButton = new WebButton(Tr.tr("Cancel"));
      cancelButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              AddUserDialog.this.dispose();
            }
          });
      final WebButton saveButton = new WebButton(Tr.tr("Save"));
      saveButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              AddUserDialog.this.saveUser();
              AddUserDialog.this.dispose();
            }
          });

      GroupPanel buttonPanel = new GroupPanel(2, cancelButton, saveButton);
      buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
      this.add(buttonPanel, BorderLayout.SOUTH);

      this.pack();
    }
示例#3
0
  @SuppressWarnings({"serial", "unchecked"})
  private Component getForm() {

    calendar.addDateSelectionListener(this);

    cmbCrew = new WebComboBox();
    cmbCrew.setActionCommand("crewSelectedChanged");
    cmbCrew.addActionListener(this);
    chkOnPort = new WebCheckBox("on Port?");
    chkOnPort.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            getSchedule(currentDate);
          }
        });

    chkAutoSave = new WebCheckBox("Auto save on change date");

    chkAutoSave.setSelected(true);
    chkAutoSave.setEnabled(false);

    refreshData();
    bindData();

    GroupPanel leftPanel =
        new GroupPanel(
            false,
            new GroupPanel(10, cmbCrew, chkOnPort),
            new GroupPanel(10, false, calendar, chkAutoSave));

    timeSheet = new TimeSheet(20);
    timeSheet.setChangeListener(this);

    txtComments = new WebTextArea();
    txtComments.setLineWrap(true);
    txtComments.setWrapStyleWord(true);

    AbstractDocument pDoc = (AbstractDocument) txtComments.getDocument();
    pDoc.setDocumentFilter(new DocumentSizeFilter(45));

    WebScrollPane areaScroll = new WebScrollPane(txtComments);
    areaScroll.setPreferredSize(new Dimension(300, 50));

    WebTextArea txtNonConformities = new WebTextArea();
    txtNonConformities.setLineWrap(true);
    txtNonConformities.setWrapStyleWord(true);

    WebScrollPane ncScroll = new WebScrollPane(txtNonConformities);
    ncScroll.setPreferredSize(new Dimension(200, 150));

    cmbCommentList = new WebComboBox();
    cmbCommentList.addItem("Select quick comment ...");

    final QuickCommentDAO qCommentDao = new QuickCommentDAO();
    final List<QuickComment> qCommentsList = qCommentDao.getAll();

    for (QuickComment qComment : qCommentsList) {
      cmbCommentList.addItem(qComment);
    }

    cmbCommentList.addItem("...or add new quick comment");

    cmbCommentList.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (cmbCommentList.getSelectedIndex() == cmbCommentList.getItemCount() - 1) {
              Object value =
                  WebOptionPane.showInputDialog(
                      getOwner(),
                      "Add new quick comment:",
                      "Quick Comment",
                      JOptionPane.QUESTION_MESSAGE,
                      null,
                      null,
                      "");

              if (value != null && value.toString().trim().length() > 0) {
                txtComments.setText(value.toString());

                if (qCommentsList.size() > 0) {
                  boolean bFound = false;

                  for (int i = 0; i < qCommentsList.size(); i++) {
                    QuickComment q = qCommentsList.get(i);

                    if (q.getQuickComment().equalsIgnoreCase(value.toString()) == true) {
                      bFound = true;
                      break;
                    }
                  }

                  if (!bFound) {
                    qCommentDao.addQuickComment(value.toString());

                    QuickComment newQuickComment = new QuickComment();
                    newQuickComment.setQuickComment(value.toString());

                    qCommentsList.add(newQuickComment);

                    cmbCommentList.insertItemAt(newQuickComment, cmbCommentList.getItemCount() - 1);
                  }

                } else {
                  QuickComment newQuickComment = new QuickComment();
                  newQuickComment.setQuickComment(value.toString());

                  qCommentsList.add(newQuickComment);

                  cmbCommentList.insertItemAt(newQuickComment, cmbCommentList.getItemCount() - 2);
                }
              }
            } else if (cmbCommentList.getSelectedIndex() > 0) {
              txtComments.setText(cmbCommentList.getSelectedItem().toString());
            }
          }
        });

    lblNonConformities = new WebLabel();

    GroupPanel panelNonConformity =
        new GroupPanel(false, new WebLabel("Non-Conformities:"), lblNonConformities);

    GroupPanel rightPanel =
        new GroupPanel(
            false,
            new WebLabel("Resting Hours") {
              {
                setDrawShade(true);
              }
            },
            timeSheet.getView(),
            new GroupPanel(
                30,
                getGrid(),
                new GroupPanel(false, new WebLabel("Comments: "), areaScroll, cmbCommentList)),
            panelNonConformity);

    return new GroupPanel(GroupingType.fillLast, 20, leftPanel, rightPanel).setMargin(10);
  }