Exemplo n.º 1
0
  /**
   * Static Init
   *
   * @throws Exception
   */
  private void jbInit() throws Exception {
    Charset[] charsets = Ini.getAvailableCharsets();

    for (int i = 0; i < charsets.length; i++)
      fCharset.appendItem(charsets[i].displayName(), charsets[i]);

    bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
    bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo"));
    bFile.addEventListener(Events.ON_CLICK, this);

    fCharset.setMold("select");
    fCharset.setRows(0);
    fCharset.setTooltiptext(Msg.getMsg(Env.getCtx(), "Charset", false));

    info.setValue("   ");

    labelFormat.setValue(Msg.translate(Env.getCtx(), "AD_ImpFormat_ID"));

    pickFormat.setMold("select");
    pickFormat.setRows(0);

    bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next"));
    bNext.setLabel(">");
    bNext.addEventListener(Events.ON_CLICK, this);

    record.setValue("------");

    bPrevious.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous"));
    bPrevious.setLabel("<");
    bPrevious.addEventListener(Events.ON_CLICK, this);

    northPanel.appendChild(bFile);
    northPanel.appendChild(fCharset);
    northPanel.appendChild(info);
    northPanel.appendChild(labelFormat);
    northPanel.appendChild(pickFormat);
    northPanel.appendChild(bPrevious);
    northPanel.appendChild(record);
    northPanel.appendChild(bNext);

    rawData.setWidth("100%");
    rawData.setCols(80);
    rawData.setRows(MAX_SHOWN_LINES);
    rawData.setHeight("40%");

    previewPanel.setWidth("100%");
    previewPanel.setHeight("58%");
    previewPanel.setStyle("overflow: auto");

    centerPanel.setWidth("100%"); // Elaine 2008/11/07 - fix text area is not expanded in IE7
    centerPanel.setHeight("100%");
    centerPanel.appendChild(rawData);
    centerPanel.appendChild(new Separator());
    centerPanel.appendChild(previewPanel);

    confirmPanel.addActionListener(Events.ON_CLICK, this);
  }
Exemplo n.º 2
0
  /**
   * Apply Current Pattern
   *
   * @param next next
   */
  private void cmd_applyFormat(boolean next) {
    if (m_format == null || m_data.size() == 0) return;

    //	set position
    if (next) m_record++;
    else m_record--;

    if (m_record < 0) m_record = 0;
    else if (m_record >= m_data.size()) m_record = m_data.size() - 1;

    record.setValue(" " + String.valueOf(m_record + 1) + " ");

    //	Line Info

    String[] lInfo =
        m_format.parseLine(
            m_data.get(m_record).toString(), false, true, false); // 	no label, trace, no ignore

    int size = m_format.getRowCount();

    if (lInfo.length != size)
      log.log(Level.SEVERE, "FormatElements=" + size + " != Fields=" + lInfo.length);

    for (int i = 0; i < size; i++) {
      m_fields[i].setText(lInfo[i]);
      // m_fields[i].setCaretPosition(0);
    }
  } //	cmd_applyFormat
Exemplo n.º 3
0
  /** Reload/Load file */
  private void cmd_reloadFile() {
    if (m_file_istream == null) return;

    m_data.clear();
    rawData.setText("");

    try {
      //  see NaturalAccountMap

      ListItem listitem = fCharset.getSelectedItem();
      Charset charset = null;

      if (listitem == null) return;

      charset = (Charset) listitem.getValue();
      BufferedReader in = new BufferedReader(new InputStreamReader(m_file_istream, charset), 10240);

      //	not safe see p108 Network pgm
      String s = null;
      String concat = "";

      while ((s = in.readLine()) != null) {
        m_data.add(s);

        concat += s;
        concat += "\n";

        if (m_data.size() < MAX_LOADED_LINES) {
          rawData.setValue(concat);
        }
      }
      in.close();
    } catch (Exception e) {
      log.log(Level.SEVERE, "", e);
      bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
    }

    int index = 1; // 	second line as first may be heading

    if (m_data.size() == 1) index = 0;

    int length = 0;

    if (m_data.size() > 0) length = m_data.get(index).toString().length();

    info.setValue(
        Msg.getMsg(Env.getCtx(), "Records")
            + "="
            + m_data.size()
            + ", "
            + Msg.getMsg(Env.getCtx(), "Length")
            + "="
            + length
            + "   ");

    // setCursor (Cursor.getDefaultCursor());

    log.config("Records=" + m_data.size() + ", Length=" + length);
  } //	cmd_loadFile
