Search in sources :

Example 1 with IBasicFormManager

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

the class JSApplication method js_showFormInWindow.

/**
 * Show the specified form in a window. (NOTE: x, y, width, height are initial bounds - applied only the fist time a window is shown)
 *
 * NOTE:
 * Forms in windows cannot be modal. They are more independent then dialogs, even non-modal ones. For example in SC, a non-modal dialog will always
 * be shown on top of the parent window and it will not have a separate entry in the OS window manager (for example Windows taskbar).
 *
 * NOTE:
 * x, y, width and height coordinates are only applied the first time the specified window is shown.
 * Use APP_UI_PROPERTY.FULL_SCREEN for these values when the window should be full-screen.
 *
 * @deprecated As of release 6.0, dialogs/windows API has been rewritten (based in JSWindow objects)
 *
 * @sample
 * //Show the specified form in a window, on default initial location and size
 * //application.showFormInWindow(forms.contacts);
 * //Show the specified form in a window with a specified name, on default initial location and size
 * //application.showFormInWindow(forms.contacts,'contactsWindow');
 * //Show the specified form in a window, at a specified initial location and size with custom title, not resizable but with text toolbar
 * application.showFormInWindow(forms.contacts,100,80,500,300,'my own window title',false,true,'mywindow');
 *
 * @param form The form to be shown in the dialog.
 * @param x optional The "x" coordinate of the dialog.
 * @param y optional The "y" coordinate of the dialog.
 * @param width optional The width of the dialog.
 * @param height optional The height of the dialog.
 * @param dialogTitle optional The title of the dialog.
 * @param resizable optional <em>true</em> if the dialog size should be modifiable; <em>false</em> if not.
 * @param showTextToolbar optional <em>true</em> to add a text toolbar; <em>false</em> to not add a text toolbar.
 * @param windowName optional The name of the window; defaults to "dialog" if nothing is specified. Window and dialog names share the same namespace.
 */
@Deprecated
public void js_showFormInWindow(Object[] args) throws ServoyException {
    if (args != null && args.length >= 1) {
        Object form = args[0];
        int x = -1;
        int y = -1;
        int w = 0;
        int h = 0;
        String title = null;
        boolean resizeble = true;
        boolean showTextToolbar = false;
        String windowName = null;
        // special short cut, args: 'form,name'
        if (args.length >= 2 && args[1] instanceof String) {
            windowName = (String) args[1];
        } else {
            if (args.length >= 2 && args[1] instanceof Number)
                x = ((Number) args[1]).intValue();
            if (args.length >= 3 && args[2] instanceof Number)
                y = ((Number) args[2]).intValue();
            if (args.length >= 4 && args[3] instanceof Number)
                w = ((Number) args[3]).intValue();
            if (args.length >= 5 && args[4] instanceof Number)
                h = ((Number) args[4]).intValue();
            if (args.length >= 6 && args[5] instanceof String)
                title = args[5].toString();
            if (args.length >= 7 && args[6] instanceof Boolean)
                resizeble = ((Boolean) args[6]).booleanValue();
            if (args.length >= 8 && args[7] instanceof Boolean)
                showTextToolbar = ((Boolean) args[7]).booleanValue();
            if (args.length >= 9 && args[8] instanceof String)
                windowName = (String) args[8];
        }
        windowName = replaceFailingCharacters(windowName);
        String formName = null;
        if (form instanceof BasicFormController) {
            formName = ((BasicFormController) form).getName();
        } else if (form instanceof FormScope) {
            formName = ((FormScope) form).getFormController().getName();
        } else if (form instanceof BasicFormController.JSForm) {
            formName = ((FormController.JSForm) form).getFormPanel().getName();
        } else if (form instanceof String) {
            formName = (String) form;
        }
        if (formName != null) {
            Form frm = application.getFlattenedSolution().getForm(formName);
            IBasicFormManager fm = application.getFormManager();
            if (frm == null && fm.isPossibleForm(formName))
                frm = fm.getPossibleForm(formName);
            if (!application.getFlattenedSolution().formCanBeInstantiated(frm)) {
                // abstract form
                throw new ApplicationException(ServoyException.ABSTRACT_FORM);
            }
            Rectangle bounds = new Rectangle(x, y, w, h);
            fm.showFormInFrame(formName, bounds, title, resizeble, showTextToolbar, windowName);
        }
    }
}
Also used : Form(com.servoy.j2db.persistence.Form) Rectangle(java.awt.Rectangle) ApplicationException(com.servoy.j2db.ApplicationException) IBasicFormManager(com.servoy.j2db.IBasicFormManager) ScriptableObject(org.mozilla.javascript.ScriptableObject) BasicFormController(com.servoy.j2db.BasicFormController)

