Search in sources :

Example 1 with SpecialTabPanel

use of com.servoy.j2db.smart.dataui.SpecialTabPanel in project servoy-client by Servoy.

the class SwingForm method setTabSeqComponents.

public void setTabSeqComponents(List<Component> tabSequence) {
    IDataRenderer formEditorRenderer = formController.getDataRenderers()[FormController.FORM_EDITOR];
    if (formEditorRenderer instanceof TableView && (tabSequence == null || !tabSequence.contains(formEditorRenderer))) {
        // table view should be added to tab sequence
        ((TableView) formEditorRenderer).setTabSeqComponents(tabSequence);
        if (tabSequence != null && tabSequence.size() > 0) {
            // this means that we have to identify components that are part of the table view and based on where these are located set the view's tabIndex
            // when called from JS tabSequence will only contain table columns, not table view as opposed to initialization when tabSequence only contains the view
            int i;
            for (i = 0; i < tabSequence.size(); i++) {
                if (((TableView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    tabSequence = new ArrayList<Component>(tabSequence);
                    tabSequence.add(i, (Component) formEditorRenderer);
                    break;
                }
            }
            i++;
            while (i < tabSequence.size()) {
                if (((TableView) formEditorRenderer).isColumnIdentifierComponent(tabSequence.get(i))) {
                    tabSequence.remove(i);
                } else {
                    i++;
                }
            }
        }
    }
    this.tabSeqComponentList = tabSequence;
    if (tabSeqComponentList != null) {
        if (tabSeqComponentList.size() > 0) {
            JComponent lastComponent = (JComponent) tabSeqComponentList.get(tabSeqComponentList.size() - 1);
            if (!(lastComponent instanceof SpecialTabPanel)) {
                int modifier = 0;
                if ((lastComponent instanceof TableView))
                    modifier = InputEvent.CTRL_DOWN_MASK;
                if ((lastComponent instanceof DataComboBox) && ((DataComboBox) lastComponent).isEditable())
                    lastComponent = (JComponent) ((DataComboBox) lastComponent).getEditor().getEditorComponent();
                addJumpOutActionToComponent(lastComponent, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, modifier), ACTION_GO_OUT_TO_NEXT, false);
            }
            JComponent firstComponent = (JComponent) tabSeqComponentList.get(0);
            if (!(firstComponent instanceof SpecialTabPanel)) {
                int modifier = 0;
                if ((firstComponent instanceof TableView))
                    modifier = InputEvent.CTRL_DOWN_MASK;
                if ((firstComponent instanceof DataComboBox) && ((DataComboBox) firstComponent).isEditable())
                    firstComponent = (JComponent) ((DataComboBox) firstComponent).getEditor().getEditorComponent();
                addJumpOutActionToComponent(firstComponent, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, modifier | InputEvent.SHIFT_DOWN_MASK), ACTION_GO_OUT_TO_PREV, true);
            }
        }
    }
}
Also used : IDataRenderer(com.servoy.j2db.ui.IDataRenderer) SpecialTabPanel(com.servoy.j2db.smart.dataui.SpecialTabPanel) JComponent(javax.swing.JComponent) IComponent(com.servoy.j2db.ui.IComponent) Component(java.awt.Component) PortalComponent(com.servoy.j2db.smart.dataui.PortalComponent) JComponent(javax.swing.JComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) Point(java.awt.Point) DataComboBox(com.servoy.j2db.smart.dataui.DataComboBox)

Example 2 with SpecialTabPanel

use of com.servoy.j2db.smart.dataui.SpecialTabPanel in project servoy-client by Servoy.

the class SwingForm method getFormContext.

