Search in sources :

Example 6 with IClientPlugin

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

the class PluginScope method getIds.

/**
 * @see com.servoy.j2db.scripting.DefaultScope#getIds()
 */
@Override
public Object[] getIds() {
    if (application.getPluginManager() == null)
        return new Object[0];
    List<IClientPlugin> lst = application.getPluginManager().getPlugins(IClientPlugin.class);
    Object[] array = new String[lst.size()];
    for (int i = 0; i < lst.size(); i++) {
        IClientPlugin plugin = lst.get(i);
        array[i] = plugin.getName();
    }
    Arrays.sort(array);
    return array;
}
Also used : IClientPlugin(com.servoy.j2db.plugins.IClientPlugin)

Example 7 with IClientPlugin

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

the class JSApplication method js_writeXMLFile.

/**
 * @deprecated  As of release 2.x, replaced by {@link plugins.file#writeXMLFile(Object, String)}.
 */
@Deprecated
public boolean js_writeXMLFile(String fileName, String xml) {
    // $NON-NLS-1$
    IClientPlugin cp = application.getPluginManager().getPlugin(IClientPlugin.class, "file");
    if (cp != null) {
        IScriptable so = cp.getScriptObject();
        if (so != null) {
            try {
                // $NON-NLS-1$
                Method m = so.getClass().getMethod("js_writeXMLFile", new Class[] { String.class, String.class });
                Boolean obj = (Boolean) m.invoke(so, new Object[] { fileName, xml });
                if (obj != null)
                    return obj.booleanValue();
                return false;
            } catch (Exception e) {
                Debug.error(e);
            }
        }
    }
    application.reportError("Writing to xml file failed", "For this operation the file plugin is needed\nNote this method is deprecated, use the plugin directly in your code");
    return false;
}
Also used : IClientPlugin(com.servoy.j2db.plugins.IClientPlugin) ScriptableObject(org.mozilla.javascript.ScriptableObject) Method(java.lang.reflect.Method) ApplicationException(com.servoy.j2db.ApplicationException) ExitScriptException(com.servoy.j2db.ExitScriptException) ServoyException(com.servoy.j2db.util.ServoyException) JavaScriptException(org.mozilla.javascript.JavaScriptException)

Example 8 with IClientPlugin

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

the class JSApplication method js_showFileOpenDialog.

/**
 * @deprecated  As of release 2.x, replaced by {@link plugins.file#showFileOpenDialog(Object[])}.
 */
@Deprecated
public String js_showFileOpenDialog() {
    // $NON-NLS-1$
    IClientPlugin cp = application.getPluginManager().getPlugin(IClientPlugin.class, "file");
    if (cp != null) {
        IScriptable so = cp.getScriptObject();
        if (so != null) {
            try {
                // $NON-NLS-1$
                Method m = so.getClass().getMethod("js_showFileOpenDialog", new Class[] {});
                Object obj = m.invoke(so, (Object[]) null);
                if (obj != null)
                    return obj.toString();
                return null;
            } catch (Exception e) {
                Debug.error(e);
            }
        }
    }
    application.reportError("Showing file open dialog failed", "For this operation the file plugin is needed\nNote this method is deprecated, use the plugin directly in your code");
    return null;
}
Also used : IClientPlugin(com.servoy.j2db.plugins.IClientPlugin) ScriptableObject(org.mozilla.javascript.ScriptableObject) Method(java.lang.reflect.Method) ApplicationException(com.servoy.j2db.ApplicationException) ExitScriptException(com.servoy.j2db.ExitScriptException) ServoyException(com.servoy.j2db.util.ServoyException) JavaScriptException(org.mozilla.javascript.JavaScriptException)

Example 9 with IClientPlugin

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

the class JSApplication method js_writeFile.

/**
 * @deprecated  As of release 2.x, replaced by {@link plugins.file#writeFile(Object, byte[])}.
 */
@Deprecated
public boolean js_writeFile(String fileName, byte[] data) {
    // $NON-NLS-1$
    IClientPlugin cp = application.getPluginManager().getPlugin(IClientPlugin.class, "file");
    if (cp != null) {
        IScriptable so = cp.getScriptObject();
        if (so != null) {
            try {
                // $NON-NLS-1$
                Method m = so.getClass().getMethod("js_writeFile", new Class[] { String.class, byte[].class });
                Boolean obj = (Boolean) m.invoke(so, new Object[] { fileName, data });
                if (obj != null)
                    return obj.booleanValue();
                return false;
            } catch (Exception e) {
                Debug.error(e);
            }
        }
    }
    application.reportError("Writing to file failed", "For this operation the file plugin is needed\nNote this method is deprecated, use the plugin directly in your code");
    return false;
}
Also used : IClientPlugin(com.servoy.j2db.plugins.IClientPlugin) ScriptableObject(org.mozilla.javascript.ScriptableObject) Method(java.lang.reflect.Method) ApplicationException(com.servoy.j2db.ApplicationException) ExitScriptException(com.servoy.j2db.ExitScriptException) ServoyException(com.servoy.j2db.util.ServoyException) JavaScriptException(org.mozilla.javascript.JavaScriptException)

Example 10 with IClientPlugin

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

the class JSApplication method js_readTXTFile.

/**
 * @deprecated  As of release 2.x, replaced by {@link plugins.file#readTXTFile(Object[])}.
 */
@Deprecated
public String js_readTXTFile(Object[] args) {
    // $NON-NLS-1$
    IClientPlugin cp = application.getPluginManager().getPlugin(IClientPlugin.class, "file");
    if (cp != null) {
        IScriptable so = cp.getScriptObject();
        if (so != null) {
            try {
                // $NON-NLS-1$
                Method m = so.getClass().getMethod("js_readTXTFile", getClassArrayFromObjectArgs(args));
                Object obj = m.invoke(so, args);
                if (obj != null)
                    return obj.toString();
                return null;
            } catch (Exception e) {
                Debug.error(e);
            }
        }
    }
    application.reportError("Reading from file failed", "For this operation the file plugin is needed\nNote this method is deprecated, use the plugin directly in your code");
    return null;
}
Also used : IClientPlugin(com.servoy.j2db.plugins.IClientPlugin) ScriptableObject(org.mozilla.javascript.ScriptableObject) Method(java.lang.reflect.Method) ApplicationException(com.servoy.j2db.ApplicationException) ExitScriptException(com.servoy.j2db.ExitScriptException) ServoyException(com.servoy.j2db.util.ServoyException) JavaScriptException(org.mozilla.javascript.JavaScriptException)

Aggregations

IClientPlugin (com.servoy.j2db.plugins.IClientPlugin)13 Method (java.lang.reflect.Method)12 ApplicationException (com.servoy.j2db.ApplicationException)11 ServoyException (com.servoy.j2db.util.ServoyException)11 ExitScriptException (com.servoy.j2db.ExitScriptException)10 JavaScriptException (org.mozilla.javascript.JavaScriptException)10 ScriptableObject (org.mozilla.javascript.ScriptableObject)7 RepositoryException (com.servoy.j2db.persistence.RepositoryException)1 IScriptable (com.servoy.j2db.scripting.IScriptable)1 RemoteException (java.rmi.RemoteException)1 SQLException (java.sql.SQLException)1 NativeJavaArray (org.mozilla.javascript.NativeJavaArray)1 NativeObject (org.mozilla.javascript.NativeObject)1