Search in sources :

Example 1 with GridFieldVO

use of org.compiere.model.GridFieldVO in project adempiere by adempiere.

the class VAccountDialog method initAccount.

//	jbInit
/**
	 *	Dyanmic Init.
	 *  When a row is selected, the editor values are set
	 *  (editors do not change grid)
	 *  @return true if initialized
	 */
private boolean initAccount() {
    m_AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID");
    //	Get AcctSchema Info
    if (s_AcctSchema == null || s_AcctSchema.getC_AcctSchema_ID() != m_C_AcctSchema_ID)
        s_AcctSchema = new MAcctSchema(Env.getCtx(), m_C_AcctSchema_ID, null);
    log.config(s_AcctSchema.toString() + ", #" + s_AcctSchema.getAcctSchemaElements().length);
    Env.setContext(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", m_C_AcctSchema_ID);
    //  Model
    //	Maintain Account Combinations 
    int AD_Window_ID = 153;
    GridWindowVO wVO = AEnv.getMWindowVO(m_WindowNo, AD_Window_ID, 0);
    if (wVO == null)
        return false;
    m_mWindow = new GridWindow(wVO);
    m_mTab = m_mWindow.getTab(0);
    // Make sure is the tab is loaded - teo_sarca [ 1659124 ]
    if (!m_mTab.isLoadComplete())
        m_mWindow.initTab(0);
    //  ParameterPanel restrictions
    m_mTab.getField("Alias").setDisplayLength(15);
    m_mTab.getField("Combination").setDisplayLength(15);
    //  Grid restrictions
    m_mTab.getField("AD_Client_ID").setDisplayed(false);
    m_mTab.getField("C_AcctSchema_ID").setDisplayed(false);
    m_mTab.getField("IsActive").setDisplayed(false);
    m_mTab.getField("IsFullyQualified").setDisplayed(false);
    //  don't show fields not being displayed in this environment
    for (int i = 0; i < m_mTab.getFieldCount(); i++) {
        GridField field = m_mTab.getField(i);
        if (//  check context
        !field.isDisplayed(true))
            field.setDisplayed(false);
    }
    //  GridController
    m_gridController = new GridController();
    m_gridController.initGrid(m_mTab, true, m_WindowNo, null, null);
    m_gridController.setPreferredSize(new Dimension(300, 100));
    panel.add(m_gridController, BorderLayout.CENTER);
    //  Prepare Parameter
    m_gbc.anchor = GridBagConstraints.NORTHWEST;
    //	line
    m_gbc.gridy = 0;
    m_gbc.gridx = 0;
    m_gbc.gridwidth = 1;
    m_gbc.insets = m_fieldInsets;
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    m_gbc.weightx = 0;
    m_gbc.weighty = 0;
    int TabNo = 0;
    //	Alias
    if (s_AcctSchema.isHasAlias()) {
        GridField alias = m_mTab.getField("Alias");
        f_Alias = VEditorFactory.getEditor(m_mTab, alias, false);
        addLine(alias, f_Alias, false);
    }
    //	Alias
    //	Combination
    GridField combination = m_mTab.getField("Combination");
    f_Combination = VEditorFactory.getEditor(m_mTab, combination, false);
    addLine(combination, f_Combination, false);
    m_newRow = true;
    /**
		 *	Create Fields in Element Order
		 */
    MAcctSchemaElement[] elements = s_AcctSchema.getAcctSchemaElements();
    for (int i = 0; i < elements.length; i++) {
        MAcctSchemaElement ase = elements[i];
        String type = ase.getElementType();
        boolean isMandatory = ase.isMandatory();
        //
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Organization)) {
            GridField field = m_mTab.getField("AD_Org_ID");
            f_AD_Org_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_AD_Org_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Account)) {
            GridField field = m_mTab.getField("Account_ID");
            f_Account_ID = VEditorFactory.getEditor(m_mTab, field, false);
            //	((VLookup)f_Account_ID).setWidth(400);
            addLine(field, f_Account_ID, isMandatory);
            f_Account_ID.addVetoableChangeListener(this);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) {
            GridField field = m_mTab.getField("C_SubAcct_ID");
            f_SubAcct_ID = VEditorFactory.getEditor(m_mTab, field, false);
            //	((VLookup)f_SubAcct_ID).setWidth(400);
            addLine(field, f_SubAcct_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Product)) {
            GridField field = m_mTab.getField("M_Product_ID");
            f_M_Product_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_M_Product_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_BPartner)) {
            GridField field = m_mTab.getField("C_BPartner_ID");
            f_C_BPartner_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_BPartner_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Campaign)) {
            GridField field = m_mTab.getField("C_Campaign_ID");
            f_C_Campaign_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_Campaign_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom)) {
            GridField field = m_mTab.getField("C_LocFrom_ID");
            f_C_LocFrom_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_LocFrom_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo)) {
            GridField field = m_mTab.getField("C_LocTo_ID");
            f_C_LocTo_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_LocTo_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Project)) {
            GridField field = m_mTab.getField("C_Project_ID");
            f_C_Project_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_Project_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion)) {
            GridField field = m_mTab.getField("C_SalesRegion_ID");
            f_C_SalesRegion_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_SalesRegion_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx)) {
            GridField field = m_mTab.getField("AD_OrgTrx_ID");
            f_AD_OrgTrx_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_AD_OrgTrx_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_Activity)) {
            GridField field = m_mTab.getField("C_Activity_ID");
            f_C_Activity_ID = VEditorFactory.getEditor(m_mTab, field, false);
            addLine(field, f_C_Activity_ID, isMandatory);
        } else //	User1
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList1)) {
            GridField field = m_mTab.getField("User1_ID");
            f_User1_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User1_ID.getField().getVO();
            newFieldVO.Header = f_User1_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User1_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList2)) {
            GridField field = m_mTab.getField("User2_ID");
            f_User2_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User2_ID.getField().getVO();
            newFieldVO.Header = f_User2_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User2_ID, isMandatory);
        } else //	User3
        if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList3)) {
            GridField field = m_mTab.getField("User3_ID");
            f_User3_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User3_ID.getField().getVO();
            newFieldVO.Header = f_User3_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User3_ID, isMandatory);
        } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_UserList4)) {
            GridField field = m_mTab.getField("User4_ID");
            f_User4_ID = VEditorFactory.getEditor(m_mTab, field, false);
            GridFieldVO newFieldVO = f_User4_ID.getField().getVO();
            newFieldVO.Header = f_User4_ID.getName();
            field = new GridField(newFieldVO);
            addLine(field, f_User4_ID, isMandatory);
        }
    }
    //	Create Fields in Element Order
    //	Add description
    m_newRow = true;
    m_gbc.gridy = m_line++;
    m_gbc.gridx = 0;
    m_gbc.gridwidth = 4;
    // 	top,left,bottom,right
    m_gbc.insets = new Insets(5, 15, 2, 0);
    m_gbc.fill = GridBagConstraints.HORIZONTAL;
    f_Description.setFont(f_Description.getFont().deriveFont(Font.ITALIC));
    parameterPanel.add(f_Description, m_gbc);
    //	Finish
    m_query = new MQuery();
    m_query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
    m_query.addRestriction("IsFullyQualified", MQuery.EQUAL, "Y");
    if (m_mAccount.C_ValidCombination_ID == 0)
        m_mTab.setQuery(MQuery.getEqualQuery("1", "2"));
    else {
        MQuery query = new MQuery();
        query.addRestriction("C_AcctSchema_ID", MQuery.EQUAL, m_C_AcctSchema_ID);
        query.addRestriction("C_ValidCombination_ID", MQuery.EQUAL, m_mAccount.C_ValidCombination_ID);
        m_mTab.setQuery(query);
    }
    m_mTab.query(false);
    m_gridController.getTable().addMouseListener(new VAccountDialog_mouseAdapter(this));
    m_gridController.addDataStatusListener(this);
    statusBar.setStatusLine(s_AcctSchema.toString());
    statusBar.setStatusDB("?");
    //	Initial value
    if (m_mAccount.C_ValidCombination_ID != 0)
        m_mTab.navigate(0);
    log.config("fini");
    return true;
}
Also used : Insets(java.awt.Insets) GridWindow(org.compiere.model.GridWindow) GridFieldVO(org.compiere.model.GridFieldVO) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) Dimension(java.awt.Dimension) MAcctSchema(org.compiere.model.MAcctSchema) GridWindowVO(org.compiere.model.GridWindowVO) GridController(org.compiere.grid.GridController) MAcctSchemaElement(org.compiere.model.MAcctSchemaElement)

