Search in sources :

Example 1 with MWindow

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

the class WindowCopy method doIt.

//	prepare
/**
	 * 	Process
	 *	@return message
	 *	@throws Exception
	 */
protected String doIt() throws Exception {
    log.info("doIt - To AD_Window_ID=" + p_AD_WindowTo_ID + ", From=" + p_AD_WindowFrom_ID);
    MWindow from = new MWindow(getCtx(), p_AD_WindowFrom_ID, get_TrxName());
    if (from.get_ID() == 0)
        throw new AdempiereUserError("@NotFound@ (from->) @AD_Window_ID@");
    MWindow to = new MWindow(getCtx(), p_AD_WindowTo_ID, get_TrxName());
    if (to.get_ID() == 0)
        throw new AdempiereUserError("@NotFound@ (to<-) @AD_Window_ID@");
    int tabCount = 0;
    int fieldCount = 0;
    MTab[] oldTabs = from.getTabs(false, get_TrxName());
    for (int i = 0; i < oldTabs.length; i++) {
        MTab oldTab = oldTabs[i];
        MTab newTab = new MTab(to, oldTab);
        if (newTab.save()) {
            tabCount++;
            //	Copy Fields
            MField[] oldFields = oldTab.getFields(false, get_TrxName());
            for (int j = 0; j < oldFields.length; j++) {
                MField oldField = oldFields[j];
                MField newField = new MField(newTab, oldField);
                if (newField.save())
                    fieldCount++;
                else
                    throw new AdempiereUserError("@Error@ @AD_Field_ID@");
            }
        } else
            throw new AdempiereUserError("@Error@ @AD_Tab_ID@");
    }
    return "@Copied@ #" + tabCount + "/" + fieldCount;
}
Also used : AdempiereUserError(org.compiere.util.AdempiereUserError) MTab(org.compiere.model.MTab) MWindow(org.compiere.model.MWindow) MField(org.compiere.model.MField)

Example 2 with MWindow

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

the class ExportFormatGenerator method doIt.

//	prepare
/**
     * Generate Export Format
     *
     * @return info
     * @throws Exception
     */
protected String doIt() throws Exception {
    MWindow window = new MWindow(getCtx(), getWindowId(), get_TrxName());
    MTab[] tabs = window.getTabs(true, get_TrxName());
    for (MTab tab : tabs) {
        MTable table = null;
        String format = null;
        if (iscludesonlytheTabsthatInsertrecords() && tab.isInsertRecord()) {
            table = new MTable(getCtx(), tab.getAD_Table_ID(), get_TrxName());
            format = createFormat(table);
        } else if (!iscludesonlytheTabsthatInsertrecords()) {
            table = new MTable(getCtx(), tab.getAD_Table_ID(), get_TrxName());
            format = createFormat(table);
        }
        if (tab.getTabLevel() > level) {
            parentTable = table.getTableName();
            formatValue = format;
        }
    }
    return "ok";
}
Also used : MTable(org.compiere.model.MTable) MTab(org.compiere.model.MTab) MWindow(org.compiere.model.MWindow)

Example 3 with MWindow

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

the class ASPGenerateLevel method addNodeToLevel.

