Search in sources :

Example 21 with MbengNode

use of com.qwest.mbeng.MbengNode in project mdw-designer by CenturyLinkCloud.

the class SwingFormGenerator method getValue.

private String getValue(MbengNode node) {
    String value = null;
    String dataassoc = node.getAttribute(FormConstants.FORMATTR_DATA);
    MbengNode vnode = dataassoc == null ? null : dataxml.getNode(dataassoc);
    if (vnode != null)
        value = vnode.getValue();
    else
        value = null;
    if (value == null || value.length() == 0) {
        String av = node.getAttribute(FormConstants.FORMATTR_AUTOVALUE);
        if (av != null && av.length() > 0) {
            // String rulename = node.getAttribute(FormConstants.FORMATTR_ID) + "_DEFAULT";
            // try {
            // value = this.evaluateExpression(rulename, av, dataxml);
            // } catch (MbengException e) {
            // // return null if data element is not there
            // // rule syntax error should be detected at design time?
            // value = null;
            // }
            // this makes it the same as JSF version
            value = av;
            try {
                dataxml.setValue(dataassoc, value, FormDataDocument.KIND_FIELD);
            } catch (MbengException e) {
            }
        }
    }
    return value;
}
Also used : MbengException(com.qwest.mbeng.MbengException) MbengNode(com.qwest.mbeng.MbengNode)

Example 22 with MbengNode

use of com.qwest.mbeng.MbengNode in project mdw-designer by CenturyLinkCloud.

the class SwingFormGenerator method saveGeoInfo.

public void saveGeoInfo(Component component) {
    MbengNode node;
    if (component instanceof JLabel) {
        node = labelmap.get(component);
        this.saving_lr(node, component.getBounds());
        if (node.getName().equals(FormConstants.WIDGET_TEXTAREA)) {
            String isStatic = node.getAttribute(FormConstants.FORMATTR_IS_STATIC);
            if (isStatic != null && isStatic.equalsIgnoreCase("true")) {
                this.saving_vr(node, component.getBounds());
                Component textarea_pane = nodewidget.get(getDomNode(node));
                textarea_pane.setBounds(component.getBounds());
            }
        }
    } else {
        node = widgetmap.get(component);
        this.saving_vr(node, component.getBounds());
    }
}
Also used : MbengNode(com.qwest.mbeng.MbengNode)

Example 23 with MbengNode

use of com.qwest.mbeng.MbengNode in project mdw-designer by CenturyLinkCloud.

the class JTablePlus method performSorting.

private void performSorting(ActionEvent e) {
    int columnIndex = e.getID();
    boolean descending = columnIndex < 0;
    if (columnIndex < 0)
        columnIndex = -columnIndex - 1;
    else
        columnIndex = columnIndex - 1;
    if (!model.isColumnSortable(columnIndex)) {
        e.setSource(null);
        return;
    }
    String sorton = getColumnName(columnIndex);
    if (sorton == null)
        return;
    if (descending)
        sorton = "-" + sorton;
    MbengNode metanode = datadoc.getNode(datapath + "_META");
    try {
        if (metanode != null)
            datadoc.setValue(metanode, "sort_on", sorton);
    } catch (MbengException e1) {
    }
    String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=S&sorton=" + sorton;
    call_engine(action);
}
Also used : MbengException(com.qwest.mbeng.MbengException) MbengNode(com.qwest.mbeng.MbengNode)

Example 24 with MbengNode

use of com.qwest.mbeng.MbengNode in project mdw-designer by CenturyLinkCloud.

