use of com.servoy.j2db.scripting.SolutionScope in project servoy-client by Servoy.
the class DebugClientHandler method setDesignerCallback.
/**
* @param designerCallback the designerCallback to set
*/
public void setDesignerCallback(IDesignerCallback designerCallback) {
this.designerCallback = designerCallback;
if (debugJ2DBClient != null && debugJ2DBClient.getSolution() != null) {
SolutionScope solutionScope = debugJ2DBClient.getScriptEngine().getSolutionScope();
designerCallback.addScriptObjects(debugJ2DBClient, solutionScope);
}
if (debugWebClient != null && debugWebClient.getSolution() != null) {
SolutionScope solutionScope = debugWebClient.getScriptEngine().getSolutionScope();
designerCallback.addScriptObjects(debugWebClient, solutionScope);
}
if (debugNGClient != null && debugNGClient.getSolution() != null) {
SolutionScope solutionScope = debugNGClient.getScriptEngine().getSolutionScope();
designerCallback.addScriptObjects(debugNGClient, solutionScope);
}
if (debugHeadlessClient != null && debugHeadlessClient.getSolution() != null) {
SolutionScope solutionScope = debugHeadlessClient.getScriptEngine().getSolutionScope();
designerCallback.addScriptObjects(debugHeadlessClient, solutionScope);
}
for (IDebugClient c : customDebugClients.values()) {
if (c.getSolution() != null) {
SolutionScope solutionScope = c.getScriptEngine().getSolutionScope();
designerCallback.addScriptObjects(c, solutionScope);
}
}
}
use of com.servoy.j2db.scripting.SolutionScope in project servoy-client by Servoy.
the class NGFormManager method setCurrentControllerJS.
public void setCurrentControllerJS(IWebFormController currentController) {
if (currentController != null) {
SolutionScope ss = application.getScriptEngine().getSolutionScope();
Context.enter();
try {
// $NON-NLS-1$
ss.put(// $NON-NLS-1$
"currentcontroller", // $NON-NLS-1$
ss, new NativeJavaObject(ss, currentController.initForJSUsage(), ScriptObjectRegistry.getJavaMembers(com.servoy.j2db.BasicFormController.JSForm.class, ss)));
} finally {
Context.exit();
}
} else {
Debug.warn("A null current controller is tried to be set in the solution, very likely this is a problem with visibility of a form in a window");
}
}
use of com.servoy.j2db.scripting.SolutionScope in project servoy-client by Servoy.
the class FormManager method showFormInMainPanel.
// show a form in the main panel
public FormController showFormInMainPanel(final String formName, final IMainContainer container, final String title, final boolean closeAll, final String dialogName) {
if (loginForm != null && loginForm.getName() != formName) {
// not allowed to leave here...or show anything else than login form
return null;
}
// $NON-NLS-1$
if (formName == null)
throw new IllegalArgumentException(application.getI18NMessage("servoy.formManager.error.SettingVoidForm"));
FormController currentMainShowingForm = null;
if (currentContainer != null) {
currentMainShowingForm = container.getController();
}
boolean containerSwitch = container != currentContainer;
if (currentMainShowingForm != null && formName.equals(currentMainShowingForm.getName()) && !containerSwitch && !design)
return leaseFormPanel(currentMainShowingForm.getName());
final Form f = possibleForms.get(formName);
if (f == null) {
return null;
}
try {
int access = application.getFlattenedSolution().getSecurityAccess(f.getUUID(), f.getImplicitSecurityNoRights() ? IRepository.IMPLICIT_FORM_NO_ACCESS : IRepository.IMPLICIT_FORM_ACCESS);
if (access != -1) {
boolean b_visible = ((access & IRepository.VIEWABLE) != 0);
if (!b_visible) {
application.invokeLater(new Runnable() {
public void run() {
// $NON-NLS-1$
application.reportWarningInStatus(application.getI18NMessage("servoy.formManager.warningAccessForm"));
}
});
return null;
}
}
// handle old panel
if (currentMainShowingForm != null) {
// leave forms in browse mode // TODO can this be set if notifyVisible returns false (current form is being kept)
if (!containerSwitch && application.getModeManager().getMode() != IModeManager.EDIT_MODE) {
application.getModeManager().setMode(IModeManager.EDIT_MODE);
}
FormController fp = leaseFormPanel(currentMainShowingForm.getName());
if (fp != null && !containerSwitch) {
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
boolean ok = fp.notifyVisible(false, invokeLaterRunnables);
Utils.invokeLater(application, invokeLaterRunnables);
// solution closed in onhide method of previous form?
if (application.getSolution() == null)
return null;
if (!ok) {
selectFormMenuItem(currentMainShowingForm.getForm());
return fp;
}
}
}
// set main
FormController tmpForm = currentMainShowingForm;
final FormController fp = leaseFormPanel(formName);
currentMainShowingForm = fp;
currentContainer = container;
if (fp != null) {
if (application.getCmdManager() instanceof ICmdManagerInternal) {
((ICmdManagerInternal) application.getCmdManager()).setCurrentUndoManager(fp.getUndoManager());
}
boolean isNewUser = checkAndUpdateFormUser(fp, container);
IFormUIInternal formUI = fp.getFormUI();
if (isNewUser) {
container.add(fp.getFormUI(), formName);
}
if (formUI != null && !formUI.isVisible())
formUI.setComponentVisible(true);
// this code must be below the checkAndUpdateUser because setFormController can already set the formui
currentContainer.setController(fp);
SolutionScope ss = application.getScriptEngine().getSolutionScope();
Context.enter();
try {
// $NON-NLS-1$
ss.put("currentcontroller", ss, new NativeJavaObject(ss, fp.initForJSUsage(), new InstanceJavaMembers(ss, JSForm.class)));
} finally {
Context.exit();
}
fp.setView(fp.getView());
fp.executeOnLoadMethod();
// test if solution is closed in the onload method.
if (application.getSolution() == null)
return null;
// correct script menu for this form
fillScriptMenu();
// if this is first show and we have to mimic the legacy 3.1 behavior of dialogs (show all in 1 window), allow 100 forms
if (!container.isVisible() && !closeAll) {
((FormManager) application.getFormManager()).getHistory(currentContainer).clear(100);
}
// add to history
getHistory(currentContainer).add(fp.getName());
// check for programatic change
selectFormMenuItem(f);
// show panel as main
List<Runnable> invokeLaterRunnables = new ArrayList<Runnable>();
fp.notifyVisible(true, invokeLaterRunnables);
// only enable command when it is the default container
// if (getMainContainer(null) == currentContainer)
// Command should rightly enabled for the forms
enableCmds(true);
final IMainContainer cachedContainer = currentContainer;
Runnable title_focus = new Runnable() {
public void run() {
FormController fc = cachedContainer.getController();
if (fc != null && fc == fp && application.getSolution() != null) {
// correct title
String titleText = title;
if (titleText == null)
titleText = f.getTitleText();
// $NON-NLS-1$
if (NO_TITLE_TEXT.equals(titleText))
titleText = "";
cachedContainer.setTitle(titleText);
cachedContainer.requestFocus();
}
}
};
if (isNewUser) {
final IMainContainer showContainer = currentContainer;
// to overcome paint problem in swing...
currentContainer.showBlankPanel();
invokeLaterRunnables.add(new Runnable() {
public void run() {
// only call show if it is still the right form.
FormController currentController = showContainer.getController();
if (currentController != null && fp.getName().equals(currentController.getName())) {
showContainer.show(fp.getName());
application.getRuntimeWindowManager().setCurrentWindowName(dialogName);
}
}
});
} else {
currentContainer.show(fp.getName());
application.getRuntimeWindowManager().setCurrentWindowName(dialogName);
}
invokeLaterRunnables.add(title_focus);
Utils.invokeLater(application, invokeLaterRunnables);
} else {
currentContainer.setController(null);
}
// $NON-NLS-1$
J2DBGlobals.firePropertyChange(this, "form", tmpForm, currentMainShowingForm);
return fp;
} catch (Exception e) {
Debug.error(e);
}
return null;
}
use of com.servoy.j2db.scripting.SolutionScope in project servoy-client by Servoy.
the class BasicFormController method initForJSUsage.
// if the js init is not done , do!
public synchronized JSForm initForJSUsage() {
if (formScope == null) {
if (destroyed) {
Debug.error("Calling initForJSUsage on a destroyed form: " + this, new RuntimeException("Calling initForJSUsage on a destroyed form: " + this));
return null;
}
Context.enter();
try {
IExecutingEnviroment se = application.getScriptEngine();
if (se != null) {
SolutionScope solScope = application.getScriptEngine().getSolutionScope();
// $NON-NLS-1$
initForJSUsage((CreationalPrototype) solScope.get("forms", solScope));
} else {
// saw this happen on MAC debug smart client - edit the value in a combobox (change it) then directly click on the close window button;
// shutDown executed first (windowClosing) - setting solution to null, then the combo item state change (generated by focus lost) event was triggered
// $NON-NLS-1$
Debug.log("Trying to initForJSUsage with null script engine - probably a method was about to be invoked post-shutdown", null);
}
} catch (Exception ex) {
// $NON-NLS-1$
application.reportError(application.getI18NMessage("servoy.formPanel.error.initScriptEngine"), ex);
} finally {
Context.exit();
}
}
return scriptableForm;
}
use of com.servoy.j2db.scripting.SolutionScope in project servoy-client by Servoy.
the class BasicFormManager method canBeDeleted.
protected boolean canBeDeleted(IFormController fp) {
if (fp.isFormVisible()) {
if (Debug.tracing())
Debug.trace("Couldn't destroy form " + fp.getName() + " instance because it is still visible");
return false;
}
// cannot be deleted if a global var has a ref
ScopesScope scopesScope = application.getScriptEngine().getScopesScope();
if (hasReferenceInScriptable(scopesScope, fp, new HashSet<Scriptable>())) {
if (Debug.tracing())
Debug.trace("Couldn't destroy form " + fp.getName() + " instance because it has references in scripting");
return false;
}
if (fp.isFormExecutingFunction()) {
if (Debug.tracing())
Debug.trace("Couldn't destroy form " + fp.getName() + " instance because it is executing a function");
return false;
}
// if this controller uses a separate foundset
if (fp.getForm().getUseSeparateFoundSet()) {
// test if that foundset has edited records that can't be saved
EditRecordList editRecordList = application.getFoundSetManager().getEditRecordList();
if (editRecordList.stopIfEditing(fp.getFoundSet()) != ISaveConstants.STOPPED) {
if (Debug.tracing())
Debug.trace("Couldn't destroy form " + fp.getName() + " instance because it has a seperate foundset that has editing records");
return false;
}
}
// the cached currentcontroller may not be destroyed
SolutionScope ss = application.getScriptEngine().getSolutionScope();
// $NON-NLS-1$
return ss == null || fp.initForJSUsage() != ss.get("currentcontroller", ss);
}
Aggregations