//	doIt
private void addNodeToLevel(MTreeNode nn) {
    // Add Menu
    MMenu menu = new MMenu(getCtx(), nn.getNode_ID(), get_TrxName());
    if (menu.getAction().equals(MMenu.ACTION_Window)) {
        MWindow window = new MWindow(getCtx(), menu.getAD_Window_ID(), get_TrxName());
        int asp_window_id = DB.getSQLValueEx(get_TrxName(), "SELECT ASP_Window_ID FROM ASP_Window WHERE ASP_Level_ID = ? AND AD_Window_ID = ?", p_ASP_Level_ID, window.getAD_Window_ID());
        X_ASP_Window aspWindow = null;
        if (asp_window_id < 1) {
            // Add Window, Tabs and Fields (if IsGenerateFields)
            aspWindow = new X_ASP_Window(getCtx(), 0, get_TrxName());
            aspWindow.setASP_Level_ID(p_ASP_Level_ID);
            aspWindow.setAD_Window_ID(window.getAD_Window_ID());
            aspWindow.setASP_Status(p_ASP_Status);
            if (aspWindow.save()) {
                noWindows++;
                asp_window_id = aspWindow.getASP_Window_ID();
            }
        } else {
            aspWindow = new X_ASP_Window(getCtx(), asp_window_id, get_TrxName());
        }
        // tabs
        for (MTab tab : window.getTabs(true, get_TrxName())) {
            int asp_tab_id = DB.getSQLValueEx(get_TrxName(), "SELECT ASP_Tab_ID FROM ASP_Tab WHERE ASP_Window_ID = ? AND AD_Tab_ID = ?", asp_window_id, tab.getAD_Tab_ID());
            X_ASP_Tab aspTab = null;
            if (asp_tab_id < 1) {
                aspTab = new X_ASP_Tab(getCtx(), 0, get_TrxName());
                aspTab.setASP_Window_ID(asp_window_id);
                aspTab.setAD_Tab_ID(tab.getAD_Tab_ID());
                aspTab.setASP_Status(p_ASP_Status);
                aspTab.setAllFields(!p_IsGenerateFields);
                if (aspTab.save()) {
                    noTabs++;
                    asp_tab_id = aspTab.getASP_Tab_ID();
                }
            } else {
                aspTab = new X_ASP_Tab(getCtx(), asp_tab_id, get_TrxName());
            }
            // fields
            for (MField field : tab.getFields(true, get_TrxName())) {
                if (p_IsGenerateFields) {
                    if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Field WHERE ASP_Tab_ID = ? AND AD_Field_ID = ?", aspTab.getASP_Tab_ID(), field.getAD_Field_ID()) < 1) {
                        X_ASP_Field aspField = new X_ASP_Field(getCtx(), 0, get_TrxName());
                        aspField.setASP_Tab_ID(aspTab.getASP_Tab_ID());
                        aspField.setAD_Field_ID(field.getAD_Field_ID());
                        aspField.setASP_Status(p_ASP_Status);
                        if (aspField.save())
                            noFields++;
                    }
                }
                // verify if a field is a button and assign permission to the corresponding process
                MColumn column = MColumn.get(getCtx(), field.getAD_Column_ID());
                if (column.getAD_Reference_ID() == DisplayType.Button) {
                    if (column.getAD_Process_ID() > 0) {
                        generateProcess(column.getAD_Process_ID());
                    }
                }
            }
        }
    } else if (menu.getAction().equals(MMenu.ACTION_Process) || menu.getAction().equals(MMenu.ACTION_Report)) {
        generateProcess(menu.getAD_Process_ID());
    } else if (menu.getAction().equals(MMenu.ACTION_Form)) {
        // Add Form
        MForm form = new MForm(getCtx(), menu.getAD_Form_ID(), get_TrxName());
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Form WHERE ASP_Level_ID = ? AND AD_Form_ID = ?", p_ASP_Level_ID, form.getAD_Form_ID()) < 1) {
            X_ASP_Form aspForm = new X_ASP_Form(getCtx(), 0, get_TrxName());
            aspForm.setASP_Level_ID(p_ASP_Level_ID);
            aspForm.setAD_Form_ID(form.getAD_Form_ID());
            aspForm.setASP_Status(p_ASP_Status);
            if (aspForm.save())
                noForms++;
        }
    } else if (menu.getAction().equals(MMenu.ACTION_SmartBrowse)) {
        // Add Browse
        MBrowse browse = new MBrowse(getCtx(), menu.getAD_Browse_ID(), get_TrxName());
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Browse WHERE ASP_Level_ID = ? AND AD_Browse_ID = ?", p_ASP_Level_ID, browse.getAD_Browse_ID()) < 1) {
            X_ASP_Browse aspBrowse = new X_ASP_Browse(getCtx(), 0, get_TrxName());
            aspBrowse.setASP_Level_ID(p_ASP_Level_ID);
            aspBrowse.setAD_Browse_ID(browse.getAD_Browse_ID());
            aspBrowse.setASP_Status(p_ASP_Status);
            if (aspBrowse.save())
                noBrowses++;
        }
    } else if (menu.getAction().equals(MMenu.ACTION_Task)) {
        // Add Task
        MTask task = new MTask(getCtx(), menu.getAD_Task_ID(), get_TrxName());
        if (DB.getSQLValueEx(get_TrxName(), "SELECT COUNT(*) FROM ASP_Task WHERE ASP_Level_ID = ? AND AD_Task_ID = ?", p_ASP_Level_ID, task.getAD_Task_ID()) < 1) {
            X_ASP_Task aspTask = new X_ASP_Task(getCtx(), 0, get_TrxName());
            aspTask.setASP_Level_ID(p_ASP_Level_ID);
            aspTask.setAD_Task_ID(task.getAD_Task_ID());
            aspTask.setASP_Status(p_ASP_Status);
            if (aspTask.save())
                noTasks++;
        }
    } else if (menu.getAction().equals(MMenu.ACTION_WorkFlow)) {
        generateWorkflow(menu.getAD_Workflow_ID());
    }
}
Also used : MColumn(org.compiere.model.MColumn) X_ASP_Field(org.compiere.model.X_ASP_Field) MTab(org.compiere.model.MTab) MMenu(org.compiere.model.MMenu) MWindow(org.compiere.model.MWindow) X_ASP_Tab(org.compiere.model.X_ASP_Tab) MBrowse(org.adempiere.model.MBrowse) MForm(org.compiere.model.MForm) MTask(org.compiere.model.MTask) X_ASP_Task(org.compiere.model.X_ASP_Task) X_ASP_Form(org.compiere.model.X_ASP_Form) X_ASP_Window(org.compiere.model.X_ASP_Window) MField(org.compiere.model.MField) X_ASP_Browse(org.eevolution.model.X_ASP_Browse)