Exemplo n.º 4
0
  /** Load Format */
  private void cmd_loadFormat() {
    //	clear panel
    previewPanel.getChildren().clear();

    ListItem listitem = pickFormat.getSelectedItem();

    String formatName = (String) listitem.getValue();

    if (formatName.equals(s_none)) return;

    m_format = ImpFormat.load(formatName);

    if (m_format == null) {
      FDialog.error(m_WindowNo, this, formatName);
      return;
    }

    //	pointers

    int size = m_format.getRowCount();
    m_labels = new Label[size];
    m_fields = new Textbox[size];

    for (int i = 0; i < size; i++) {
      ImpFormatRow row = m_format.getRow(i);

      m_labels[i] = new Label(row.getColumnName());

      Hbox hbox = new Hbox();
      hbox.setWidth("100%");
      hbox.setWidths("30%, 70%");
      hbox.setStyle("padding-bottom: 3px");

      hbox.appendChild(m_labels[i].rightAlign());

      int length = row.getEndNo() - row.getStartNo();

      if (length <= 5) length = 5;
      else if (length > 20) length = 20;

      m_fields[i] = new Textbox();
      m_fields[i].setStyle("margin-left: 2px");

      hbox.appendChild(m_fields[i]);

      previewPanel.appendChild(hbox);
    }
    m_record = -1;
    record.setValue("------");
    previewPanel.invalidate();
  } //	cmd_format
Exemplo n.º 5
0
  public void onEvent(Event e) throws Exception {
    if (m_setting) return;
    //	Update Assignment
    ListItem listItem = fResource.getSelectedItem();
    KeyNamePair resource =
        listItem != null
            ? new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel())
            : null;
    if (resource != null) {
      int S_Resource_ID = resource.getKey();
      m_mAssignment.setS_Resource_ID(S_Resource_ID);
    }

    Calendar date = new GregorianCalendar();
    getDateAndTimeFrom(date);

    Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
    if (assignDateFrom != null) m_mAssignment.setAssignDateFrom(assignDateFrom);
    if (fQty.getValue() != null) {
      BigDecimal qty = fQty.getValue();
      m_mAssignment.setQty(qty);
    }
    m_mAssignment.setName((String) fName.getValue());
    m_mAssignment.setDescription((String) fDescription.getValue());

    //	Resource - Look up UOM
    if (e.getTarget() == fResource) {
      Object o = m_lookup.get(fResource.getSelectedItem());
      if (o == null) lUOM.setValue(" ? ");
      else lUOM.setValue(o.toString());
    }

    //	Zoom - InfoResource
    else if (e.getTarget().getId().equals("Zoom")) {
      InfoSchedule is = new InfoSchedule(m_mAssignment, true);
      if (is.getMResourceAssignment() != null) {
        m_mAssignment = is.getMResourceAssignment();
        //	setDisplay();
        detach();
      }
      is = null;
    }

    //	cancel - return
    else if (e.getTarget().getId().equals("Cancel")) {
      m_cancel = true;
      detach();
    }

    //	delete - delete and return
    else if (e.getTarget().getId().equals("Delete")) {
      if (m_mAssignment.delete(true)) {
        m_mAssignment = null;
        detach();
      } else FDialog.error(0, this, "ResourceAssignmentNotDeleted");
    }

    //	OK - Save
    else if (e.getTarget().getId().equals("Ok")) {
      if (cmd_save()) detach();
    }
  }