Example 2 with GridFieldVO

use of org.compiere.model.GridFieldVO in project adempiere by adempiere.

the class ADServiceImpl method fillTab.

private void fillTab(Tab t, GridTabVO to) {
    t.setADColumnID(to.AD_Column_ID);
    t.setADColumnSortOrderID(to.AD_ColumnSortOrder_ID);
    t.setADImageID(to.AD_Image_ID);
    t.setADProcessID(to.AD_Process_ID);
    t.setADTabID(to.AD_Tab_ID);
    t.setADTableID(to.AD_Table_ID);
    t.setADWindowID(to.AD_Window_ID);
    t.setDescription(to.Description);
    t.setName(to.Name);
    t.setIsSingleRow(to.IsSingleRow);
    t.setCommitWarning(to.CommitWarning);
    t.setHasTree(to.HasTree);
    t.setDisplayLogic(to.DisplayLogic);
    t.setHelp(to.Help);
    t.setIncludedTabID(to.Included_Tab_ID);
    t.setIsDeleteable(to.IsDeleteable);
    t.setIsHighVolume(to.IsHighVolume);
    t.setIsInsertRecord(to.IsInsertRecord);
    t.setIsReadOnly(to.IsReadOnly);
    t.setIsSecurityEnabled(to.IsSecurityEnabled);
    t.setIsSingleRow(to.IsSingleRow);
    t.setIsSortTab(to.IsSortTab);
    //t.setIsSoTrx( to.)
    t.setIsView(to.IsView);
    t.setReadOnlyLogic(to.ReadOnlyLogic);
    t.setTableName(to.TableName);
    t.setTabLevel(to.TabLevel);
    // ADEMPIERE/COMPIERE
    // adempiere
    ArrayList<GridFieldVO> Fields = to.getFields();
    if (Fields != null) {
        FieldList fl = t.addNewFields();
        for (int i = 0; i < Fields.size(); i++) {
            fillField(fl.addNewField(), (GridFieldVO) Fields.get(i));
        }
    }
}
Also used : GridFieldVO(org.compiere.model.GridFieldVO) FieldList(pl.x3E.adInterface.FieldList)

