예제 #1
2
  protected boolean setDir(JTextField txf, String strValue) {
    String strTxt = txf.getText();
    String strName = txf.getName();
    boolean bSet = false;

    if ((strTxt == null || strTxt.trim().length() == 0 || strTxt.equals(INFOSTR))
        && strName.equalsIgnoreCase("value")) {
      if (timer != null) {
        timer.cancel();
        txf.setForeground(Color.black);
      }

      bSet = true;
      txf.setText(strValue);
      txf.grabFocus();
    }
    return bSet;
  }
 public void validacamposobrigatorio(Container container, String tabela) {
   conecta_oracle.executeSQL("select * from" + tabela + "where rownum = 1");
   Component components[] = container.getComponents();
   for (Component component : components) {
     if (component instanceof JTextField) {
       JTextField field = (JTextField) component;
       String nome = field.getName();
       String conteudo = field.getText();
       String text = field.getToolTipText();
       int chave = field.getColumns();
       try {
         int numcols = conecta_oracle.metaData.getColumnCount();
         for (int conta = 1; conta <= numcols; conta++) {
           String colsname = conecta_oracle.metaData.getColumnName(conta);
           int obrigatorio = conecta_oracle.metaData.isNullable(conta);
           if (conteudo.equals("") && obrigatorio == 0) {
             if (chave != 1) {
               JOptionPane.showMessageDialog(null, "Campo " + text + " Obrigatório");
               field.grabFocus();
               retorno = 1;
               return;
             }
           }
         }
       } catch (SQLException erro) {
         JOptionPane.showMessageDialog(null, erro);
       }
     }
   }
 }
 public void keyReleased(KeyEvent event) {
   JTextField tf = (JTextField) event.getSource();
   while (true) {
     if (tf.getName().equals("description")) {
       this.getTimer().setDescription(tf.getText());
       break;
     }
     if (tf.getName().equals("startDate")) {
       GregorianCalendar newDate = SerFormatter.getDateFromString(tf.getText(), "dd.MM.yy");
       timer.getMainTimer().setUnformattedStartDate(newDate);
       break;
     }
     if (tf.getName().equals("startTime")) {
       GregorianCalendar newDate = SerFormatter.getDateFromString(tf.getText(), "HH:mm");
       newDate.set(Calendar.SECOND, 0);
       timer.getMainTimer().setUnformattedStartTime(newDate);
       break;
     }
     if (tf.getName().equals("stopTime")) {
       GregorianCalendar newDate = SerFormatter.getDateFromString(tf.getText(), "HH:mm");
       newDate.set(Calendar.SECOND, 0);
       timer.getMainTimer().setUnformattedStopTime(newDate);
       break;
     }
     if (tf.getName().equals("jTextFieldFilePattern")) {
       this.getTimer().setFilePattern(tf.getText());
       break;
     }
     if (tf.getName().equals("jTextFieldDirPattern")) {
       this.getTimer().setDirPattern(tf.getText());
       break;
     }
     break;
   }
 }
예제 #4
0
  public static void getUserInfo(String path, String fileName, Object[] o) throws Exception {
    Map userMap = new HashMap();
    if (o.length > 0) {
      for (Object s : o) {
        JTextComponent f = (JTextComponent) s;
        if (!StringUtil.isEmptyString(f.getText().trim())) {
          if (f.getClass() == JTextField.class) {
            JTextField jtf = (JTextField) f;
            logger.debug("[key = " + jtf.getName() + ",value = " + jtf.getText().trim() + "]");
            userMap.put(jtf.getName(), jtf.getText().trim());
          }
          if (f.getClass() == JPasswordField.class) {
            JPasswordField jpf = (JPasswordField) f;
            logger.debug("[key = " + jpf.getName() + ",value = " + jpf.getText().trim() + "]");
            userMap.put(jpf.getName(), jpf.getText().trim());
          }
        }
      }
    }

    writeFile(userMap, path, fileName);
  }
예제 #5
0
 public static void setUserInfo(String path, String fileName, Object[] o)
     throws FileNotFoundException, Exception {
   if (!new File(path + fileName).exists()) {
     return;
   }
   ObjectInputStream in = new ObjectInputStream(new FileInputStream(path + fileName));
   Map userMap = (Map) in.readObject();
   in.close();
   if (o.length > 0)
     for (Object s : o) {
       JTextComponent f = (JTextComponent) s;
       if (f.getClass() == JTextField.class) {
         JTextField jtf = (JTextField) f;
         jtf.setText(
             userMap.get(jtf.getName()) == null ? "" : (String) userMap.get(jtf.getName()));
       }
       if (f.getClass() == JPasswordField.class) {
         JPasswordField jpf = (JPasswordField) f;
         jpf.setText(
             userMap.get(jpf.getName()) == null ? "" : (String) userMap.get(jpf.getName()));
       }
     }
 }
