Search in sources :

Example 1 with IView

use of com.servoy.j2db.IView in project servoy-client by Servoy.

the class SwingForm method prepareForSave.

public void prepareForSave(boolean looseFocus) {
    final Component currentFocusHolder = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    Component component = currentFocusHolder;
    if (component instanceof JRootPane || component instanceof JFrame) {
    // do not give focus to swing form as will transfer it to first field
    // component = this;
    } else
        while (component != null && !(component instanceof Window) && !(component instanceof IView) && !isPartOfSlider(component) && !isPartOfTabPanel(component)) {
            component = component.getParent();
        }
    if (component != null && currentFocusHolder != component && !(component instanceof TableView) && !(component instanceof ListView && !((ListView) component).isEditing())) {
        // this used to be in invokelater, however reverted the change because it interfered with js focus calls
        component.requestFocus();
    }
}
Also used : Window(java.awt.Window) IView(com.servoy.j2db.IView) JFrame(javax.swing.JFrame) JRootPane(javax.swing.JRootPane) 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)

Example 2 with IView

use of com.servoy.j2db.IView in project servoy-client by Servoy.

the class CellAdapter method getBgColor.

private Color getBgColor(JTable jtable, boolean isSelected, int row, boolean isEdited) {
    Color bgColor = null;
    IRecordInternal state = ((IFoundSetInternal) jtable.getModel()).getRecord(row);
    boolean specialStateCase = (state instanceof PrototypeState || state instanceof FindState || state == null || state.getRawData() == null);
    if (/* !(renderer instanceof JButton) && */
    !specialStateCase) {
        ISwingFoundSet foundset = (ISwingFoundSet) jtable.getModel();
        bgColor = (Color) getStyleAttributeForRow(jtable, isSelected, row, ISupportRowStyling.ATTRIBUTE.BGCOLOR);
        String strRowBGColorProvider = null;
        List<Object> rowBGColorArgs = null;
        if (jtable instanceof IView) {
            strRowBGColorProvider = ((IView) jtable).getRowBGColorScript();
            rowBGColorArgs = ((IView) jtable).getRowBGColorArgs();
        }
        // $NON-NLS-1$
        if (strRowBGColorProvider == null)
            strRowBGColorProvider = "servoy_row_bgcolor";
        boolean isRowBGColorCalculation = state.getRawData().containsCalculation(strRowBGColorProvider);
        if (// $NON-NLS-1$
        !isRowBGColorCalculation && strRowBGColorProvider.equals("servoy_row_bgcolor")) {
            // $NON-NLS-1$
            strRowBGColorProvider = "";
        }
        if (// $NON-NLS-1$
        strRowBGColorProvider != null && !"".equals(strRowBGColorProvider)) {
            Object bg_color = null;
            // TODO this should be done better....
            Record.VALIDATE_CALCS.set(Boolean.FALSE);
            try {
                String type = (editor instanceof IScriptableProvider && ((IScriptableProvider) editor).getScriptObject() instanceof IRuntimeComponent) ? ((IRuntimeComponent) ((IScriptableProvider) editor).getScriptObject()).getElementType() : null;
                String nm = (editor instanceof IDisplayData) ? ((IDisplayData) editor).getDataProviderID() : null;
                if (isRowBGColorCalculation) {
                    bg_color = foundset.getCalculationValue(state, strRowBGColorProvider, Utils.arrayMerge((new Object[] { new Integer(row), new Boolean(isSelected), type, nm, new Boolean(isEdited) }), Utils.parseJSExpressions(rowBGColorArgs)), null);
                } else {
                    try {
                        FormController currentForm = dal.getFormController();
                        bg_color = currentForm.executeFunction(strRowBGColorProvider, Utils.arrayMerge((new Object[] { new Integer(row), new Boolean(isSelected), type, nm, currentForm.getName(), state, new Boolean(isEdited) }), Utils.parseJSExpressions(rowBGColorArgs)), false, null, true, null);
                    } catch (Exception ex) {
                        Debug.error(ex);
                    }
                }
            } finally {
                Record.VALIDATE_CALCS.set(null);
            }
            if (bg_color != null && !(bg_color.toString().trim().length() == 0) && !(bg_color instanceof Undefined)) {
                bgColor = PersistHelper.createColor(bg_color.toString());
            }
        }
    }
    return bgColor;
}
Also used : FormController(com.servoy.j2db.FormController) Undefined(org.mozilla.javascript.Undefined) IView(com.servoy.j2db.IView) IRecordInternal(com.servoy.j2db.dataprocessing.IRecordInternal) IFoundSetInternal(com.servoy.j2db.dataprocessing.IFoundSetInternal) Color(java.awt.Color) ISwingFoundSet(com.servoy.j2db.dataprocessing.ISwingFoundSet) ServoyException(com.servoy.j2db.util.ServoyException) ParseException(java.text.ParseException) ApplicationException(com.servoy.j2db.ApplicationException) FindState(com.servoy.j2db.dataprocessing.FindState) EventObject(java.util.EventObject) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) PrototypeState(com.servoy.j2db.dataprocessing.PrototypeState) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider)

Aggregations

IView (com.servoy.j2db.IView)2 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)2 ApplicationException (com.servoy.j2db.ApplicationException)1 FormController (com.servoy.j2db.FormController)1 FindState (com.servoy.j2db.dataprocessing.FindState)1 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)1 IFoundSetInternal (com.servoy.j2db.dataprocessing.IFoundSetInternal)1 IRecordInternal (com.servoy.j2db.dataprocessing.IRecordInternal)1 ISwingFoundSet (com.servoy.j2db.dataprocessing.ISwingFoundSet)1 PrototypeState (com.servoy.j2db.dataprocessing.PrototypeState)1 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)1 PortalComponent (com.servoy.j2db.smart.dataui.PortalComponent)1 IComponent (com.servoy.j2db.ui.IComponent)1 ServoyException (com.servoy.j2db.util.ServoyException)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Window (java.awt.Window)1 ParseException (java.text.ParseException)1 EventObject (java.util.EventObject)1 JComponent (javax.swing.JComponent)1