Example 3 with GridFieldVO

use of org.compiere.model.GridFieldVO in project adempiere by adempiere.

the class MBrowseField method createGridFieldVO.

/**
	 *
	 * @param field
	 * @param windowNo
	 */
public static GridField createGridFieldVO(MBrowseField field, int windowNo) {
    GridFieldVO valueObject = GridFieldVO.createStdField(field.getCtx(), windowNo, 0, 0, 0, false, false, false);
    //	
    String uniqueName = field.getAD_View_Column().getColumnName();
    valueObject.isProcess = true;
    valueObject.IsDisplayed = field.isDisplayed();
    valueObject.IsReadOnly = field.isReadOnly();
    valueObject.IsUpdateable = true;
    valueObject.WindowNo = windowNo;
    //	BR [ 318 ]
    if (field.getAD_View_Column().getAD_Column_ID() > 0) {
        valueObject.ColumnName = field.getAD_View_Column().getAD_Column().getColumnName();
        valueObject.AD_Column_ID = field.getAD_View_Column().getAD_Column_ID();
        valueObject.AD_Table_ID = field.getAD_View_Column().getAD_Column().getAD_Table_ID();
    } else {
        valueObject.ColumnName = field.getAD_View_Column().getColumnSQL();
    }
    //	Add Alias
    //	BR [ 340 ]
    valueObject.ColumnNameAlias = CONTEXT_TABLE_PREFIX + uniqueName;
    //	
    valueObject.displayType = field.getAD_Reference_ID();
    valueObject.AD_Reference_Value_ID = field.getAD_Reference_Value_ID();
    valueObject.IsMandatory = field.isMandatory();
    valueObject.IsAlwaysUpdateable = false;
    valueObject.IsKey = field.isKey();
    valueObject.DefaultValue = field.getDefaultValue();
    valueObject.DefaultValue2 = field.getDefaultValue2();
    valueObject.InfoFactoryClass = field.getInfoFactoryClass();
    valueObject.FieldLength = field.getFieldLength();
    valueObject.ReadOnlyLogic = field.getReadOnlyLogic();
    valueObject.DisplayLogic = field.getDisplayLogic();
    valueObject.VFormat = field.getVFormat();
    valueObject.ValueMin = field.getValueMin();
    valueObject.ValueMax = field.getValueMax();
    valueObject.ValidationCode = field.getAD_Val_Rule().getCode();
    valueObject.IsRange = field.isRange();
    try {
        valueObject.Description = field.getDescription();
    } catch (IllegalArgumentException e) {
        valueObject.Description = (String) field.get_Value("Description");
    }
    if (field.getAD_View_Column().getAD_Column_ID() <= 0 && field.isReadOnly())
        valueObject.ColumnSQL = uniqueName;
    valueObject.Help = uniqueName;
    try {
        valueObject.Header = field.getName();
    } catch (IllegalArgumentException e) {
        valueObject.Header = (String) field.get_Value("Name");
        ;
    }
    valueObject.Callout = field.getCallout();
    valueObject.initFinish();
    GridField gridField = new GridField(valueObject);
    if (gridField.isLookup())
        gridField.lookupLoadComplete();
    if (!gridField.isReadOnly()) {
        Object defaultObject = gridField.getDefault();
        gridField.setValue(defaultObject, true);
    }
    return gridField;
}
Also used : GridFieldVO(org.compiere.model.GridFieldVO) GridField(org.compiere.model.GridField)