Exemplo n.º 6
0
  public void addField(MBrowseField field, Row row, String name, String title) {
    GridFieldVO voBase =
        GridFieldVO.createStdField(field.getCtx(), p_WindowNo, 0, 0, 0, false, false, false);

    String uniqueName = field.getAD_View_Column().getColumnSQL();

    voBase.isProcess = true;
    voBase.IsDisplayed = true;
    voBase.IsReadOnly = false;
    voBase.IsUpdateable = true;
    voBase.WindowNo = p_WindowNo;

    voBase.AD_Column_ID = field.getAD_View_Column().getAD_Column_ID();
    voBase.AD_Table_ID = field.getAD_View_Column().getAD_Column().getAD_Table_ID();
    voBase.ColumnName = field.getAD_View_Column().getAD_Column().getColumnName();
    voBase.displayType = field.getAD_Reference_ID();
    voBase.AD_Reference_Value_ID = field.getAD_Reference_Value_ID();
    voBase.IsMandatory = field.isMandatory();
    voBase.IsAlwaysUpdateable = false;
    voBase.IsKey = field.isKey();

    voBase.DefaultValue = field.getDefaultValue();
    voBase.DefaultValue2 = field.getDefaultValue2();
    voBase.InfoFactoryClass = field.getInfoFactoryClass();
    voBase.FieldLength = field.getFieldLength();
    voBase.ReadOnlyLogic = field.getReadOnlyLogic();
    voBase.DisplayLogic = field.getDisplayLogic();
    voBase.VFormat = field.getVFormat();
    voBase.ValueMin = field.getValueMin();
    voBase.ValueMax = field.getValueMax();
    voBase.ValidationCode = field.getAD_Val_Rule().getCode();

    voBase.isRange = field.isRange();
    voBase.Description = field.getDescription();
    voBase.Help = uniqueName;
    voBase.Header = title;

    GridField gField = new GridField(GridFieldVO.createParameter(voBase));
    GridField gField2 = null;

    WEditor editor = WebEditorFactory.getEditor(gField, false);
    editor.setReadWrite(true);
    editor.addValueChangeListener(this);
    editor.dynamicDisplay();
    gField.addPropertyChangeListener(editor);

    Object defaultObject = null;
    Object defaultObject2 = null;

    //  Set Default
    if (field.getAD_View_Column().getAD_Column_ID() > 0) {
      defaultObject = gField.getDefault();
      if (defaultObject != null && field.getDefaultValue() != null) {
        gField.setValue(defaultObject, true);
        editor.setValue(defaultObject);
      }
    }

    gField.lookupLoadComplete();
    m_mFields.add(gField);
    m_wEditors.add(editor);

    if (DisplayType.YesNo != field.getAD_Reference_ID()) {
      Div div = new Div();
      div.setAlign("right");
      org.adempiere.webui.component.Label label = editor.getLabel();
      label.setValue(title);
      div.appendChild(label);
      if (label.getDecorator() != null) div.appendChild(label.getDecorator());
      row.appendChild(div);
    }
    row.appendChild(editor.getComponent());
    setParameter(name, editor);

    if (field.isRange()) {
      title = Msg.getMsg(Env.getCtx(), "To");
      name = name + "_To";
      voBase.Header = title;
      voBase.DefaultValue = field.getDefaultValue2();
      gField2 = new GridField(GridFieldVO.createParameter(voBase));
      gField2.lookupLoadComplete();

      WEditor editor2 = WebEditorFactory.getEditor(gField2, false);
      editor2.setReadWrite(true);
      editor2.addValueChangeListener(this);
      editor2.dynamicDisplay();
      //  Set Default
      if (field.getAD_View_Column().getAD_Column_ID() > 0) {
        defaultObject2 = gField2.getDefault();
        if (defaultObject2 != null && field.getDefaultValue2() != null) {
          gField2.setValue(defaultObject2, true);
          editor2.setValue(defaultObject2);
        }
      }
      m_mFields2.add(gField2);
      m_wEditors2.add(editor2);

      Div div = new Div();
      div.setAlign("right");
      org.adempiere.webui.component.Label label = editor2.getLabel();
      label.setValue(title);
      div.appendChild(label);
      if (label.getDecorator() != null) div.appendChild(label.getDecorator());
      row.appendChild(div);

      row.appendChild(editor2.getComponent());
      setParameter(name, editor2);
    } else {
      m_mFields2.add(null);
      m_wEditors2.add(null);
    }

    if (gField != null) processNewValue(defaultObject, gField.getVO().Help);
    if (gField2 != null) processNewValue(defaultObject2, gField2.getVO().Help);
  }