Search in sources :

Example 1 with MenuButton

use of com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton in project mdw-designer by CenturyLinkCloud.

the class FormWidgetDialog method updateWidgetLabel.

private void updateWidgetLabel(MbengNode node) {
    String labelNew = node.getAttribute(FormConstants.FORMATTR_LABEL);
    if (labelNew != null && !labelNew.equals(labelOld)) {
        if (node.getName().equals(FormConstants.WIDGET_PANEL)) {
            JPanel panel = (JPanel) generator.getWidget(node);
            ((TitledBorder) panel.getBorder()).setTitle(labelNew);
        } else if (node.getName().equals(FormConstants.WIDGET_BUTTON)) {
            JButton button = (JButton) generator.getWidget(node);
            button.setText(labelNew);
        } else if (node.getName().equals(FormConstants.WIDGET_MENU)) {
            Component menu = generator.getWidget(node);
            if (menu instanceof JPopupMenu)
                ((JPopupMenu) menu).setName(labelNew);
            else if (menu instanceof MenuButton)
                ((MenuButton) menu).setText(labelNew);
            else
                ((JMenu) menu).setText(labelNew);
        } else if (node.getName().equals(FormConstants.WIDGET_MENUITEM)) {
            JMenuItem menuitem = (JMenuItem) generator.getWidget(node);
            menuitem.setText(labelNew);
        } else if (node.getName().equals(FormConstants.WIDGET_TAB)) {
            JPanel panel = (JPanel) generator.getWidget(node);
            JTabbedPane tabbedPane = (JTabbedPane) panel.getParent();
            for (int i = 0; i < tabbedPane.getTabCount(); i++) {
                Component comp = tabbedPane.getComponent(i);
                if (comp == panel) {
                    tabbedPane.setTitleAt(i, labelNew);
                    break;
                }
            }
        } else if (node.getName().equals(FormConstants.WIDGET_COLUMN)) {
            JTablePlus tablePlus = (JTablePlus) generator.getWidget(node.getParent());
            int c = Integer.parseInt(node.getAttribute("INDEX"));
            tablePlus.setColumnLabel(c, labelNew);
        } else {
            JLabel label = generator.getLabel(node);
            if (label != null) {
                label.setText(generator.formatText(labelNew));
            }
        }
    }
}
Also used : JPanel(javax.swing.JPanel) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) MenuButton(com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) JPopupMenu(javax.swing.JPopupMenu) JTablePlus(com.centurylink.mdw.designer.utils.JTablePlus) JComponent(javax.swing.JComponent) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu)

Example 2 with MenuButton

use of com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton in project mdw-designer by CenturyLinkCloud.

the class FormDesignCanvas method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    Component src = (Component) e.getSource();
    MbengNode node = generator.getNode(src);
    if (cmd.equals(FormConstants.ACTION_MENU)) {
        MenuButton button = (MenuButton) src;
        JPopupMenu menu = button.getMenu();
        menu.show(src, src.getWidth() - 10, src.getHeight() - 10);
    } else {
        showWidgetDialog(node);
    }
}
Also used : MbengNode(com.qwest.mbeng.MbengNode) MenuButton(com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton)

Example 3 with MenuButton

use of com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton in project mdw-designer by CenturyLinkCloud.

the class FormPanel method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    Component src = (Component) e.getSource();
    if (cmd.equals(FormConstants.ACTION_MENU)) {
        MenuButton button = (MenuButton) src;
        JPopupMenu menu = button.getMenu();
        menu.show(src, src.getWidth() - 10, src.getHeight() - 10);
    } else if (cmd.equals(SwingFormGenerator.ACTION_TABBING)) {
        JTabbedPane tabbedPane = (JTabbedPane) src;
        MbengNode node = canvas.getGenerator().getNode(tabbedPane);
        String id = node.getAttribute(FormConstants.FORMATTR_ID);
        String datapath = node.getAttribute(FormConstants.FORMATTR_DATA);
        if (datapath == null || datapath.length() == 0)
            datapath = "__mdwtabindex__" + id;
        String paginator = node.getAttribute(FormConstants.FORMATTR_ACTION);
        if (paginator == null)
            paginator = "com.centurylink.mdw.listener.formaction.TabChanger";
        int index = e.getID();
        String action = paginator + "?action=tabbing&tabs=" + id + "&tab=" + index + "&data=" + datapath;
        performGenericAction(action);
    } else if (cmd.equals(JTablePlus.ACTION_ENGINE_CALL)) {
        String action = ((JTablePlus) src).getEngineCallAction();
        performGenericAction(action);
    } else {
        MbengNode node = canvas.getGenerator().getNode(src);
        performJavaScriptAction(e, src, cmd, node);
    }
}
Also used : JTabbedPane(javax.swing.JTabbedPane) MbengNode(com.qwest.mbeng.MbengNode) MenuButton(com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton) JTablePlus(com.centurylink.mdw.designer.utils.JTablePlus) Component(java.awt.Component) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

MenuButton (com.centurylink.mdw.designer.utils.SwingFormGenerator.MenuButton)3 JTablePlus (com.centurylink.mdw.designer.utils.JTablePlus)2 MbengNode (com.qwest.mbeng.MbengNode)2 Component (java.awt.Component)2 JPopupMenu (javax.swing.JPopupMenu)2 JTabbedPane (javax.swing.JTabbedPane)2 JButton (javax.swing.JButton)1 JComponent (javax.swing.JComponent)1 JLabel (javax.swing.JLabel)1 JMenu (javax.swing.JMenu)1 JMenuItem (javax.swing.JMenuItem)1 JPanel (javax.swing.JPanel)1 TitledBorder (javax.swing.border.TitledBorder)1