Example 2 with IBasicFormManager

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

the class CreationalPrototype method getIds.

/**
 * @see com.servoy.j2db.scripting.DefaultScope#getIds()
 */
@Override
public Object[] getIds() {
    ArrayList<String> al = new ArrayList<String>();
    // $NON-NLS-1$
    al.add("allnames");
    // $NON-NLS-1$
    al.add("length");
    IBasicFormManager fm = application.getFormManager();
    Iterator<String> it = fm.getPossibleFormNames();
    while (it.hasNext()) {
        al.add(it.next());
    }
    return al.toArray();
}
Also used : ArrayList(java.util.ArrayList) IBasicFormManager(com.servoy.j2db.IBasicFormManager)

Example 3 with IBasicFormManager

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

the class JSApplication method js_showFormInDialog.

/**
 * Show the specified form in a dialog. (NOTE: x, y, width, height are initial bounds - applied only the fist time a dialog is shown)
 *
 * NOTE:
 * In the Smart Client, no code is executed after the function showFormInDialog <em>if the dialog is modal</em>.
 *
 * NOTE:
 * x, y, width and height coordinates are only applied the first time the specified dialog is shown.
 * Use APP_UI_PROPERTY.DIALOG_FULL_SCREEN for these values when the dialog should be full-screen.
 *
 * @deprecated As of release 6.0, dialogs/windows API has been rewritten (based in JSWindow objects)
 *
 * @sample
 * //Show the specified form in a modal dialog, on default initial location and size (x,y,w,h)
 * //application.showFormInDialog(forms.contacts);
 * //Note: No code is executed after the showFormInDialog until the dialog is closed if it is created as a modal dialog.
 * //Show the specified form in a non-modal dialog with a specified name, on default initial location and size (x,y,w,h)
 * //application.showFormInDialog(forms.contacts,'contactsdialog',false);
 * //Show the specified form in a modal dialog, at a specified initial location and size with custom title, not resizable but with text toolbar
 * application.showFormInDialog(forms.contacts,100,80,500,300,'my own dialog title',false,true,'mydialog',true);
 *
 * @param form The form to be shown in the dialog.
 *
 * @param x optional The "x" coordinate of the dialog.
 *
 * @param y optional The "y" coordinate of the dialog.
 *
 * @param width optional The width of the dialog.
 *
 * @param height optional The height of the dialog.
 *
 * @param dialogTitle optional The title of the dialog.
 *
 * @param resizable optional <em>true</em> if the dialog size should be modifiable; <em>false</em> if not.
 *
 * @param showTextToolbar optional <em>true</em> to add a text toolbar; <em>false</em> to not add a text toolbar.
 *
 * @param windowName optional The name of the window; defaults to "dialog" if nothing is specified. Window and dialog names share the same namespace.
 *
 * @param modal optional <em>true</em> if the dialog should be modal; <em>false</em> if not. Defaults to <em>true</em>.
 */
