use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class SwingFormManager method showPreview.
@Override
public void showPreview(final FormController afp, final IFoundSetInternal foundset, int zoomFactor, final PrinterJob printJob) {
removePreview();
final FormController fc = currentContainer.getController();
if (fc != null) {
List invokeLaterRunnables = new ArrayList();
boolean ok = fc.notifyVisible(false, invokeLaterRunnables);
Utils.invokeLater(getApplication(), invokeLaterRunnables);
if (!ok) {
// cannot hide...so skip preview
return;
}
}
showFormInMainPanel(afp.getName(), currentContainer, null, true, null);
getApplication().getModeManager().setMode(IModeManager.PREVIEW_MODE);
boolean isNewUser = checkAndUpdateFormUser(afp, currentContainer);
if (isNewUser) {
IFormUIInternal ui = afp.getFormUI();
currentContainer.add(ui, afp.getName());
}
try {
final PrintPreview printPreview = new PrintPreview((ISmartClientApplication) getApplication(), afp, foundset, zoomFactor, printJob);
Runnable r = new Runnable() {
public void run() {
printPreviews.put(currentContainer, new PrintPreviewHolder(printPreview, fc));
// $NON-NLS-1$
currentContainer.add(printPreview, "@preview");
// $NON-NLS-1$
currentContainer.show("@preview");
// handle navigator propertly
List invokeLaterRunnables = new ArrayList();
afp.showNavigator(invokeLaterRunnables);
Utils.invokeLater(getApplication(), invokeLaterRunnables);
printPreview.showPages();
}
};
getApplication().invokeLater(r);
} catch (Exception ex) {
// $NON-NLS-1$
getApplication().reportError(Messages.getString("servoy.formManager.error.PrintPreview"), ex);
}
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class SwingRuntimeWindow method doOldShowInWindow.
private void doOldShowInWindow(String formName) {
FormManager fm = ((FormManager) getApplication().getFormManager());
boolean toFront = createFrameIfNeeded(fm);
FormFrame frame = (FormFrame) wrappedWindow;
if (frame.isVisible()) {
frame.storeBounds();
}
IMainContainer container = frame.getMainContainer();
final FormController fp = fm.showFormInMainPanel(formName, container, title, true, windowName);
finalizeShowWindow(fp, formName, container, true, false, toFront);
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class SortModel method setValue.
void setValue(IApplication app, String notused) {
application = app;
try {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
ITable t = application.getFoundSetManager().getTable(form.getDataSource());
if (t != null) {
List<SortColumn> list = application.getFoundSetManager().getSortColumns(t, form.getInitialSort());
init(app, t, list);
}
}
} catch (RepositoryException e) {
Debug.error(e);
}
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class CmdPrevRecord method doIt.
@Override
public UndoableEdit doIt(java.util.EventObject ae) {
IFormManager fm = application.getFormManager();
final FormController fp = (FormController) fm.getCurrentForm();
fp.selectPrevRecord();
return null;
}
use of com.servoy.j2db.FormController in project servoy-client by Servoy.
the class ServoyWrapFactory method wrap.
/**
* @see org.mozilla.javascript.WrapFactory#wrap(org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable, java.lang.Object, java.lang.Class)
*/
@Override
public Object wrap(Context cx, Scriptable scope, Object obj, Class staticType) {
if (application.getSolution() == null) {
throw new ExitScriptException("killing current script, client/solution already terminated");
}
if (obj == null || obj == Undefined.instance || obj instanceof Scriptable || obj instanceof String || obj instanceof CharSequence || obj instanceof Number || obj instanceof Boolean) {
return obj;
}
if (obj instanceof Date) {
return cx.newObject(scope, "Date", new Object[] { new Double(NativeDate.convertToUTCMillisFromJava(((Date) obj).getTime())) });
}
if (obj instanceof DbIdentValue || obj instanceof UUID) {
return new NativeJavaObject(scope, obj, ScriptObjectRegistry.getJavaMembers(obj.getClass(), null));
}
if (cx != null) {
if (obj instanceof JSConvertedMap<?, ?>) {
Scriptable newObject = null;
JSConvertedMap<?, ?> map = (JSConvertedMap<?, ?>) obj;
if (map.getConstructorName() != null) {
newObject = cx.newObject(scope, map.getConstructorName());
} else {
newObject = cx.newObject(scope);
}
Iterator<?> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<?, ?> next = (Entry<?, ?>) iterator.next();
Object key = next.getKey();
Object value = next.getValue();
if (value != null) {
value = wrap(cx, newObject, value, value.getClass());
}
if (key instanceof Integer) {
newObject.put(((Integer) key).intValue(), newObject, value);
} else if (key instanceof String) {
newObject.put((String) key, newObject, value);
} else {
// $NON-NLS-1$ //$NON-NLS-2$
Debug.error("Try to create a JSConvertedMap->NativeObject with a key that isnt a string or integer:" + key + " for value: " + value);
}
}
return newObject;
}
if (obj.getClass() == JSONObject.class) {
JSONObject json = (JSONObject) obj;
Scriptable newObject = cx.newObject(scope);
Iterator<String> iterator = json.keys();
while (iterator.hasNext()) {
String key = iterator.next();
Object value = null;
try {
value = ServoyJSONObject.jsonNullToNull(json.get(key));
} catch (JSONException e) {
Debug.error(e);
}
if (value != null) {
value = wrap(cx, newObject, value, value.getClass());
}
newObject.put(key, newObject, value);
}
return newObject;
}
if (obj.getClass() == JSONArray.class) {
JSONArray array = (JSONArray) obj;
Scriptable newObject = cx.newObject(scope, "Array");
for (int i = 0; i < array.length(); i++) {
Object value = null;
try {
value = array.get(i);
} catch (JSONException e) {
Debug.error(e);
}
if (value != null) {
value = wrap(cx, newObject, value, value.getClass());
}
newObject.put(i, newObject, value);
}
return newObject;
}
}
if (obj instanceof IDataSet) {
return new JSDataSet(application, (IDataSet) obj);
}
if (obj instanceof FormController) {
throw new IllegalArgumentException(// $NON-NLS-1$
"Bad practice: FormController cant be wrapped to javascript (for example not usable as argument in Scheduler plugin)");
}
// if it is a none primitive array
if (obj.getClass().isArray() && !obj.getClass().getComponentType().isPrimitive()) {
// then convert the array to a NativeArray, first convert all the elements of the array itself.
Object[] source = (Object[]) obj;
Object[] array = new Object[source.length];
for (int i = 0; i < source.length; i++) {
Object src = source[i];
array[i] = wrap(cx, scope, src, src != null ? src.getClass() : null);
}
NativeArray result = obj.getClass().getComponentType() != Object.class ? new ServoyNativeArray(array, obj.getClass().getComponentType()) : new NativeArray(array);
ScriptRuntime.setBuiltinProtoAndParent(result, scope, TopLevel.Builtins.Array);
return result;
}
return super.wrap(cx, scope, obj, staticType);
}
Aggregations