Example 4 with MWindow

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

the class WindowElementHandler method startElement.

public void startElement(Properties ctx, Element element) throws SAXException {
    // Check namespace.
    String elementValue = element.getElementValue();
    Attributes atts = element.attributes;
    log.info(elementValue + " " + atts.getValue("Name"));
    String entitytype = atts.getValue("EntityType");
    if (isProcessElement(ctx, entitytype)) {
        String name = atts.getValue("Name");
        int id = get_ID(ctx, "AD_Window", name);
        if (id > 0 && windows.contains(id)) {
            return;
        }
        MWindow m_Window = new MWindow(ctx, id, getTrxName(ctx));
        if (id <= 0 && atts.getValue("AD_Window_ID") != null && Integer.parseInt(atts.getValue("AD_Window_ID")) <= PackOut.MAX_OFFICIAL_ID)
            m_Window.setAD_Window_ID(Integer.parseInt(atts.getValue("AD_Window_ID")));
        String Object_Status = null;
        int AD_Backup_ID = -1;
        if (id > 0) {
            AD_Backup_ID = copyRecord(ctx, "AD_Window", m_Window);
            Object_Status = "Update";
        } else {
            Object_Status = "New";
            AD_Backup_ID = 0;
        }
        m_Window.setName(name);
        name = atts.getValue("ADImageNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Image", "Name", name);
            /*
				if (id <= 0) {
					element.defer = true;
					return;
				}*/
            if (id > 0)
                m_Window.setAD_Image_ID(id);
        }
        name = atts.getValue("ADColorNameID");
        if (name != null && name.trim().length() > 0) {
            id = get_IDWithColumn(ctx, "AD_Color", "Name", name);
            /*
				if (id <= 0) {
					element.defer = true;
					return;
				}*/
            if (id > 0)
                m_Window.setAD_Color_ID(id);
        }
        m_Window.setDescription(getStringValue(atts, "Description"));
        m_Window.setEntityType(atts.getValue("EntityType"));
        m_Window.setHelp(getStringValue(atts, "Help"));
        m_Window.setIsActive(atts.getValue("isActive") != null ? Boolean.valueOf(atts.getValue("isActive")).booleanValue() : true);
        m_Window.setIsBetaFunctionality(Boolean.valueOf(atts.getValue("isBetaFunctionality")).booleanValue());
        m_Window.setIsDefault(Boolean.valueOf(atts.getValue("isDefault")).booleanValue());
        m_Window.setIsSOTrx(Boolean.valueOf(atts.getValue("isSOTrx")).booleanValue());
        m_Window.setName(atts.getValue("Name"));
        m_Window.setProcessing(false);
        if (!Util.isEmpty(atts.getValue("WinHeight"), true))
            m_Window.setWinWidth(getValueInt(atts, "WinWidth", 0));
        if (!Util.isEmpty(atts.getValue("WinHeight"), true))
            m_Window.setWinHeight(getValueInt(atts, "WinHeight", 0));
        m_Window.setWindowType(atts.getValue("WindowType"));
        if (m_Window.save(getTrxName(ctx)) == true) {
            record_log(ctx, 1, m_Window.getName(), "Window", m_Window.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Window"));
            element.recordId = m_Window.getAD_Window_ID();
            windows.add(m_Window.getAD_Window_ID());
        } else {
            record_log(ctx, 0, m_Window.getName(), "Window", m_Window.get_ID(), AD_Backup_ID, Object_Status, "AD_Window", get_IDWithColumn(ctx, "AD_Table", "TableName", "AD_Window"));
            throw new POSaveFailedException("Window");
        }
    } else {
        element.skip = true;
    }
}
Also used : Attributes(org.xml.sax.Attributes) POSaveFailedException(org.adempiere.pipo.exception.POSaveFailedException) MWindow(org.compiere.model.MWindow)