@Deprecated
public void js_showFormInDialog(Object[] args) throws ServoyException {
    if (args != null && args.length >= 1) {
        Object form = args[0];
        int x = -1;
        int y = -1;
        int w = 0;
        int h = 0;
        String title = null;
        boolean resizeble = true;
        boolean showTextToolbar = false;
        Boolean closeAll = Boolean.FALSE;
        boolean legacyBehaviour = false;
        boolean modal = true;
        String dialogName = null;
        // special short cut, args: 'form,name [, modal]'
        if (args.length >= 2 && args[1] instanceof String) {
            dialogName = (String) args[1];
            if (args.length >= 3 && args[2] instanceof Boolean)
                modal = ((Boolean) args[2]).booleanValue();
            else
                modal = true;
        } else {
            if (args.length >= 2 && args[1] instanceof Number)
                x = ((Number) args[1]).intValue();
            if (args.length >= 3 && args[2] instanceof Number)
                y = ((Number) args[2]).intValue();
            if (args.length >= 4 && args[3] instanceof Number)
                w = ((Number) args[3]).intValue();
            if (args.length >= 5 && args[4] instanceof Number)
                h = ((Number) args[4]).intValue();
            if (args.length >= 6 && args[5] instanceof String)
                title = args[5].toString();
            if (args.length >= 7 && args[6] instanceof Boolean)
                resizeble = ((Boolean) args[6]).booleanValue();
            if (args.length >= 8 && args[7] instanceof Boolean)
                showTextToolbar = ((Boolean) args[7]).booleanValue();
            if (args.length >= 9 && args[8] instanceof Boolean)
                closeAll = (Boolean) args[8];
            if (args.length >= 9 && args[8] instanceof String)
                dialogName = (String) args[8];
            else
                legacyBehaviour = true;
            if (args.length >= 10 && args[9] instanceof Boolean)
                modal = ((Boolean) args[9]).booleanValue();
            else if (dialogName != null)
                modal = true;
        }
        dialogName = replaceFailingCharacters(dialogName);
        String f = null;
        if (form instanceof BasicFormController) {
            f = ((BasicFormController) form).getName();
        } else if (form instanceof FormScope) {
            f = ((FormScope) form).getFormController().getName();
        } else if (form instanceof BasicFormController.JSForm) {
            f = ((BasicFormController.JSForm) form).getFormPanel().getName();
        } else if (form instanceof String) {
            f = (String) form;
        }
        if (f != null) {
            Form frm = application.getFlattenedSolution().getForm(f);
            IBasicFormManager fm = application.getFormManager();
            if (frm == null && fm.isPossibleForm(f))
                frm = fm.getPossibleForm(f);
            if (!application.getFlattenedSolution().formCanBeInstantiated(frm)) {
                // abstract form
                throw new ApplicationException(ServoyException.ABSTRACT_FORM);
            }
            Rectangle rect = new Rectangle(x, y, w, h);
            fm.showFormInDialog(f, rect, title, resizeble, showTextToolbar, closeAll.booleanValue() || !legacyBehaviour, modal, dialogName);
        }
    }
}
Also used : Form(com.servoy.j2db.persistence.Form) Rectangle(java.awt.Rectangle) ApplicationException(com.servoy.j2db.ApplicationException) IBasicFormManager(com.servoy.j2db.IBasicFormManager) ScriptableObject(org.mozilla.javascript.ScriptableObject) BasicFormController(com.servoy.j2db.BasicFormController)

Example 4 with IBasicFormManager

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

the class PageContributor method getGlobalResourceReferences.

protected ResourceReferences getGlobalResourceReferences() {
    ResourceReferences grr = null;
    IBasicFormManager fm = application.getFormManager();
    if (fm instanceof WebFormManager) {
        grr = ((WebFormManager) fm).getGlobalResourceReferences();
    }
    return grr;
}
Also used : IBasicFormManager(com.servoy.j2db.IBasicFormManager)

Example 5 with IBasicFormManager

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

the class WebForm method formMethodExecution.

/*
	 * @see com.servoy.j2db.ISupportFormExecutionState#formMethodExecution()
	 */
@Override
public FormExecutionState formMethodExecution() {
    FormController fc = getController();
    IBasicFormManager formManager = fc.getBasicFormManager();
    if (formManager != null) {
        IBasicMainContainer currentContainer = formManager.getCurrentContainer();
        MainPage formPage = getMainPage();
        if (currentContainer != formPage) {
            FormExecutionState formExecutionState = new FormExecutionState();
            formExecutionState.mainContainer = currentContainer;
            formExecutionState.mainContainerName = currentContainer.getContainerName();
            ((WebFormManager) formManager).setCurrentContainer(formPage, getContainerName());
            return formExecutionState;
        }
    }
    return null;
}
Also used : FormController(com.servoy.j2db.FormController) IBasicMainContainer(com.servoy.j2db.IBasicMainContainer) IBasicFormManager(com.servoy.j2db.IBasicFormManager) ISupportFormExecutionState(com.servoy.j2db.ISupportFormExecutionState) FormExecutionState(com.servoy.j2db.FormExecutionState)

Aggregations

IBasicFormManager (com.servoy.j2db.IBasicFormManager)8 ApplicationException (com.servoy.j2db.ApplicationException)3 BasicFormController (com.servoy.j2db.BasicFormController)3 Form (com.servoy.j2db.persistence.Form)3 ArrayList (java.util.ArrayList)3 IFormController (com.servoy.j2db.IFormController)2 Rectangle (java.awt.Rectangle)2 ScriptableObject (org.mozilla.javascript.ScriptableObject)2 FormController (com.servoy.j2db.FormController)1 FormExecutionState (com.servoy.j2db.FormExecutionState)1 IBasicMainContainer (com.servoy.j2db.IBasicMainContainer)1 ISupportFormExecutionState (com.servoy.j2db.ISupportFormExecutionState)1 JSForm (com.servoy.j2db.scripting.solutionmodel.JSForm)1 NativeJavaArray (org.mozilla.javascript.NativeJavaArray)1