Beispiel #1
0
 /** @return 01092010 */
 public static String getDateNumeric() {
   String year = getYear();
   String month = getMonth();
   String day = getDayOfMonth();
   String dn = year + month + day;
   if (mpv5.db.objects.User.getCurrentUser().getProperties().getProperty("item.date.locale")
       == null)
     mpv5.db.objects.User.getCurrentUser()
         .getProperties()
         .changeProperty("item.date.locale", Locale.getDefault().toString());
   try {
     Locale l =
         TypeConversion.stringToLocale(
             mpv5.db.objects.User.getCurrentUser()
                 .getProperties()
                 .getProperty("item.date.locale"));
     if (l.equals(Locale.GERMAN) || l.equals(Locale.GERMANY)) {
       dn = day + month + year;
     }
   } catch (Exception e) {
     Log.Debug(e);
   } finally {
     return dn;
   }
 }
 private void setSettings() {
   HashMap<String, String> m = PanelUtils.getSubComponentValues(jPanel3);
   Iterator<Entry<String, String>> i = m.entrySet().iterator();
   while (i.hasNext()) {
     Entry<String, String> it = i.next();
     User.getCurrentUser().setProperty("companyinfo." + it.getKey(), it.getValue());
   }
 }
  /**
   * Creates a hash map view to all the object's form fields and their values, including their
   * referenced objects resolved to keys and values.<br>
   * This method is safe to never return null values.
   *
   * @param identifier or NULL
   * @return A HashMap<key,value/>
   */
  public synchronized Map<String, Object> getFormattedFormFields(final String identifier) {
    Map<String, Object> map = getFormFields();
    TreeMap<String, Object> maps = new TreeMap<String, Object>();

    for (Iterator<String> it = map.keySet().iterator(); it.hasNext(); ) {
      String key = it.next();
      Object o = map.get(key);

      String skey = null;
      if (identifier == null) {
        skey = obj.getType() + "." + key;
      } else {
        skey = identifier + "." + key;
      }

      if (o == null || String.valueOf(o).equals("null")) {
        maps.put(skey, "");
      } else if (o instanceof DatabaseObject && !(o instanceof Group)) {
        maps.putAll(
            new FormFieldsHandler((DatabaseObject) o)
                .getFormattedFormFields(obj.getType() + "." + key));
      } else if (o instanceof Boolean) {
        maps.put(skey, TypeConversion.booleanToString((Boolean) o));
      } else if (o instanceof Double || o.getClass() == double.class) {
        maps.put(skey, FormatNumber.formatDezimal((Double) o));
      } else if (o instanceof Date) {
        maps.put(skey, DateConverter.getDefDateString((Date) o));
      } else {
        maps.put(skey, o);
      }
    }
    List<String[]> mapi =
        User.getCurrentUser().getProperties().getProperties("companyinfo.").getList();
    for (int i = 0; i < mapi.size(); i++) {
      String[] strings = mapi.get(i);
      if (strings[1] != null) {
        maps.put(
            "companyinfo." + strings[0],
            strings[1].contains("[") ? VariablesHandler.parse(strings[1], obj) : strings[1]);
      }
    }

    return maps;
  }
 public ControlPanel_Company() {
   initComponents();
   setValues(User.getCurrentUser().getProperties().getProperties("companyinfo."));
   setVisible(true);
 }
  private void jButton1ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton1ActionPerformed

    setSettings();
    User.getCurrentUser().saveProperties();
  } // GEN-LAST:event_jButton1ActionPerformed
  /**
   * @param target
   * @param identifier
   * @param passive
   */
  public TableViewPersistenceHandler(
      final MPTable target, final Component identifier, final boolean passive) {
    if (User.getCurrentUser().__getCname() == null
        || User.getCurrentUser().__getCname().length() == 0) {
      throw new IllegalStateException("The username is not set.");
    }
    if (target.getName() == null || target.getName().length() == 0) {
      throw new IllegalStateException("The table name is not set.");
    }
    if (identifier == null) {
      throw new IllegalStateException("The identifier is not set: " + identifier);
    }
    if (identifier.getName() == null || identifier.getName().length() == 0) {
      throw new IllegalStateException("The identifier name is not set: " + identifier);
    }

    saveFile =
        User.getCurrentUser().__getCname()
            + "_"
            + target.getName()
            + "_"
            + identifier.getName()
            + ".xml";
    mListener =
        new MouseAdapter() {

          @Override
          public void mouseReleased(MouseEvent evt) {
            persist();
          }
        };
    wListener =
        new PropertyChangeListener() {

          public void propertyChange(PropertyChangeEvent evt) {
            //                if (evt.getPropertyName().equals("model")) {
            //                    // Log.Debug(this, evt);
            //                    setObserveColumnState(true);
            //                }
            //
            ////                Log.Debug(this, evt.getPropertyName());
            //
            //                if (!passive && isObserveColumnState() &&
            // evt.getPropertyName().equals("preferredWidth")) {
            //                    // Log.Debug(this, evt);
            //                    persist();
            //                }
          }
        };
    cListener =
        new TableColumnModelListener() {

          public void columnAdded(TableColumnModelEvent e) {}

          public void columnRemoved(TableColumnModelEvent e) {}

          public void columnMoved(TableColumnModelEvent e) {}

          public void columnMarginChanged(ChangeEvent e) {}

          public void columnSelectionChanged(ListSelectionEvent e) {}
        };
    this.target = target;
    this.identifier = identifier;

    //        target.setColumnModel(new MPColumnModel());
    //
    //        try {
    //            restore();
    //        } catch (IOException ex) {
    //            Log.Debug(ex);
    //            persist();
    //        }
    //
    set();
  }