the class JTablePlus method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    if (actionListener == null)
        return;
    if (cmd.equals(JTablePlus.ACTION_FIRST)) {
        String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=F";
        call_engine(action);
    } else if (cmd.equals(JTablePlus.ACTION_PREV)) {
        String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=P";
        call_engine(action);
    } else if (cmd.equals(JTablePlus.ACTION_NEXT)) {
        String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=N";
        call_engine(action);
    } else if (cmd.equals(JTablePlus.ACTION_LAST)) {
        String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=L";
        call_engine(action);
    } else if (cmd.equals(JTablePlus.ACTION_GOTO)) {
        try {
            int row = Integer.parseInt(goto_row.getText());
            MbengNode metanode = datadoc.getNode(datapath + "_META");
            String v = datadoc.getValue(metanode, "total_rows");
            int total_rows = v == null ? model.getRowCount() : Integer.parseInt(v);
            if (row >= 1 && row <= total_rows) {
                datadoc.setValue(metanode, "start_row", Integer.toString(row));
                String action = paginator + "?action=paging&table=" + datapath + "&meta=" + datapath + "_META&topage=S";
                call_engine(action);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    } else if (cmd.equals(TableSorter.ACTION_TABLE_SORTING)) {
        performSorting(e);
    }
}
Also used : MbengNode(com.qwest.mbeng.MbengNode) MbengException(com.qwest.mbeng.MbengException)

Example 25 with MbengNode

use of com.qwest.mbeng.MbengNode in project mdw-designer by CenturyLinkCloud.

the class JTablePlus method setData.

public void setData(FormDataDocument dataxml, String datapath) {
    this.datadoc = dataxml;
    this.datapath = datapath;
    MbengNode datanode = dataxml.getNode(datapath);
    MbengNode metanode = dataxml.getNode(datapath + "_META");
    model.setData(datanode);
    if (metanode != null) {
        String sorton = datadoc.getValue(metanode, "sort_on");
        if (sorton != null) {
            boolean descending = sorton.startsWith("-");
            if (descending)
                sorton = sorton.substring(1);
            setSortingStatus(sorton, descending);
        }
        String selected_str = datadoc.getValue(metanode, "selected");
        if (!StringHelper.isEmpty(selected_str)) {
            String[] rows_str = selected_str.split(",");
            int firstRow = Integer.parseInt(rows_str[0]);
            try {
                if (model.getRowCount() > firstRow) {
                    table.setRowSelectionInterval(firstRow, firstRow);
                    datadoc.setValue(metanode, "selected", rows_str[0]);
                } else
                    datadoc.setValue(metanode, "selected", null);
            } catch (MbengException e) {
            }
        }
        if (rowrange != null) {
            int nrows = model.getRowCount();
            if (nrows == 0) {
                rowrange.setText("No rows");
                button_first.setEnabled(false);
                button_prev.setEnabled(false);
                button_next.setEnabled(false);
                button_last.setEnabled(false);
                button_goto.setEnabled(false);
            } else {
                String v = datadoc.getValue(metanode, "start_row");
                int start_row = v == null ? 1 : Integer.parseInt(v);
                v = datadoc.getValue(metanode, "total_rows");
                int total_rows = v == null ? nrows : Integer.parseInt(v);
                rowrange.setText("" + start_row + " - " + (start_row + nrows - 1) + " of " + total_rows);
                button_first.setEnabled(start_row > 1);
                button_prev.setEnabled(start_row > 1);
                button_next.setEnabled(start_row + nrows - 1 < total_rows);
                button_last.setEnabled(start_row + nrows - 1 < total_rows);
                button_goto.setEnabled(nrows < total_rows);
            }
        }
    }
    // for some reason w/o the following, layout was not done and screen shows blank until resized
    super.doLayout();
    for (int k = this.getComponentCount(); k > 0; k--) {
        Component comp = this.getComponent(k - 1);
        if (comp instanceof Container)
            ((Container) comp).doLayout();
    }
}
Also used : MbengException(com.qwest.mbeng.MbengException) Container(java.awt.Container) MbengNode(com.qwest.mbeng.MbengNode) Component(java.awt.Component)

Aggregations

MbengNode (com.qwest.mbeng.MbengNode)25 MbengException (com.qwest.mbeng.MbengException)10 JTablePlus (com.centurylink.mdw.designer.utils.JTablePlus)3 Component (java.awt.Component)3 MenuButton (com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton)2 DomDocument (com.qwest.mbeng.DomDocument)2 FormatDom (com.qwest.mbeng.FormatDom)2 Container (java.awt.Container)2 ArrayList (java.util.ArrayList)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 CallURL (com.centurylink.mdw.common.utilities.form.CallURL)1 FormActionParser (com.centurylink.mdw.common.utilities.form.FormActionParser)1 SelectOption (com.centurylink.mdw.designer.utils.SwingFormGenerator.SelectOption)1 FormDataDocument (com.centurylink.mdw.model.FormDataDocument)1 ActivityVO (com.centurylink.mdw.model.value.activity.ActivityVO)1 AttributeVO (com.centurylink.mdw.model.value.attribute.AttributeVO)1 DocumentReference (com.centurylink.mdw.model.value.variable.DocumentReference)1 DomNode (com.qwest.mbeng.DomNode)1 FormatXml (com.qwest.mbeng.FormatXml)1 MbengDocumentClass (com.qwest.mbeng.MbengDocumentClass)1