Example 4 with GridFieldVO

use of org.compiere.model.GridFieldVO in project adempiere by adempiere.

the class Browser method setParameters.

/**
	 * FR [ 245 ]
	 * Set Parameters
	 */
public void setParameters() {
    parametersValues = new ArrayList<Object>();
    parameters = new ArrayList<Object>();
    m_parameters_field = new ArrayList<GridFieldVO>();
    boolean onRange = false;
    for (Entry<String, GridField> entry : getPanelParameters().entrySet()) {
        GridField editor = (GridField) entry.getValue();
        GridFieldVO field = editor.getVO();
        if (!onRange) {
            if (editor.getValue() != null && !editor.getValue().toString().isEmpty() && !field.IsRange) {
                parameters.add(field.ColumnNameAlias);
                parametersValues.add(editor.getValue());
                m_parameters_field.add(field);
            } else if (editor.getValue() != null && !editor.getValue().toString().isEmpty() && field.IsRange) {
                parameters.add(field.ColumnNameAlias);
                parametersValues.add(editor.getValue());
                m_parameters_field.add(field);
                onRange = true;
            } else
                continue;
        } else if (editor.getValue() != null && !editor.getValue().toString().isEmpty()) {
            parameters.add(field.ColumnNameAlias);
            parametersValues.add(editor.getValue());
            m_parameters_field.add(field);
            onRange = false;
        }
    }
}
Also used : GridFieldVO(org.compiere.model.GridFieldVO) GridField(org.compiere.model.GridField)