Example 5 with MWindow

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

the class APanel method cmd_winSize.

//  cmd_end
/**
	 * 	Set Window Size
	 */
private void cmd_winSize() {
    Dimension size = getSize();
    if (!ADialog.ask(m_curWindowNo, this, "WinSizeSet", "x=" + size.width + " - y=" + size.height)) {
        setPreferredSize(null);
        SwingUtilities.getWindowAncestor(this).pack();
        size = new Dimension(0, 0);
    }
    //
    MWindow win = new MWindow(m_ctx, m_curTab.getAD_Window_ID(), null);
    win.setWindowSize(size);
    win.saveEx();
}
Also used : Dimension(java.awt.Dimension) MWindow(org.compiere.model.MWindow)

Aggregations

MWindow (org.compiere.model.MWindow)5 MTab (org.compiere.model.MTab)3 MField (org.compiere.model.MField)2 Dimension (java.awt.Dimension)1 MBrowse (org.adempiere.model.MBrowse)1 POSaveFailedException (org.adempiere.pipo.exception.POSaveFailedException)1 MColumn (org.compiere.model.MColumn)1 MForm (org.compiere.model.MForm)1 MMenu (org.compiere.model.MMenu)1 MTable (org.compiere.model.MTable)1 MTask (org.compiere.model.MTask)1 X_ASP_Field (org.compiere.model.X_ASP_Field)1 X_ASP_Form (org.compiere.model.X_ASP_Form)1 X_ASP_Tab (org.compiere.model.X_ASP_Tab)1 X_ASP_Task (org.compiere.model.X_ASP_Task)1 X_ASP_Window (org.compiere.model.X_ASP_Window)1 AdempiereUserError (org.compiere.util.AdempiereUserError)1 X_ASP_Browse (org.eevolution.model.X_ASP_Browse)1 Attributes (org.xml.sax.Attributes)1