public JSDataSet getFormContext() {
    SwingForm current = this;
    FormLookupPanel currentLookupPanel = null;
    SpecialTabPanel currentTabPanel = null;
    String currentBeanName = null;
    SpecialSplitPane currentSplitPane = null;
    IDataSet set = new BufferedDataSet(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$
    new String[] { "containername", "formname", "tabpanel/splitpane/accordion/beanname", "tabname", "tabindex", "tabindex1based" }, new ArrayList<Object[]>());
    set.addRow(new Object[] { null, current.formController.getName(), null, null, null, null });
    Container parent = getParent();
    while (parent != null) {
        if (parent instanceof SpecialTabPanel) {
            currentTabPanel = (SpecialTabPanel) parent;
        } else if (parent instanceof SpecialSplitPane) {
            currentSplitPane = (SpecialSplitPane) parent;
        } else if (parent instanceof FormLookupPanel) {
            currentLookupPanel = (FormLookupPanel) parent;
        } else if (parent instanceof IServoyAwareBean && parent instanceof IComponent) {
            currentBeanName = ((IComponent) parent).getName();
        } else if (parent instanceof SwingForm) {
            current = (SwingForm) parent;
            if (currentTabPanel != null) {
                ITabPaneAlike panel = currentTabPanel.getEnclosingComponent();
                int index = -1;
                String tabName = null;
                if (currentLookupPanel != null) {
                    index = panel.getTabIndex(currentLookupPanel);
                    if (index != -1) {
                        tabName = panel.getNameAt(index);
                    }
                }
                set.addRow(0, new Object[] { null, current.formController.getName(), currentTabPanel.getName(), tabName, new Integer(index), new Integer(index + 1) });
            } else if (currentBeanName != null) {
                set.addRow(0, new Object[] { null, current.formController.getName(), currentBeanName, null, null, null });
            } else if (currentSplitPane != null) {
                int idx = currentLookupPanel != null && currentLookupPanel.equals(currentSplitPane.getLeftForm()) ? 0 : 1;
                set.addRow(0, new Object[] { null, current.formController.getName(), currentSplitPane.getName(), currentSplitPane.getTabNameAt(idx), new Integer(idx + 1), new Integer(idx + 1) });
            } else {
                set.addRow(0, new Object[] { null, current.formController.getName(), null, null, null, null });
            }
            currentBeanName = null;
            currentTabPanel = null;
            currentLookupPanel = null;
            currentSplitPane = null;
        } else if (parent instanceof MainPanel) {
            String containerName = ((MainPanel) parent).getContainerName();
            if (containerName != null) {
                for (int i = 0; i < set.getRowCount(); i++) {
                    set.getRow(i)[0] = containerName;
                }
            }
            return new JSDataSet(formController.getApplication(), set);
        }
        parent = parent.getParent();
    }
    return new JSDataSet(formController.getApplication(), set);
}
Also used : IComponent(com.servoy.j2db.ui.IComponent) JSDataSet(com.servoy.j2db.dataprocessing.JSDataSet) ITabPaneAlike(com.servoy.j2db.util.ITabPaneAlike) Point(java.awt.Point) Container(java.awt.Container) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) BufferedDataSet(com.servoy.j2db.dataprocessing.BufferedDataSet) SpecialSplitPane(com.servoy.j2db.smart.dataui.SpecialSplitPane) SpecialTabPanel(com.servoy.j2db.smart.dataui.SpecialTabPanel) TwoNativeJavaObject(com.servoy.j2db.smart.scripting.TwoNativeJavaObject) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) ScriptableObject(org.mozilla.javascript.ScriptableObject) IDataSet(com.servoy.j2db.dataprocessing.IDataSet) FormLookupPanel(com.servoy.j2db.smart.dataui.FormLookupPanel)

Aggregations

SpecialTabPanel (com.servoy.j2db.smart.dataui.SpecialTabPanel)2 IComponent (com.servoy.j2db.ui.IComponent)2 Point (java.awt.Point)2 BufferedDataSet (com.servoy.j2db.dataprocessing.BufferedDataSet)1 IDataSet (com.servoy.j2db.dataprocessing.IDataSet)1 JSDataSet (com.servoy.j2db.dataprocessing.JSDataSet)1 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)1 DataComboBox (com.servoy.j2db.smart.dataui.DataComboBox)1 FormLookupPanel (com.servoy.j2db.smart.dataui.FormLookupPanel)1 PortalComponent (com.servoy.j2db.smart.dataui.PortalComponent)1 SpecialSplitPane (com.servoy.j2db.smart.dataui.SpecialSplitPane)1 TwoNativeJavaObject (com.servoy.j2db.smart.scripting.TwoNativeJavaObject)1 IDataRenderer (com.servoy.j2db.ui.IDataRenderer)1 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)1 ITabPaneAlike (com.servoy.j2db.util.ITabPaneAlike)1 Component (java.awt.Component)1 Container (java.awt.Container)1 JComponent (javax.swing.JComponent)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 NativeJavaObject (org.mozilla.javascript.NativeJavaObject)1