예제 #6
0
  public static List<Component> disableTextField(final Container c, String textfieldTujuan) {
    comp = c.getComponents();
    listComp = new ArrayList<Component>();
    for (Component co : comp) {
      listComp.add(co);
      if (isJTextField(co)) {
        JTextField field = (JTextField) co;
        if (field.getName().equalsIgnoreCase(textfieldTujuan)) {
          field.setEditable(false);
        }
      }

      if (co instanceof Container) {
        listComp.addAll(disableTextField((Container) c, textfieldTujuan));
      }
    }
    return null;
  }
 private void collectFieldValues() {
   params.clear();
   for (Object control : namedControls) {
     if (control instanceof JWFNumberField) {
       JWFNumberField numberField = (JWFNumberField) control;
       params.put(numberField.getName(), new ScriptParam(numberField.getDoubleValue()));
     } else if (control instanceof JTextField) {
       JTextField textField = (JTextField) control;
       params.put(textField.getName(), new ScriptParam(textField.getText()));
     } else if (control instanceof JComboBox) {
       JComboBox comboBox = (JComboBox) control;
       params.put(comboBox.getName(), new ScriptParam((String) comboBox.getSelectedItem()));
     } else if (control instanceof JCheckBox) {
       JCheckBox checkBox = (JCheckBox) control;
       params.put(checkBox.getName(), new ScriptParam(checkBox.isSelected()));
     } else {
       throw new IllegalStateException(control.getClass().getName());
     }
   }
 }
예제 #8
0
  private boolean validateFields() {
    String rname = nameField.getText();
    if (StringUtils.isEmpty(rname)) {
      error("Please enter a repository name!");
      return false;
    }

    // automatically convert backslashes to forward slashes
    rname = rname.replace('\\', '/');
    // Automatically replace // with /
    rname = rname.replace("//", "/");

    // prohibit folder paths
    if (rname.startsWith("/")) {
      error("Leading root folder references (/) are prohibited.");
      return false;
    }
    if (rname.startsWith("../")) {
      error("Relative folder references (../) are prohibited.");
      return false;
    }
    if (rname.contains("/../")) {
      error("Relative folder references (../) are prohibited.");
      return false;
    }

    // confirm valid characters in repository name
    Character c = StringUtils.findInvalidCharacter(rname);
    if (c != null) {
      error(MessageFormat.format("Illegal character ''{0}'' in repository name!", c));
      return false;
    }

    // verify repository name uniqueness on create
    if (isCreate) {
      // force repo names to lowercase
      // this means that repository name checking for rpc creation
      // is case-insensitive, regardless of the Gitblit server's
      // filesystem
      if (repositoryNames.contains(rname.toLowerCase())) {
        error(
            MessageFormat.format(
                "Can not create repository ''{0}'' because it already exists.", rname));
        return false;
      }
    } else {
      // check rename collision
      if (!repositoryName.equalsIgnoreCase(rname)) {
        if (repositoryNames.contains(rname.toLowerCase())) {
          error(
              MessageFormat.format(
                  "Failed to rename ''{0}'' because ''{1}'' already exists.",
                  repositoryName, rname));
          return false;
        }
      }
    }

    if (accessRestriction.getSelectedItem() == null) {
      error("Please select access restriction!");
      return false;
    }

    if (federationStrategy.getSelectedItem() == null) {
      error("Please select federation strategy!");
      return false;
    }

    repository.name = rname;
    repository.description = descriptionField.getText();
    repository.owner =
        ownerField.getSelectedItem() == null ? null : ownerField.getSelectedItem().toString();
    repository.HEAD =
        headRefField.getSelectedItem() == null ? null : headRefField.getSelectedItem().toString();
    repository.useTickets = useTickets.isSelected();
    repository.useDocs = useDocs.isSelected();
    repository.showRemoteBranches = showRemoteBranches.isSelected();
    repository.showReadme = showReadme.isSelected();
    repository.skipSizeCalculation = skipSizeCalculation.isSelected();
    repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();
    repository.isFrozen = isFrozen.isSelected();

    String ml = mailingListsField.getText();
    if (!StringUtils.isEmpty(ml)) {
      Set<String> list = new HashSet<String>();
      for (String address : ml.split("(,|\\s)")) {
        if (StringUtils.isEmpty(address)) {
          continue;
        }
        list.add(address.toLowerCase());
      }
      repository.mailingLists = new ArrayList<String>(list);
    }

    repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem();
    repository.federationStrategy = (FederationStrategy) federationStrategy.getSelectedItem();

    if (repository.federationStrategy.exceeds(FederationStrategy.EXCLUDE)) {
      repository.federationSets = setsPalette.getSelections();
    }

    repository.indexedBranches = indexedBranchesPalette.getSelections();
    repository.preReceiveScripts = preReceivePalette.getSelections();
    repository.postReceiveScripts = postReceivePalette.getSelections();

    // Custom Fields
    repository.customFields = new LinkedHashMap<String, String>();
    if (customTextfields != null) {
      for (JTextField field : customTextfields) {
        String key = field.getName();
        String value = field.getText();
        repository.customFields.put(key, value);
      }
    }
    return true;
  }