Example 5 with GridFieldVO

use of org.compiere.model.GridFieldVO in project adempiere by adempiere.

the class SmallViewController method createVO.

//	createField
/**
	 * Create GridFieldVO from a MBrowseField field
	 * @param field the MBrowseField
	 * @param isTo true if the MBrowseField represents the "To" part of a range
	 * @param windowNo - the window number that will be used in the context
	 * @return GridFieldVO used to establish a GridField field.
	 */
private GridFieldVO createVO(MBrowseField field, boolean isTo, int windowNo) {
    //  Create Field
    GridFieldVO voBase = GridFieldVO.createStdField(field.getCtx(), windowNo, 0, 0, 0, false, false, false);
    String uniqueName = field.getAD_View_Column().getColumnName() + (isTo ? "_To" : "");
    voBase.isProcess = true;
    voBase.IsDisplayed = true;
    voBase.IsReadOnly = false;
    voBase.IsUpdateable = true;
    voBase.WindowNo = windowNo;
    M_Element element = (M_Element) field.getAD_Element();
    voBase.ColumnName = element.getColumnName();
    //	FR [ 344 ]
    voBase.ColumnSQL = field.getAD_View_Column().getColumnSQL();
    //	BR [ 318 ]
    if (field.getAD_View_Column().getAD_Column_ID() > 0) {
        voBase.AD_Column_ID = field.getAD_View_Column().getAD_Column_ID();
        voBase.AD_Table_ID = field.getAD_View_Column().getAD_Column().getAD_Table_ID();
    }
    //	Set unique alias
    voBase.ColumnNameAlias = uniqueName;
    voBase.displayType = field.getAD_Reference_ID();
    voBase.AD_Reference_Value_ID = field.getAD_Reference_Value_ID();
    voBase.IsMandatory = field.isMandatory();
    voBase.IsAlwaysUpdateable = true;
    voBase.IsKey = field.isKey();
    voBase.DefaultValue = isTo ? field.getDefaultValue2() : 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();
    //	FR [ 349 ]
    voBase.IsRange = field.isRange();
    voBase.Description = field.getDescription();
    voBase.Help = field.getHelp();
    voBase.Header = isTo ? Msg.getMsg(Env.getCtx(), "To") : field.getName();
    voBase.IsColumnSQLReference = true;
    voBase.initFinish();
    //	Return 
    return voBase;
}
Also used : GridFieldVO(org.compiere.model.GridFieldVO) M_Element(org.compiere.model.M_Element)

Aggregations

GridFieldVO (org.compiere.model.GridFieldVO)12 GridField (org.compiere.model.GridField)10 Properties (java.util.Properties)2 MLocatorLookup (org.compiere.model.MLocatorLookup)2 MLookup (org.compiere.model.MLookup)2 Language (org.compiere.util.Language)2 Dimension (java.awt.Dimension)1 Insets (java.awt.Insets)1 WLocatorEditor (org.adempiere.webui.editor.WLocatorEditor)1 WPAttributeEditor (org.adempiere.webui.editor.WPAttributeEditor)1 WSearchEditor (org.adempiere.webui.editor.WSearchEditor)1 GridController (org.compiere.grid.GridController)1 VLocator (org.compiere.grid.ed.VLocator)1 VLookup (org.compiere.grid.ed.VLookup)1 VPAttribute (org.compiere.grid.ed.VPAttribute)1 GridWindow (org.compiere.model.GridWindow)1 GridWindowVO (org.compiere.model.GridWindowVO)1 MAcctSchema (org.compiere.model.MAcctSchema)1 MAcctSchemaElement (org.compiere.model.MAcctSchemaElement)1 MPAttributeLookup (org.compiere.model.MPAttributeLookup)1